OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 174 Rev 177
Line 21... Line 21...
21
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
21
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
22
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
22
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
23
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
23
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
24
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
24
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
25
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
25
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
-
 
26
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
-
 
27
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
26
import org.openconcerto.erp.preferences.DefaultNXProps;
28
import org.openconcerto.erp.preferences.DefaultNXProps;
27
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
29
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
28
import org.openconcerto.sql.Configuration;
30
import org.openconcerto.sql.Configuration;
29
import org.openconcerto.sql.element.SQLElement;
31
import org.openconcerto.sql.element.SQLElement;
30
import org.openconcerto.sql.model.FieldPath;
32
import org.openconcerto.sql.model.FieldPath;
Line 38... Line 40...
38
import org.openconcerto.sql.model.Where;
40
import org.openconcerto.sql.model.Where;
39
import org.openconcerto.sql.model.graph.Path;
41
import org.openconcerto.sql.model.graph.Path;
40
import org.openconcerto.sql.preferences.SQLPreferences;
42
import org.openconcerto.sql.preferences.SQLPreferences;
41
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
43
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
42
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
44
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
-
 
45
import org.openconcerto.sql.view.EditFrame;
-
 
46
import org.openconcerto.sql.view.EditPanel.EditMode;
43
import org.openconcerto.sql.view.list.AutoCompletionManager;
47
import org.openconcerto.sql.view.list.AutoCompletionManager;
44
import org.openconcerto.sql.view.list.CellDynamicModifier;
48
import org.openconcerto.sql.view.list.CellDynamicModifier;
45
import org.openconcerto.sql.view.list.RowValuesTable;
49
import org.openconcerto.sql.view.list.RowValuesTable;
46
import org.openconcerto.sql.view.list.RowValuesTableModel;
50
import org.openconcerto.sql.view.list.RowValuesTableModel;
47
import org.openconcerto.sql.view.list.SQLTableElement;
51
import org.openconcerto.sql.view.list.SQLTableElement;
48
import org.openconcerto.sql.view.list.ValidStateChecker;
52
import org.openconcerto.sql.view.list.ValidStateChecker;
-
 
53
import org.openconcerto.ui.preferences.DefaultProps;
49
import org.openconcerto.utils.DecimalUtils;
54
import org.openconcerto.utils.DecimalUtils;
50
import org.openconcerto.utils.Tuple3;
55
import org.openconcerto.utils.Tuple3;
51
import org.openconcerto.utils.i18n.TranslationManager;
56
import org.openconcerto.utils.i18n.TranslationManager;
52
 
57
 
53
import java.awt.Component;
58
import java.awt.Component;
54
import java.awt.event.ActionEvent;
59
import java.awt.event.ActionEvent;
-
 
60
import java.awt.event.ActionListener;
55
import java.awt.event.HierarchyEvent;
61
import java.awt.event.HierarchyEvent;
56
import java.awt.event.HierarchyListener;
62
import java.awt.event.HierarchyListener;
57
import java.awt.event.KeyEvent;
63
import java.awt.event.KeyEvent;
58
import java.awt.event.MouseAdapter;
64
import java.awt.event.MouseAdapter;
59
import java.awt.event.MouseEvent;
65
import java.awt.event.MouseEvent;
Line 68... Line 74...
68
import java.util.Map;
74
import java.util.Map;
69
import java.util.Set;
75
import java.util.Set;
70
import java.util.Vector;
76
import java.util.Vector;
71
 
77
 
72
import javax.swing.AbstractAction;
78
import javax.swing.AbstractAction;
-
 
79
import javax.swing.JButton;
73
import javax.swing.JFrame;
80
import javax.swing.JFrame;
74
import javax.swing.JLabel;
81
import javax.swing.JLabel;
75
import javax.swing.JOptionPane;
82
import javax.swing.JOptionPane;
76
import javax.swing.JPopupMenu;
83
import javax.swing.JPopupMenu;
77
import javax.swing.JTable;
84
import javax.swing.JTable;
Line 353... Line 360...
353
        list.add(tableElementPoids);
360
        list.add(tableElementPoids);
354
 
361
 
355
        // Poids total
362
        // Poids total
356
        this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class);
363
        this.tableElementPoidsTotal = new SQLTableElement(e.getTable().getField("T_POIDS"), Float.class);
357
        list.add(this.tableElementPoidsTotal);
364
        list.add(this.tableElementPoidsTotal);
-
 
365
        // Packaging
-
 
366
        if (e.getTable().contains("POIDS_COLIS_NET") && prefs.getBoolean(GestionArticleGlobalPreferencePanel.ITEM_PACKAGING, false)) {
358
 
367
 
-
 
368
            SQLTableElement tareColis = new SQLTableElement(e.getTable().getField("TARE"), BigDecimal.class) {
-
 
369
                @Override
-
 
370
                public TableCellRenderer getTableCellRenderer() {
-
 
371
                    return new QteUnitRowValuesRenderer();
-
 
372
                }
-
 
373
 
-
 
374
            };
-
 
375
            list.add(tareColis);
-
 
376
 
-
 
377
            SQLTableElement poidsColis = new SQLTableElement(e.getTable().getField("POIDS_COLIS_NET"), BigDecimal.class) {
-
 
378
                @Override
-
 
379
                public TableCellRenderer getTableCellRenderer() {
-
 
380
                    return new QteUnitRowValuesRenderer();
-
 
381
                }
-
 
382
 
-
 
383
            };
-
 
384
            list.add(poidsColis);
-
 
385
 
-
 
386
            SQLTableElement nbColis = new SQLTableElement(e.getTable().getField("NB_COLIS"), Integer.class);
-
 
387
            list.add(nbColis);
-
 
388
 
-
 
389
            final SQLTableElement totalPoidsColis = new SQLTableElement(e.getTable().getField("T_POIDS_COLIS_NET"), BigDecimal.class) {
-
 
390
                @Override
-
 
391
                public TableCellRenderer getTableCellRenderer() {
-
 
392
                    return new QteUnitRowValuesRenderer();
-
 
393
                }
-
 
394
 
-
 
395
            };
-
 
396
            list.add(totalPoidsColis);
-
 
397
 
-
 
398
            poidsColis.addModificationListener(totalPoidsColis);
-
 
399
            nbColis.addModificationListener(totalPoidsColis);
-
 
400
            totalPoidsColis.setModifier(new CellDynamicModifier() {
-
 
401
                public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
-
 
402
                    final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
-
 
403
                    final Object o3 = row.getObject("NB_COLIS");
-
 
404
 
-
 
405
                    BigDecimal pdsColisTotal = BigDecimal.ZERO;
-
 
406
 
-
 
407
                    if (pdsColis != null && o3 != null) {
-
 
408
                        int nb = (Integer) o3;
-
 
409
                        pdsColisTotal = pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION);
-
 
410
                    }
-
 
411
                    return pdsColisTotal.setScale(totalPoidsColis.getDecimalDigits(), RoundingMode.HALF_UP);
-
 
412
                }
-
 
413
            });
-
 
414
 
-
 
415
            final SQLTableElement totalPoidsBrut = new SQLTableElement(e.getTable().getField("T_POIDS_BRUT"), BigDecimal.class) {
-
 
416
                @Override
-
 
417
                public TableCellRenderer getTableCellRenderer() {
-
 
418
                    return new QteUnitRowValuesRenderer();
-
 
419
                }
-
 
420
 
-
 
421
            };
-
 
422
            list.add(totalPoidsBrut);
-
 
423
 
-
 
424
            tareColis.addModificationListener(totalPoidsBrut);
-
 
425
            poidsColis.addModificationListener(totalPoidsBrut);
-
 
426
            nbColis.addModificationListener(totalPoidsBrut);
-
 
427
            this.tableElementPoidsTotal.addModificationListener(totalPoidsBrut);
-
 
428
            totalPoidsBrut.setModifier(new CellDynamicModifier() {
-
 
429
                public Object computeValueFrom(final SQLRowValues row, SQLTableElement source) {
-
 
430
                    final BigDecimal tare = row.getBigDecimal("TARE");
-
 
431
                    final int qte = row.getInt("QTE");
-
 
432
                    final BigDecimal pdsColis = row.getBigDecimal("POIDS_COLIS_NET");
-
 
433
                    final Object o3 = row.getObject("NB_COLIS");
-
 
434
 
-
 
435
                    BigDecimal pdsBrutTotal = BigDecimal.ZERO;
-
 
436
 
-
 
437
                    if (row.getObject("T_POIDS") != null) {
-
 
438
                        pdsBrutTotal = new BigDecimal(row.getFloat("T_POIDS"));
-
 
439
                    }
-
 
440
 
-
 
441
                    if (tare != null) {
-
 
442
                        pdsBrutTotal = pdsBrutTotal.add(tare.multiply(new BigDecimal(qte)));
-
 
443
                    }
-
 
444
 
-
 
445
                    if (pdsColis != null && o3 != null) {
-
 
446
                        int nb = (Integer) o3;
-
 
447
                        pdsBrutTotal = pdsBrutTotal.add(pdsColis.multiply(new BigDecimal(nb), DecimalUtils.HIGH_PRECISION));
-
 
448
                    }
-
 
449
                    // return row.getObject("T_POIDS_COLIS_NET");
-
 
450
                    return pdsBrutTotal.setScale(totalPoidsBrut.getDecimalDigits(), RoundingMode.HALF_UP);
-
 
451
                }
-
 
452
            });
-
 
453
 
-
 
454
        }
359
        // Service
455
        // Service
360
        String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
456
        String val = DefaultNXProps.getInstance().getStringProperty("ArticleService");
361
        Boolean b = Boolean.valueOf(val);
457
        Boolean b = Boolean.valueOf(val);
362
        if (b != null && b.booleanValue()) {
458
        if (b != null && b.booleanValue()) {
363
            this.service = new SQLTableElement(e.getTable().getField("SERVICE"), Boolean.class);
459
            this.service = new SQLTableElement(e.getTable().getField("SERVICE"), Boolean.class);
Line 399... Line 495...
399
        this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PA_TTC"), BigDecimal.class);
495
        this.tableElementTotalTTC = new SQLTableElement(e.getTable().getField("T_PA_TTC"), BigDecimal.class);
400
        this.tableElementTotalTTC.setRenderer(totalRenderer);
496
        this.tableElementTotalTTC.setRenderer(totalRenderer);
401
        list.add(this.tableElementTotalTTC);
497
        list.add(this.tableElementTotalTTC);
402
 
498
 
403
        this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
499
        this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
404
        this.defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
500
        this.defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxeAchat().getID());
405
        this.defaultRowVals.put("CODE", "");
501
        this.defaultRowVals.put("CODE", "");
406
        this.defaultRowVals.put("NOM", "");
502
        this.defaultRowVals.put("NOM", "");
407
        this.defaultRowVals.put("QTE", 1);
503
        this.defaultRowVals.put("QTE", 1);
408
        this.defaultRowVals.put("QTE_UNITAIRE", BigDecimal.ONE);
504
        this.defaultRowVals.put("QTE_UNITAIRE", BigDecimal.ONE);
409
        this.defaultRowVals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
505
        this.defaultRowVals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
410
        this.defaultRowVals.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
506
        this.defaultRowVals.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
-
 
507
 
-
 
508
        if (e.getTable().contains("ID_DEPOT_STOCK")) {
-
 
509
            DefaultProps props = DefaultNXProps.getInstance();
-
 
510
            Integer depotDefault = props.getIntProperty("DepotStockDefault", DepotStockSQLElement.DEFAULT_ID);
-
 
511
            this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault);
-
 
512
        }
-
 
513
 
411
        final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals);
514
        final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals) {
-
 
515
            @Override
-
 
516
            public void commitData() {
-
 
517
                super.commitData(true);
-
 
518
            }
-
 
519
        };
-
 
520
 
412
        setModel(model);
521
        setModel(model);
413
 
522
 
414
        this.table = new RowValuesTable(model, getConfigurationFile());
523
        this.table = new RowValuesTable(model, getConfigurationFile());
415
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
524
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
416
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
525
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
-
 
526
        if (getSQLElement().getTable().getName().equals("COMMANDE_ELEMENT")) {
-
 
527
            this.table.getClearCloneTableElement().add("QTE_RECUE");
-
 
528
            this.table.getClearCloneTableElement().add("RECU");
-
 
529
            this.table.getClearCloneTableElement().add("RECU_FORCED");
-
 
530
        } else if (getSQLElement().getTable().getName().equals("BON_RECEPTION_ELEMENT")) {
-
 
531
            this.table.getClearCloneTableElement().add("ID_COMMANDE_ELEMENT");
-
 
532
        }
417
 
533
 
418
        table.addMouseListener(new MouseAdapter() {
534
        table.addMouseListener(new MouseAdapter() {
419
            @Override
535
            @Override
420
            public void mouseReleased(MouseEvent e) {
536
            public void mouseReleased(MouseEvent e) {
421
                handlePopup(e);
537
                handlePopup(e);
Line 504... Line 620...
504
            completionFields.add("DESCRIPTIF");
620
            completionFields.add("DESCRIPTIF");
505
        }
621
        }
506
        if (e.getTable().getFieldsName().contains("ID_FAMILLE_ARTICLE")) {
622
        if (e.getTable().getFieldsName().contains("ID_FAMILLE_ARTICLE")) {
507
            completionFields.add("ID_FAMILLE_ARTICLE");
623
            completionFields.add("ID_FAMILLE_ARTICLE");
508
        }
624
        }
-
 
625
        final SQLTable sqlTableArticle = e.getTable().getTable("ARTICLE");
-
 
626
        if (getSQLElement().getTable().getFieldsName().contains("POIDS_COLIS_NET") && sqlTableArticle.getTable().getFieldsName().contains("POIDS_COLIS_NET")) {
-
 
627
            completionFields.add("POIDS_COLIS_NET");
509
 
628
        }
510
        this.m = new AutoCompletionManager(tableElementCode, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.CODE"), this.table,
629
        if (getSQLElement().getTable().getFieldsName().contains("TARE") && sqlTableArticle.getTable().getFieldsName().contains("TARE")) {
511
                this.table.getRowValuesTableModel()) {
630
            completionFields.add("TARE");
-
 
631
        }
-
 
632
        this.m = new AutoCompletionManager(tableElementCode, sqlTableArticle.getField("CODE"), this.table, this.table.getRowValuesTableModel()) {
512
            @Override
633
            @Override
513
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
634
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
514
                Object res = tarifCompletion(row, field);
635
                Object res = tarifCompletion(row, field);
515
                if (res == null) {
636
                if (res == null) {
516
                    return super.getValueFrom(row, field, rowDest);
637
                    return super.getValueFrom(row, field, rowDest);
Line 519... Line 640...
519
                }
640
                }
520
            }
641
            }
521
        };
642
        };
522
        m.fill("NOM", "NOM");
643
        m.fill("NOM", "NOM");
523
        m.fill("ID", "ID_ARTICLE");
644
        m.fill("ID", "ID_ARTICLE");
-
 
645
        if (e.getTable().contains("ID_CODE_FOURNISSEUR") && supplierCode) {
-
 
646
            m.fill("ID_CODE_FOURNISSEUR", "ID_CODE_FOURNISSEUR");
-
 
647
        }
524
        for (String string : completionFields) {
648
        for (String string : completionFields) {
525
            m.fill(string, string);
649
            m.fill(string, string);
526
        }
650
        }
527
        final SQLTable sqlTableArticle = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("ARTICLE");
-
 
528
        final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
651
        final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
529
        m.setWhere(w);
652
        m.setWhere(w);
530
 
653
 
531
        this.m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
654
        this.m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
532
                this.table.getRowValuesTableModel()) {
655
                this.table.getRowValuesTableModel()) {
Line 577... Line 700...
577
                    } else {
700
                    } else {
578
                        return res;
701
                        return res;
579
                    }
702
                    }
580
                }
703
                }
581
            };
704
            };
-
 
705
            m4.fill("ID", "ID_ARTICLE");
582
            m4.fill("CODE", "CODE");
706
            m4.fill("CODE", "CODE");
583
            m4.fill("NOM", "NOM");
707
            m4.fill("NOM", "NOM");
584
            for (String string : completionFields) {
708
            for (String string : completionFields) {
585
                m4.fill(string, string);
709
                m4.fill(string, string);
586
            }
710
            }
Line 725... Line 849...
725
            @Override
849
            @Override
726
            public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
850
            public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
727
                int qte = Integer.parseInt(row.getObject("QTE").toString());
851
                int qte = Integer.parseInt(row.getObject("QTE").toString());
728
                BigDecimal f = (BigDecimal) row.getObject("PA_HT");
852
                BigDecimal f = (BigDecimal) row.getObject("PA_HT");
729
                int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
853
                int idTaux = Integer.parseInt(row.getObject("ID_TAXE").toString());
730
                if (idTaux < 0) {
-
 
731
                    System.out.println(row);
-
 
732
                }
-
 
733
                Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
854
                Float resultTaux = TaxeCache.getCache().getTauxFromId(idTaux);
-
 
855
                if (resultTaux == null) {
-
 
856
                    SQLRow rowTax = TaxeCache.getCache().getFirstTaxe();
-
 
857
                    row.put("ID_TAXE", rowTax.getID());
-
 
858
                    resultTaux = rowTax.getFloat("TAUX");
-
 
859
                }
734
                editorPAHT.setTaxe(resultTaux);
860
                editorPAHT.setTaxe(resultTaux);
735
                BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
861
                BigDecimal b = (row.getObject("QTE_UNITAIRE") == null) ? BigDecimal.ONE : (BigDecimal) row.getObject("QTE_UNITAIRE");
736
                BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION).setScale(tableElementTotalTTC.getDecimalDigits(),
862
                BigDecimal r = b.multiply(f.multiply(BigDecimal.valueOf(qte), DecimalUtils.HIGH_PRECISION), DecimalUtils.HIGH_PRECISION).setScale(tableElementTotalTTC.getDecimalDigits(),
737
                        BigDecimal.ROUND_HALF_UP);
863
                        BigDecimal.ROUND_HALF_UP);
738
                float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
864
                float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
Line 777... Line 903...
777
        setColumnVisible(model.getColumnForField("CODE"), !selectArticle || (selectArticle && createAuto));
903
        setColumnVisible(model.getColumnForField("CODE"), !selectArticle || (selectArticle && createAuto));
778
        setColumnVisible(model.getColumnForField("NOM"), !selectArticle || (selectArticle && createAuto));
904
        setColumnVisible(model.getColumnForField("NOM"), !selectArticle || (selectArticle && createAuto));
779
 
905
 
780
        setColumnVisible(model.getColumnForField("ID_DEPOT_STOCK"), prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
906
        setColumnVisible(model.getColumnForField("ID_DEPOT_STOCK"), prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
781
 
907
 
-
 
908
        setColumnVisible(model.getColumnForField("T_POIDS_COLIS_NET"), false);
-
 
909
        setColumnVisible(model.getColumnForField("T_POIDS_BRUT"), false);
-
 
910
 
782
        // Calcul automatique du poids unitaire
911
        // Calcul automatique du poids unitaire
783
        tableElement_ValeurMetrique1.addModificationListener(tableElementPoids);
912
        tableElement_ValeurMetrique1.addModificationListener(tableElementPoids);
784
        tableElement_ValeurMetrique2.addModificationListener(tableElementPoids);
913
        tableElement_ValeurMetrique2.addModificationListener(tableElementPoids);
785
        tableElement_ValeurMetrique3.addModificationListener(tableElementPoids);
914
        tableElement_ValeurMetrique3.addModificationListener(tableElementPoids);
786
        tableElementPoids.setModifier(new CellDynamicModifier() {
915
        tableElementPoids.setModifier(new CellDynamicModifier() {
Line 914... Line 1043...
914
 
1043
 
915
        }
1044
        }
916
 
1045
 
917
        // On réécrit la configuration au cas ou les preferences aurait changé
1046
        // On réécrit la configuration au cas ou les preferences aurait changé
918
        this.table.writeState();
1047
        this.table.writeState();
-
 
1048
 
-
 
1049
        if (this.table.getRowValuesTableModel().getColumnForField("ID_DEPOT_STOCK") >= 0 && this.table.getRowValuesTableModel().getColumnForField("ID_ARTICLE") >= 0) {
-
 
1050
            if (this.buttons == null) {
-
 
1051
                this.buttons = new ArrayList<>();
-
 
1052
            }
-
 
1053
 
-
 
1054
            JButton buttonStock = new JButton("Consulter le stock");
-
 
1055
            buttonStock.addActionListener(new ActionListener() {
-
 
1056
                public void actionPerformed(ActionEvent event) {
-
 
1057
                    SQLRowValues rowValsSel = table.getSelectedRowValues();
-
 
1058
                    if (rowValsSel != null) {
-
 
1059
                        SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
-
 
1060
                        if (foreignArt != null && !foreignArt.isUndefined()) {
-
 
1061
                            SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
-
 
1062
                            if (rowValsStock != null && !rowValsStock.isUndefined()) {
-
 
1063
                                EditFrame frame = new EditFrame(table.getRowValuesTableModel().getSQLElement().getDirectory().getElement("STOCK"), EditMode.READONLY);
-
 
1064
                                frame.selectionId(rowValsStock.getID());
-
 
1065
                                frame.setVisible(true);
-
 
1066
                            }
-
 
1067
                        }
-
 
1068
                    }
-
 
1069
 
-
 
1070
                }
-
 
1071
            });
-
 
1072
 
-
 
1073
            this.buttons.add(buttonStock);
-
 
1074
 
-
 
1075
        }
919
    }
1076
    }
920
 
1077
 
921
    private static Map<String, Boolean> visibilityMap = new HashMap<String, Boolean>();
1078
    private static Map<String, Boolean> visibilityMap = new HashMap<String, Boolean>();
922
 
1079
 
923
    public static Map<String, Boolean> getVisibilityMap() {
1080
    public static Map<String, Boolean> getVisibilityMap() {
Line 961... Line 1118...
961
    }
1118
    }
962
 
1119
 
963
    public Object tarifCompletion(SQLRow row, String field) {
1120
    public Object tarifCompletion(SQLRow row, String field) {
964
        final SQLTable tTarifFournisseur = this.getSQLElement().getTable().getDBRoot().getTable("ARTICLE_TARIF_FOURNISSEUR");
1121
        final SQLTable tTarifFournisseur = this.getSQLElement().getTable().getDBRoot().getTable("ARTICLE_TARIF_FOURNISSEUR");
965
 
1122
 
-
 
1123
        if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("ID_CODE_FOURNISSEUR")) && this.rowFournisseur != null && !this.rowFournisseur.isUndefined()) {
-
 
1124
            final SQLTable foreignTableCodeF = getSQLElement().getTable().getForeignTable("ID_CODE_FOURNISSEUR");
-
 
1125
            List<SQLRow> resultCode = row.getReferentRows(foreignTableCodeF);
-
 
1126
            int idCode = foreignTableCodeF.getUndefinedID();
-
 
1127
            for (SQLRow sqlRow : resultCode) {
-
 
1128
                if (sqlRow.getForeignID("ID_FOURNISSEUR") == this.rowFournisseur.getID()) {
-
 
1129
                    return sqlRow.getID();
-
 
1130
                }
-
 
1131
 
-
 
1132
            }
-
 
1133
            return idCode;
-
 
1134
        }
-
 
1135
        if (field.equalsIgnoreCase("ID_CODE_FOURNISSEUR")) {
-
 
1136
            final SQLTable foreignTableCodeF = getSQLElement().getTable().getForeignTable("ID_CODE_FOURNISSEUR");
-
 
1137
            return foreignTableCodeF.getUndefinedID();
-
 
1138
        }
-
 
1139
 
966
        if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("PRIX_METRIQUE_HA_1") || field.equalsIgnoreCase("PA_HT")) && tTarifFournisseur != null) {
1140
        if (row != null && !row.isUndefined() && (field.equalsIgnoreCase("PRIX_METRIQUE_HA_1") || field.equalsIgnoreCase("PA_HT")) && tTarifFournisseur != null) {
967
            List<String> incoTerms;
1141
            List<String> incoTerms;
968
 
1142
 
969
            if (this.incoterm != null && this.incoterm.equalsIgnoreCase("CPT")) {
1143
            if (this.incoterm != null && this.incoterm.equalsIgnoreCase("CPT")) {
970
                incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT");
1144
                incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT");
Line 972... Line 1146...
972
                incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT", "COEF_TAXE_D");
1146
                incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT", "COEF_TAXE_D");
973
            } else {
1147
            } else {
974
                incoTerms = Arrays.asList("PRIX_ACHAT");
1148
                incoTerms = Arrays.asList("PRIX_ACHAT");
975
            }
1149
            }
976
            List<SQLRow> rows = row.getReferentRows(tTarifFournisseur);
1150
            List<SQLRow> rows = row.getReferentRows(tTarifFournisseur);
977
            if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE")) {
1151
            if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE") && row.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
978
 
1152
 
979
                List<SQLRow> rowsElt = row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
1153
                List<SQLRow> rowsElt = row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
980
                BigDecimal price = BigDecimal.ZERO;
1154
                BigDecimal price = BigDecimal.ZERO;
981
                final Set<String> tarifNotFound = new HashSet<String>();
1155
                final Set<String> tarifNotFound = new HashSet<String>();
982
                for (SQLRow sqlRow : rowsElt) {
1156
                for (SQLRow sqlRow : rowsElt) {
Line 1234... Line 1408...
1234
                row2Insert.put("T_PA_HT", resultTotalHT);
1408
                row2Insert.put("T_PA_HT", resultTotalHT);
1235
 
1409
 
1236
                Float resultTaux = TaxeCache.getCache().getTauxFromId(row2Insert.getForeignID("ID_TAXE"));
1410
                Float resultTaux = TaxeCache.getCache().getTauxFromId(row2Insert.getForeignID("ID_TAXE"));
1237
 
1411
 
1238
                if (resultTaux == null) {
1412
                if (resultTaux == null) {
1239
                    SQLRow rowTax = TaxeCache.getCache().getFirstTaxe();
1413
                    SQLRow rowTax = TaxeCache.getCache().getFirstTaxeAchat();
1240
                    resultTaux = rowTax.getFloat("TAUX");
1414
                    resultTaux = rowTax.getFloat("TAUX");
1241
                }
1415
                }
1242
 
1416
 
1243
                float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
1417
                float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue();
1244
 
1418