OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 180 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.erp.core.sales.product.component;
14
 package org.openconcerto.erp.core.sales.product.component;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
-
 
18
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18
import org.openconcerto.erp.core.common.ui.CodeFournisseurItemTable;
19
import org.openconcerto.erp.core.common.ui.CodeFournisseurItemTable;
19
import org.openconcerto.erp.core.common.ui.TotalPanel;
20
import org.openconcerto.erp.core.common.ui.TotalPanel;
20
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
21
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
21
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
22
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
22
import org.openconcerto.erp.core.sales.product.element.ArticleCodeClientTable;
23
import org.openconcerto.erp.core.sales.product.element.ArticleCodeClientTable;
Line 24... Line 25...
24
import org.openconcerto.erp.core.sales.product.element.SupplierPriceListTable;
25
import org.openconcerto.erp.core.sales.product.element.SupplierPriceListTable;
25
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
26
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
26
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
27
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
27
import org.openconcerto.erp.core.sales.product.ui.ArticleCategorieComptableTable;
28
import org.openconcerto.erp.core.sales.product.ui.ArticleCategorieComptableTable;
28
import org.openconcerto.erp.core.sales.product.ui.ArticleDesignationTable;
29
import org.openconcerto.erp.core.sales.product.ui.ArticleDesignationTable;
-
 
30
import org.openconcerto.erp.core.sales.product.ui.ArticlePromotionTable;
29
import org.openconcerto.erp.core.sales.product.ui.ArticleTarifTable;
31
import org.openconcerto.erp.core.sales.product.ui.ArticleTarifTable;
30
import org.openconcerto.erp.core.sales.product.ui.ProductItemListTable;
32
import org.openconcerto.erp.core.sales.product.ui.ProductItemListTable;
31
import org.openconcerto.erp.core.sales.product.ui.ProductQtyPriceListTable;
33
import org.openconcerto.erp.core.sales.product.ui.ProductQtyPriceListTable;
32
import org.openconcerto.erp.core.sales.product.ui.RowValuesTableEditionPanel;
34
import org.openconcerto.erp.core.sales.product.ui.RowValuesTableEditionPanel;
33
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
35
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
Line 43... Line 45...
43
import org.openconcerto.sql.model.SQLRowValues;
45
import org.openconcerto.sql.model.SQLRowValues;
44
import org.openconcerto.sql.model.SQLSelect;
46
import org.openconcerto.sql.model.SQLSelect;
45
import org.openconcerto.sql.model.SQLTable;
47
import org.openconcerto.sql.model.SQLTable;
46
import org.openconcerto.sql.model.Where;
48
import org.openconcerto.sql.model.Where;
47
import org.openconcerto.sql.preferences.SQLPreferences;
49
import org.openconcerto.sql.preferences.SQLPreferences;
-
 
50
import org.openconcerto.sql.request.ComboSQLRequest;
48
import org.openconcerto.sql.sqlobject.ElementComboBox;
51
import org.openconcerto.sql.sqlobject.ElementComboBox;
49
import org.openconcerto.sql.sqlobject.SQLTextCombo;
52
import org.openconcerto.sql.sqlobject.SQLTextCombo;
50
import org.openconcerto.ui.DefaultGridBagConstraints;
53
import org.openconcerto.ui.DefaultGridBagConstraints;
51
import org.openconcerto.ui.FormLayouter;
54
import org.openconcerto.ui.FormLayouter;
52
import org.openconcerto.ui.JDate;
55
import org.openconcerto.ui.JDate;
53
import org.openconcerto.ui.TitledSeparator;
56
import org.openconcerto.ui.TitledSeparator;
54
import org.openconcerto.ui.component.ITextArea;
57
import org.openconcerto.ui.component.ITextArea;
-
 
58
import org.openconcerto.ui.component.InteractionMode;
55
import org.openconcerto.ui.preferences.DefaultProps;
59
import org.openconcerto.ui.preferences.DefaultProps;
56
import org.openconcerto.utils.DecimalUtils;
60
import org.openconcerto.utils.DecimalUtils;
57
import org.openconcerto.utils.ExceptionHandler;
61
import org.openconcerto.utils.ExceptionHandler;
58
import org.openconcerto.utils.StringUtils;
62
import org.openconcerto.utils.StringUtils;
59
import org.openconcerto.utils.Tuple2;
63
import org.openconcerto.utils.Tuple2;
Line 68... Line 72...
68
import java.beans.PropertyChangeEvent;
72
import java.beans.PropertyChangeEvent;
69
import java.beans.PropertyChangeListener;
73
import java.beans.PropertyChangeListener;
70
import java.math.BigDecimal;
74
import java.math.BigDecimal;
71
import java.math.RoundingMode;
75
import java.math.RoundingMode;
72
import java.sql.SQLException;
76
import java.sql.SQLException;
-
 
77
import java.util.ArrayList;
73
import java.util.Date;
78
import java.util.Date;
74
import java.util.List;
79
import java.util.List;
75
 
80
 
76
import javax.swing.JButton;
81
import javax.swing.JButton;
77
import javax.swing.JCheckBox;
82
import javax.swing.JCheckBox;
Line 90... Line 95...
90
public class ReferenceArticleSQLComponent extends BaseSQLComponent {
95
public class ReferenceArticleSQLComponent extends BaseSQLComponent {
91
 
96
 
92
    protected JTextField textPVHT, textPVTTC, textPAHT;
97
    protected JTextField textPVHT, textPVTTC, textPAHT;
93
    protected JTextField textMetrique1VT, textMetrique1HA;
98
    protected JTextField textMetrique1VT, textMetrique1HA;
94
 
99
 
95
    protected final JCheckBox boxService = new JCheckBox(getLabelFor("SERVICE"));
100
    private final JCheckBox boxService = new JCheckBox(getLabelFor("SERVICE"));
96
    protected final JCheckBox checkObs = new JCheckBox(getLabelFor("OBSOLETE"));
101
    private final JCheckBox checkObs = new JCheckBox(getLabelFor("OBSOLETE"));
-
 
102
    private JTextField textNom;
97
    protected JTextField textNom, textCode;
103
    private JTextField textCode;
98
    protected JTextField textPoids;
104
    private JTextField textPoids;
99
    protected JTextField textValMetrique1, textValMetrique2, textValMetrique3;
105
    private JTextField textValMetrique1, textValMetrique2, textValMetrique3;
100
    protected DocumentListener htDocListener, ttcDocListener, detailsListener;
106
    private DocumentListener htDocListener, ttcDocListener, detailsListener;
101
    protected PropertyChangeListener propertyChangeListener;
107
    private PropertyChangeListener propertyChangeListener;
102
    protected PropertyChangeListener taxeListener;
108
    private PropertyChangeListener taxeListener;
103
    protected final ElementComboBox comboSelTaxe = new ElementComboBox(false, 10);
109
    private final ElementComboBox comboSelTaxe = new ElementComboBox(false, 10);
104
    protected final ElementComboBox comboSelModeVente = new ElementComboBox(false, 25);
110
    private final ElementComboBox comboSelModeVente = new ElementComboBox(false, 25);
105
    protected JLabel labelMetriqueHA1 = new JLabel(getLabelFor("PRIX_METRIQUE_HA_1"), SwingConstants.RIGHT);
111
    private JLabel labelMetriqueHA1 = new JLabel(getLabelFor("PRIX_METRIQUE_HA_1"), SwingConstants.RIGHT);
106
    protected JLabel labelMetriqueVT1 = new JLabel(getLabelFor("PRIX_METRIQUE_VT_1"), SwingConstants.RIGHT);
112
    private JLabel labelMetriqueVT1 = new JLabel(getLabelFor("PRIX_METRIQUE_VT_1"), SwingConstants.RIGHT);
107
 
113
 
108
    protected ArticleDesignationTable tableDes = new ArticleDesignationTable();
114
    protected ArticleDesignationTable tableDes = new ArticleDesignationTable();
109
    protected ArticleCodeClientTable tableCodeClient = new ArticleCodeClientTable();
115
    protected ArticleCodeClientTable tableCodeClient = new ArticleCodeClientTable();
110
    protected ArticleTarifTable tableTarifVente = new ArticleTarifTable(this);
116
    protected ArticleTarifTable tableTarifVente = new ArticleTarifTable(this);
-
 
117
    protected ArticlePromotionTable tableTarifPromotionVente = new ArticlePromotionTable(this);
111
    protected ArticleCategorieComptableTable tableCatComptable = new ArticleCategorieComptableTable();
118
    protected final ArticleCategorieComptableTable tableCatComptable = new ArticleCategorieComptableTable();;
112
    protected SupplierPriceListTable tableFourSec = new SupplierPriceListTable();
119
    protected SupplierPriceListTable tableFourSec = new SupplierPriceListTable();
113
 
120
 
114
    protected ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this);
121
    protected ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this);
115
    protected ProductItemListTable tableBom;
122
    protected ProductItemListTable tableBom;
116
    protected final JTextField textMarge = new JTextField(10);
123
    protected final JTextField textMarge = new JTextField(10);
117
    protected final JLabel labelMarge = new JLabel("%           ");
124
    protected final JLabel labelMarge = new JLabel("%           ");
118
    protected ElementComboBox boxCR;
125
    protected ElementComboBox boxCR;
119
    protected JCheckBox boxMargeWithCR;
126
    protected JCheckBox boxMargeWithCR;
120
 
127
 
-
 
128
    protected List<ElementComboBox> boxesDeclinaison = new ArrayList<>();
-
 
129
 
121
    protected DocumentListener pieceHAArticle = new SimpleDocumentListener() {
130
    protected DocumentListener pieceHAArticle = new SimpleDocumentListener() {
122
 
131
 
123
        @Override
132
        @Override
124
        public void update(DocumentEvent e) {
133
        public void update(DocumentEvent e) {
125
 
134
 
Line 254... Line 263...
254
    public void select(SQLRowAccessor r) {
263
    public void select(SQLRowAccessor r) {
255
        super.select(r);
264
        super.select(r);
256
        if (r != null && r.getID() > getTable().getUndefinedID()) {
265
        if (r != null && r.getID() > getTable().getUndefinedID()) {
257
            this.checkObs.setVisible(true);
266
            this.checkObs.setVisible(true);
258
            this.tableTarifVente.setArticleValues(r);
267
            this.tableTarifVente.setArticleValues(r);
-
 
268
            selectModeVente(r.getForeignID("ID_MODE_VENTE_ARTICLE"));
-
 
269
        } else {
-
 
270
            if (r == null || !r.contains("CODE") || r.getString("CODE") == null || r.getString("CODE").trim().length() == 0) {
-
 
271
                this.textCode.setText(getElement().getDirectory().getElement(NumerotationAutoSQLElement.class).getNextNumero(getElement().getClass()));
-
 
272
            }
-
 
273
        }
259
            this.tableTarifVente.insertFrom("ID_ARTICLE", r.getID());
274
        this.tableTarifVente.getRowValuesTable().insertFrom(r);
-
 
275
        this.tableTarifPromotionVente.getRowValuesTable().insertFrom(r);
260
            this.tableCatComptable.insertFrom("ID_ARTICLE", r.getID());
276
        this.tableCatComptable.getRowValuesTable().insertFrom(r);
261
            this.tableFourSec.insertFrom("ID_ARTICLE", r.getID());
277
        this.tableFourSec.getRowValuesTable().insertFrom(r);
262
            this.tableTarifQteVente.insertFrom("ID_ARTICLE", r.getID());
278
        this.tableTarifQteVente.getRowValuesTable().insertFrom(r);
263
            if (this.tableBom != null) {
279
        if (this.tableBom != null) {
264
                this.tableBom.insertFrom("ID_ARTICLE_PARENT", r.getID());
280
            this.tableBom.getRowValuesTable().getRowValuesTableModel().insertFrom(r, getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
265
            }
281
        }
266
            this.tableDes.insertFrom("ID_ARTICLE", r.getID());
282
        this.tableDes.getRowValuesTable().insertFrom(r);
267
            this.tableCodeClient.insertFrom("ID_ARTICLE", r.getID());
283
        this.tableCodeClient.getRowValuesTable().insertFrom(r);
268
            if (this.codeFournisseurTable != null) {
284
        if (this.codeFournisseurTable != null) {
269
                this.codeFournisseurTable.insertFrom("ID_ARTICLE", r.getID());
285
            this.codeFournisseurTable.getModel().insertFrom(r);
270
            }
286
        }
-
 
287
 
271
            selectModeVente(r.getForeignID("ID_MODE_VENTE_ARTICLE"));
288
        for (ElementComboBox elementComboBox : boxesDeclinaison) {
-
 
289
            elementComboBox.setEnabled(r != null && r.getNonEmptyForeign("ID_ARTICLE_VIRTUEL_PERE") != null ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
272
        }
290
        }
273
    }
291
    }
274
 
292
 
275
    public void addViews() {
293
    public void addViews() {
276
        this.setLayout(new GridBagLayout());
294
        this.setLayout(new GridBagLayout());
Line 430... Line 448...
430
        c.weightx = 1;
448
        c.weightx = 1;
431
        c.weighty = 1;
449
        c.weighty = 1;
432
 
450
 
433
        pane.add("Tarifs de vente spéciaux", createTarifPanel());
451
        pane.add("Tarifs de vente spéciaux", createTarifPanel());
434
        pane.add("Tarifs de vente par quantité", createTarifQtePanel());
452
        pane.add("Tarifs de vente par quantité", createTarifQtePanel());
-
 
453
        pane.add("Tarifs promotionnels", createTarifPromotionPanel());
-
 
454
 
435
        if (this.tableBom != null) {
455
        if (this.tableBom != null) {
436
            pane.add("Nomenclature", createBOMpanel());
456
            pane.add("Nomenclature", createBOMpanel());
437
        }
457
        }
438
        pane.add("Exportation", createExportationPanel());
458
        pane.add("Exportation", createExportationPanel());
439
        pane.add("Achat", createAchatPanel());
459
        pane.add("Achat", createAchatPanel());
440
        pane.add("Stock", createStockPanel());
460
        pane.add("Stock", createStockPanel());
441
        pane.add("Descriptif", createDescriptifPanel());
461
        pane.add("Descriptif", createDescriptifPanel());
442
        pane.add("Désignations multilingues", createDesignationPanel());
462
        pane.add("Désignations multilingues", createDesignationPanel());
443
        pane.add("Désignations clients", createCodeClientPanel());
463
        pane.add("Désignations clients", createCodeClientPanel());
-
 
464
 
-
 
465
        if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVER_DECLINAISON, false)) {
-
 
466
 
-
 
467
            pane.add("Déclinaison", createDeclinaisonPanel());
-
 
468
        }
444
        pane.add("Comptabilité", createComptaPanel());
469
        pane.add("Comptabilité", createComptaPanel());
445
        pane.add(getLabelFor("INFOS"), createInfosPanel());
470
        pane.add(getLabelFor("INFOS"), createInfosPanel());
446
 
471
 
447
        c.fill = GridBagConstraints.BOTH;
472
        c.fill = GridBagConstraints.BOTH;
448
        this.add(pane, c);
473
        this.add(pane, c);
Line 499... Line 524...
499
        c.gridx++;
524
        c.gridx++;
500
        JTextField textTare = new JTextField(40);
525
        JTextField textTare = new JTextField(40);
501
        panel.add(textTare, c);
526
        panel.add(textTare, c);
502
        addView(textTare, "TARE");
527
        addView(textTare, "TARE");
503
 
528
 
-
 
529
        // c.gridy++;
-
 
530
        // c.gridx = 0;
-
 
531
        // c.weightx = 0;
-
 
532
        // JLabel labelDLC = new JLabel(getLabelFor("DLC"));
-
 
533
        // panel.add(labelDLC, c);
-
 
534
        // c.weightx = 1;
-
 
535
        // c.gridx++;
-
 
536
        // JDate dateDLC = new JDate();
-
 
537
        // panel.add(dateDLC, c);
-
 
538
        // addView(dateDLC, "DLC");
-
 
539
 
-
 
540
        c.weightx = 0;
504
        c.gridy++;
541
        c.gridy++;
505
        c.gridx = 0;
542
        c.gridx = 0;
506
        c.weightx = 0;
-
 
507
        JLabel labelDLC = new JLabel(getLabelFor("DLC"));
543
        JLabel labelOption = new JLabel(getLabelFor("OPTION"));
-
 
544
        c.fill = GridBagConstraints.BOTH;
508
        panel.add(labelDLC, c);
545
        panel.add(labelOption, c);
509
        c.weightx = 1;
546
        c.weightx = 1;
510
        c.gridx++;
547
        c.gridx++;
511
        JDate dateDLC = new JDate();
548
        JCheckBox boxOption = new JCheckBox();
512
        panel.add(dateDLC, c);
549
        panel.add(boxOption, c);
513
        addView(dateDLC, "DLC");
550
        this.addSQLObject(boxOption, "OPTION");
514
 
551
 
515
        c.weightx = 0;
552
        c.weightx = 0;
516
        c.gridy++;
553
        c.gridy++;
517
        c.gridx = 0;
554
        c.gridx = 0;
518
        if (getTable().contains("POIDS_COLIS_NET")) {
555
        if (getTable().contains("POIDS_COLIS_NET")) {
Line 758... Line 795...
758
        panel.add(this.tableCodeClient, c);
795
        panel.add(this.tableCodeClient, c);
759
 
796
 
760
        return panel;
797
        return panel;
761
    }
798
    }
762
 
799
 
-
 
800
    protected Component createDeclinaisonPanel() {
-
 
801
        JPanel panel = new JPanel(new GridBagLayout());
-
 
802
        panel.setOpaque(false);
-
 
803
        GridBagConstraints c = new DefaultGridBagConstraints();
-
 
804
 
-
 
805
        c.weighty = 0;
-
 
806
        c.weightx = 0;
-
 
807
 
-
 
808
        panel.add(new JLabel(getLabelFor("ID_ARTICLE_VIRTUEL_PERE")), c);
-
 
809
        c.gridx++;
-
 
810
        c.weightx = 1;
-
 
811
        final ElementComboBox boxPere = new ElementComboBox();
-
 
812
        panel.add(boxPere, c);
-
 
813
        final ComboSQLRequest reqVir = getElement().createComboRequest();
-
 
814
        reqVir.setWhere(new Where(getElement().getTable().getField("VIRTUEL"), "=", Boolean.TRUE));
-
 
815
        boxPere.init(getElement(), reqVir);
-
 
816
        this.addView(boxPere, "ID_ARTICLE_VIRTUEL_PERE");
-
 
817
        c.gridx = 0;
-
 
818
        c.gridy++;
-
 
819
 
-
 
820
        List<String> declFiels = new ArrayList<String>();
-
 
821
        for (String string : getTable().getFieldsName()) {
-
 
822
            if (string.startsWith("ID_ARTICLE_DECLINAISON_")) {
-
 
823
                declFiels.add(string);
-
 
824
            }
-
 
825
        }
-
 
826
 
-
 
827
        this.boxesDeclinaison.clear();
-
 
828
 
-
 
829
        for (String field : declFiels) {
-
 
830
            c.weightx = 0;
-
 
831
            if (c.gridx == 4) {
-
 
832
                c.gridx = 0;
-
 
833
                c.gridy++;
-
 
834
            }
-
 
835
            panel.add(new JLabel(getLabelFor(field)), c);
-
 
836
            c.gridx++;
-
 
837
            c.weightx = 1;
-
 
838
            ElementComboBox box1 = new ElementComboBox();
-
 
839
            final SQLElement declElement = getElement().getForeignElement(field);
-
 
840
            box1.init(declElement, declElement.createComboRequest());
-
 
841
            box1.setEnabled(InteractionMode.DISABLED);
-
 
842
            panel.add(box1, c);
-
 
843
            this.addView(box1, field);
-
 
844
 
-
 
845
            this.boxesDeclinaison.add(box1);
-
 
846
            c.gridx++;
-
 
847
        }
-
 
848
 
-
 
849
        boxPere.addModelListener("wantedID", new PropertyChangeListener() {
-
 
850
 
-
 
851
            @Override
-
 
852
            public void propertyChange(PropertyChangeEvent evt) {
-
 
853
 
-
 
854
                for (ElementComboBox elementComboBox : boxesDeclinaison) {
-
 
855
                    elementComboBox.setEnabled(boxPere.getWantedID() != SQLRow.NONEXISTANT_ID ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
-
 
856
                }
-
 
857
            }
-
 
858
        });
-
 
859
 
-
 
860
        return panel;
-
 
861
    }
-
 
862
 
763
    protected Component createStockPanel() {
863
    protected Component createStockPanel() {
764
        JPanel panel = new JPanel(new GridBagLayout());
864
        JPanel panel = new JPanel(new GridBagLayout());
765
        panel.setOpaque(false);
865
        panel.setOpaque(false);
766
        GridBagConstraints c = new DefaultGridBagConstraints();
866
        GridBagConstraints c = new DefaultGridBagConstraints();
767
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
867
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
Line 818... Line 918...
818
            c.weightx = 1;
918
            c.weightx = 1;
819
            panel.add(fieldQteAchat, c);
919
            panel.add(fieldQteAchat, c);
820
            this.addView(fieldQteAchat, "QTE_ACHAT");
920
            this.addView(fieldQteAchat, "QTE_ACHAT");
821
        }
921
        }
822
 
922
 
-
 
923
        //
-
 
924
        c.gridy++;
-
 
925
        c.gridx = 1;
-
 
926
        c.weightx = 1;
-
 
927
        JCheckBox DLCrequis = new JCheckBox("DLC requis");
-
 
928
        panel.add(DLCrequis, c);
-
 
929
        addView(DLCrequis, "DLC_REQUIS");
-
 
930
        c.gridy++;
-
 
931
        JCheckBox DLUOrequis = new JCheckBox("DLUO requis");
-
 
932
        panel.add(DLUOrequis, c);
-
 
933
        addView(DLUOrequis, "DLUO_REQUIS");
-
 
934
        c.gridy++;
-
 
935
        JCheckBox numeroLotRequis = new JCheckBox("n° de lot requis");
-
 
936
        panel.add(numeroLotRequis, c);
-
 
937
        addView(numeroLotRequis, "NUMERO_LOT_REQUIS");
-
 
938
        c.gridy++;
-
 
939
        JCheckBox numeroSerieRequis = new JCheckBox("n° de série requis");
-
 
940
        panel.add(numeroSerieRequis, c);
-
 
941
        addView(numeroSerieRequis, "NUMERO_SERIE_REQUIS");
-
 
942
 
823
        c.gridy++;
943
        c.gridy++;
824
        c.weighty = 1;
944
        c.weighty = 1;
825
        c.weightx = 1;
945
        c.weightx = 1;
826
        c.fill = GridBagConstraints.BOTH;
946
        c.fill = GridBagConstraints.BOTH;
827
        final JPanel spacer = new JPanel();
947
        final JPanel spacer = new JPanel();
Line 1125... Line 1245...
1125
            }
1245
            }
1126
        });
1246
        });
1127
        return panel;
1247
        return panel;
1128
    }
1248
    }
1129
 
1249
 
-
 
1250
    protected JPanel createTarifPromotionPanel() {
-
 
1251
        JPanel panel = new JPanel(new GridBagLayout());
-
 
1252
        panel.setOpaque(false);
-
 
1253
        GridBagConstraints c = new DefaultGridBagConstraints();
-
 
1254
 
-
 
1255
        // Ajout tarif
-
 
1256
        c.gridwidth = 1;
-
 
1257
        c.weightx = 0;
-
 
1258
        c.gridy++;
-
 
1259
        c.gridx = 0;
-
 
1260
        panel.add(new JLabel("Ajouter la promotion"), c);
-
 
1261
 
-
 
1262
        final ElementComboBox boxTarif = new ElementComboBox();
-
 
1263
        boxTarif.init(Configuration.getInstance().getDirectory().getElement("TARIF_PROMOTION"));
-
 
1264
 
-
 
1265
        c.gridx++;
-
 
1266
        panel.add(boxTarif, c);
-
 
1267
 
-
 
1268
        c.fill = GridBagConstraints.NONE;
-
 
1269
        c.gridx++;
-
 
1270
        JButton buttonAjouter = new JButton("Ajouter");
-
 
1271
        buttonAjouter.setOpaque(false);
-
 
1272
        panel.add(buttonAjouter, c);
-
 
1273
        c.gridx++;
-
 
1274
        JButton buttonSupprimer = new JButton("Supprimer");
-
 
1275
        buttonSupprimer.setOpaque(false);
-
 
1276
        panel.add(buttonSupprimer, c);
-
 
1277
 
-
 
1278
        c.gridwidth = GridBagConstraints.REMAINDER;
-
 
1279
        c.fill = GridBagConstraints.BOTH;
-
 
1280
        c.weightx = 1;
-
 
1281
        c.weighty = 1;
-
 
1282
        c.gridy++;
-
 
1283
        c.gridx = 0;
-
 
1284
        c.fill = GridBagConstraints.BOTH;
-
 
1285
        this.tableTarifPromotionVente.setOpaque(false);
-
 
1286
        panel.add(this.tableTarifPromotionVente, c);
-
 
1287
 
-
 
1288
        // Listeners
-
 
1289
        buttonAjouter.addActionListener(new ActionListener() {
-
 
1290
 
-
 
1291
            @Override
-
 
1292
            public void actionPerformed(ActionEvent e) {
-
 
1293
 
-
 
1294
                SQLRow rowTarif = boxTarif.getSelectedRow();
-
 
1295
                if (rowTarif == null || rowTarif.isUndefined()) {
-
 
1296
                    return;
-
 
1297
                }
-
 
1298
 
-
 
1299
                SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF_PROMOTION"));
-
 
1300
                if (getSelectedID() > 1) {
-
 
1301
                    rowVals.put("ID_ARTICLE", getSelectedID());
-
 
1302
                }
-
 
1303
                rowVals.put("ID_TARIF_PROMOTION", rowTarif.getID());
-
 
1304
                rowVals.put("PRIX_METRIQUE_VT_1", BigDecimal.ZERO);
-
 
1305
                rowVals.put("PV_HT", BigDecimal.ZERO);
-
 
1306
                rowVals.put("PV_TTC", BigDecimal.ZERO);
-
 
1307
                tableTarifPromotionVente.getModel().addRow(rowVals);
-
 
1308
            }
-
 
1309
        });
-
 
1310
        buttonSupprimer.addActionListener(new ActionListener() {
-
 
1311
 
-
 
1312
            @Override
-
 
1313
            public void actionPerformed(ActionEvent e) {
-
 
1314
                tableTarifPromotionVente.removeSelectedRow();
-
 
1315
            }
-
 
1316
        });
-
 
1317
        return panel;
-
 
1318
    }
-
 
1319
 
1130
    protected JPanel createCategorieComptablePanel() {
1320
    protected JPanel createCategorieComptablePanel() {
1131
        JPanel panel = new JPanel(new GridBagLayout());
1321
        JPanel panel = new JPanel(new GridBagLayout());
1132
        panel.setOpaque(false);
1322
        panel.setOpaque(false);
1133
        GridBagConstraints c = new DefaultGridBagConstraints();
1323
        GridBagConstraints c = new DefaultGridBagConstraints();
1134
 
1324
 
Line 1684... Line 1874...
1684
            super.update();
1874
            super.update();
1685
        this.tableTarifVente.updateField("ID_ARTICLE", selectedID);
1875
        this.tableTarifVente.updateField("ID_ARTICLE", selectedID);
1686
        this.tableCatComptable.updateField("ID_ARTICLE", selectedID);
1876
        this.tableCatComptable.updateField("ID_ARTICLE", selectedID);
1687
        this.tableFourSec.updateField("ID_ARTICLE", selectedID);
1877
        this.tableFourSec.updateField("ID_ARTICLE", selectedID);
1688
        this.tableTarifQteVente.updateField("ID_ARTICLE", selectedID);
1878
        this.tableTarifQteVente.updateField("ID_ARTICLE", selectedID);
-
 
1879
        this.tableTarifPromotionVente.updateField("ID_ARTICLE", selectedID);
-
 
1880
 
1689
        if (this.tableBom != null) {
1881
        if (this.tableBom != null) {
1690
            this.tableBom.updateField("ID_ARTICLE_PARENT", selectedID);
1882
            this.tableBom.updateField("ID_ARTICLE_PARENT", selectedID);
1691
        }
1883
        }
1692
 
1884
 
1693
        this.tableDes.updateField("ID_ARTICLE", selectedID);
1885
        this.tableDes.updateField("ID_ARTICLE", selectedID);
Line 1816... Line 2008...
1816
        int id = super.insert(order);
2008
        int id = super.insert(order);
1817
        this.tableTarifVente.updateField("ID_ARTICLE", id);
2009
        this.tableTarifVente.updateField("ID_ARTICLE", id);
1818
        this.tableCatComptable.updateField("ID_ARTICLE", id);
2010
        this.tableCatComptable.updateField("ID_ARTICLE", id);
1819
        this.tableFourSec.updateField("ID_ARTICLE", id);
2011
        this.tableFourSec.updateField("ID_ARTICLE", id);
1820
        this.tableTarifQteVente.updateField("ID_ARTICLE", id);
2012
        this.tableTarifQteVente.updateField("ID_ARTICLE", id);
-
 
2013
        this.tableTarifPromotionVente.updateField("ID_ARTICLE", id);
1821
        if (this.tableBom != null) {
2014
        if (this.tableBom != null) {
1822
            this.tableBom.updateField("ID_ARTICLE_PARENT", id);
2015
            this.tableBom.updateField("ID_ARTICLE_PARENT", id);
1823
        }
2016
        }
1824
        this.tableDes.updateField("ID_ARTICLE", id);
2017
        this.tableDes.updateField("ID_ARTICLE", id);
1825
        this.tableCodeClient.updateField("ID_ARTICLE", id);
2018
        this.tableCodeClient.updateField("ID_ARTICLE", id);
1826
        if (this.codeFournisseurTable != null) {
2019
        if (this.codeFournisseurTable != null) {
1827
            this.codeFournisseurTable.updateField("ID_ARTICLE", id);
2020
            this.codeFournisseurTable.updateField("ID_ARTICLE", id);
1828
        }
2021
        }
1829
        ((ReferenceArticleSQLElement) getElement()).initStock(id);
2022
        ((ReferenceArticleSQLElement) getElement()).initStock(id);
1830
        ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(id));
2023
        ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(id));
-
 
2024
 
-
 
2025
        // incrémentation du numéro auto
-
 
2026
        if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.textCode.getText().trim())) {
-
 
2027
            final SQLTable tableNum = getElement().getDirectory().getElement(NumerotationAutoSQLElement.class).getTable();
-
 
2028
            SQLRowValues rowVals = new SQLRowValues(tableNum);
-
 
2029
 
-
 
2030
            final SQLRow rowNumAuto = tableNum.getRow(2);
-
 
2031
            if (rowNumAuto.getObject("ARTICLE_START") != null) {
-
 
2032
                int val = rowNumAuto.getInt("ARTICLE_START");
-
 
2033
                val++;
-
 
2034
                rowVals.put("ARTICLE_START", new Integer(val));
-
 
2035
 
-
 
2036
                try {
-
 
2037
                    rowVals.update(2);
-
 
2038
                } catch (SQLException e) {
-
 
2039
                    e.printStackTrace();
-
 
2040
                }
-
 
2041
            }
-
 
2042
        }
-
 
2043
 
1831
        return id;
2044
        return id;
1832
    }
2045
    }
1833
 
2046
 
1834
    @Override
2047
    @Override
1835
    protected SQLRowValues createDefaults() {
2048
    protected SQLRowValues createDefaults() {