OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 182 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 182 Rev 185
Line 21... Line 21...
21
import org.openconcerto.erp.core.edm.AttachmentAction;
21
import org.openconcerto.erp.core.edm.AttachmentAction;
22
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
22
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
23
import org.openconcerto.erp.core.reports.history.ui.HistoriqueArticleFrame;
23
import org.openconcerto.erp.core.reports.history.ui.HistoriqueArticleFrame;
24
import org.openconcerto.erp.core.sales.product.action.InitializeStockPanel;
24
import org.openconcerto.erp.core.sales.product.action.InitializeStockPanel;
25
import org.openconcerto.erp.core.sales.product.action.InventairePanel;
25
import org.openconcerto.erp.core.sales.product.action.InventairePanel;
-
 
26
import org.openconcerto.erp.core.sales.product.action.TransfertStockFromArticlePanel;
26
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
27
import org.openconcerto.erp.core.sales.product.component.ReferenceArticleSQLComponent;
27
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
28
import org.openconcerto.erp.core.sales.product.model.ProductComponent;
28
import org.openconcerto.erp.core.supplychain.stock.action.ListeDesMouvementsStockAction;
29
import org.openconcerto.erp.core.supplychain.stock.action.ListeDesMouvementsStockAction;
29
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
30
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
30
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
31
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
-
 
32
import org.openconcerto.erp.core.supplychain.stock.element.StockConsultPanel;
31
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
33
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
32
import org.openconcerto.erp.core.supplychain.stock.element.StockItem.TypeStockMouvement;
34
import org.openconcerto.erp.core.supplychain.stock.element.StockItem.TypeStockMouvement;
33
import org.openconcerto.erp.generationDoc.gestcomm.FicheArticleXmlSheet;
35
import org.openconcerto.erp.generationDoc.gestcomm.FicheArticleXmlSheet;
34
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
36
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
35
import org.openconcerto.erp.preferences.DefaultNXProps;
37
import org.openconcerto.erp.preferences.DefaultNXProps;
Line 44... Line 46...
44
import org.openconcerto.sql.model.SQLDataSource;
46
import org.openconcerto.sql.model.SQLDataSource;
45
import org.openconcerto.sql.model.SQLRow;
47
import org.openconcerto.sql.model.SQLRow;
46
import org.openconcerto.sql.model.SQLRowAccessor;
48
import org.openconcerto.sql.model.SQLRowAccessor;
47
import org.openconcerto.sql.model.SQLRowListRSH;
49
import org.openconcerto.sql.model.SQLRowListRSH;
48
import org.openconcerto.sql.model.SQLRowValues;
50
import org.openconcerto.sql.model.SQLRowValues;
-
 
51
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
49
import org.openconcerto.sql.model.SQLSelect;
52
import org.openconcerto.sql.model.SQLSelect;
50
import org.openconcerto.sql.model.SQLTable;
53
import org.openconcerto.sql.model.SQLTable;
51
import org.openconcerto.sql.model.Where;
54
import org.openconcerto.sql.model.Where;
52
import org.openconcerto.sql.model.graph.Path;
55
import org.openconcerto.sql.model.graph.Path;
53
import org.openconcerto.sql.preferences.SQLPreferences;
56
import org.openconcerto.sql.preferences.SQLPreferences;
Line 85... Line 88...
85
import java.sql.SQLException;
88
import java.sql.SQLException;
86
import java.text.SimpleDateFormat;
89
import java.text.SimpleDateFormat;
87
import java.util.ArrayList;
90
import java.util.ArrayList;
88
import java.util.Collection;
91
import java.util.Collection;
89
import java.util.Date;
92
import java.util.Date;
-
 
93
import java.util.HashMap;
90
import java.util.HashSet;
94
import java.util.HashSet;
91
import java.util.List;
95
import java.util.List;
-
 
96
import java.util.Map;
92
import java.util.Set;
97
import java.util.Set;
93
 
98
 
94
import javax.swing.AbstractAction;
99
import javax.swing.AbstractAction;
95
import javax.swing.JFrame;
100
import javax.swing.JFrame;
96
import javax.swing.JOptionPane;
101
import javax.swing.JOptionPane;
Line 104... Line 109...
104
    public static final int AU_METRE_LONGUEUR = 2;
109
    public static final int AU_METRE_LONGUEUR = 2;
105
    public static final int AU_METRE_CARRE = 3;
110
    public static final int AU_METRE_CARRE = 3;
106
    public static final int AU_POID_METRECARRE = 4;
111
    public static final int AU_POID_METRECARRE = 4;
107
    public static final int A_LA_PIECE = 5;
112
    public static final int A_LA_PIECE = 5;
108
    public static final int AU_METRE_LARGEUR = 6;
113
    public static final int AU_METRE_LARGEUR = 6;
-
 
114
    public static final int AU_KILO = 7;
109
    private static final int PRIX_HA = 1;
115
    private static final int PRIX_HA = 1;
110
    private static final int PRIX_VT = 2;
116
    private static final int PRIX_VT = 2;
111
    protected PredicateRowAction stock;
117
    protected PredicateRowAction stock;
112
 
118
 
113
    public static final String[] CONDITIONS = new String[] { "CFR", "CIF", "CPT", "DAT", "DDP", "DDU", "EXW", "FCA", "FOB" };
119
    public static final String[] CONDITIONS = new String[] { "CFR", "CIF", "CPT", "DAT", "DDP", "DDU", "EXW", "FCA", "FOB" };
Line 167... Line 173...
167
                    FrameUtil.showPacked(frame);
173
                    FrameUtil.showPacked(frame);
168
 
174
 
169
                }
175
                }
170
            }, true, false).setPredicate(ListEvent.getNonEmptySelectionPredicate());
176
            }, true, false).setPredicate(ListEvent.getNonEmptySelectionPredicate());
171
            getRowActions().add(actionConvVirtuel);
177
            getRowActions().add(actionConvVirtuel);
-
 
178
 
-
 
179
            RowAction actionTransfert = new RowAction(new AbstractAction("Transfert de stock") {
-
 
180
 
-
 
181
                @Override
-
 
182
                public void actionPerformed(ActionEvent e) {
-
 
183
 
-
 
184
                    final SQLRowAccessor selectedRowAccessor = IListe.get(e).getSelectedRowAccessor().fetchNewRow(false);
-
 
185
                    PanelFrame frame = new PanelFrame(new TransfertStockFromArticlePanel(ComptaPropsConfiguration.getInstance(), selectedRowAccessor, null), "Transfert de stock");
-
 
186
                    FrameUtil.showPacked(frame);
-
 
187
                    frame.setLocationRelativeTo(IListe.get(e));
-
 
188
                }
-
 
189
            }, true, false) {
-
 
190
 
-
 
191
                @Override
-
 
192
                public boolean enabledFor(ListEvent evt) {
-
 
193
                    return evt.getSelectedRowAccessors().size() == 1 && evt.getSelectedRowAccessors().get(0).getBoolean("GESTION_STOCK");
-
 
194
                }
-
 
195
            };
-
 
196
            getRowActions().add(actionTransfert);
-
 
197
 
-
 
198
            RowAction actionStockShow = new RowAction(new AbstractAction("Consulter le stock") {
-
 
199
 
-
 
200
                @Override
-
 
201
                public void actionPerformed(ActionEvent e) {
-
 
202
 
-
 
203
                    final StockConsultPanel p = new StockConsultPanel(ReferenceArticleSQLElement.this, IListe.get(e).getSelectedRowAccessor());
-
 
204
                    // p.load(IListe.get(e).getSelectedRowAccessor());
-
 
205
                    PanelFrame frame = new PanelFrame(p, "Consultation du stock");
-
 
206
                    FrameUtil.showPacked(frame);
-
 
207
                    frame.setLocationRelativeTo(IListe.get(e));
-
 
208
                }
-
 
209
            }, true, false) {
-
 
210
 
-
 
211
                @Override
-
 
212
                public boolean enabledFor(ListEvent evt) {
-
 
213
                    return evt.getSelectedRowAccessors().size() == 1 && evt.getSelectedRowAccessors().get(0).getBoolean("GESTION_STOCK");
-
 
214
                }
-
 
215
            };
-
 
216
            getRowActions().add(actionStockShow);
-
 
217
 
172
        }
218
        }
173
        if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVER_DECLINAISON, false)) {
219
        if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVER_DECLINAISON, false)) {
174
 
220
 
175
            RowAction actionConvVirtuel = new RowAction(new AbstractAction("Convertir en article virtuel") {
221
            RowAction actionConvVirtuel = new RowAction(new AbstractAction("Convertir en article virtuel") {
176
 
222
 
Line 184... Line 230...
184
                        ExceptionHandler.handle("Erreur lors de la conversion de l'article en virtuel", e1);
230
                        ExceptionHandler.handle("Erreur lors de la conversion de l'article en virtuel", e1);
185
                    }
231
                    }
186
 
232
 
187
                }
233
                }
188
            }, true, false) {
234
            }, true, false) {
-
 
235
 
189
                @Override
236
                @Override
190
                public boolean enabledFor(ListEvent evt) {
237
                public boolean enabledFor(ListEvent evt) {
191
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
238
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
192
                    if (selection.size() == 1) {
239
                    if (selection.size() == 1) {
193
                        return !selection.get(0).getBoolean("VIRTUEL") && selection.get(0).isForeignEmpty("ID_ARTICLE_VIRTUEL_PERE");
240
                        return !selection.get(0).getBoolean("VIRTUEL") && selection.get(0).isForeignEmpty("ID_ARTICLE_VIRTUEL_PERE");
-
 
241
 
194
                    }
242
                    }
195
                    return false;
243
                    return false;
196
                }
244
                }
197
            };
245
            };
198
            getRowActions().add(actionConvVirtuel);
246
            getRowActions().add(actionConvVirtuel);
Line 216... Line 264...
216
                    f.getSQLComponent().select(rowVals);
264
                    f.getSQLComponent().select(rowVals);
217
                    FrameUtil.show(f);
265
                    FrameUtil.show(f);
218
 
266
 
219
                }
267
                }
220
            }, true, false) {
268
            }, true, false) {
-
 
269
 
221
                @Override
270
                @Override
222
                public boolean enabledFor(ListEvent evt) {
271
                public boolean enabledFor(ListEvent evt) {
223
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
272
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
224
                    if (selection.size() == 1) {
273
                    if (selection.size() == 1) {
225
                        return selection.get(0).getBoolean("VIRTUEL");
274
                        return selection.get(0).getBoolean("VIRTUEL");
Line 250... Line 299...
250
                    f.setLocationRelativeTo(null);
299
                    f.setLocationRelativeTo(null);
251
                    FrameUtil.show(f);
300
                    FrameUtil.show(f);
252
 
301
 
253
                }
302
                }
254
            }, false, true) {
303
            }, false, true) {
-
 
304
 
255
                @Override
305
                @Override
256
                public boolean enabledFor(ListEvent evt) {
306
                public boolean enabledFor(ListEvent evt) {
257
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
307
                    final List<? extends SQLRowAccessor> selection = evt.getSelectedRowAccessors();
258
                    if (selection.size() == 1) {
308
                    if (selection.size() == 1) {
259
                        return selection.get(0).getBoolean("VIRTUEL");
309
                        return selection.get(0).getBoolean("VIRTUEL");
Line 262... Line 312...
262
                }
312
                }
263
            };
313
            };
264
            getRowActions().add(actionCreateDecls);
314
            getRowActions().add(actionCreateDecls);
265
 
315
 
266
        }
316
        }
-
 
317
 
267
        PredicateRowAction history = new PredicateRowAction(new AbstractAction("Historique") {
318
        PredicateRowAction history = new PredicateRowAction(new AbstractAction("Historique") {
268
 
319
 
269
            @Override
320
            @Override
270
            public void actionPerformed(ActionEvent e) {
321
            public void actionPerformed(ActionEvent e) {
271
                HistoriqueArticleFrame frame = new HistoriqueArticleFrame(ReferenceArticleSQLElement.this);
322
                HistoriqueArticleFrame frame = new HistoriqueArticleFrame(ReferenceArticleSQLElement.this);
Line 285... Line 336...
285
            }
336
            }
286
        }, false, true);
337
        }, false, true);
287
        mvtStock.setPredicate(IListeEvent.getSingleSelectionPredicate());
338
        mvtStock.setPredicate(IListeEvent.getSingleSelectionPredicate());
288
        getRowActions().add(mvtStock);
339
        getRowActions().add(mvtStock);
289
 
340
 
290
        if (ComptaPropsConfiguration.getInstanceCompta().isExperimental()) {
-
 
291
            PredicateRowAction batches = new PredicateRowAction(new AbstractAction("Lots et numéros de série") {
341
        PredicateRowAction batches = new PredicateRowAction(new AbstractAction("Lots et numéros de série") {
292
                @Override
342
            @Override
293
                public void actionPerformed(ActionEvent e) {
343
            public void actionPerformed(ActionEvent e) {
294
                    ListeDesLotsAction action = new ListeDesLotsAction(ReferenceArticleSQLElement.this.getDirectory(), IListe.get(e).getSelectedRowAccessor());
344
                ListeDesLotsAction action = new ListeDesLotsAction(ReferenceArticleSQLElement.this.getDirectory(), IListe.get(e).getSelectedRowAccessor());
295
                    action.actionPerformed(e);
345
                action.actionPerformed(e);
296
                }
346
            }
297
            }, false, true);
347
        }, false, true);
298
            batches.setPredicate(IListeEvent.getSingleSelectionPredicate());
348
        batches.setPredicate(IListeEvent.getSingleSelectionPredicate());
299
            getRowActions().add(batches);
349
        getRowActions().add(batches);
300
        }
350
 
301
        PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
351
        PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
302
 
352
 
303
            @Override
353
            @Override
304
            public void actionPerformed(ActionEvent e) {
354
            public void actionPerformed(ActionEvent e) {
305
 
355
 
Line 396... Line 446...
396
            final BaseSQLTableModelColumn colStockGlobal = new BaseSQLTableModelColumn("Stock Global", BigDecimal.class) {
446
            final BaseSQLTableModelColumn colStockGlobal = new BaseSQLTableModelColumn("Stock Global", BigDecimal.class) {
397
 
447
 
398
                @Override
448
                @Override
399
                protected Object show_(SQLRowAccessor r) {
449
                protected Object show_(SQLRowAccessor r) {
400
 
450
 
-
 
451
                    if (!r.getBoolean("GESTION_STOCK")) {
-
 
452
                        return null;
-
 
453
                    }
401
                    BigDecimal totalQte = BigDecimal.ZERO;
454
                    BigDecimal totalQte = BigDecimal.ZERO;
402
 
455
 
403
                    Collection<? extends SQLRowAccessor> stockElt = r.getReferentRows(getTable().getTable("STOCK").getField("ID_ARTICLE"));
456
                    Collection<? extends SQLRowAccessor> stockElt = r.getReferentRows(getTable().getTable("STOCK").getField("ID_ARTICLE"));
404
                    for (SQLRowAccessor rowElt : stockElt) {
457
                    for (SQLRowAccessor rowElt : stockElt) {
405
                        BigDecimal qteCmd = new BigDecimal(rowElt.getFloat("QTE_REEL"));
458
                        BigDecimal qteCmd = new BigDecimal(rowElt.getFloat("QTE_REEL"));
Line 408... Line 461...
408
                    return totalQte;
461
                    return totalQte;
409
                }
462
                }
410
 
463
 
411
                @Override
464
                @Override
412
                public Set<FieldPath> getPaths() {
465
                public Set<FieldPath> getPaths() {
-
 
466
                    final Path p = new Path(getTable());
413
                    Path p2 = new Path(getTable()).add(getTable().getTable("STOCK").getField("ID_ARTICLE"));
467
                    Path p2 = p.add(getTable().getTable("STOCK").getField("ID_ARTICLE"));
414
 
468
 
415
                    return CollectionUtils.createSet(new FieldPath(p2, "QTE_REEL"));
469
                    return CollectionUtils.createSet(new FieldPath(p, "GESTION_STOCK"), new FieldPath(p2, "QTE_REEL"));
416
                }
470
                }
417
            };
471
            };
418
            colStockGlobal.setRenderer(new NumberCellRenderer());
472
            colStockGlobal.setRenderer(new NumberCellRenderer());
419
            source.getColumns().add(colStockGlobal);
473
            source.getColumns().add(colStockGlobal);
420
        }
474
        }
Line 439... Line 493...
439
                public Set<FieldPath> getPaths() {
493
                public Set<FieldPath> getPaths() {
440
                    Path p = new Path(getTable());
494
                    Path p = new Path(getTable());
441
                    p = p.add(getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
495
                    p = p.add(getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
442
                    return CollectionUtils.createSet(new FieldPath(p, "QTE"));
496
                    return CollectionUtils.createSet(new FieldPath(p, "QTE"));
443
                }
497
                }
-
 
498
 
444
            });
499
            });
445
        }
500
        }
446
    }
501
    }
447
 
502
 
448
    @Override
503
    @Override
Line 486... Line 541...
486
            l.add("ID_FOURNISSEUR");
541
            l.add("ID_FOURNISSEUR");
487
        }
542
        }
488
        l.add("POIDS");
543
        l.add("POIDS");
489
        l.add("SKU");
544
        l.add("SKU");
490
 
545
 
491
        // if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
546
        if (!prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false)) {
492
        l.add("GESTION_STOCK");
547
            l.add("GESTION_STOCK");
493
        l.add("ID_STOCK");
548
            l.add("ID_STOCK");
494
        // }
549
        }
495
        String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
550
        String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
496
        Boolean b = Boolean.valueOf(val);
551
        Boolean b = Boolean.valueOf(val);
497
        if (b != null && b.booleanValue()) {
552
        if (b != null && b.booleanValue()) {
498
            l.add("SERVICE");
553
            l.add("SERVICE");
499
        }
554
        }
Line 993... Line 1048...
993
        }
1048
        }
994
        mvtStockQuery += ")";
1049
        mvtStockQuery += ")";
995
        return mvtStockQuery;
1050
        return mvtStockQuery;
996
    }
1051
    }
997
 
1052
 
-
 
1053
    /**
-
 
1054
     * Article qui ont comme code les codes fournis en paramètre,
-
 
1055
     */
-
 
1056
    public Map<String, SQLRowAccessor> findArticleFromCode(List<String> codes) {
-
 
1057
        final SQLRowValues rv = new SQLRowValues(getTable());
-
 
1058
        rv.setAllToNull();
-
 
1059
        final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rv);
-
 
1060
        final List<SQLRowValues> list = fetcher.fetch(Where.inValues(getTable().getField("CODE"), codes));
-
 
1061
        final Map<String, SQLRowAccessor> result = new HashMap<>(list.size());
-
 
1062
        for (SQLRowValues r : list) {
-
 
1063
            result.put(r.getString("CODE"), r);
-
 
1064
        }
-
 
1065
        return result;
-
 
1066
    }
-
 
1067
 
998
}
1068
}