OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 177 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 24... Line 24...
24
import org.openconcerto.erp.core.sales.product.model.ProductHelper.TypePrice;
24
import org.openconcerto.erp.core.sales.product.model.ProductHelper.TypePrice;
25
import org.openconcerto.erp.core.sales.product.ui.ArticleRowValuesRenderer;
25
import org.openconcerto.erp.core.sales.product.ui.ArticleRowValuesRenderer;
26
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
26
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
27
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
27
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
28
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
28
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
-
 
29
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
29
import org.openconcerto.erp.importer.ArrayTableModel;
30
import org.openconcerto.erp.importer.ArrayTableModel;
30
import org.openconcerto.erp.importer.DataImporter;
31
import org.openconcerto.erp.importer.DataImporter;
31
import org.openconcerto.erp.preferences.DefaultNXProps;
32
import org.openconcerto.erp.preferences.DefaultNXProps;
32
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
33
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
33
import org.openconcerto.sql.Configuration;
34
import org.openconcerto.sql.Configuration;
Line 46... Line 47...
46
import org.openconcerto.sql.preferences.SQLPreferences;
47
import org.openconcerto.sql.preferences.SQLPreferences;
47
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
48
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
48
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
49
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
49
import org.openconcerto.sql.users.rights.UserRights;
50
import org.openconcerto.sql.users.rights.UserRights;
50
import org.openconcerto.sql.users.rights.UserRightsManager;
51
import org.openconcerto.sql.users.rights.UserRightsManager;
-
 
52
import org.openconcerto.sql.view.EditFrame;
-
 
53
import org.openconcerto.sql.view.EditPanel.EditMode;
51
import org.openconcerto.sql.view.list.AutoCompletionManager;
54
import org.openconcerto.sql.view.list.AutoCompletionManager;
52
import org.openconcerto.sql.view.list.CellDynamicModifier;
55
import org.openconcerto.sql.view.list.CellDynamicModifier;
53
import org.openconcerto.sql.view.list.RowValuesTable;
56
import org.openconcerto.sql.view.list.RowValuesTable;
54
import org.openconcerto.sql.view.list.RowValuesTableModel;
57
import org.openconcerto.sql.view.list.RowValuesTableModel;
55
import org.openconcerto.sql.view.list.SQLTableElement;
58
import org.openconcerto.sql.view.list.SQLTableElement;
Line 68... Line 71...
68
import java.awt.datatransfer.UnsupportedFlavorException;
71
import java.awt.datatransfer.UnsupportedFlavorException;
69
import java.awt.dnd.DnDConstants;
72
import java.awt.dnd.DnDConstants;
70
import java.awt.dnd.DropTarget;
73
import java.awt.dnd.DropTarget;
71
import java.awt.dnd.DropTargetDropEvent;
74
import java.awt.dnd.DropTargetDropEvent;
72
import java.awt.event.ActionEvent;
75
import java.awt.event.ActionEvent;
-
 
76
import java.awt.event.ActionListener;
73
import java.awt.event.HierarchyEvent;
77
import java.awt.event.HierarchyEvent;
74
import java.awt.event.HierarchyListener;
78
import java.awt.event.HierarchyListener;
75
import java.awt.event.KeyEvent;
79
import java.awt.event.KeyEvent;
76
import java.awt.event.MouseAdapter;
80
import java.awt.event.MouseAdapter;
77
import java.awt.event.MouseEvent;
81
import java.awt.event.MouseEvent;
Line 90... Line 94...
90
 
94
 
91
import javax.swing.AbstractAction;
95
import javax.swing.AbstractAction;
92
import javax.swing.JButton;
96
import javax.swing.JButton;
93
import javax.swing.JFrame;
97
import javax.swing.JFrame;
94
import javax.swing.JLabel;
98
import javax.swing.JLabel;
-
 
99
import javax.swing.JMenu;
-
 
100
import javax.swing.JMenuItem;
95
import javax.swing.JOptionPane;
101
import javax.swing.JOptionPane;
96
import javax.swing.JPopupMenu;
102
import javax.swing.JPopupMenu;
97
import javax.swing.JTable;
103
import javax.swing.JTable;
98
import javax.swing.SwingUtilities;
104
import javax.swing.SwingUtilities;
99
import javax.swing.ToolTipManager;
105
import javax.swing.ToolTipManager;
Line 285... Line 291...
285
        eNiveau.setEditor(new NiveauTableCellEditor());
291
        eNiveau.setEditor(new NiveauTableCellEditor());
286
        list.add(eNiveau);
292
        list.add(eNiveau);
287
 
293
 
288
        list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
294
        list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
289
 
295
 
-
 
296
        if (e.getTable().contains("ID_COMPTE_PCE")) {
-
 
297
            list.add(new SQLTableElement(e.getTable().getField("ID_COMPTE_PCE")));
-
 
298
        }
-
 
299
 
290
        final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
300
        final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
291
        list.add(tableFamille);
301
        list.add(tableFamille);
292
 
302
 
293
        // Article
303
        // Article
294
        SQLTableElement tableElementDepot = new SQLTableElement(e.getTable().getField("ID_DEPOT_STOCK"), true, true, true);
304
        SQLTableElement tableElementDepot = new SQLTableElement(e.getTable().getField("ID_DEPOT_STOCK"), true, true, true);
Line 641... Line 651...
641
            @Override
651
            @Override
642
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
652
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
643
                return isCellNiveauEditable(vals, rowIndex, columnIndex);
653
                return isCellNiveauEditable(vals, rowIndex, columnIndex);
644
            }
654
            }
645
        };
655
        };
-
 
656
        CurrencyWithSymbolRenderer totalRenderer = new CurrencyWithSymbolRenderer();
-
 
657
        totalRenderer.setHideZeroValue(true);
646
        this.totalHT.setRenderer(new CurrencyWithSymbolRenderer());
658
        this.totalHT.setRenderer(totalRenderer);
647
        this.totalHT.setEditable(false);
659
        this.totalHT.setEditable(false);
648
        if (e.getTable().getFieldsName().contains("MONTANT_FACTURABLE")) {
660
        if (e.getTable().getFieldsName().contains("MONTANT_FACTURABLE")) {
649
            // SQLTableElement tableElementAcompte = new
661
            // SQLTableElement tableElementAcompte = new
650
            // SQLTableElement(e.getTable().getField("POURCENT_ACOMPTE"));
662
            // SQLTableElement(e.getTable().getField("POURCENT_ACOMPTE"));
651
            // list.add(tableElementAcompte);
663
            // list.add(tableElementAcompte);
Line 725... Line 737...
725
            list.add(tableElementRG);
737
            list.add(tableElementRG);
726
        }
738
        }
727
 
739
 
728
        // Total HT
740
        // Total HT
729
        this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
741
        this.totalHA = new SQLTableElement(e.getTable().getField("T_PA_HT"), BigDecimal.class);
730
        this.totalHA.setRenderer(new CurrencyWithSymbolRenderer());
742
        this.totalHA.setRenderer(totalRenderer);
731
        this.totalHA.setEditable(false);
743
        this.totalHA.setEditable(false);
732
        list.add(this.totalHA);
744
        list.add(this.totalHA);
733
 
745
 
734
        if (showDevise) {
746
        if (showDevise) {
735
            // Total HT
747
            // Total HT
Line 738... Line 750...
738
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
750
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
739
                    return isCellNiveauEditable(vals, rowIndex, columnIndex);
751
                    return isCellNiveauEditable(vals, rowIndex, columnIndex);
740
                }
752
                }
741
            };
753
            };
742
            Path p = new Path(getSQLElement().getTable()).addForeignField("ID_DEVISE");
754
            Path p = new Path(getSQLElement().getTable()).addForeignField("ID_DEVISE");
743
            this.tableElementTotalDevise.setRenderer(new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE")));
755
            CurrencyWithSymbolRenderer currencyRenderer = new CurrencyWithSymbolRenderer(new FieldPath(p, "CODE"));
-
 
756
            currencyRenderer.setHideZeroValue(true);
-
 
757
            this.tableElementTotalDevise.setRenderer(currencyRenderer);
744
            list.add(tableElementTotalDevise);
758
            list.add(this.tableElementTotalDevise);
745
        }
759
        }
746
 
760
 
747
        // Marge HT
761
        // Marge HT
748
        if (e.getTable().getFieldsName().contains("MARGE_HT")) {
762
        if (e.getTable().getFieldsName().contains("MARGE_HT")) {
749
 
763
 
Line 756... Line 770...
756
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
770
                public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
757
                    return isCellNiveauEditable(vals, rowIndex, columnIndex);
771
                    return isCellNiveauEditable(vals, rowIndex, columnIndex);
758
                }
772
                }
759
 
773
 
760
            };
774
            };
761
            marge.setRenderer(new CurrencyWithSymbolRenderer());
775
            marge.setRenderer(totalRenderer);
762
            marge.setEditable(false);
776
            marge.setEditable(false);
763
            list.add(marge);
777
            list.add(marge);
764
            this.totalHT.addModificationListener(marge);
778
            this.totalHT.addModificationListener(marge);
765
            this.totalHA.addModificationListener(marge);
779
            this.totalHA.addModificationListener(marge);
766
            marge.setModifier(new CellDynamicModifier() {
780
            marge.setModifier(new CellDynamicModifier() {
Line 832... Line 846...
832
            @Override
846
            @Override
833
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
847
            public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
834
                return isCellNiveauEditable(vals, rowIndex, columnIndex);
848
                return isCellNiveauEditable(vals, rowIndex, columnIndex);
835
            }
849
            }
836
        };
850
        };
837
        this.tableElementTotalTTC.setRenderer(new CurrencyWithSymbolRenderer());
851
        this.tableElementTotalTTC.setRenderer(totalRenderer);
838
        this.tableElementTotalTTC.setEditable(false);
852
        this.tableElementTotalTTC.setEditable(false);
839
        list.add(this.tableElementTotalTTC);
853
        list.add(this.tableElementTotalTTC);
840
 
854
 
841
        this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
855
        this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
842
        defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
856
        defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
Line 861... Line 875...
861
 
875
 
862
        this.table = new RowValuesTable(model, getConfigurationFile());
876
        this.table = new RowValuesTable(model, getConfigurationFile());
863
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
877
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
864
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
878
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
865
 
879
 
-
 
880
        this.table.getTableHeader().addMouseListener(new MouseAdapter() {
-
 
881
            @Override
-
 
882
            public void mousePressed(MouseEvent e) {
-
 
883
                if (e.isPopupTrigger()) {
-
 
884
                    displayPopupMenu(e);
-
 
885
                }
-
 
886
            }
-
 
887
 
-
 
888
            @Override
-
 
889
            public void mouseReleased(MouseEvent e) {
-
 
890
                if (e.isPopupTrigger()) {
-
 
891
                    displayPopupMenu(e);
-
 
892
                }
-
 
893
            }
-
 
894
 
-
 
895
            private void displayPopupMenu(MouseEvent e) {
-
 
896
                JPopupMenu menu = new JPopupMenu();
-
 
897
 
-
 
898
                TaxeCache cache = TaxeCache.getCache();
-
 
899
                Set<SQLRowAccessor> taxes = cache.getAllTaxe();
-
 
900
                JMenu subMenuTVA = new JMenu("Appliquer une TVA spécifique sur toutes les lignes");
-
 
901
                menu.add(subMenuTVA);
-
 
902
                for (SQLRowAccessor taxe : taxes) {
-
 
903
 
-
 
904
                    subMenuTVA.add(new JMenuItem(new AbstractAction(taxe.getFloat("TAUX") + "%") {
-
 
905
 
-
 
906
                        @Override
-
 
907
                        public void actionPerformed(ActionEvent e) {
-
 
908
                            for (int i = 0; i < AbstractVenteArticleItemTable.this.table.getRowCount(); i++) {
-
 
909
                                AbstractVenteArticleItemTable.this.table.getRowValuesTableModel().putValue(taxe.getID(), i, "ID_TAXE");
-
 
910
                            }
-
 
911
                        }
-
 
912
                    }));
-
 
913
                }
-
 
914
                menu.show(e.getComponent(), e.getX(), e.getY());
-
 
915
            }
-
 
916
        });
-
 
917
 
866
        if (filterFamilleArticle) {
918
        if (filterFamilleArticle) {
867
            ((SQLTextComboTableCellEditor) tableElementArticle.getTableCellEditor(this.table)).setDynamicWhere(e.getTable().getTable("ARTICLE").getField("ID_FAMILLE_ARTICLE"));
919
            ((SQLTextComboTableCellEditor) tableElementArticle.getTableCellEditor(this.table)).setDynamicWhere(e.getTable().getTable("ARTICLE").getField("ID_FAMILLE_ARTICLE"));
868
        }
920
        }
869
 
921
 
870
        // Autocompletion
922
        // Autocompletion
Line 911... Line 963...
911
 
963
 
912
            @Override
964
            @Override
913
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
965
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
914
                Object res = tarifCompletion(row, field, rowDest, true);
966
                Object res = tarifCompletion(row, field, rowDest, true);
915
                if (res == null) {
967
                if (res == null) {
916
                    return super.getValueFrom(row, field, rowDest);
968
                    res = super.getValueFrom(row, field, rowDest);
917
                } else {
969
                }
-
 
970
                if (field.equals("POURCENT_REMISE")) {
918
                    return res;
971
                    return getRemiseClient(row);
919
                }
972
                }
-
 
973
                return res;
920
            }
974
            }
921
 
975
 
922
        };
976
        };
923
        m.fill("NOM", "NOM");
977
        m.fill("NOM", "NOM");
924
        m.fill("ID", "ID_ARTICLE");
978
        m.fill("ID", "ID_ARTICLE");
Line 1007... Line 1061...
1007
        final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNom, sqlTableArticle.getField("NOM"), this.table, this.table.getRowValuesTableModel()) {
1061
        final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNom, sqlTableArticle.getField("NOM"), this.table, this.table.getRowValuesTableModel()) {
1008
            @Override
1062
            @Override
1009
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
1063
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
1010
                Object res = tarifCompletion(row, field, rowDest, true);
1064
                Object res = tarifCompletion(row, field, rowDest, true);
1011
                if (res == null) {
1065
                if (res == null) {
1012
                    return super.getValueFrom(row, field, rowDest);
1066
                    res = super.getValueFrom(row, field, rowDest);
1013
                } else {
-
 
1014
                    return res;
-
 
1015
                }
1067
                }
-
 
1068
                if (field.equals("POURCENT_REMISE")) {
-
 
1069
                    return getRemiseClient(row);
-
 
1070
                }
-
 
1071
                return res;
1016
            }
1072
            }
1017
 
1073
 
1018
        };
1074
        };
1019
        m2.fill("CODE", "CODE");
1075
        m2.fill("CODE", "CODE");
1020
        m2.fill("ID", "ID_ARTICLE");
1076
        m2.fill("ID", "ID_ARTICLE");
Line 1028... Line 1084...
1028
                ITextWithCompletion.MODE_CONTAINS, true, true, new ValidStateChecker()) {
1084
                ITextWithCompletion.MODE_CONTAINS, true, true, new ValidStateChecker()) {
1029
            @Override
1085
            @Override
1030
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
1086
            protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
1031
                Object res = tarifCompletion(row, field, rowDest, true);
1087
                Object res = tarifCompletion(row, field, rowDest, true);
1032
                if (res == null) {
1088
                if (res == null) {
1033
                    return super.getValueFrom(row, field, rowDest);
1089
                    res = super.getValueFrom(row, field, rowDest);
1034
                } else {
-
 
1035
                    return res;
-
 
1036
                }
1090
                }
-
 
1091
                if (field.equals("POURCENT_REMISE")) {
-
 
1092
                    return getRemiseClient(row);
-
 
1093
                }
-
 
1094
                return res;
1037
            }
1095
            }
1038
 
1096
 
1039
        };
1097
        };
1040
        m3.fill("CODE", "CODE");
1098
        m3.fill("CODE", "CODE");
1041
        m3.fill("NOM", "NOM");
1099
        m3.fill("NOM", "NOM");
Line 1525... Line 1583...
1525
        }
1583
        }
1526
 
1584
 
1527
        // On réécrit la configuration au cas ou les preferences aurait changé (ajout ou suppression
1585
        // On réécrit la configuration au cas ou les preferences aurait changé (ajout ou suppression
1528
        // du mode de vente specifique)
1586
        // du mode de vente specifique)
1529
        this.table.writeState();
1587
        this.table.writeState();
-
 
1588
 
-
 
1589
        if (this.table.getRowValuesTableModel().getColumnForField("ID_DEPOT_STOCK") >= 0 && this.table.getRowValuesTableModel().getColumnForField("ID_ARTICLE") >= 0) {
-
 
1590
            if (this.buttons == null) {
-
 
1591
                this.buttons = new ArrayList<>();
-
 
1592
            }
-
 
1593
 
-
 
1594
            JButton buttonStock = new JButton("Consulter le stock");
-
 
1595
            buttonStock.addActionListener(new ActionListener() {
-
 
1596
                public void actionPerformed(ActionEvent event) {
-
 
1597
                    SQLRowValues rowValsSel = table.getSelectedRowValues();
-
 
1598
                    if (rowValsSel != null) {
-
 
1599
                        SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
-
 
1600
                        if (foreignArt != null && !foreignArt.isUndefined()) {
-
 
1601
                            SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
-
 
1602
                            if (rowValsStock != null && !rowValsStock.isUndefined()) {
-
 
1603
                                EditFrame frame = new EditFrame(table.getRowValuesTableModel().getSQLElement().getDirectory().getElement("STOCK"), EditMode.READONLY);
-
 
1604
                                frame.selectionId(rowValsStock.getID());
-
 
1605
                                frame.setVisible(true);
-
 
1606
                            }
-
 
1607
                        }
-
 
1608
                    }
-
 
1609
 
-
 
1610
                }
-
 
1611
            });
-
 
1612
 
-
 
1613
            this.buttons.add(buttonStock);
-
 
1614
 
-
 
1615
        }
-
 
1616
 
-
 
1617
    }
-
 
1618
 
-
 
1619
    Collection<? extends SQLRowAccessor> cacheRemise = null;
-
 
1620
 
-
 
1621
    protected BigDecimal getTarifRemiseClient(SQLRowAccessor article, BigDecimal pv) {
-
 
1622
        if (cacheRemise != null) {
-
 
1623
            if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
-
 
1624
                for (SQLRowAccessor sqlRowAccessor : cacheRemise) {
-
 
1625
                    if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
-
 
1626
                        BigDecimal remise = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
-
 
1627
                        if (remise != null) {
-
 
1628
                            return pv.multiply(BigDecimal.ONE.subtract(remise.movePointLeft(2)), DecimalUtils.HIGH_PRECISION).setScale(pv.scale(), RoundingMode.HALF_UP);
-
 
1629
                        }
-
 
1630
                    }
-
 
1631
                }
-
 
1632
            }
-
 
1633
        }
-
 
1634
        return pv;
-
 
1635
    }
-
 
1636
 
-
 
1637
    protected Acompte getRemiseClient(SQLRowAccessor article) {
-
 
1638
        Acompte remise = new Acompte(BigDecimal.ZERO, BigDecimal.ZERO);
-
 
1639
        if (this.cacheRemise != null) {
-
 
1640
            if (getRowClient() != null && !getRowClient().isUndefined() && article != null && !article.isUndefined()) {
-
 
1641
                for (SQLRowAccessor sqlRowAccessor : this.cacheRemise) {
-
 
1642
                    if (!sqlRowAccessor.isForeignEmpty("ID_ARTICLE") && sqlRowAccessor.getForeignID("ID_ARTICLE") == article.getID()) {
-
 
1643
                        BigDecimal r = sqlRowAccessor.getBigDecimal("POURCENT_REMISE");
-
 
1644
                        if (remise != null) {
-
 
1645
                            remise = new Acompte(r, null);
-
 
1646
                        }
-
 
1647
                    }
-
 
1648
                }
-
 
1649
            }
-
 
1650
        }
-
 
1651
        return remise;
1530
    }
1652
    }
1531
 
1653
 
1532
    @Override
1654
    @Override
1533
    protected void refreshDeviseAmount() {
1655
    protected void refreshDeviseAmount() {
1534
        int count = getRowValuesTable().getRowCount();
1656
        int count = getRowValuesTable().getRowCount();
Line 1669... Line 1791...
1669
            return null;
1791
            return null;
1670
        }
1792
        }
1671
    }
1793
    }
1672
 
1794
 
1673
    @Override
1795
    @Override
-
 
1796
    public void setClient(SQLRowAccessor rowClient, boolean ask) {
-
 
1797
        if (rowClient == null || getRowClient() == null || rowClient.getID() != getRowClient().getID()) {
-
 
1798
            super.setClient(rowClient, ask);
-
 
1799
            if (getRowClient() != null && !getRowClient().isUndefined()) {
-
 
1800
                this.cacheRemise = getRowClient().getReferentRows(getSQLElement().getTable().getTable("TARIF_ARTICLE_CLIENT"));
-
 
1801
                if (ask && getRowValuesTable().getRowCount() > 0
-
 
1802
                        && JOptionPane.showConfirmDialog(null, "Appliquer les remises associées au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
-
 
1803
                    int nbRows = this.table.getRowCount();
-
 
1804
                    for (int i = 0; i < nbRows; i++) {
-
 
1805
                        SQLRowValues rowVals = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(i);
-
 
1806
 
-
 
1807
                        if (!rowVals.isForeignEmpty("ID_ARTICLE")) {
-
 
1808
                            SQLRowAccessor rowValsArt = rowVals.getForeign("ID_ARTICLE");
-
 
1809
                            final Object taxeValue = tarifCompletion(rowValsArt, "ID_TAXE", rowVals);
-
 
1810
                            if (taxeValue != null) {
-
 
1811
                                getRowValuesTable().getRowValuesTableModel().putValue(taxeValue, i, "ID_TAXE");
-
 
1812
                            }
-
 
1813
 
-
 
1814
                            final Object deviseValue = tarifCompletion(rowValsArt, "ID_DEVISE", rowVals);
-
 
1815
                            if (deviseValue != null) {
-
 
1816
                                getRowValuesTable().getRowValuesTableModel().putValue(deviseValue, i, "ID_DEVISE");
-
 
1817
                            }
-
 
1818
                            getRowValuesTable().getRowValuesTableModel().putValue(tarifCompletion(rowValsArt, "PV_U_DEVISE", rowVals), i, "PV_U_DEVISE");
-
 
1819
                            getRowValuesTable().getRowValuesTableModel().putValue(tarifCompletion(rowValsArt, "PRIX_METRIQUE_VT_1", rowVals), i, "PRIX_METRIQUE_VT_1");
-
 
1820
                        }
-
 
1821
                    }
-
 
1822
                }
-
 
1823
            } else {
-
 
1824
                this.cacheRemise = null;
-
 
1825
            }
-
 
1826
        }
-
 
1827
    }
-
 
1828
 
-
 
1829
    @Override
1674
    public void setTarif(SQLRowAccessor rowValuesTarif, boolean ask) {
1830
    public void setTarif(SQLRowAccessor rowValuesTarif, boolean ask) {
1675
        if (rowValuesTarif == null || getTarif() == null || rowValuesTarif.getID() != getTarif().getID()) {
1831
        if (rowValuesTarif == null || getTarif() == null || rowValuesTarif.getID() != getTarif().getID()) {
1676
            super.setTarif(rowValuesTarif, ask);
1832
            super.setTarif(rowValuesTarif, ask);
1677
            if (ask && getRowValuesTable().getRowCount() > 0
1833
            if (ask && getRowValuesTable().getRowCount() > 0
1678
                    && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {
1834
                    && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associés au client sur les lignes déjà présentes?") == JOptionPane.YES_OPTION) {