OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Rev 182 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
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
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.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.sales.product.component;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
63 ilm 17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
67 ilm 18
import org.openconcerto.erp.core.common.ui.CodeFournisseurItemTable;
21 ilm 19
import org.openconcerto.erp.core.common.ui.TotalPanel;
93 ilm 20
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
18 ilm 21
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
144 ilm 22
import org.openconcerto.erp.core.sales.product.element.ArticleCodeClientTable;
18 ilm 23
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
156 ilm 24
import org.openconcerto.erp.core.sales.product.element.SupplierPriceListTable;
61 ilm 25
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
177 ilm 26
import org.openconcerto.erp.core.sales.product.model.ProductHelper;
156 ilm 27
import org.openconcerto.erp.core.sales.product.ui.ArticleCategorieComptableTable;
19 ilm 28
import org.openconcerto.erp.core.sales.product.ui.ArticleDesignationTable;
29
import org.openconcerto.erp.core.sales.product.ui.ArticleTarifTable;
94 ilm 30
import org.openconcerto.erp.core.sales.product.ui.ProductItemListTable;
31
import org.openconcerto.erp.core.sales.product.ui.ProductQtyPriceListTable;
32
import org.openconcerto.erp.core.sales.product.ui.RowValuesTableEditionPanel;
156 ilm 33
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
67 ilm 34
import org.openconcerto.erp.model.ISQLCompteSelector;
18 ilm 35
import org.openconcerto.erp.preferences.DefaultNXProps;
61 ilm 36
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
18 ilm 37
import org.openconcerto.sql.Configuration;
38
import org.openconcerto.sql.element.BaseSQLComponent;
39
import org.openconcerto.sql.element.SQLElement;
40
import org.openconcerto.sql.model.SQLRow;
41
import org.openconcerto.sql.model.SQLRowAccessor;
42
import org.openconcerto.sql.model.SQLRowListRSH;
43
import org.openconcerto.sql.model.SQLRowValues;
44
import org.openconcerto.sql.model.SQLSelect;
156 ilm 45
import org.openconcerto.sql.model.SQLTable;
18 ilm 46
import org.openconcerto.sql.model.Where;
61 ilm 47
import org.openconcerto.sql.preferences.SQLPreferences;
18 ilm 48
import org.openconcerto.sql.sqlobject.ElementComboBox;
156 ilm 49
import org.openconcerto.sql.sqlobject.SQLTextCombo;
18 ilm 50
import org.openconcerto.ui.DefaultGridBagConstraints;
27 ilm 51
import org.openconcerto.ui.FormLayouter;
177 ilm 52
import org.openconcerto.ui.JDate;
142 ilm 53
import org.openconcerto.ui.TitledSeparator;
19 ilm 54
import org.openconcerto.ui.component.ITextArea;
18 ilm 55
import org.openconcerto.ui.preferences.DefaultProps;
90 ilm 56
import org.openconcerto.utils.DecimalUtils;
156 ilm 57
import org.openconcerto.utils.ExceptionHandler;
83 ilm 58
import org.openconcerto.utils.StringUtils;
177 ilm 59
import org.openconcerto.utils.Tuple2;
18 ilm 60
import org.openconcerto.utils.text.SimpleDocumentListener;
61
 
19 ilm 62
import java.awt.Component;
18 ilm 63
import java.awt.GridBagConstraints;
64
import java.awt.GridBagLayout;
80 ilm 65
import java.awt.Insets;
19 ilm 66
import java.awt.event.ActionEvent;
67
import java.awt.event.ActionListener;
18 ilm 68
import java.beans.PropertyChangeEvent;
69
import java.beans.PropertyChangeListener;
19 ilm 70
import java.math.BigDecimal;
67 ilm 71
import java.math.RoundingMode;
18 ilm 72
import java.sql.SQLException;
93 ilm 73
import java.util.Date;
18 ilm 74
import java.util.List;
75
 
19 ilm 76
import javax.swing.JButton;
18 ilm 77
import javax.swing.JCheckBox;
78
import javax.swing.JLabel;
19 ilm 79
import javax.swing.JOptionPane;
18 ilm 80
import javax.swing.JPanel;
81
import javax.swing.JSeparator;
19 ilm 82
import javax.swing.JTabbedPane;
18 ilm 83
import javax.swing.JTextField;
84
import javax.swing.SwingConstants;
85
import javax.swing.event.DocumentEvent;
86
import javax.swing.event.DocumentListener;
177 ilm 87
import javax.swing.event.TableModelEvent;
88
import javax.swing.event.TableModelListener;
18 ilm 89
 
90
public class ReferenceArticleSQLComponent extends BaseSQLComponent {
91
 
180 ilm 92
    protected JTextField textPVHT, textPVTTC, textPAHT;
93
    protected JTextField textMetrique1VT, textMetrique1HA;
18 ilm 94
 
180 ilm 95
    protected final JCheckBox boxService = new JCheckBox(getLabelFor("SERVICE"));
96
    protected final JCheckBox checkObs = new JCheckBox(getLabelFor("OBSOLETE"));
97
    protected JTextField textNom, textCode;
98
    protected JTextField textPoids;
99
    protected JTextField textValMetrique1, textValMetrique2, textValMetrique3;
100
    protected DocumentListener htDocListener, ttcDocListener, detailsListener;
101
    protected PropertyChangeListener propertyChangeListener;
102
    protected PropertyChangeListener taxeListener;
103
    protected final ElementComboBox comboSelTaxe = new ElementComboBox(false, 10);
104
    protected final ElementComboBox comboSelModeVente = new ElementComboBox(false, 25);
105
    protected JLabel labelMetriqueHA1 = new JLabel(getLabelFor("PRIX_METRIQUE_HA_1"), SwingConstants.RIGHT);
106
    protected JLabel labelMetriqueVT1 = new JLabel(getLabelFor("PRIX_METRIQUE_VT_1"), SwingConstants.RIGHT);
19 ilm 107
 
180 ilm 108
    protected ArticleDesignationTable tableDes = new ArticleDesignationTable();
109
    protected ArticleCodeClientTable tableCodeClient = new ArticleCodeClientTable();
110
    protected ArticleTarifTable tableTarifVente = new ArticleTarifTable(this);
111
    protected ArticleCategorieComptableTable tableCatComptable = new ArticleCategorieComptableTable();
112
    protected SupplierPriceListTable tableFourSec = new SupplierPriceListTable();
156 ilm 113
 
180 ilm 114
    protected ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this);
115
    protected ProductItemListTable tableBom;
116
    protected final JTextField textMarge = new JTextField(10);
117
    protected final JLabel labelMarge = new JLabel("%           ");
118
    protected ElementComboBox boxCR;
119
    protected JCheckBox boxMargeWithCR;
19 ilm 120
 
180 ilm 121
    protected DocumentListener pieceHAArticle = new SimpleDocumentListener() {
18 ilm 122
 
93 ilm 123
        @Override
124
        public void update(DocumentEvent e) {
18 ilm 125
 
93 ilm 126
            if (!ReferenceArticleSQLComponent.this.textPAHT.getText().equalsIgnoreCase(ReferenceArticleSQLComponent.this.textMetrique1HA.getText())) {
127
                ReferenceArticleSQLComponent.this.textMetrique1HA.setText(ReferenceArticleSQLComponent.this.textPAHT.getText());
128
            }
18 ilm 129
        }
130
 
131
    };
180 ilm 132
    protected DocumentListener pieceVTArticle = new SimpleDocumentListener() {
18 ilm 133
 
93 ilm 134
        @Override
135
        public void update(DocumentEvent e) {
136
            if (!ReferenceArticleSQLComponent.this.textPVHT.getText().equalsIgnoreCase(ReferenceArticleSQLComponent.this.textMetrique1VT.getText())) {
137
                ReferenceArticleSQLComponent.this.textMetrique1VT.setText(ReferenceArticleSQLComponent.this.textPVHT.getText());
138
            }
18 ilm 139
        }
140
 
141
    };
142
 
180 ilm 143
    protected DocumentListener listenerMargeTextMarge = new SimpleDocumentListener() {
18 ilm 144
        @Override
145
        public void update(DocumentEvent e) {
146
            ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
147
            updateVtFromMarge();
148
            ReferenceArticleSQLComponent.this.textPVHT.getDocument().addDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
149
        }
150
 
151
    };
152
 
180 ilm 153
    protected DocumentListener listenerMargeTextVT = new SimpleDocumentListener() {
18 ilm 154
        @Override
155
        public void update(DocumentEvent e) {
156
            ReferenceArticleSQLComponent.this.textMarge.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextMarge);
157
            if (ReferenceArticleSQLComponent.this.textPVHT.getText().trim().length() > 0 && ReferenceArticleSQLComponent.this.textPAHT.getText().trim().length() > 0) {
83 ilm 158
                final BigDecimal vt = StringUtils.getBigDecimalFromUserText(ReferenceArticleSQLComponent.this.textPVHT.getText());
156 ilm 159
                BigDecimal ha = StringUtils.getBigDecimalFromUserText(ReferenceArticleSQLComponent.this.textPAHT.getText());
67 ilm 160
 
18 ilm 161
                if (vt != null && ha != null) {
73 ilm 162
                    if (vt.signum() != 0 && ha.signum() != 0) {
156 ilm 163
 
164
                        if (boxMargeWithCR.isSelected() && boxCR != null) {
165
                            SQLRow rowCR = boxCR.getSelectedRow();
166
                            if (rowCR != null && !rowCR.isUndefined()) {
167
                                BigDecimal cr = rowCR.getBigDecimal("POURCENT");
168
                                ha = ha.multiply(cr.movePointLeft(2).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION);
169
                            }
170
                        }
171
 
67 ilm 172
                        BigDecimal margeHT = vt.subtract(ha);
21 ilm 173
 
67 ilm 174
                        BigDecimal value;
175
 
21 ilm 176
                        if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
67 ilm 177
                            if (vt.compareTo(BigDecimal.ZERO) > 0) {
90 ilm 178
                                value = margeHT.divide(vt, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
21 ilm 179
                            } else {
67 ilm 180
                                value = BigDecimal.ZERO;
21 ilm 181
                            }
182
                        } else {
90 ilm 183
                            value = margeHT.divide(ha, DecimalUtils.HIGH_PRECISION).multiply(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION);
21 ilm 184
                        }
185
 
67 ilm 186
                        if (value.compareTo(BigDecimal.ZERO) > 0) {
187
                            ReferenceArticleSQLComponent.this.textMarge.setText(value.setScale(6, RoundingMode.HALF_UP).toString());
18 ilm 188
                        } else {
189
                            ReferenceArticleSQLComponent.this.textMarge.setText("0");
190
                        }
156 ilm 191
                        labelMarge.setText("% (" + StringUtils.leftAlign(margeHT.setScale(2, RoundingMode.HALF_UP).toString(), 9) + ")");
18 ilm 192
                    }
193
                }
194
            }
195
            ReferenceArticleSQLComponent.this.textMarge.getDocument().addDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextMarge);
196
        }
197
    };
198
 
180 ilm 199
    protected DocumentListener listenerMargeTextHA = new SimpleDocumentListener() {
18 ilm 200
        @Override
201
        public void update(DocumentEvent e) {
202
            ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
203
            updateVtFromMarge();
204
            ReferenceArticleSQLComponent.this.textPVHT.getDocument().addDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
205
        }
206
    };
207
 
180 ilm 208
    public void updateVtFromMarge() {
67 ilm 209
        if (this.textPAHT.getText().trim().length() > 0) {
21 ilm 210
 
83 ilm 211
            BigDecimal ha = StringUtils.getBigDecimalFromUserText(this.textPAHT.getText());
18 ilm 212
            if (ha != null && this.textMarge.getText().trim().length() > 0) {
73 ilm 213
 
156 ilm 214
                if (boxMargeWithCR.isSelected() && boxCR != null) {
215
                    SQLRow rowCR = this.boxCR.getSelectedRow();
216
                    if (rowCR != null && !rowCR.isUndefined()) {
217
                        BigDecimal cr = rowCR.getBigDecimal("POURCENT");
218
                        ha = ha.multiply(cr.movePointLeft(2).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION);
219
                    }
220
                }
221
 
83 ilm 222
                BigDecimal d = StringUtils.getBigDecimalFromUserText(this.textMarge.getText());
156 ilm 223
                if (d == null) {
224
                    d = BigDecimal.ZERO;
225
                }
226
                final BigDecimal vt;
21 ilm 227
                if (DefaultNXProps.getInstance().getBooleanValue(TotalPanel.MARGE_MARQUE, false)) {
90 ilm 228
                    final BigDecimal e = BigDecimal.ONE.subtract(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION));
73 ilm 229
                    if (e.signum() == 0) {
156 ilm 230
                        vt = BigDecimal.ZERO;
21 ilm 231
                    } else {
156 ilm 232
                        vt = ha.divide(e, DecimalUtils.HIGH_PRECISION).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP);
21 ilm 233
                    }
234
                } else {
90 ilm 235
                    BigDecimal result = ha.multiply(d.divide(BigDecimal.valueOf(100), DecimalUtils.HIGH_PRECISION).add(BigDecimal.ONE));
156 ilm 236
                    vt = result.setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP);
237
                    this.textPVHT.setText(vt.toString());
21 ilm 238
                }
156 ilm 239
                this.textPVHT.setText(vt.toString());
240
                BigDecimal margeHT = vt.subtract(ha);
241
                labelMarge.setText("% (" + StringUtils.leftAlign(margeHT.setScale(2, RoundingMode.HALF_UP).toString(), 9) + ")");
18 ilm 242
            }
243
        }
244
    }
245
 
246
    public ReferenceArticleSQLComponent(SQLElement elt) {
247
        super(elt);
94 ilm 248
        if (elt.getTable().getDBRoot().contains("ARTICLE_ELEMENT")) {
249
            this.tableBom = new ProductItemListTable();
250
        }
18 ilm 251
    }
252
 
253
    @Override
254
    public void select(SQLRowAccessor r) {
255
        super.select(r);
256
        if (r != null && r.getID() > getTable().getUndefinedID()) {
257
            this.checkObs.setVisible(true);
19 ilm 258
            this.tableTarifVente.setArticleValues(r);
259
            this.tableTarifVente.insertFrom("ID_ARTICLE", r.getID());
156 ilm 260
            this.tableCatComptable.insertFrom("ID_ARTICLE", r.getID());
261
            this.tableFourSec.insertFrom("ID_ARTICLE", r.getID());
94 ilm 262
            this.tableTarifQteVente.insertFrom("ID_ARTICLE", r.getID());
263
            if (this.tableBom != null) {
264
                this.tableBom.insertFrom("ID_ARTICLE_PARENT", r.getID());
265
            }
19 ilm 266
            this.tableDes.insertFrom("ID_ARTICLE", r.getID());
144 ilm 267
            this.tableCodeClient.insertFrom("ID_ARTICLE", r.getID());
67 ilm 268
            if (this.codeFournisseurTable != null) {
269
                this.codeFournisseurTable.insertFrom("ID_ARTICLE", r.getID());
270
            }
132 ilm 271
            selectModeVente(r.getForeignID("ID_MODE_VENTE_ARTICLE"));
18 ilm 272
        }
273
    }
274
 
275
    public void addViews() {
276
        this.setLayout(new GridBagLayout());
277
        final GridBagConstraints c = new DefaultGridBagConstraints();
278
 
67 ilm 279
        this.textPVHT = new JTextField(15);
280
        this.textPVTTC = new JTextField(15);
281
        this.textPAHT = new JTextField(15);
18 ilm 282
        this.textPVHT.getDocument().addDocumentListener(this.listenerMargeTextVT);
283
 
284
        // Init metrique devise field
67 ilm 285
        this.textMetrique1HA = new JTextField(15);
286
        this.textMetrique1VT = new JTextField(15);
18 ilm 287
 
288
        // init metrique value field
67 ilm 289
        this.textValMetrique1 = new JTextField(15);
290
        this.textValMetrique2 = new JTextField(15);
291
        this.textValMetrique3 = new JTextField(15);
18 ilm 292
 
293
        this.textCode = new JTextField();
294
        this.textNom = new JTextField();
295
        this.textPoids = new JTextField(6);
296
 
297
        // Code
19 ilm 298
        JLabel codelabel = new JLabel(getLabelFor("CODE"));
299
        codelabel.setHorizontalAlignment(SwingConstants.RIGHT);
300
        DefaultGridBagConstraints.lockMinimumSize(codelabel);
301
        this.add(codelabel, c);
18 ilm 302
        c.gridx++;
19 ilm 303
        c.weightx = 1;
304
        DefaultGridBagConstraints.lockMinimumSize(textCode);
18 ilm 305
        this.add(this.textCode, c);
306
 
19 ilm 307
        // Famille
18 ilm 308
        c.gridx++;
19 ilm 309
        c.gridwidth = 1;
18 ilm 310
        c.weightx = 0;
19 ilm 311
        JLabel labelFamille = new JLabel(getLabelFor("ID_FAMILLE_ARTICLE"));
312
        labelFamille.setHorizontalAlignment(SwingConstants.RIGHT);
313
        DefaultGridBagConstraints.lockMinimumSize(labelFamille);
314
        this.add(labelFamille, c);
18 ilm 315
        c.gridx++;
19 ilm 316
        c.weightx = 1;
317
        c.gridwidth = 1;
318
        final ElementComboBox comboSelFamille = new ElementComboBox(false, 25);
67 ilm 319
        this.addSQLObject(comboSelFamille, "ID_FAMILLE_ARTICLE");
19 ilm 320
        DefaultGridBagConstraints.lockMinimumSize(comboSelFamille);
321
        this.add(comboSelFamille, c);
18 ilm 322
 
19 ilm 323
        // Nom
18 ilm 324
        c.gridy++;
325
        c.gridx = 0;
326
        c.weightx = 0;
19 ilm 327
        JLabel labelNom = new JLabel(getLabelFor("NOM"));
328
        labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
329
        DefaultGridBagConstraints.lockMinimumSize(labelNom);
330
        this.add(labelNom, c);
18 ilm 331
        c.gridx++;
19 ilm 332
        c.weightx = 1;
333
        DefaultGridBagConstraints.lockMinimumSize(textNom);
334
        this.add(this.textNom, c);
18 ilm 335
 
19 ilm 336
        // Code barre
18 ilm 337
        c.gridx++;
19 ilm 338
        c.weightx = 0;
339
        JLabel labelCodeBarre = new JLabel(getLabelFor("CODE_BARRE"));
340
        labelCodeBarre.setHorizontalAlignment(SwingConstants.RIGHT);
341
        DefaultGridBagConstraints.lockMinimumSize(labelCodeBarre);
342
        this.add(labelCodeBarre, c);
343
        c.gridx++;
18 ilm 344
        c.weightx = 1;
19 ilm 345
        JTextField fieldCodeBarre = new JTextField();
346
        DefaultGridBagConstraints.lockMinimumSize(fieldCodeBarre);
347
        this.add(fieldCodeBarre, c);
348
        this.addView(fieldCodeBarre, "CODE_BARRE");
18 ilm 349
 
61 ilm 350
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
351
        // Gestion des unités de vente
352
        final boolean gestionUV = prefs.getBoolean(GestionArticleGlobalPreferencePanel.UNITE_VENTE, true);
93 ilm 353
        c.gridy++;
156 ilm 354
        final ElementComboBox boxUnite = new ElementComboBox();
61 ilm 355
        if (gestionUV) {
356
            c.gridx = 0;
65 ilm 357
            c.weightx = 0;
358
            this.add(new JLabel(getLabelFor("ID_UNITE_VENTE"), SwingConstants.RIGHT), c);
61 ilm 359
            c.gridx++;
65 ilm 360
            c.weightx = 1;
80 ilm 361
            c.fill = GridBagConstraints.NONE;
362
            DefaultGridBagConstraints.lockMinimumSize(boxUnite);
61 ilm 363
            this.add(boxUnite, c);
364
            this.addView(boxUnite, "ID_UNITE_VENTE");
80 ilm 365
            c.fill = GridBagConstraints.HORIZONTAL;
61 ilm 366
        }
93 ilm 367
        c.gridx = 2;
368
        c.weightx = 0;
369
        this.add(new JLabel(getLabelFor("SKU"), SwingConstants.RIGHT), c);
370
        c.gridx++;
371
        c.weightx = 1;
372
        JTextField fieldSKU = new JTextField();
373
        DefaultGridBagConstraints.lockMinimumSize(fieldSKU);
374
        this.add(fieldSKU, c);
375
        this.addView(fieldSKU, "SKU");
376
        c.fill = GridBagConstraints.HORIZONTAL;
377
 
156 ilm 378
        c.gridy++;
379
        if (gestionUV) {
380
            c.gridx = 0;
381
            c.weightx = 0;
382
            this.add(new JLabel(getLabelFor("QTE_UNITAIRE"), SwingConstants.RIGHT), c);
383
            c.gridx++;
384
            c.weightx = 1;
385
            c.fill = GridBagConstraints.NONE;
386
            final JTextField qte = new JTextField(10);
387
            qte.setEditable(false);
388
 
389
            this.add(qte, c);
390
            this.addView(qte, "QTE_UNITAIRE", REQ);
391
            boxUnite.addModelListener("wantedID", new PropertyChangeListener() {
392
 
393
                @Override
394
                public void propertyChange(PropertyChangeEvent evt) {
395
                    if (!boxUnite.isEmpty() && boxUnite.getSelectedId() == UniteVenteArticleSQLElement.A_LA_PIECE) {
396
                        qte.setText("1");
397
                        qte.setEditable(false);
398
                    } else {
399
                        qte.setEditable(true);
400
                    }
401
 
402
                }
403
            });
404
            c.fill = GridBagConstraints.HORIZONTAL;
405
        }
406
 
19 ilm 407
        DefaultProps props = DefaultNXProps.getInstance();
18 ilm 408
 
409
        // Article détaillé
410
        String modeVente = props.getStringProperty("ArticleModeVenteAvance");
411
        Boolean bModeVente = Boolean.valueOf(modeVente);
412
        boolean modeVenteAvance = (bModeVente == null || bModeVente.booleanValue());
413
 
414
        if (modeVenteAvance) {
415
            addModeVenteAvance(c);
416
        }
417
 
418
        getMontantPanel(c, props);
419
 
27 ilm 420
        // Champ Module
421
        c.gridx = 0;
422
        c.gridy++;
423
        c.gridwidth = GridBagConstraints.REMAINDER;
63 ilm 424
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
27 ilm 425
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
41 ilm 426
        this.add(addP, c);
27 ilm 427
 
19 ilm 428
        JTabbedPane pane = new JTabbedPane();
18 ilm 429
        c.gridy++;
430
        c.weightx = 1;
67 ilm 431
        c.weighty = 1;
19 ilm 432
 
94 ilm 433
        pane.add("Tarifs de vente spéciaux", createTarifPanel());
434
        pane.add("Tarifs de vente par quantité", createTarifQtePanel());
435
        if (this.tableBom != null) {
436
            pane.add("Nomenclature", createBOMpanel());
437
        }
19 ilm 438
        pane.add("Exportation", createExportationPanel());
439
        pane.add("Achat", createAchatPanel());
440
        pane.add("Stock", createStockPanel());
441
        pane.add("Descriptif", createDescriptifPanel());
442
        pane.add("Désignations multilingues", createDesignationPanel());
144 ilm 443
        pane.add("Désignations clients", createCodeClientPanel());
67 ilm 444
        pane.add("Comptabilité", createComptaPanel());
445
        pane.add(getLabelFor("INFOS"), createInfosPanel());
446
 
18 ilm 447
        c.fill = GridBagConstraints.BOTH;
19 ilm 448
        this.add(pane, c);
449
 
18 ilm 450
        this.addSQLObject(this.textMetrique1HA, "PRIX_METRIQUE_HA_1");
451
        this.addSQLObject(this.textMetrique1VT, "PRIX_METRIQUE_VT_1");
452
        this.addSQLObject(this.textValMetrique1, "VALEUR_METRIQUE_1");
453
        this.addSQLObject(this.textValMetrique2, "VALEUR_METRIQUE_2");
454
        this.addSQLObject(this.textValMetrique3, "VALEUR_METRIQUE_3");
455
        this.addSQLObject(this.comboSelModeVente, "ID_MODE_VENTE_ARTICLE");
456
        this.addSQLObject(this.boxService, "SERVICE");
457
 
458
        this.addRequiredSQLObject(this.textNom, "NOM");
459
        this.addRequiredSQLObject(this.textCode, "CODE");
460
 
461
        this.addSQLObject(this.textPoids, "POIDS");
462
 
463
        this.comboSelTaxe.setButtonsVisible(false);
464
        this.propertyChangeListener = new PropertyChangeListener() {
465
 
466
            public void propertyChange(PropertyChangeEvent evt) {
467
                System.err.println(ReferenceArticleSQLComponent.this.comboSelModeVente.getSelectedId());
468
                selectModeVente(ReferenceArticleSQLComponent.this.comboSelModeVente.getSelectedId());
19 ilm 469
 
18 ilm 470
            }
177 ilm 471
 
18 ilm 472
        };
473
        setListenerModeVenteActive(true);
474
        this.comboSelModeVente.setValue(ReferenceArticleSQLElement.A_LA_PIECE);
475
    }
476
 
180 ilm 477
    protected Component createInfosPanel() {
67 ilm 478
        JPanel panel = new JPanel(new GridBagLayout());
479
        panel.setOpaque(false);
480
        GridBagConstraints c = new DefaultGridBagConstraints();
144 ilm 481
        c.weightx = 0;
482
        c.gridy++;
483
        c.gridx = 0;
484
        c.weightx = 0;
485
        JLabel labelifco = new JLabel(getLabelFor("IFCO"));
67 ilm 486
 
144 ilm 487
        panel.add(labelifco, c);
488
        c.weightx = 1;
489
        c.gridx++;
490
        JTextField textIfco = new JTextField(40);
491
        panel.add(textIfco, c);
492
        addView(textIfco, "IFCO");
493
 
494
        c.gridx++;
142 ilm 495
        c.weightx = 0;
144 ilm 496
        JLabel labelTare = new JLabel(getLabelFor("TARE"));
497
        panel.add(labelTare, c);
498
        c.weightx = 1;
499
        c.gridx++;
500
        JTextField textTare = new JTextField(40);
501
        panel.add(textTare, c);
502
        addView(textTare, "TARE");
503
 
177 ilm 504
        c.gridy++;
505
        c.gridx = 0;
149 ilm 506
        c.weightx = 0;
177 ilm 507
        JLabel labelDLC = new JLabel(getLabelFor("DLC"));
508
        panel.add(labelDLC, c);
509
        c.weightx = 1;
510
        c.gridx++;
511
        JDate dateDLC = new JDate();
512
        panel.add(dateDLC, c);
513
        addView(dateDLC, "DLC");
514
 
515
        c.weightx = 0;
144 ilm 516
        c.gridy++;
517
        c.gridx = 0;
177 ilm 518
        if (getTable().contains("POIDS_COLIS_NET")) {
519
            JLabel labelPdsColis = new JLabel(getLabelFor("POIDS_COLIS_NET"));
520
            panel.add(labelPdsColis, c);
521
            c.weightx = 1;
522
            c.gridx++;
523
            JTextField textPdsColis = new JTextField(40);
524
            panel.add(textPdsColis, c);
525
            addView(textPdsColis, "POIDS_COLIS_NET");
526
            c.gridx++;
527
        }
528
 
149 ilm 529
        JLabel labelMasque = new JLabel(getLabelFor("MASQUE_CAISSE"));
530
        c.fill = GridBagConstraints.BOTH;
531
        panel.add(labelMasque, c);
532
        c.weightx = 1;
533
        c.gridx++;
534
        JCheckBox boxMasqueCaisse = new JCheckBox();
535
        panel.add(boxMasqueCaisse, c);
536
        this.addSQLObject(boxMasqueCaisse, "MASQUE_CAISSE");
537
 
538
        c.gridy++;
539
        c.gridx = 0;
144 ilm 540
        c.weightx = 0;
142 ilm 541
        JLabel labelEco = new JLabel(getLabelFor("ID_ECO_CONTRIBUTION"));
542
        c.fill = GridBagConstraints.BOTH;
543
        panel.add(labelEco, c);
67 ilm 544
        c.weightx = 1;
142 ilm 545
        c.gridx++;
546
        ElementComboBox box = new ElementComboBox();
547
        panel.add(box, c);
548
 
549
        c.weightx = 0;
550
        c.gridy++;
551
        c.gridx = 0;
552
        JLabel labelTaxeCompl = new JLabel(getLabelFor("ID_TAXE_COMPLEMENTAIRE"));
553
        c.fill = GridBagConstraints.BOTH;
554
        panel.add(labelTaxeCompl, c);
555
        c.weightx = 1;
556
        c.gridx++;
557
        ElementComboBox boxTaxeCompl = new ElementComboBox();
558
        panel.add(boxTaxeCompl, c);
559
 
156 ilm 560
        c.weightx = 0;
142 ilm 561
        c.gridy++;
562
        c.gridx = 0;
156 ilm 563
        JLabel labelMatiere = new JLabel(getLabelFor("MATIERE"));
564
        c.fill = GridBagConstraints.BOTH;
565
        panel.add(labelMatiere, c);
566
        c.weightx = 1;
567
        c.gridx++;
568
        SQLTextCombo comboMatiere = new SQLTextCombo();
569
        panel.add(comboMatiere, c);
570
 
571
        c.gridy++;
572
        c.gridx = 0;
142 ilm 573
        c.gridwidth = GridBagConstraints.REMAINDER;
574
        TitledSeparator sep = new TitledSeparator(getLabelFor("INFOS"));
575
        panel.add(sep, c);
576
        c.gridy++;
67 ilm 577
        c.weighty = 1;
578
        ITextArea infos = new ITextArea();
579
        c.fill = GridBagConstraints.BOTH;
580
        panel.add(infos, c);
581
 
582
        this.addSQLObject(infos, "INFOS");
156 ilm 583
        this.addSQLObject(comboMatiere, "MATIERE");
142 ilm 584
        this.addSQLObject(box, "ID_ECO_CONTRIBUTION");
585
        this.addSQLObject(boxTaxeCompl, "ID_TAXE_COMPLEMENTAIRE");
67 ilm 586
        return panel;
587
    }
588
 
180 ilm 589
    protected Component createDescriptifPanel() {
19 ilm 590
        JPanel panel = new JPanel(new GridBagLayout());
591
        panel.setOpaque(false);
592
        GridBagConstraints c = new DefaultGridBagConstraints();
593
 
594
        // Obsolete
595
        c.fill = GridBagConstraints.NONE;
41 ilm 596
        c.gridwidth = GridBagConstraints.REMAINDER;
19 ilm 597
        c.weightx = 1;
25 ilm 598
        this.checkObs.setOpaque(false);
19 ilm 599
        panel.add(this.checkObs, c);
600
 
601
        this.checkObs.setVisible(false);
602
        this.addView(this.checkObs, "OBSOLETE");
603
 
41 ilm 604
        if (getTable().getFieldsName().contains("COLORIS")) {
605
            JTextField fieldColoris = new JTextField();
606
            c.gridy++;
607
            c.fill = GridBagConstraints.HORIZONTAL;
608
            c.weightx = 0;
609
            c.gridwidth = 1;
610
            panel.add(new JLabel(getLabelFor("COLORIS")), c);
611
 
612
            c.weightx = 1;
613
            c.gridx++;
614
            panel.add(fieldColoris, c);
615
            this.addView(fieldColoris, "COLORIS");
616
        }
177 ilm 617
        JTextField fieldLongueur = new JTextField();
618
        c.gridy++;
619
        c.fill = GridBagConstraints.HORIZONTAL;
620
        c.weightx = 0;
621
        c.gridwidth = 1;
622
        panel.add(new JLabel(getLabelFor("LONGUEUR")), c);
623
 
624
        c.weightx = 1;
625
        c.gridx++;
626
        panel.add(fieldLongueur, c);
627
        this.addView(fieldLongueur, "LONGUEUR");
628
 
629
        JTextField fieldLargeur = new JTextField();
630
        c.gridx++;
631
        c.fill = GridBagConstraints.HORIZONTAL;
632
        c.weightx = 0;
633
        c.gridwidth = 1;
634
        panel.add(new JLabel(getLabelFor("LARGEUR")), c);
635
        c.weightx = 1;
636
        c.gridx++;
637
        panel.add(fieldLargeur, c);
638
        this.addView(fieldLargeur, "LARGEUR");
639
 
640
        JTextField fieldHauteur = new JTextField();
641
        c.gridy++;
642
        c.gridx = 0;
643
        c.fill = GridBagConstraints.HORIZONTAL;
644
        c.weightx = 0;
645
        c.gridwidth = 1;
646
        panel.add(new JLabel(getLabelFor("HAUTEUR")), c);
647
 
648
        c.weightx = 1;
649
        c.gridx++;
650
        panel.add(fieldHauteur, c);
651
        this.addView(fieldHauteur, "HAUTEUR");
652
 
19 ilm 653
        ITextArea area = new ITextArea();
654
        JLabel sep = new JLabel("Descriptif complet");
655
        c.gridy++;
41 ilm 656
        c.gridx = 0;
657
        c.gridwidth = GridBagConstraints.REMAINDER;
19 ilm 658
        c.fill = GridBagConstraints.HORIZONTAL;
659
        panel.add(sep, c);
660
 
661
        c.gridy++;
662
        c.weighty = 1;
663
        c.fill = GridBagConstraints.BOTH;
664
        panel.add(area, c);
665
        this.addView(area, "DESCRIPTIF");
666
        return panel;
667
    }
668
 
180 ilm 669
    protected Component createDesignationPanel() {
19 ilm 670
        JPanel panel = new JPanel(new GridBagLayout());
671
        panel.setOpaque(false);
672
        GridBagConstraints c = new DefaultGridBagConstraints();
673
 
674
        // Ajout des
675
        c.gridwidth = 1;
676
        c.weightx = 0;
677
        c.gridy++;
678
        c.gridx = 0;
679
        panel.add(new JLabel("Ajouter une désignation "), c);
680
 
681
        final ElementComboBox boxDes = new ElementComboBox();
682
        boxDes.init(Configuration.getInstance().getDirectory().getElement("LANGUE"));
683
 
684
        c.gridx++;
685
        panel.add(boxDes, c);
686
 
687
        c.fill = GridBagConstraints.NONE;
688
        c.gridx++;
689
        JButton buttonAjouterDes = new JButton("Ajouter");
690
        buttonAjouterDes.setOpaque(false);
691
        panel.add(buttonAjouterDes, c);
692
        c.gridx++;
693
        JButton buttonSupprimerDes = new JButton("Supprimer");
694
        buttonSupprimerDes.setOpaque(false);
695
        panel.add(buttonSupprimerDes, c);
696
 
697
        c.gridy++;
698
        c.gridx = 0;
699
        c.gridwidth = GridBagConstraints.REMAINDER;
700
        c.fill = GridBagConstraints.BOTH;
701
        c.weighty = 1;
702
        c.weightx = 1;
703
        this.tableDes.setOpaque(false);
704
        panel.add(this.tableDes, c);
705
 
706
        // Listerners
707
        buttonAjouterDes.addActionListener(new ActionListener() {
708
 
709
            @Override
710
            public void actionPerformed(ActionEvent e) {
711
 
712
                int id = boxDes.getSelectedId();
713
                if (id <= 1) {
714
                    return;
715
                }
716
                int nbRows = tableDes.getModel().getRowCount();
717
 
718
                for (int i = 0; i < nbRows; i++) {
719
                    SQLRowValues rowVals = tableDes.getModel().getRowValuesAt(i);
720
                    int idLangue = Integer.parseInt(rowVals.getObject("ID_LANGUE").toString());
721
                    if (idLangue == id) {
722
                        JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLa langue est déjà présente dans la liste!");
723
                        return;
724
                    }
725
                }
726
 
727
                SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_DESIGNATION"));
728
                if (getSelectedID() > 1) {
729
                    rowVals.put("ID_ARTICLE", getSelectedID());
730
                }
731
                rowVals.put("ID_LANGUE", id);
732
                rowVals.put("NOM", "");
733
                tableDes.getModel().addRow(rowVals);
734
            }
735
        });
736
        buttonSupprimerDes.addActionListener(new ActionListener() {
737
 
738
            @Override
739
            public void actionPerformed(ActionEvent e) {
740
                tableDes.removeSelectedRow();
741
            }
742
        });
743
 
744
        return panel;
745
    }
746
 
180 ilm 747
    protected Component createCodeClientPanel() {
144 ilm 748
        JPanel panel = new JPanel(new GridBagLayout());
749
        panel.setOpaque(false);
750
        GridBagConstraints c = new DefaultGridBagConstraints();
751
 
752
        c.gridx = 0;
753
        c.gridwidth = GridBagConstraints.REMAINDER;
754
        c.fill = GridBagConstraints.BOTH;
755
        c.weighty = 1;
756
        c.weightx = 1;
757
        this.tableCodeClient.setOpaque(false);
758
        panel.add(this.tableCodeClient, c);
759
 
760
        return panel;
761
    }
762
 
180 ilm 763
    protected Component createStockPanel() {
19 ilm 764
        JPanel panel = new JPanel(new GridBagLayout());
765
        panel.setOpaque(false);
766
        GridBagConstraints c = new DefaultGridBagConstraints();
93 ilm 767
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
142 ilm 768
        boolean gestionStockMin = prefs.getBoolean(GestionArticleGlobalPreferencePanel.WARNING_STOCK_MIN, true);
19 ilm 769
        c.gridx = 0;
770
        c.gridy++;
771
 
772
        final JCheckBox boxStock = new JCheckBox(getLabelFor("GESTION_STOCK"));
773
        boxStock.setOpaque(false);
774
        panel.add(boxStock, c);
775
        this.addView(boxStock, "GESTION_STOCK");
776
 
777
        final JTextField fieldQteMin = new JTextField();
778
        final JTextField fieldQteAchat = new JTextField();
779
        boxStock.addActionListener(new ActionListener() {
780
 
781
            @Override
782
            public void actionPerformed(ActionEvent e) {
783
                fieldQteMin.setEnabled(boxStock.isSelected());
784
                fieldQteAchat.setEnabled(boxStock.isSelected());
785
            }
786
        });
787
 
156 ilm 788
        boolean visibleDepot = (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_MULTI_DEPOT, false));
789
        c.gridx = 0;
790
        c.gridy++;
791
        c.weightx = 0;
792
        final JLabel labelDepot = new JLabel(getLabelFor("ID_DEPOT_STOCK"));
793
        panel.add(labelDepot, c);
794
        labelDepot.setVisible(visibleDepot);
795
        c.gridx++;
796
        c.weightx = 1;
797
        ElementComboBox boxDepot = new ElementComboBox();
798
        panel.add(boxDepot, c);
799
        boxDepot.setVisible(visibleDepot);
800
        this.addView(boxDepot, "ID_DEPOT_STOCK", REQ);
801
 
19 ilm 802
        c.gridwidth = 1;
803
        if (gestionStockMin) {
156 ilm 804
            // c.gridx = 0;
805
            // c.gridy++;
806
            // c.weightx = 0;
807
            // panel.add(new JLabel(getLabelFor("QTE_MIN")), c);
808
            // c.gridx++;
809
            // c.weightx = 1;
810
            // panel.add(fieldQteMin, c);
811
            // this.addView(fieldQteMin, "QTE_MIN");
19 ilm 812
 
813
            c.gridx = 0;
814
            c.gridy++;
815
            c.weightx = 0;
816
            panel.add(new JLabel(getLabelFor("QTE_ACHAT")), c);
817
            c.gridx++;
818
            c.weightx = 1;
819
            panel.add(fieldQteAchat, c);
820
            this.addView(fieldQteAchat, "QTE_ACHAT");
821
        }
822
 
823
        c.gridy++;
824
        c.weighty = 1;
825
        c.weightx = 1;
826
        c.fill = GridBagConstraints.BOTH;
827
        final JPanel spacer = new JPanel();
828
        spacer.setOpaque(false);
829
        panel.add(spacer, c);
830
        return panel;
831
    }
832
 
180 ilm 833
    protected Component createComptaPanel() {
67 ilm 834
        JPanel panel = new JPanel(new GridBagLayout());
835
        panel.setOpaque(false);
836
        GridBagConstraints c = new DefaultGridBagConstraints();
837
        c.gridwidth = 1;
838
        c.weighty = 0;
839
        c.weightx = 0;
840
        ISQLCompteSelector sel = new ISQLCompteSelector();
841
        c.fill = GridBagConstraints.BOTH;
842
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE")), c);
843
        c.gridx++;
844
        c.weightx = 1;
845
        panel.add(sel, c);
846
        this.addView(sel, "ID_COMPTE_PCE");
847
 
848
        c.gridwidth = 1;
849
        c.gridy++;
850
        c.weighty = 0;
851
        c.gridx = 0;
852
        c.weightx = 0;
853
        ISQLCompteSelector selAchat = new ISQLCompteSelector();
854
        c.fill = GridBagConstraints.BOTH;
855
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_ACHAT")), c);
856
        c.gridx++;
857
        c.weightx = 1;
858
        panel.add(selAchat, c);
859
        this.addView(selAchat, "ID_COMPTE_PCE_ACHAT");
860
 
861
        c.gridy++;
156 ilm 862
        c.gridx = 0;
67 ilm 863
        c.weighty = 1;
864
        c.weightx = 1;
865
        c.fill = GridBagConstraints.BOTH;
156 ilm 866
        c.gridwidth = GridBagConstraints.REMAINDER;
867
 
868
        panel.add(createCategorieComptablePanel(), c);
869
        // final JPanel spacer = new JPanel();
870
        // spacer.setOpaque(false);
871
        // panel.add(spacer, c);
67 ilm 872
        return panel;
873
    }
874
 
180 ilm 875
    protected SQLRowValues rowValuesDefaultCodeFournisseur;
876
    protected CodeFournisseurItemTable codeFournisseurTable;
67 ilm 877
 
180 ilm 878
    protected Component createAchatPanel() {
19 ilm 879
        JPanel panel = new JPanel(new GridBagLayout());
880
        panel.setOpaque(false);
881
        GridBagConstraints c = new DefaultGridBagConstraints();
882
        // Fournisseur
883
        c.gridy++;
884
        c.gridx = 0;
885
        c.gridwidth = 1;
886
        c.weightx = 0;
887
        JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
888
        labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
889
        panel.add(labelFournisseur, c);
890
        c.gridx++;
891
        c.weightx = 1;
892
        c.gridwidth = 2;
893
        final ElementComboBox comboSelFournisseur = new ElementComboBox(false, 25);
894
        panel.add(comboSelFournisseur, c);
895
        this.addView(comboSelFournisseur, "ID_FOURNISSEUR");
896
 
67 ilm 897
        SQLPreferences prefs = new SQLPreferences(ComptaPropsConfiguration.getInstanceCompta().getRootSociete());
898
        final boolean supplierCode = prefs.getBoolean(GestionArticleGlobalPreferencePanel.SUPPLIER_PRODUCT_CODE, false);
899
 
177 ilm 900
        // Tarif fournisseur
901
        c.gridy++;
902
        c.gridx = 0;
903
        c.gridwidth = GridBagConstraints.REMAINDER;
904
        TitledSeparator sep = new TitledSeparator("Tarifs fournisseurs");
905
        panel.add(sep, c);
906
 
907
        // Ajout fournisseur
908
        c.gridwidth = 1;
909
        c.weightx = 0;
910
        c.gridy++;
911
        c.gridx = 0;
912
        panel.add(new JLabel("Ajouter le fournisseur "), c);
913
 
914
        final ElementComboBox boxF = new ElementComboBox();
915
        boxF.init(Configuration.getInstance().getDirectory().getElement("FOURNISSEUR"));
916
 
917
        c.gridx++;
918
        panel.add(boxF, c);
919
 
920
        c.fill = GridBagConstraints.NONE;
921
        c.gridx++;
922
        JButton buttonAjouter = new JButton("Ajouter");
923
        buttonAjouter.setOpaque(false);
924
        panel.add(buttonAjouter, c);
925
        c.gridx++;
926
        JButton buttonSupprimer = new JButton("Supprimer");
927
        buttonSupprimer.setOpaque(false);
928
        panel.add(buttonSupprimer, c);
929
 
930
        c.gridwidth = GridBagConstraints.REMAINDER;
931
        c.fill = GridBagConstraints.BOTH;
932
        c.weightx = 1;
933
        c.weighty = 1;
934
        c.gridy++;
935
        c.gridx = 0;
936
        c.fill = GridBagConstraints.BOTH;
937
        this.tableFourSec.setOpaque(false);
938
        panel.add(this.tableFourSec, c);
939
 
940
        // Listeners
941
        buttonAjouter.addActionListener(new ActionListener() {
942
 
943
            @Override
944
            public void actionPerformed(ActionEvent e) {
945
 
946
                SQLRow rowCat = boxF.getSelectedRow();
947
                if (rowCat == null || rowCat.isUndefined()) {
948
                    return;
949
                }
950
                int nbRows = tableFourSec.getModel().getRowCount();
951
 
952
                // for (int i = 0; i < nbRows; i++) {
953
                // SQLRowValues rowVals = tableFourSec.getModel().getRowValuesAt(i);
954
                // int idTarif =
955
                // Integer.parseInt(rowVals.getObject("ID_FOURNISSEUR").toString());
956
                // if (idTarif == rowCat.getID()) {
957
                // JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLe fournisseur
958
                // est déjà présent dans la liste!");
959
                // return;
960
                // }
961
                // }
962
 
963
                SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF_FOURNISSEUR"));
964
                if (getSelectedID() > 1) {
965
                    rowVals.put("ID_ARTICLE", getSelectedID());
966
                }
967
                rowVals.put("ID_FOURNISSEUR", rowCat.getID());
968
                tableFourSec.getModel().addRow(rowVals);
969
            }
970
        });
971
        buttonSupprimer.addActionListener(new ActionListener() {
972
 
973
            @Override
974
            public void actionPerformed(ActionEvent e) {
975
                tableFourSec.removeSelectedRow();
976
            }
977
        });
67 ilm 978
        if (getTable().getSchema().contains("CODE_FOURNISSEUR") && supplierCode) {
177 ilm 979
            c.gridy++;
980
            c.gridx = 0;
981
            c.gridwidth = GridBagConstraints.REMAINDER;
982
            TitledSeparator sepC = new TitledSeparator("Codes fournisseurs");
983
            panel.add(sepC, c);
984
 
67 ilm 985
            this.rowValuesDefaultCodeFournisseur = new SQLRowValues(getTable().getTable("CODE_FOURNISSEUR"));
986
            this.codeFournisseurTable = new CodeFournisseurItemTable(this.rowValuesDefaultCodeFournisseur);
987
            c.gridy++;
988
            c.gridx = 0;
177 ilm 989
            c.gridwidth = GridBagConstraints.REMAINDER;
67 ilm 990
            c.weighty = 1;
991
            c.weightx = 1;
992
            c.fill = GridBagConstraints.BOTH;
993
            panel.add(this.codeFournisseurTable, c);
994
            comboSelFournisseur.addValueListener(new PropertyChangeListener() {
995
 
996
                @Override
997
                public void propertyChange(PropertyChangeEvent evt) {
998
                    rowValuesDefaultCodeFournisseur.put("ID_FOURNISSEUR", comboSelFournisseur.getSelectedId());
999
                }
1000
            });
1001
        }
19 ilm 1002
        return panel;
177 ilm 1003
 
19 ilm 1004
    }
1005
 
180 ilm 1006
    protected JPanel createExportationPanel() {
19 ilm 1007
        JPanel panel = new JPanel(new GridBagLayout());
1008
        panel.setOpaque(false);
1009
        GridBagConstraints c = new DefaultGridBagConstraints();
1010
        // Code douanier
1011
        c.gridx = 0;
1012
        c.weightx = 0;
1013
        c.gridy++;
1014
        c.gridwidth = 1;
1015
        JLabel labelCodeD = new JLabel(getLabelFor("CODE_DOUANIER"));
1016
        labelCodeD.setHorizontalAlignment(SwingConstants.RIGHT);
1017
        panel.add(labelCodeD, c);
1018
 
1019
        c.gridx++;
1020
        JTextField fieldCodeDouanier = new JTextField();
1021
        c.weightx = 1;
1022
        panel.add(fieldCodeDouanier, c);
1023
        this.addView(fieldCodeDouanier, "CODE_DOUANIER");
1024
 
1025
        // Pays d'origine
1026
        c.gridx++;
1027
        c.weightx = 0;
1028
        JLabel labelPays = new JLabel(getLabelFor("ID_PAYS"));
1029
        labelPays.setHorizontalAlignment(SwingConstants.RIGHT);
1030
        panel.add(labelPays, c);
1031
        c.gridx++;
1032
        c.weightx = 1;
1033
        final ElementComboBox comboSelPays = new ElementComboBox(false);
1034
        panel.add(comboSelPays, c);
1035
        this.addView(comboSelPays, "ID_PAYS");
1036
        c.gridy++;
1037
        c.weighty = 1;
1038
        c.weightx = 1;
1039
        c.fill = GridBagConstraints.BOTH;
1040
        final JPanel spacer = new JPanel();
1041
        spacer.setOpaque(false);
1042
        panel.add(spacer, c);
1043
        return panel;
1044
    }
1045
 
180 ilm 1046
    protected JPanel createTarifPanel() {
19 ilm 1047
        JPanel panel = new JPanel(new GridBagLayout());
1048
        panel.setOpaque(false);
1049
        GridBagConstraints c = new DefaultGridBagConstraints();
1050
 
1051
        // Ajout tarif
1052
        c.gridwidth = 1;
1053
        c.weightx = 0;
1054
        c.gridy++;
1055
        c.gridx = 0;
1056
        panel.add(new JLabel("Ajouter le tarif "), c);
1057
 
1058
        final ElementComboBox boxTarif = new ElementComboBox();
1059
        boxTarif.init(Configuration.getInstance().getDirectory().getElement("TARIF"));
1060
 
1061
        c.gridx++;
1062
        panel.add(boxTarif, c);
1063
 
1064
        c.fill = GridBagConstraints.NONE;
1065
        c.gridx++;
1066
        JButton buttonAjouter = new JButton("Ajouter");
1067
        buttonAjouter.setOpaque(false);
1068
        panel.add(buttonAjouter, c);
1069
        c.gridx++;
1070
        JButton buttonSupprimer = new JButton("Supprimer");
1071
        buttonSupprimer.setOpaque(false);
1072
        panel.add(buttonSupprimer, c);
1073
 
1074
        c.gridwidth = GridBagConstraints.REMAINDER;
1075
        c.fill = GridBagConstraints.BOTH;
1076
        c.weightx = 1;
1077
        c.weighty = 1;
1078
        c.gridy++;
1079
        c.gridx = 0;
1080
        c.fill = GridBagConstraints.BOTH;
1081
        this.tableTarifVente.setOpaque(false);
1082
        panel.add(this.tableTarifVente, c);
1083
 
1084
        // Listeners
1085
        buttonAjouter.addActionListener(new ActionListener() {
1086
 
1087
            @Override
1088
            public void actionPerformed(ActionEvent e) {
1089
 
1090
                SQLRow rowTarif = boxTarif.getSelectedRow();
1091
                if (rowTarif == null || rowTarif.isUndefined()) {
1092
                    return;
1093
                }
94 ilm 1094
                // int nbRows = tableTarifVente.getModel().getRowCount();
19 ilm 1095
 
94 ilm 1096
                // FIXME Check with qty
1097
                // for (int i = 0; i < nbRows; i++) {
1098
                // SQLRowValues rowVals = tableTarifVente.getModel().getRowValuesAt(i);
1099
                // int idTarif = Integer.parseInt(rowVals.getObject("ID_TARIF").toString());
1100
                // if (idTarif == rowTarif.getID()) {
1101
                // JOptionPane.showMessageDialog(null,
1102
                // "Impossible d'ajouter.\nLe tarif est déjà présent dans la liste!");
1103
                // return;
1104
                // }
1105
                // }
19 ilm 1106
 
1107
                SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF"));
1108
                if (getSelectedID() > 1) {
1109
                    rowVals.put("ID_ARTICLE", getSelectedID());
1110
                }
1111
                rowVals.put("ID_TARIF", rowTarif.getID());
1112
                rowVals.put("ID_DEVISE", rowTarif.getInt("ID_DEVISE"));
1113
                rowVals.put("ID_TAXE", rowTarif.getInt("ID_TAXE"));
67 ilm 1114
                rowVals.put("PRIX_METRIQUE_VT_1", BigDecimal.ZERO);
1115
                rowVals.put("PV_HT", BigDecimal.ZERO);
1116
                rowVals.put("PV_TTC", BigDecimal.ZERO);
19 ilm 1117
                tableTarifVente.getModel().addRow(rowVals);
1118
            }
1119
        });
1120
        buttonSupprimer.addActionListener(new ActionListener() {
1121
 
1122
            @Override
1123
            public void actionPerformed(ActionEvent e) {
1124
                tableTarifVente.removeSelectedRow();
1125
            }
1126
        });
1127
        return panel;
1128
    }
1129
 
180 ilm 1130
    protected JPanel createCategorieComptablePanel() {
156 ilm 1131
        JPanel panel = new JPanel(new GridBagLayout());
1132
        panel.setOpaque(false);
1133
        GridBagConstraints c = new DefaultGridBagConstraints();
1134
 
1135
        // Ajout catégorie
1136
        c.gridwidth = 1;
1137
        c.weightx = 0;
1138
        c.gridy++;
1139
        c.gridx = 0;
1140
        panel.add(new JLabel("Ajouter la catégorie "), c);
1141
 
1142
        final ElementComboBox boxCat = new ElementComboBox();
1143
        boxCat.init(Configuration.getInstance().getDirectory().getElement("CATEGORIE_COMPTABLE"));
1144
 
1145
        c.gridx++;
1146
        panel.add(boxCat, c);
1147
 
1148
        c.fill = GridBagConstraints.NONE;
1149
        c.gridx++;
1150
        JButton buttonAjouter = new JButton("Ajouter");
1151
        buttonAjouter.setOpaque(false);
1152
        panel.add(buttonAjouter, c);
1153
        c.gridx++;
1154
        JButton buttonSupprimer = new JButton("Supprimer");
1155
        buttonSupprimer.setOpaque(false);
1156
        panel.add(buttonSupprimer, c);
1157
 
1158
        c.gridwidth = GridBagConstraints.REMAINDER;
1159
        c.fill = GridBagConstraints.BOTH;
1160
        c.weightx = 1;
1161
        c.weighty = 1;
1162
        c.gridy++;
1163
        c.gridx = 0;
1164
        c.fill = GridBagConstraints.BOTH;
1165
        this.tableCatComptable.setOpaque(false);
1166
        panel.add(this.tableCatComptable, c);
1167
 
1168
        // Listeners
1169
        buttonAjouter.addActionListener(new ActionListener() {
1170
 
1171
            @Override
1172
            public void actionPerformed(ActionEvent e) {
1173
 
1174
                SQLRow rowCat = boxCat.getSelectedRow();
1175
                if (rowCat == null || rowCat.isUndefined()) {
1176
                    return;
1177
                }
1178
                int nbRows = tableCatComptable.getModel().getRowCount();
1179
 
1180
                for (int i = 0; i < nbRows; i++) {
1181
                    SQLRowValues rowVals = tableCatComptable.getModel().getRowValuesAt(i);
1182
                    int idTarif = Integer.parseInt(rowVals.getObject("ID_CATEGORIE_COMPTABLE").toString());
1183
                    if (idTarif == rowCat.getID()) {
1184
                        JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLa catégorie est déjà présente dans la liste!");
1185
                        return;
1186
                    }
1187
                }
1188
 
1189
                SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_CATEGORIE_COMPTABLE"));
1190
                if (getSelectedID() > 1) {
1191
                    rowVals.put("ID_ARTICLE", getSelectedID());
1192
                }
1193
                rowVals.put("ID_CATEGORIE_COMPTABLE", rowCat.getID());
1194
                tableCatComptable.getModel().addRow(rowVals);
1195
            }
1196
        });
1197
        buttonSupprimer.addActionListener(new ActionListener() {
1198
 
1199
            @Override
1200
            public void actionPerformed(ActionEvent e) {
1201
                tableCatComptable.removeSelectedRow();
1202
            }
1203
        });
1204
        return panel;
1205
    }
1206
 
180 ilm 1207
    protected JPanel createBOMpanel() {
94 ilm 1208
        JPanel panel = new JPanel(new GridBagLayout());
1209
        panel.setOpaque(false);
1210
        GridBagConstraints c = new DefaultGridBagConstraints();
1211
 
177 ilm 1212
        final JCheckBox checkAutoPrice = new JCheckBox(getLabelFor("AUTO_PRIX_MIN_VENTE_NOMENCLATURE"));
1213
        panel.add(checkAutoPrice, c);
1214
        this.addView(checkAutoPrice, "AUTO_PRIX_MIN_VENTE_NOMENCLATURE");
1215
        c.gridx++;
1216
        final JCheckBox checkAutoPriceHA = new JCheckBox(getLabelFor("AUTO_PRIX_ACHAT_NOMENCLATURE"));
1217
        panel.add(checkAutoPriceHA, c);
1218
        this.addView(checkAutoPriceHA, "AUTO_PRIX_ACHAT_NOMENCLATURE");
1219
 
1220
        checkAutoPrice.addActionListener(new ActionListener() {
1221
 
1222
            @Override
1223
            public void actionPerformed(ActionEvent e) {
1224
                updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
1225
            }
1226
        });
1227
        checkAutoPriceHA.addActionListener(new ActionListener() {
1228
 
1229
            @Override
1230
            public void actionPerformed(ActionEvent e) {
1231
                updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
1232
            }
1233
        });
1234
 
94 ilm 1235
        c.gridwidth = GridBagConstraints.REMAINDER;
1236
        c.fill = GridBagConstraints.BOTH;
1237
        c.weightx = 1;
1238
        c.weighty = 1;
1239
        c.gridx = 0;
177 ilm 1240
        c.gridy++;
94 ilm 1241
        c.fill = GridBagConstraints.BOTH;
1242
        this.tableBom.setOpaque(false);
1243
        panel.add(new RowValuesTableEditionPanel(this.tableBom), c);
177 ilm 1244
 
1245
        this.tableBom.getModel().addTableModelListener(new TableModelListener() {
1246
 
1247
            @Override
1248
            public void tableChanged(TableModelEvent e) {
1249
                updatePricesNomenclature(checkAutoPrice, checkAutoPriceHA);
1250
 
1251
            }
1252
 
1253
        });
94 ilm 1254
        return panel;
177 ilm 1255
 
94 ilm 1256
    }
1257
 
180 ilm 1258
    protected void updatePricesNomenclature(final JCheckBox checkAutoPrice, final JCheckBox checkAutoPriceHA) {
177 ilm 1259
        final Boolean vtAuto = checkAutoPrice.isSelected();
1260
        final Boolean haAuto = checkAutoPriceHA.isSelected();
1261
        if (vtAuto || haAuto) {
1262
            ProductHelper helper = new ProductHelper(getTable().getDBRoot());
1263
 
1264
            Tuple2<BigDecimal, BigDecimal> p = helper.getStandardBomPrices(tableBom.getRowValuesTable().getRowValuesTableModel().getCopyOfValues());
1265
            if (haAuto && p.get0() != null) {
1266
                textPAHT.setText(p.get0().toString());
1267
            }
1268
            if (vtAuto && p.get1() != null) {
1269
                textPVHT.setText(p.get1().toString());
1270
            }
1271
        }
1272
    }
1273
 
180 ilm 1274
    protected JPanel createTarifQtePanel() {
94 ilm 1275
        JPanel panel = new JPanel(new GridBagLayout());
1276
        panel.setOpaque(false);
1277
        GridBagConstraints c = new DefaultGridBagConstraints();
1278
 
1279
        c.gridwidth = GridBagConstraints.REMAINDER;
1280
        c.fill = GridBagConstraints.BOTH;
1281
        c.weightx = 1;
1282
        c.weighty = 1;
1283
        c.gridx = 0;
1284
        c.fill = GridBagConstraints.BOTH;
1285
        this.tableTarifQteVente.setOpaque(false);
1286
        panel.add(new RowValuesTableEditionPanel(this.tableTarifQteVente), c);
1287
        return panel;
1288
    }
1289
 
18 ilm 1290
    protected void getMontantPanel(final GridBagConstraints c, DefaultProps props) {
80 ilm 1291
        c.gridx = 0;
1292
        c.gridy++;
1293
        c.gridwidth = 1;
19 ilm 1294
        // PA devise
67 ilm 1295
        JPanel pDevise = new JPanel(new GridBagLayout());
1296
        GridBagConstraints cDevise = new DefaultGridBagConstraints();
80 ilm 1297
        cDevise.insets = new Insets(0, 0, 0, 4);
1298
        c.weightx = 0;
1299
        c.fill = GridBagConstraints.HORIZONTAL;
1300
        this.add(new JLabel("Devise du fournisseur"), c);
67 ilm 1301
        final ElementComboBox boxDevise = new ElementComboBox(true, 15);
1302
        cDevise.gridx++;
1303
        cDevise.weightx = 1;
1304
        pDevise.add(boxDevise, cDevise);
19 ilm 1305
        this.addView(boxDevise, "ID_DEVISE_HA");
67 ilm 1306
        DefaultGridBagConstraints.lockMinimumSize(boxDevise);
19 ilm 1307
 
67 ilm 1308
        cDevise.weightx = 0;
1309
        cDevise.gridx++;
1310
        pDevise.add(new JLabel("Prix d'achat devise"), cDevise);
1311
        final JTextField fieldHAD = new JTextField(15);
1312
        cDevise.weightx = 1;
1313
        cDevise.gridx++;
1314
        pDevise.add(fieldHAD, cDevise);
19 ilm 1315
        this.addView(fieldHAD, "PA_DEVISE");
67 ilm 1316
        DefaultGridBagConstraints.lockMinimumSize(fieldHAD);
1317
 
80 ilm 1318
        c.gridx++;
19 ilm 1319
        c.gridwidth = GridBagConstraints.REMAINDER;
1320
        c.anchor = GridBagConstraints.WEST;
1321
        c.weightx = 1;
1322
        c.fill = GridBagConstraints.NONE;
1323
        this.add(pDevise, c);
1324
        fieldHAD.getDocument().addDocumentListener(new SimpleDocumentListener() {
1325
 
1326
            @Override
1327
            public void update(DocumentEvent e) {
1328
 
83 ilm 1329
                if (!isFilling() && boxDevise != null && boxDevise.getSelectedRow() != null && !boxDevise.getSelectedRow().isUndefined()) {
1330
                    BigDecimal ha = StringUtils.getBigDecimalFromUserText(fieldHAD.getText());
1331
                    if (ha == null) {
1332
                        ha = BigDecimal.ZERO;
19 ilm 1333
                    }
93 ilm 1334
                    CurrencyConverter c = new CurrencyConverter();
132 ilm 1335
                    String devCode = boxDevise.getSelectedRow().getString("CODE");
93 ilm 1336
                    textPAHT.setText(c.convert(ha, devCode, c.getCompanyCurrencyCode(), new Date(), true).setScale(getTable().getField("PA_DEVISE").getType().getDecimalDigits(), RoundingMode.HALF_UP)
1337
                            .toString());
67 ilm 1338
 
19 ilm 1339
                }
1340
            }
1341
        });
1342
 
18 ilm 1343
        // PA
67 ilm 1344
        JPanel p = new JPanel(new GridBagLayout());
1345
        GridBagConstraints cAchat = new DefaultGridBagConstraints();
80 ilm 1346
        cAchat.insets = new Insets(0, 0, 0, 4);
1347
        c.gridx = 0;
1348
        c.gridy++;
1349
        c.weightx = 0;
1350
        c.gridwidth = 1;
1351
        c.fill = GridBagConstraints.HORIZONTAL;
1352
        this.add(new JLabel(getLabelFor("PA_HT"), SwingConstants.RIGHT), c);
67 ilm 1353
        cAchat.gridx++;
1354
        cAchat.weightx = 1;
1355
        p.add(this.textPAHT, cAchat);
18 ilm 1356
        this.textPAHT.getDocument().addDocumentListener(this.listenerMargeTextHA);
1357
 
1358
        // Marge
67 ilm 1359
        cAchat.gridx++;
1360
        cAchat.weightx = 0;
1361
        p.add(new JLabel("Marge"), cAchat);
1362
        cAchat.weightx = 1;
1363
        cAchat.gridx++;
1364
        p.add(this.textMarge, cAchat);
18 ilm 1365
        this.textMarge.getDocument().addDocumentListener(this.listenerMargeTextMarge);
67 ilm 1366
        cAchat.gridx++;
1367
        cAchat.weightx = 0;
156 ilm 1368
        p.add(this.labelMarge, cAchat);
18 ilm 1369
 
1370
        // Poids
1371
        JLabel labelPds = new JLabel(getLabelFor("POIDS"));
67 ilm 1372
        cAchat.gridx++;
1373
        cAchat.weightx = 0;
1374
        p.add(labelPds, cAchat);
18 ilm 1375
        labelPds.setHorizontalAlignment(SwingConstants.RIGHT);
67 ilm 1376
        cAchat.weightx = 1;
1377
        cAchat.gridx++;
1378
        p.add(this.textPoids, cAchat);
1379
        DefaultGridBagConstraints.lockMinimumSize(this.textPoids);
18 ilm 1380
 
1381
        // Service
1382
        String sService = props.getStringProperty("ArticleService");
1383
        Boolean bService = Boolean.valueOf(sService);
1384
        if (bService != null && bService.booleanValue()) {
67 ilm 1385
            cAchat.gridx++;
1386
            cAchat.weightx = 0;
1387
            p.add(this.boxService, cAchat);
18 ilm 1388
        }
1389
 
80 ilm 1390
        c.gridx++;
18 ilm 1391
        c.gridwidth = GridBagConstraints.REMAINDER;
1392
        c.anchor = GridBagConstraints.WEST;
1393
        c.weightx = 1;
1394
        c.fill = GridBagConstraints.NONE;
1395
 
1396
        this.add(p, c);
156 ilm 1397
        c.gridx = 0;
1398
        c.gridy++;
1399
        c.gridwidth = 1;
18 ilm 1400
 
156 ilm 1401
        if (getTable().contains("ID_COUT_REVIENT")) {
1402
            // Cout de revient
1403
            c.weightx = 0;
1404
            c.fill = GridBagConstraints.HORIZONTAL;
1405
            this.add(new JLabel(getLabelFor("ID_COUT_REVIENT"), SwingConstants.RIGHT), c);
1406
 
1407
            JPanel pCR = new JPanel(new GridBagLayout());
1408
            GridBagConstraints cCR = new DefaultGridBagConstraints();
1409
            cCR.insets = new Insets(0, 0, 0, 4);
1410
            this.boxCR = new ElementComboBox(true, 15);
1411
 
1412
            pCR.add(boxCR, cCR);
1413
            this.addView(boxCR, "ID_COUT_REVIENT");
1414
            DefaultGridBagConstraints.lockMinimumSize(boxCR);
1415
            boxCR.addModelListener("wantedID", new PropertyChangeListener() {
1416
 
1417
                @Override
1418
                public void propertyChange(PropertyChangeEvent evt) {
1419
                    if (!isFilling()) {
1420
                        ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
1421
                        updateVtFromMarge();
1422
                        ReferenceArticleSQLComponent.this.textPVHT.getDocument().addDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
1423
                    }
1424
                }
1425
            });
1426
            cCR.gridx++;
1427
            this.boxMargeWithCR = new JCheckBox(getLabelFor("MARGE_WITH_COUT_REVIENT"));
1428
            pCR.add(boxMargeWithCR, cCR);
1429
            addView(boxMargeWithCR, "MARGE_WITH_COUT_REVIENT");
1430
            boxMargeWithCR.addActionListener(new ActionListener() {
1431
 
1432
                @Override
1433
                public void actionPerformed(ActionEvent e) {
1434
                    if (!isFilling()) {
1435
                        ReferenceArticleSQLComponent.this.textPVHT.getDocument().removeDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
1436
                        updateVtFromMarge();
1437
                        ReferenceArticleSQLComponent.this.textPVHT.getDocument().addDocumentListener(ReferenceArticleSQLComponent.this.listenerMargeTextVT);
1438
                    }
1439
                }
1440
            });
1441
            c.gridx++;
1442
            c.gridwidth = GridBagConstraints.REMAINDER;
1443
            c.anchor = GridBagConstraints.WEST;
1444
            c.weightx = 1;
1445
            c.fill = GridBagConstraints.NONE;
1446
            this.add(pCR, c);
1447
        }
1448
 
18 ilm 1449
        // PV HT
80 ilm 1450
        c.gridx = 0;
1451
        c.gridy++;
1452
 
67 ilm 1453
        JPanel p2 = new JPanel(new GridBagLayout());
1454
        GridBagConstraints cVT = new DefaultGridBagConstraints();
80 ilm 1455
        cVT.insets = new Insets(0, 0, 0, 4);
1456
 
1457
        c.weightx = 0;
1458
        c.fill = GridBagConstraints.HORIZONTAL;
1459
        c.gridwidth = 1;
1460
        this.add(new JLabel(getLabelFor("PV_HT"), SwingConstants.RIGHT), c);
67 ilm 1461
        cVT.gridx++;
1462
        cVT.weightx = 1;
80 ilm 1463
 
67 ilm 1464
        p2.add(this.textPVHT, cVT);
18 ilm 1465
 
1466
        // Taxe
1467
        JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE"));
67 ilm 1468
        cVT.gridx++;
1469
        cVT.weightx = 0;
1470
        p2.add(labelTaxe, cVT);
18 ilm 1471
        labelTaxe.setHorizontalAlignment(SwingConstants.RIGHT);
67 ilm 1472
        cVT.gridx++;
1473
        // cVT.weightx = 1;
18 ilm 1474
 
67 ilm 1475
        p2.add(this.comboSelTaxe, cVT);
18 ilm 1476
 
1477
        // PV_TTC
67 ilm 1478
        cVT.gridx++;
1479
        cVT.weightx = 0;
1480
        p2.add(new JLabel(getLabelFor("PV_TTC")), cVT);
1481
        cVT.gridx++;
1482
        cVT.weightx = 1;
1483
        p2.add(this.textPVTTC, cVT);
80 ilm 1484
        c.gridx = 1;
1485
 
18 ilm 1486
        c.gridwidth = GridBagConstraints.REMAINDER;
1487
        c.anchor = GridBagConstraints.WEST;
1488
        c.weightx = 1;
1489
        c.fill = GridBagConstraints.NONE;
1490
        this.add(p2, c);
1491
 
1492
        this.addRequiredSQLObject(this.textPAHT, "PA_HT");
1493
        this.addRequiredSQLObject(this.textPVHT, "PV_HT");
67 ilm 1494
        DefaultGridBagConstraints.lockMinimumSize(this.textPVHT);
18 ilm 1495
        this.addRequiredSQLObject(this.comboSelTaxe, "ID_TAXE");
67 ilm 1496
        DefaultGridBagConstraints.lockMinimumSize(this.comboSelTaxe);
80 ilm 1497
        DefaultGridBagConstraints.lockMaximumSize(this.comboSelTaxe);
18 ilm 1498
        this.addRequiredSQLObject(this.textPVTTC, "PV_TTC");
67 ilm 1499
        DefaultGridBagConstraints.lockMinimumSize(this.textPVTTC);
1500
        DefaultGridBagConstraints.lockMinimumSize(this.textPAHT);
1501
        DefaultGridBagConstraints.lockMinimumSize(this.textMarge);
18 ilm 1502
        this.ttcDocListener = new DocumentListener() {
1503
            public void changedUpdate(DocumentEvent e) {
1504
                setTextHT();
1505
            }
1506
 
1507
            public void insertUpdate(DocumentEvent e) {
1508
                setTextHT();
1509
            }
1510
 
1511
            public void removeUpdate(DocumentEvent e) {
1512
                setTextHT();
1513
            }
1514
        };
1515
 
1516
        this.htDocListener = new DocumentListener() {
1517
            public void changedUpdate(DocumentEvent e) {
1518
                setTextTTC();
1519
            }
1520
 
1521
            public void insertUpdate(DocumentEvent e) {
1522
                setTextTTC();
1523
            }
1524
 
1525
            public void removeUpdate(DocumentEvent e) {
1526
                setTextTTC();
1527
            }
1528
 
1529
        };
1530
 
1531
        this.detailsListener = new SimpleDocumentListener() {
1532
 
1533
            @Override
1534
            public void update(DocumentEvent e) {
1535
                updatePiece();
1536
            }
1537
 
1538
        };
1539
 
1540
        this.taxeListener = new PropertyChangeListener() {
1541
 
1542
            public void propertyChange(PropertyChangeEvent evt) {
156 ilm 1543
                if (!isFilling()) {
1544
                    if (ReferenceArticleSQLComponent.this.textPVHT.getText().trim().length() > 0) {
1545
                        setTextTTC();
1546
                    } else {
1547
                        setTextHT();
1548
                    }
18 ilm 1549
                }
19 ilm 1550
                tableTarifVente.fireModification();
18 ilm 1551
            }
1552
        };
1553
        this.textPVHT.getDocument().addDocumentListener(this.htDocListener);
1554
        this.textPVTTC.getDocument().addDocumentListener(this.ttcDocListener);
1555
        this.comboSelTaxe.addValueListener(this.taxeListener);
1556
 
1557
        this.textMetrique1HA.getDocument().addDocumentListener(this.detailsListener);
1558
        this.textMetrique1VT.getDocument().addDocumentListener(this.detailsListener);
1559
 
1560
        this.textValMetrique1.getDocument().addDocumentListener(this.detailsListener);
1561
        this.textValMetrique2.getDocument().addDocumentListener(this.detailsListener);
1562
        this.textValMetrique3.getDocument().addDocumentListener(this.detailsListener);
1563
 
1564
    }
1565
 
180 ilm 1566
    protected void setListenerModeVenteActive(boolean b) {
18 ilm 1567
        if (b) {
1568
            this.comboSelModeVente.addValueListener(this.propertyChangeListener);
1569
        } else {
1570
            this.comboSelModeVente.removePropertyChangeListener(this.propertyChangeListener);
1571
        }
1572
    }
1573
 
1574
    /**
1575
     * @param c
1576
     * @param props
1577
     */
180 ilm 1578
    protected void addModeVenteAvance(GridBagConstraints c) {
18 ilm 1579
        DefaultProps props = DefaultNXProps.getInstance();
1580
        JSeparator sep = new JSeparator();
65 ilm 1581
        JLabel labelDetails = new JLabel("Article détaillé", SwingConstants.RIGHT);
18 ilm 1582
        c.gridx = 0;
1583
        c.gridy++;
1584
        c.weightx = 0;
1585
        this.add(labelDetails, c);
1586
        c.gridx++;
1587
        c.gridwidth = GridBagConstraints.REMAINDER;
1588
        c.fill = GridBagConstraints.HORIZONTAL;
1589
        c.weightx = 1;
1590
        this.add(sep, c);
1591
 
1592
        // Mode de vente
1593
        c.gridwidth = 1;
1594
        c.weightx = 0;
1595
        c.gridx = 0;
1596
        c.gridy++;
65 ilm 1597
        this.add(new JLabel(getLabelFor("ID_MODE_VENTE_ARTICLE"), SwingConstants.RIGHT), c);
1598
        c.weightx = 1;
18 ilm 1599
        c.gridx++;
1600
        this.add(this.comboSelModeVente, c);
1601
 
1602
        // Prix metrique
1603
        c.gridx = 0;
65 ilm 1604
        c.weightx = 0;
18 ilm 1605
        c.gridy++;
1606
        this.add(this.labelMetriqueHA1, c);
1607
        c.gridx++;
1608
        c.weightx = 1;
1609
        this.add(this.textMetrique1HA, c);
1610
 
1611
        c.gridx++;
1612
        c.weightx = 0;
1613
        this.add(this.labelMetriqueVT1, c);
1614
        c.gridx++;
1615
        c.weightx = 1;
1616
        this.add(this.textMetrique1VT, c);
1617
 
1618
        // Metrique 1
1619
        c.weightx = 0;
65 ilm 1620
        JLabel labelMetrique1 = new JLabel(getLabelFor("VALEUR_METRIQUE_1"), SwingConstants.RIGHT);
18 ilm 1621
        c.gridx = 0;
1622
        c.gridy++;
1623
        this.add(labelMetrique1, c);
1624
        c.gridx++;
1625
        c.weightx = 1;
1626
        this.add(this.textValMetrique1, c);
1627
        c.gridx++;
1628
        c.weightx = 0;
1629
 
1630
        Boolean bMetrique1 = Boolean.valueOf(props.getStringProperty("ArticleLongueur"));
1631
        labelMetrique1.setVisible(bMetrique1 == null || bMetrique1.booleanValue());
1632
        this.textValMetrique1.setVisible(bMetrique1 == null || bMetrique1.booleanValue());
1633
 
1634
        // Metrique 2
65 ilm 1635
        JLabel labelMetrique2 = new JLabel(getLabelFor("VALEUR_METRIQUE_2"), SwingConstants.RIGHT);
18 ilm 1636
        c.gridx = 0;
1637
        c.gridy++;
1638
        c.weightx = 0;
1639
        this.add(labelMetrique2, c);
1640
        c.gridx++;
1641
        c.weightx = 1;
1642
        this.add(this.textValMetrique2, c);
1643
        c.gridx++;
1644
        c.weightx = 0;
1645
 
1646
        Boolean bMetrique2 = Boolean.valueOf(props.getStringProperty("ArticleLargeur"));
1647
        labelMetrique2.setVisible(bMetrique2 == null || bMetrique2.booleanValue());
1648
        this.textValMetrique2.setVisible(bMetrique2 == null || bMetrique2.booleanValue());
1649
 
1650
        // Metrique 3
65 ilm 1651
        JLabel labelMetrique3 = new JLabel(getLabelFor("VALEUR_METRIQUE_3"), SwingConstants.RIGHT);
18 ilm 1652
        c.gridx = 0;
1653
        c.gridy++;
1654
        c.weightx = 0;
1655
        this.add(labelMetrique3, c);
1656
        c.gridx++;
1657
        c.weightx = 1;
1658
        this.add(this.textValMetrique3, c);
1659
        c.gridx++;
1660
 
1661
        Boolean bMetrique3 = Boolean.valueOf(props.getStringProperty("ArticlePoids"));
1662
        labelMetrique3.setVisible(bMetrique3 == null || bMetrique3.booleanValue());
1663
        this.textValMetrique3.setVisible(bMetrique3 == null || bMetrique3.booleanValue());
1664
 
1665
        // Article détaillé
1666
        JSeparator sep2 = new JSeparator();
65 ilm 1667
        JLabel labelPiece = new JLabel("Article pièce", SwingConstants.RIGHT);
18 ilm 1668
        c.gridx = 0;
1669
        c.gridy++;
1670
        c.weightx = 0;
1671
        this.add(labelPiece, c);
1672
        c.gridx++;
1673
        c.gridwidth = GridBagConstraints.REMAINDER;
1674
        c.fill = GridBagConstraints.HORIZONTAL;
1675
        c.weightx = 1;
1676
        this.add(sep2, c);
1677
 
1678
    }
1679
 
19 ilm 1680
    @Override
1681
    public void update() {
156 ilm 1682
        SQLRow row = this.getTable().getRow(this.getSelectedID());
177 ilm 1683
        final int selectedID = getSelectedID();
19 ilm 1684
            super.update();
177 ilm 1685
        this.tableTarifVente.updateField("ID_ARTICLE", selectedID);
1686
        this.tableCatComptable.updateField("ID_ARTICLE", selectedID);
1687
        this.tableFourSec.updateField("ID_ARTICLE", selectedID);
1688
        this.tableTarifQteVente.updateField("ID_ARTICLE", selectedID);
94 ilm 1689
        if (this.tableBom != null) {
177 ilm 1690
            this.tableBom.updateField("ID_ARTICLE_PARENT", selectedID);
94 ilm 1691
        }
1692
 
177 ilm 1693
        this.tableDes.updateField("ID_ARTICLE", selectedID);
1694
        this.tableCodeClient.updateField("ID_ARTICLE", selectedID);
67 ilm 1695
        if (this.codeFournisseurTable != null) {
177 ilm 1696
            this.codeFournisseurTable.updateField("ID_ARTICLE", selectedID);
67 ilm 1697
        }
156 ilm 1698
 
177 ilm 1699
        ((ReferenceArticleSQLElement) getElement()).initStock(selectedID);
156 ilm 1700
 
1701
        SQLSelect sel = new SQLSelect();
1702
        SQLTable tableStock = getTable().getTable("STOCK");
1703
        sel.addSelect(tableStock.getKey());
177 ilm 1704
        Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", selectedID).and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", row.getForeignID("ID_DEPOT_STOCK")));
156 ilm 1705
        sel.setWhere(w);
1706
 
1707
        List<SQLRow> stock = SQLRowListRSH.execute(sel);
1708
        if (stock != null && stock.size() == 1) {
1709
            try {
1710
                row.createEmptyUpdateRow().put("ID_STOCK", stock.get(0).getID()).update();
1711
            } catch (SQLException e) {
1712
                ExceptionHandler.handle("Erreur lors de la mise à jour du stock principal", e);
1713
            }
1714
        }
1715
 
177 ilm 1716
        Runnable r = new Runnable() {
1717
            @Override
1718
            public void run() {
1719
                SQLRow rowArticle = getTable().getRow(selectedID);
1720
                List<SQLRow> itemsRows = rowArticle.getReferentRows(getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE"));
1721
                for (SQLRow rowArticleItem : itemsRows) {
1722
                    SQLRow rowA = rowArticleItem.getForeign("ID_ARTICLE_PARENT");
1723
 
1724
                    if (rowA != null && !rowA.isUndefined()) {
1725
                        final Boolean vtAuto = rowA.getBoolean("AUTO_PRIX_MIN_VENTE_NOMENCLATURE");
1726
                        final Boolean haAuto = rowA.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE");
1727
                        if (vtAuto || haAuto) {
1728
                            ProductHelper helper = new ProductHelper(rowA.getTable().getDBRoot());
1729
                            Tuple2<BigDecimal, BigDecimal> p = helper.getStandardBomPrices(rowA.getReferentRows(rowA.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")));
1730
                            SQLRowValues rowVals = rowA.createEmptyUpdateRow();
1731
                            boolean up = false;
1732
                            if (vtAuto && p.get1() != null) {
1733
                                rowVals.put("PRIX_METRIQUE_VT_1", p.get1());
1734
                                rowVals.put("PV_HT", p.get1());
1735
                                float t = TaxeCache.getCache().getFirstTaxe().getFloat("TAUX");
1736
                                if (!rowA.isForeignEmpty("ID_TAXE")) {
1737
                                    t = TaxeCache.getCache().getTauxFromId(rowA.getForeignID("ID_TAXE"));
1738
                                }
1739
 
1740
                                rowVals.put("PV_TTC", p.get1().multiply(new BigDecimal(t).movePointLeft(2).add(BigDecimal.ONE)).setScale(2, RoundingMode.HALF_UP));
1741
                                up = true;
1742
                            }
1743
                            if (haAuto && p.get0() != null) {
1744
                                rowVals.put("PRIX_METRIQUE_HA_1", p.get0());
1745
                                rowVals.put("PA_HT", p.get0());
1746
                                up = true;
1747
                            }
1748
                            if (up) {
1749
                                try {
1750
                                    rowVals.commit();
1751
                                } catch (SQLException e) {
1752
                                    ExceptionHandler.handle("Erreur lors de la mise à jour des tarifs des nomenclatures", e);
1753
                                }
1754
                            }
1755
                        }
1756
                    }
1757
                }
1758
 
1759
            }
1760
        };
1761
        new Thread(r).run();
1762
        ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(selectedID));
1763
 
19 ilm 1764
    }
18 ilm 1765
 
1766
    /**
1767
     * Sélection d'un mode de vente pour l'article. Affiche les prix metriques requis et fixe les
1768
     * valeurs.
1769
     *
1770
     * @param id id du mode de vente
1771
     */
180 ilm 1772
    protected void selectModeVente(int id) {
18 ilm 1773
 
1774
        this.labelMetriqueHA1.setEnabled(true);
1775
        this.labelMetriqueVT1.setEnabled(true);
1776
        this.textMetrique1HA.setEnabled(true);
1777
        this.textMetrique1VT.setEnabled(true);
1778
 
1779
        this.textPAHT.getDocument().removeDocumentListener(this.pieceHAArticle);
1780
        this.textPVHT.getDocument().removeDocumentListener(this.pieceVTArticle);
1781
 
1782
        switch (id) {
1783
        case ReferenceArticleSQLElement.AU_METRE_CARRE:
1784
            this.labelMetriqueHA1.setText("Prix d'achat HT au mètre carré");
1785
            this.labelMetriqueVT1.setText("Prix de vente HT au mètre carré");
1786
            break;
1787
        case ReferenceArticleSQLElement.AU_METRE_LARGEUR:
1788
        case ReferenceArticleSQLElement.AU_METRE_LONGUEUR:
1789
            this.labelMetriqueHA1.setText("Prix d'achat HT au mètre");
1790
            this.labelMetriqueVT1.setText("Prix de vente HT au mètre");
1791
            break;
1792
 
1793
        case ReferenceArticleSQLElement.AU_POID_METRECARRE:
1794
            this.labelMetriqueHA1.setText("Prix d'achat HT au kilo");
1795
            this.labelMetriqueVT1.setText("Prix de vente HT au kilo");
1796
            break;
1797
        case -1:
73 ilm 1798
            // No break need to enable the listener
18 ilm 1799
        default:
1800
            this.labelMetriqueHA1.setEnabled(false);
1801
            this.labelMetriqueVT1.setEnabled(false);
1802
            this.textMetrique1HA.setEnabled(false);
1803
            this.textMetrique1VT.setEnabled(false);
1804
 
67 ilm 1805
            this.textMetrique1HA.setText(this.textPAHT.getText().trim());
1806
            this.textMetrique1VT.setText(this.textPVHT.getText().trim());
18 ilm 1807
            this.textPAHT.getDocument().addDocumentListener(this.pieceHAArticle);
1808
            this.textPVHT.getDocument().addDocumentListener(this.pieceVTArticle);
1809
            break;
1810
        }
19 ilm 1811
        this.tableTarifVente.fireModification();
1812
    }
18 ilm 1813
 
19 ilm 1814
    @Override
1815
    public int insert(SQLRow order) {
1816
        int id = super.insert(order);
1817
        this.tableTarifVente.updateField("ID_ARTICLE", id);
156 ilm 1818
        this.tableCatComptable.updateField("ID_ARTICLE", id);
1819
        this.tableFourSec.updateField("ID_ARTICLE", id);
94 ilm 1820
        this.tableTarifQteVente.updateField("ID_ARTICLE", id);
1821
        if (this.tableBom != null) {
1822
            this.tableBom.updateField("ID_ARTICLE_PARENT", id);
1823
        }
19 ilm 1824
        this.tableDes.updateField("ID_ARTICLE", id);
144 ilm 1825
        this.tableCodeClient.updateField("ID_ARTICLE", id);
67 ilm 1826
        if (this.codeFournisseurTable != null) {
1827
            this.codeFournisseurTable.updateField("ID_ARTICLE", id);
1828
        }
156 ilm 1829
        ((ReferenceArticleSQLElement) getElement()).initStock(id);
177 ilm 1830
        ReferenceArticleSQLElement.updateDateAchat(getTable(), getTable().getRow(id));
19 ilm 1831
        return id;
18 ilm 1832
    }
1833
 
1834
    @Override
1835
    protected SQLRowValues createDefaults() {
1836
        SQLRowValues rowVals = new SQLRowValues(getTable());
1837
 
94 ilm 1838
        rowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
156 ilm 1839
        rowVals.put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
61 ilm 1840
        rowVals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
156 ilm 1841
        rowVals.put("QTE_UNITAIRE", BigDecimal.ONE);
18 ilm 1842
        rowVals.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE);
1843
        selectModeVente(ReferenceArticleSQLElement.A_LA_PIECE);
1844
        rowVals.put("VALEUR_METRIQUE_1", Float.valueOf("1.0"));
67 ilm 1845
        rowVals.put("PA_HT", BigDecimal.ZERO);
156 ilm 1846
        rowVals.put("QTE_UNITAIRE", BigDecimal.ONE);
18 ilm 1847
        rowVals.put("POIDS", Float.valueOf(0));
156 ilm 1848
        rowVals.put("GESTION_STOCK", Boolean.TRUE);
19 ilm 1849
 
18 ilm 1850
        return rowVals;
1851
    }
1852
 
180 ilm 1853
    protected void setTextHT() {
149 ilm 1854
        if (!isFilling()) {
1855
            this.textPVHT.getDocument().removeDocumentListener(this.htDocListener);
1856
            final BigDecimal ttc = StringUtils.getBigDecimalFromUserText(this.textPVTTC.getText());
1857
            if (ttc != null) {
1858
                int id = this.comboSelTaxe.getSelectedId();
1859
                if (id > 1) {
1860
                    Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
1861
                    float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
1862
                    this.textPVHT.setText(ttc.divide(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
1863
                            .setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
1864
                }
67 ilm 1865
            }
149 ilm 1866
            this.textPVHT.getDocument().addDocumentListener(this.htDocListener);
18 ilm 1867
        }
1868
    }
1869
 
180 ilm 1870
    protected void setTextTTC() {
149 ilm 1871
        if (!isFilling()) {
1872
            this.textPVTTC.getDocument().removeDocumentListener(this.ttcDocListener);
1873
            final BigDecimal ht = StringUtils.getBigDecimalFromUserText(this.textPVHT.getText());
1874
            if (ht != null) {
1875
                int id = this.comboSelTaxe.getSelectedId();
1876
                if (id > 1) {
1877
                    final Float resultTaux = TaxeCache.getCache().getTauxFromId(id);
1878
                    final float taux = (resultTaux == null) ? 0.0F : resultTaux.floatValue() / 100.0F;
1879
                    this.textPVTTC.setText(ht.multiply(BigDecimal.valueOf(taux).add(BigDecimal.ONE), DecimalUtils.HIGH_PRECISION)
1880
                            .setScale(getTable().getField("PV_TTC").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
1881
                }
67 ilm 1882
            }
149 ilm 1883
            this.textPVTTC.getDocument().addDocumentListener(this.ttcDocListener);
18 ilm 1884
        }
1885
    }
1886
 
1887
    /**
1888
     * calcul du prix achat et vente ainsi que le poids total pour la piece
1889
     */
180 ilm 1890
    protected void updatePiece() {
18 ilm 1891
        if (this.comboSelModeVente.getSelectedId() > 1 && this.comboSelModeVente.getSelectedId() != ReferenceArticleSQLElement.A_LA_PIECE) {
1892
            SQLRowValues rowVals = getDetailsRowValues();
1893
            float poidsTot = ReferenceArticleSQLElement.getPoidsFromDetails(rowVals);
1894
            this.textPoids.setText(String.valueOf(poidsTot));
67 ilm 1895
            this.textPAHT.setText(ReferenceArticleSQLElement.getPrixHAFromDetails(rowVals).setScale(getTable().getField("PA_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
1896
            this.textPVHT.setText(ReferenceArticleSQLElement.getPrixVTFromDetails(rowVals).setScale(getTable().getField("PV_HT").getType().getDecimalDigits(), RoundingMode.HALF_UP).toString());
19 ilm 1897
            this.tableTarifVente.fireModification();
18 ilm 1898
        }
1899
    }
1900
 
19 ilm 1901
    public int getSelectedTaxe() {
1902
        return this.comboSelTaxe.getSelectedId();
1903
    }
1904
 
1905
    public SQLRowValues getDetailsRowValues() {
73 ilm 1906
        final SQLRowValues rowVals = new SQLRowValues(getTable());
18 ilm 1907
 
83 ilm 1908
        BigDecimal pAchat = StringUtils.getBigDecimalFromUserText(this.textMetrique1HA.getText());
1909
        if (pAchat == null) {
1910
            pAchat = BigDecimal.ZERO;
1911
        }
1912
        rowVals.put("PRIX_METRIQUE_HA_1", pAchat);
67 ilm 1913
 
83 ilm 1914
        BigDecimal pVente = StringUtils.getBigDecimalFromUserText(this.textMetrique1VT.getText());
1915
        if (pVente == null) {
1916
            pVente = BigDecimal.ZERO;
1917
        }
1918
        rowVals.put("PRIX_METRIQUE_VT_1", pVente);
18 ilm 1919
        put(rowVals, this.textValMetrique1);
1920
        put(rowVals, this.textValMetrique2);
1921
        put(rowVals, this.textValMetrique3);
1922
        rowVals.put("ID_MODE_VENTE_ARTICLE", this.comboSelModeVente.getSelectedId());
1923
 
1924
        return rowVals;
1925
    }
1926
 
180 ilm 1927
    protected void put(SQLRowValues rowVals, JTextField comp) {
18 ilm 1928
        Float f = (comp.getText() == null || comp.getText().trim().length() == 0) ? 0.0F : Float.valueOf(comp.getText());
1929
        rowVals.put(this.getView(comp).getField().getName(), f);
1930
    }
1931
 
1932
}