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 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
Line 14... Line 14...
14
 package org.openconcerto.erp.core.supplychain.order.component;
14
 package org.openconcerto.erp.core.supplychain.order.component;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
17
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
18
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
-
 
19
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
19
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
20
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
20
import org.openconcerto.erp.core.common.ui.DeviseField;
21
import org.openconcerto.erp.core.common.ui.DeviseField;
21
import org.openconcerto.erp.core.common.ui.TotalPanel;
22
import org.openconcerto.erp.core.common.ui.TotalPanel;
22
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
23
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
23
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
24
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
Line 27... Line 28...
27
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
28
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
28
import org.openconcerto.erp.generationEcritures.GenerationMvtFactureFournisseur;
29
import org.openconcerto.erp.generationEcritures.GenerationMvtFactureFournisseur;
29
import org.openconcerto.erp.panel.PanelOOSQLComponent;
30
import org.openconcerto.erp.panel.PanelOOSQLComponent;
30
import org.openconcerto.erp.preferences.DefaultNXProps;
31
import org.openconcerto.erp.preferences.DefaultNXProps;
31
import org.openconcerto.sql.Configuration;
32
import org.openconcerto.sql.Configuration;
32
import org.openconcerto.sql.element.DefaultElementSQLObject;
-
 
33
import org.openconcerto.sql.element.ElementSQLObject;
33
import org.openconcerto.sql.element.ElementSQLObject;
34
import org.openconcerto.sql.element.SQLElement;
34
import org.openconcerto.sql.element.SQLElement;
35
import org.openconcerto.sql.model.SQLBackgroundTableCache;
35
import org.openconcerto.sql.model.SQLBackgroundTableCache;
36
import org.openconcerto.sql.model.SQLRow;
36
import org.openconcerto.sql.model.SQLRow;
37
import org.openconcerto.sql.model.SQLRowAccessor;
37
import org.openconcerto.sql.model.SQLRowAccessor;
Line 39... Line 39...
39
import org.openconcerto.sql.model.SQLTable;
39
import org.openconcerto.sql.model.SQLTable;
40
import org.openconcerto.sql.model.Where;
40
import org.openconcerto.sql.model.Where;
41
import org.openconcerto.sql.preferences.SQLPreferences;
41
import org.openconcerto.sql.preferences.SQLPreferences;
42
import org.openconcerto.sql.request.ComboSQLRequest;
42
import org.openconcerto.sql.request.ComboSQLRequest;
43
import org.openconcerto.sql.sqlobject.ElementComboBox;
43
import org.openconcerto.sql.sqlobject.ElementComboBox;
-
 
44
import org.openconcerto.sql.sqlobject.JUniqueTextField;
-
 
45
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
44
import org.openconcerto.sql.users.UserManager;
46
import org.openconcerto.sql.users.UserManager;
45
import org.openconcerto.sql.view.list.RowValuesTable;
47
import org.openconcerto.sql.view.list.RowValuesTable;
-
 
48
import org.openconcerto.sql.view.list.RowValuesTableModel;
46
import org.openconcerto.ui.AutoHideListener;
49
import org.openconcerto.ui.AutoHideListener;
47
import org.openconcerto.ui.DefaultGridBagConstraints;
50
import org.openconcerto.ui.DefaultGridBagConstraints;
48
import org.openconcerto.ui.FormLayouter;
51
import org.openconcerto.ui.FormLayouter;
49
import org.openconcerto.ui.JDate;
52
import org.openconcerto.ui.JDate;
50
import org.openconcerto.ui.TitledSeparator;
-
 
51
import org.openconcerto.ui.component.ITextArea;
53
import org.openconcerto.ui.component.ITextArea;
52
import org.openconcerto.ui.preferences.DefaultProps;
54
import org.openconcerto.ui.preferences.DefaultProps;
53
import org.openconcerto.utils.ExceptionHandler;
55
import org.openconcerto.utils.ExceptionHandler;
-
 
56
import org.openconcerto.utils.checks.ValidState;
54
import org.openconcerto.utils.text.SimpleDocumentListener;
57
import org.openconcerto.utils.text.SimpleDocumentListener;
55
 
58
 
56
import java.awt.Color;
59
import java.awt.Color;
57
import java.awt.GridBagConstraints;
60
import java.awt.GridBagConstraints;
58
import java.awt.GridBagLayout;
61
import java.awt.GridBagLayout;
59
import java.beans.PropertyChangeEvent;
62
import java.beans.PropertyChangeEvent;
60
import java.beans.PropertyChangeListener;
63
import java.beans.PropertyChangeListener;
61
import java.math.BigDecimal;
64
import java.math.BigDecimal;
62
import java.sql.SQLException;
65
import java.sql.SQLException;
-
 
66
import java.util.Arrays;
-
 
67
import java.util.Date;
63
import java.util.HashSet;
68
import java.util.HashSet;
64
import java.util.List;
69
import java.util.List;
65
import java.util.Set;
70
import java.util.Set;
66
 
71
 
67
import javax.swing.JLabel;
72
import javax.swing.JLabel;
68
import javax.swing.JOptionPane;
73
import javax.swing.JOptionPane;
69
import javax.swing.JPanel;
74
import javax.swing.JPanel;
70
import javax.swing.JScrollPane;
75
import javax.swing.JScrollPane;
-
 
76
import javax.swing.JTabbedPane;
71
import javax.swing.JTextField;
77
import javax.swing.JTextField;
72
import javax.swing.SwingConstants;
78
import javax.swing.SwingConstants;
73
import javax.swing.SwingUtilities;
79
import javax.swing.SwingUtilities;
74
import javax.swing.event.DocumentEvent;
80
import javax.swing.event.DocumentEvent;
75
import javax.swing.event.DocumentListener;
81
import javax.swing.event.DocumentListener;
Line 81... Line 87...
81
    private FactureFournisseurItemTable table = new FactureFournisseurItemTable();
87
    private FactureFournisseurItemTable table = new FactureFournisseurItemTable();
82
    private final ITextArea infos = new ITextArea(3, 3);
88
    private final ITextArea infos = new ITextArea(3, 3);
83
    private ElementComboBox fourn = new ElementComboBox();
89
    private ElementComboBox fourn = new ElementComboBox();
84
    private ElementComboBox comptePCE = new ElementComboBox();
90
    private ElementComboBox comptePCE = new ElementComboBox();
85
    private ElementComboBox avoirFourn = new ElementComboBox();
91
    private ElementComboBox avoirFourn = new ElementComboBox();
86
    private DefaultElementSQLObject compAdr;
92
    private ElementComboBox avoirFourn2 = new ElementComboBox();
-
 
93
 
87
    private PanelOOSQLComponent panelOO;
94
    private PanelOOSQLComponent panelOO;
88
    final JPanel panelAdrSpec = new JPanel(new GridBagLayout());
95
    final JPanel panelAdrSpec = new JPanel(new GridBagLayout());
89
    private JDate dateCommande = new JDate();
96
    private JDate dateCommande = new JDate();
90
    private final JTextField fieldTaux = new JTextField(15);
97
    private final JTextField fieldTaux = new JTextField(15);
91
    private final DeviseField textNetAPayer = new DeviseField(15);
98
    private final DeviseField textNetAPayer = new DeviseField(15);
Line 95... Line 102...
95
    DeviseField avoirTTC = new DeviseField();
102
    DeviseField avoirTTC = new DeviseField();
96
    private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
103
    private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
97
 
104
 
98
        public void propertyChange(PropertyChangeEvent evt) {
105
        public void propertyChange(PropertyChangeEvent evt) {
99
 
106
 
100
            SQLRow rowFourn = fourn.getRequest().getPrimaryTable().getRow(fourn.getWantedID());
107
            final SQLRow rowFourn = FactureFournisseurSQLComponent.this.fourn.getRequest().getPrimaryTable().getRow(FactureFournisseurSQLComponent.this.fourn.getWantedID());
101
 
-
 
102
            if (!isFilling() && rowFourn != null && !rowFourn.isUndefined()) {
108
            if ((getMode() == Mode.INSERTION || !isFilling()) && rowFourn != null && !rowFourn.isUndefined()) {
103
 
-
 
104
                // SQLRow rowCharge = rowFourn.getForeign("ID_COMPTE_PCE_CHARGE");
-
 
105
                // if (rowCharge != null && !rowCharge.isUndefined()) {
-
 
106
                // compteSel.setValue(rowCharge);
-
 
107
                // }
-
 
108
 
109
 
109
                int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
110
                int idModeRegl = rowFourn.getInt("ID_MODE_REGLEMENT");
110
                if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
111
                if (idModeRegl > 1 && FactureFournisseurSQLComponent.this.eltModeRegl != null && getMode() == Mode.INSERTION) {
111
                    SQLElement sqlEltModeRegl = getElement().getDirectory().getElement("MODE_REGLEMENT");
112
                    SQLElement sqlEltModeRegl = getElement().getDirectory().getElement("MODE_REGLEMENT");
112
                    SQLRow rowModeRegl = sqlEltModeRegl.getTable().getRow(idModeRegl);
113
                    SQLRow rowModeRegl = sqlEltModeRegl.getTable().getRow(idModeRegl);
113
                    SQLRowValues rowVals = rowModeRegl.createUpdateRow();
114
                    SQLRowValues rowVals = rowModeRegl.createUpdateRow();
114
                    rowVals.clearPrimaryKeys();
115
                    rowVals.clearPrimaryKeys();
115
                    FactureFournisseurSQLComponent.this.eltModeRegl.setValue(rowVals);
116
                    FactureFournisseurSQLComponent.this.eltModeRegl.setValue(rowVals);
116
                    System.err.println("Select Mode regl " + idModeRegl);
-
 
117
                }
117
                }
118
                // }
-
 
-
 
118
 
119
            }
119
            }
120
 
120
 
121
        }
121
        }
122
 
122
 
123
    };
123
    };
Line 137... Line 137...
137
            s.add("ID_TYPE_CMD");
137
            s.add("ID_TYPE_CMD");
138
        }
138
        }
139
        return s;
139
        return s;
140
    }
140
    }
141
 
141
 
-
 
142
    @Override
-
 
143
    public synchronized ValidState getValidState() {
-
 
144
        if (getTable().contains("ID_COMPTE_PCE") && getTable().contains("ID_TYPE_CMD") && getTable().getTable("FACTURE_FOURNISSEUR_ELEMENT").contains("ID_COMPTE_PCE")) {
-
 
145
            SQLRequestComboBox boxCpt = (SQLRequestComboBox) getView("ID_COMPTE_PCE").getComp();
-
 
146
            final SQLRow selectedCpt = boxCpt.getSelectedRow();
-
 
147
            if (selectedCpt == null || selectedCpt.isUndefined()) {
-
 
148
                RowValuesTableModel tableRow = this.table.getRowValuesTable().getRowValuesTableModel();
-
 
149
 
-
 
150
                for (int i = 0; i < tableRow.getRowCount(); i++) {
-
 
151
                    SQLRowValues rowVals = tableRow.getRowValuesAt(i);
-
 
152
                    if (rowVals.getInt("QTE") != 0 && (rowVals.getObject("ID_COMPTE_PCE") == null || rowVals.isForeignEmpty("ID_COMPTE_PCE"))) {
-
 
153
                        return ValidState.create(false, "Aucun compte global sélectionné et une ligne avec une quantité > 0 n'est pas affectée à un compte!");
-
 
154
                    }
-
 
155
                }
-
 
156
            }
-
 
157
 
-
 
158
        }
-
 
159
        return super.getValidState();
-
 
160
    }
-
 
161
 
-
 
162
    private JUniqueTextField numero;
-
 
163
 
142
    public void addViews() {
164
    public void addViews() {
143
        this.setLayout(new GridBagLayout());
165
        this.setLayout(new GridBagLayout());
144
        final GridBagConstraints c = new DefaultGridBagConstraints();
166
        final GridBagConstraints c = new DefaultGridBagConstraints();
145
 
167
 
-
 
168
        if (getTable().getTable("NUMEROTATION_AUTO").contains("FACTURE_FOURNISSEUR_START")) {
-
 
169
            this.numero = new JUniqueTextField(35) {
-
 
170
                @Override
-
 
171
                public String getAutoRefreshNumber() {
-
 
172
                    if (getMode() == Mode.INSERTION) {
-
 
173
                        final Date date = FactureFournisseurSQLComponent.this.dateCommande.getDate();
-
 
174
                        return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), date == null ? new Date() : date);
-
 
175
                    } else {
-
 
176
                        return null;
-
 
177
                    }
-
 
178
                }
-
 
179
            };
-
 
180
            this.dateCommande.addValueListener(new PropertyChangeListener() {
-
 
181
 
-
 
182
                @Override
-
 
183
                public void propertyChange(PropertyChangeEvent evt) {
-
 
184
                    if (!isFilling() && FactureFournisseurSQLComponent.this.dateCommande.getValue() != null) {
-
 
185
 
-
 
186
                        final String nextNumero = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), FactureFournisseurSQLComponent.this.dateCommande.getValue());
-
 
187
 
-
 
188
                        if (FactureFournisseurSQLComponent.this.numero.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(FactureFournisseurSQLComponent.this.numero.getText())) {
-
 
189
 
-
 
190
                            int answer = JOptionPane.showConfirmDialog(FactureFournisseurSQLComponent.this, "Voulez vous actualiser le numéro de la facture?", "Changement du numéro de facture",
-
 
191
                                    JOptionPane.YES_NO_OPTION);
-
 
192
                            if (answer == JOptionPane.NO_OPTION) {
-
 
193
                                return;
-
 
194
                            }
-
 
195
                        }
-
 
196
 
-
 
197
                        FactureFournisseurSQLComponent.this.numero.setText(nextNumero);
-
 
198
 
-
 
199
                    }
-
 
200
                }
-
 
201
            });
-
 
202
        } else {
-
 
203
            this.numero = new JUniqueTextField(35);
-
 
204
        }
146
        // Numero du commande
205
        // Numero du commande
147
        c.gridx = 0;
206
        c.gridx = 0;
148
        c.weightx = 0;
207
        c.weightx = 0;
149
        this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
208
        this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
150
 
209
 
151
        JTextField numero = new JTextField(25);
-
 
152
        c.gridx++;
210
        c.gridx++;
153
        c.weightx = 1;
211
        c.weightx = 1;
154
        c.fill = GridBagConstraints.NONE;
212
        c.fill = GridBagConstraints.NONE;
155
        DefaultGridBagConstraints.lockMinimumSize(numero);
213
        DefaultGridBagConstraints.lockMinimumSize(this.numero);
156
        this.add(numero, c);
214
        this.add(this.numero, c);
157
 
215
 
158
        // Date
216
        // Date
159
        JLabel labelDate = new JLabel(getLabelFor("DATE"));
217
        JLabel labelDate = new JLabel(getLabelFor("DATE"));
160
        labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
218
        labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
161
        c.gridx = 2;
219
        c.gridx = 2;
Line 163... Line 221...
163
        c.fill = GridBagConstraints.HORIZONTAL;
221
        c.fill = GridBagConstraints.HORIZONTAL;
164
        this.add(labelDate, c);
222
        this.add(labelDate, c);
165
 
223
 
166
        c.gridx++;
224
        c.gridx++;
167
        c.fill = GridBagConstraints.NONE;
225
        c.fill = GridBagConstraints.NONE;
168
        this.add(dateCommande, c);
226
        this.add(this.dateCommande, c);
169
 
227
 
170
        this.dateCommande.addValueListener(new PropertyChangeListener() {
228
        this.dateCommande.addValueListener(new PropertyChangeListener() {
171
 
229
 
172
            @Override
230
            @Override
173
            public void propertyChange(PropertyChangeEvent evt) {
231
            public void propertyChange(PropertyChangeEvent evt) {
174
                if (!isFilling() && dateCommande.getValue() != null) {
232
                if (!isFilling() && FactureFournisseurSQLComponent.this.dateCommande.getValue() != null) {
175
                    table.setDateDevise(dateCommande.getValue());
233
                    FactureFournisseurSQLComponent.this.table.setDateDevise(FactureFournisseurSQLComponent.this.dateCommande.getValue());
176
                    updateLabelTauxConversion();
234
                    updateLabelTauxConversion();
177
                }
235
                }
178
            }
236
            }
179
        });
237
        });
180
 
238
 
Line 191... Line 249...
191
        c.weighty = 0;
249
        c.weighty = 0;
192
        c.fill = GridBagConstraints.NONE;
250
        c.fill = GridBagConstraints.NONE;
193
        this.add(this.fourn, c);
251
        this.add(this.fourn, c);
194
        addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
252
        addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
195
 
253
 
196
        fourn.addModelListener("wantedID", new PropertyChangeListener() {
254
        this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
197
 
255
 
198
            @Override
256
            @Override
199
            public void propertyChange(PropertyChangeEvent evt) {
257
            public void propertyChange(PropertyChangeEvent evt) {
200
                int wantedID = fourn.getWantedID();
258
                int wantedID = FactureFournisseurSQLComponent.this.fourn.getWantedID();
201
                if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
259
                if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
202
 
260
 
203
                    final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID);
261
                    final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID);
204
 
262
 
205
                    if (rowF.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowF.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
263
                    if (rowF.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowF.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
206
                        table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE"));
264
                        FactureFournisseurSQLComponent.this.table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE"));
207
                    } else {
265
                    } else {
208
                        table.setRowCatComptable(null);
266
                        FactureFournisseurSQLComponent.this.table.setRowCatComptable(null);
209
                    }
267
                    }
210
 
268
 
211
                } else {
269
                } else {
212
                    table.setRowCatComptable(null);
270
                    FactureFournisseurSQLComponent.this.table.setRowCatComptable(null);
213
                }
271
                }
214
            }
272
            }
215
        });
273
        });
216
        this.fourn.addModelListener("wantedID", this.listenerModeReglDefaut);
274
        this.fourn.addModelListener("wantedID", this.listenerModeReglDefaut);
217
 
275
 
Line 248... Line 306...
248
 
306
 
249
            this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
307
            this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
250
 
308
 
251
                @Override
309
                @Override
252
                public void propertyChange(PropertyChangeEvent evt) {
310
                public void propertyChange(PropertyChangeEvent evt) {
253
                    table.setFournisseur(fourn.getSelectedRow());
311
                    FactureFournisseurSQLComponent.this.table.setFournisseur(FactureFournisseurSQLComponent.this.fourn.getSelectedRow());
254
                    SQLRow row = fourn.getSelectedRow();
312
                    SQLRow row = FactureFournisseurSQLComponent.this.fourn.getSelectedRow();
255
                    if (!isFilling()) {
313
                    if (!isFilling()) {
256
                        if (row != null && !row.isUndefined() && !row.isForeignEmpty("ID_DEVISE")) {
314
                        if (row != null && !row.isUndefined() && !row.isForeignEmpty("ID_DEVISE")) {
257
                            boxDevise.setValue(row.getForeignID("ID_DEVISE"));
315
                            boxDevise.setValue(row.getForeignID("ID_DEVISE"));
258
                        }
316
                        }
259
                    }
317
                    }
260
 
318
 
261
                    if (row != null && !row.isUndefined()) {
319
                    if (row != null && !row.isUndefined()) {
-
 
320
                        FactureFournisseurSQLComponent.this.avoirFourn.getRequest()
262
                        avoirFourn.getRequest().setWhere(new Where(avoirFourn.getRequest().getPrimaryTable().getField("ID_FOURNISSEUR"), "=", row.getID()));
321
                                .setWhere(new Where(FactureFournisseurSQLComponent.this.avoirFourn.getRequest().getPrimaryTable().getField("ID_FOURNISSEUR"), "=", row.getID()));
263
                    } else {
322
                    } else {
264
                        avoirFourn.getRequest().setWhere(null);
323
                        FactureFournisseurSQLComponent.this.avoirFourn.getRequest().setWhere(null);
265
                    }
324
                    }
266
                }
325
                }
267
            });
326
            });
268
 
327
 
269
            if (getTable().contains("TAUX_APPLIQUE")) {
328
            if (getTable().contains("TAUX_APPLIQUE")) {
Line 353... Line 412...
353
 
412
 
354
            boxDevise.addValueListener(new PropertyChangeListener() {
413
            boxDevise.addValueListener(new PropertyChangeListener() {
355
 
414
 
356
                @Override
415
                @Override
357
                public void propertyChange(PropertyChangeEvent evt) {
416
                public void propertyChange(PropertyChangeEvent evt) {
358
                    table.setDevise(boxDevise.getSelectedRow());
417
                    FactureFournisseurSQLComponent.this.table.setDevise(boxDevise.getSelectedRow());
359
                    updateLabelTauxConversion();
418
                    updateLabelTauxConversion();
360
 
419
 
361
                }
420
                }
362
            });
421
            });
363
 
422
 
364
            fieldTaux.getDocument().addDocumentListener(new SimpleDocumentListener() {
423
            this.fieldTaux.getDocument().addDocumentListener(new SimpleDocumentListener() {
365
 
424
 
366
                @Override
425
                @Override
367
                public void update(DocumentEvent e) {
426
                public void update(DocumentEvent e) {
368
                    BigDecimal tauxConversion = null;
427
                    BigDecimal tauxConversion = null;
369
                    if (fieldTaux.getText().trim().length() > 0) {
428
                    if (FactureFournisseurSQLComponent.this.fieldTaux.getText().trim().length() > 0) {
370
                        tauxConversion = new BigDecimal(fieldTaux.getText());
429
                        tauxConversion = new BigDecimal(FactureFournisseurSQLComponent.this.fieldTaux.getText());
371
                    }
430
                    }
372
                    table.setTauxConversion(tauxConversion);
431
                    FactureFournisseurSQLComponent.this.table.setTauxConversion(tauxConversion);
373
                    updateLabelTauxConversion();
432
                    updateLabelTauxConversion();
374
                }
433
                }
375
            });
434
            });
376
        }
435
        }
377
 
436
 
378
        this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
437
        this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
379
 
438
 
380
            @Override
439
            @Override
381
            public void propertyChange(PropertyChangeEvent evt) {
440
            public void propertyChange(PropertyChangeEvent evt) {
382
                table.setFournisseur(fourn.getSelectedRow());
441
                FactureFournisseurSQLComponent.this.table.setFournisseur(FactureFournisseurSQLComponent.this.fourn.getSelectedRow());
383
                if (!isFilling()) {
442
                if (!isFilling()) {
384
                    SQLRow row = fourn.getSelectedRow();
443
                    SQLRow row = FactureFournisseurSQLComponent.this.fourn.getSelectedRow();
385
                    if (row != null && !row.isUndefined()) {
444
                    if (row != null && !row.isUndefined()) {
386
                        row.fetchValues();
445
                        row.fetchValues();
387
                        if (!row.isForeignEmpty("ID_COMPTE_PCE_CHARGE")) {
446
                        if (!row.isForeignEmpty("ID_COMPTE_PCE_CHARGE")) {
388
                            comptePCE.setValue(row.getForeign("ID_COMPTE_PCE_CHARGE"));
447
                            FactureFournisseurSQLComponent.this.comptePCE.setValue(row.getForeign("ID_COMPTE_PCE_CHARGE"));
389
                        }
448
                        }
390
                    }
449
                    }
391
                }
450
                }
392
            }
451
            }
393
        });
452
        });
394
        // Bottom
453
        // Bottom
395
        c.gridy++;
454
        c.gridy++;
396
        c.weighty = 0;
455
        c.weighty = 0;
397
        this.add(getBottomPanel(), c);
456
        this.add(getBottomPanel(), c);
398
        ModeDeReglementSQLComponent modeReglComp;
-
 
399
 
457
 
400
        modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
458
        ModeDeReglementSQLComponent modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
401
        modeReglComp.addDateCompListener(this.dateCommande);
459
        modeReglComp.addDateCompListener(this.dateCommande);
402
 
460
 
403
        c.gridx = 0;
-
 
404
        c.gridy++;
-
 
405
        c.fill = GridBagConstraints.HORIZONTAL;
-
 
406
        c.anchor = GridBagConstraints.WEST;
461
        // Modèle, visualiser, imprimer..
407
 
-
 
408
        c.gridx = 0;
462
        c.gridx = 0;
409
        c.gridy++;
463
        c.gridy++;
410
        c.fill = GridBagConstraints.NONE;
464
        c.fill = GridBagConstraints.NONE;
411
        c.anchor = GridBagConstraints.SOUTHEAST;
465
        c.anchor = GridBagConstraints.SOUTHEAST;
412
        c.gridwidth = GridBagConstraints.REMAINDER;
466
        c.gridwidth = GridBagConstraints.REMAINDER;
413
 
467
 
414
        this.panelOO = new PanelOOSQLComponent(this);
468
        this.panelOO = new PanelOOSQLComponent(this);
415
        this.add(this.panelOO, c);
469
        this.add(this.panelOO, c);
416
 
470
 
417
        addSQLObject(textNom, "NOM");
471
        addSQLObject(textNom, "NOM");
418
        addRequiredSQLObject(dateCommande, "DATE");
472
        addRequiredSQLObject(this.dateCommande, "DATE");
419
        addRequiredSQLObject(numero, "NUMERO");
473
        addRequiredSQLObject(this.numero, "NUMERO");
420
        addSQLObject(this.infos, "INFOS");
474
        addSQLObject(this.infos, "INFOS");
421
 
475
 
422
        DefaultGridBagConstraints.lockMinimumSize(this.fourn);
476
        DefaultGridBagConstraints.lockMinimumSize(this.fourn);
423
        DefaultGridBagConstraints.lockMinimumSize(commSel);
477
        DefaultGridBagConstraints.lockMinimumSize(commSel);
424
    }
478
    }
Line 437... Line 491...
437
 
491
 
438
    private JPanel getBottomPanel() {
492
    private JPanel getBottomPanel() {
439
        final JPanel panel = new JPanel(new GridBagLayout());
493
        final JPanel panel = new JPanel(new GridBagLayout());
440
        final GridBagConstraints c = new DefaultGridBagConstraints();
494
        final GridBagConstraints c = new DefaultGridBagConstraints();
441
 
495
 
-
 
496
        JTabbedPane tabs = new JTabbedPane();
-
 
497
 
-
 
498
        JPanel mainBottomPanel = new JPanel();
-
 
499
        mainBottomPanel.setOpaque(false);
-
 
500
        tabs.add(mainBottomPanel, "Règlements et caractéristiques");
-
 
501
        final JScrollPane scrollPane = new JScrollPane(this.infos);
442
        // Colonne 1 : Infos
502
        scrollPane.setBorder(null);
-
 
503
 
-
 
504
        tabs.add(scrollPane, getLabelFor("INFOS"));
443
        c.gridx = 0;
505
        c.gridx = 0;
444
        c.weightx = 1;
506
        c.weightx = 1;
445
        c.anchor = GridBagConstraints.WEST;
507
        c.anchor = GridBagConstraints.WEST;
446
        c.fill = GridBagConstraints.HORIZONTAL;
508
        c.fill = GridBagConstraints.BOTH;
-
 
509
        panel.add(tabs, c);
447
 
510
 
448
        panel.add(new TitledSeparator(getLabelFor("INFOS")), c);
511
        mainBottomPanel.setLayout(new GridBagLayout());
-
 
512
        GridBagConstraints cMainBottomPanel = new DefaultGridBagConstraints();
449
 
513
 
450
        c.gridy++;
514
        // Colonne 1 : Infos
-
 
515
 
451
        c.weighty = 0;
516
        cMainBottomPanel.weighty = 0;
452
        c.weightx = 1;
517
        cMainBottomPanel.weightx = 0;
453
        c.fill = GridBagConstraints.BOTH;
518
        cMainBottomPanel.fill = GridBagConstraints.BOTH;
454
        final JScrollPane scrollPane = new JScrollPane(this.infos);
-
 
455
        scrollPane.setBorder(null);
-
 
456
        panel.add(scrollPane, c);
-
 
457
 
519
 
458
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
520
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
459
        this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
521
        this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
460
 
522
 
461
        c.gridx++;
523
        c.gridx++;
462
        c.fill = GridBagConstraints.NONE;
524
        c.fill = GridBagConstraints.NONE;
-
 
525
        c.weightx = 1;
463
        c.weighty = 1;
526
        c.weighty = 1;
464
        eltModeRegl.setOpaque(false);
527
        this.eltModeRegl.setOpaque(false);
465
        panel.add(eltModeRegl, c);
528
        mainBottomPanel.add(this.eltModeRegl, cMainBottomPanel);
466
 
529
 
467
        // Colonne 2 : Poids & autres
530
        // Colonne 2 : Poids & autres
-
 
531
        JPanel column2 = new JPanel();
-
 
532
        column2.setOpaque(false);
-
 
533
        cMainBottomPanel.gridx++;
-
 
534
        cMainBottomPanel.weightx = 0;
-
 
535
        mainBottomPanel.add(column2, cMainBottomPanel);
-
 
536
 
-
 
537
        column2.setLayout(new GridBagLayout());
-
 
538
        GridBagConstraints c2 = new DefaultGridBagConstraints();
-
 
539
 
-
 
540
        c2.weightx = 0;
-
 
541
        c2.weighty = 0;
-
 
542
        c2.gridwidth = 1;
-
 
543
        c2.gridheight = 1;
-
 
544
        c2.fill = GridBagConstraints.HORIZONTAL;
-
 
545
        c2.anchor = GridBagConstraints.NORTHEAST;
-
 
546
        // Poids
468
        DefaultProps props = DefaultNXProps.getInstance();
547
        DefaultProps props = DefaultNXProps.getInstance();
469
        Boolean b = props.getBooleanValue("ArticleShowPoids");
548
        Boolean poidsVisible = props.getBooleanValue("ArticleShowPoids");
-
 
549
        if (poidsVisible) {
-
 
550
            column2.add(new JLabel(getLabelFor("T_POIDS"), SwingConstants.RIGHT), c2);
470
        final JTextField textPoidsTotal = new JTextField(8);
551
            final JTextField textPoidsTotal = new JTextField(8);
471
        JTextField poids = new JTextField();
-
 
472
        if (b) {
-
 
473
            final JPanel panelPoids = new JPanel();
-
 
474
 
-
 
475
            panelPoids.add(new JLabel(getLabelFor("T_POIDS")), c);
-
 
476
 
-
 
477
            textPoidsTotal.setEnabled(false);
552
            textPoidsTotal.setEnabled(false);
478
            textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
553
            textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
479
            textPoidsTotal.setDisabledTextColor(Color.BLACK);
554
            textPoidsTotal.setDisabledTextColor(Color.BLACK);
-
 
555
            c2.weightx = 1;
-
 
556
            c2.gridx++;
-
 
557
            column2.add(textPoidsTotal, c2);
-
 
558
            DefaultGridBagConstraints.lockMinimumSize(textPoidsTotal);
-
 
559
            addSQLObject(textPoidsTotal, "T_POIDS");
480
 
560
 
-
 
561
            this.table.getModel().addTableModelListener(new TableModelListener() {
-
 
562
 
481
            panelPoids.add(textPoidsTotal, c);
563
                public void tableChanged(TableModelEvent e) {
-
 
564
                    textPoidsTotal.setText(String.valueOf(FactureFournisseurSQLComponent.this.table.getPoidsTotal()));
-
 
565
                }
-
 
566
            });
482
 
567
 
483
            c.gridx++;
-
 
484
            c.gridy = 0;
-
 
485
            c.weightx = 0;
-
 
486
            c.weighty = 0;
-
 
487
            c.gridwidth = 1;
-
 
488
            c.gridheight = 2;
-
 
489
            c.fill = GridBagConstraints.NONE;
-
 
490
            c.anchor = GridBagConstraints.NORTHEAST;
-
 
491
            panel.add(panelPoids, c);
-
 
492
            DefaultGridBagConstraints.lockMinimumSize(panelPoids);
-
 
493
            addSQLObject(textPoidsTotal, "T_POIDS");
-
 
494
        } else {
568
        } else {
495
            addSQLObject(poids, "T_POIDS");
569
            addSQLObject(new JTextField(), "T_POIDS");
496
        }
570
        }
497
 
571
 
498
        DeviseField textPortHT = new DeviseField();
572
        DeviseField textPortHT = new DeviseField();
499
        ElementComboBox comboTaxePort = new ElementComboBox();
573
        ElementComboBox comboTaxePort = new ElementComboBox();
500
        DeviseField textRemiseHT = new DeviseField();
574
        DeviseField textRemiseHT = new DeviseField();
501
 
575
 
502
        final JPanel panelPoids = new JPanel(new GridBagLayout());
-
 
503
        GridBagConstraints cPort = new DefaultGridBagConstraints();
-
 
504
        if (getTable().contains("PORT_HT")) {
576
        if (getTable().contains("PORT_HT")) {
-
 
577
            // Port HT
505
            addSQLObject(textPortHT, "PORT_HT");
578
            addSQLObject(textPortHT, "PORT_HT");
506
            cPort.gridx = 0;
579
            c2.gridx = 0;
-
 
580
            c2.gridy++;
507
            cPort.weightx = 0;
581
            c2.weightx = 0;
508
            panelPoids.add(new JLabel(getLabelFor("PORT_HT")), cPort);
582
            column2.add(new JLabel(getLabelFor("PORT_HT"), SwingConstants.RIGHT), c2);
509
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
583
            textPortHT.setHorizontalAlignment(JTextField.RIGHT);
510
            cPort.gridx++;
584
            c2.gridx++;
511
            cPort.weightx = 1;
585
            c2.weightx = 1;
512
            panelPoids.add(textPortHT, cPort);
586
            column2.add(textPortHT, c2);
513
 
-
 
-
 
587
            // TVA sur port
514
            cPort.gridy++;
588
            c2.gridy++;
515
            cPort.gridx = 0;
589
            c2.gridx = 0;
516
            cPort.weightx = 0;
590
            c2.weightx = 0;
517
            addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
591
            addRequiredSQLObject(comboTaxePort, "ID_TAXE_PORT");
518
            panelPoids.add(new JLabel(getLabelFor("ID_TAXE_PORT")), cPort);
592
            column2.add(new JLabel(getLabelFor("ID_TAXE_PORT"), SwingConstants.RIGHT), c2);
519
            cPort.gridx++;
593
            c2.gridx++;
520
            cPort.weightx = 0;
594
            c2.weightx = 0;
521
            panelPoids.add(comboTaxePort, cPort);
595
            column2.add(comboTaxePort, c2);
522
 
-
 
523
            c.gridx++;
-
 
524
            c.gridy = 0;
596
            // Remise HT
525
            c.weightx = 0;
-
 
526
            c.weighty = 0;
-
 
527
            c.gridwidth = 1;
-
 
528
            c.gridheight = 2;
-
 
529
            c.fill = GridBagConstraints.NONE;
-
 
530
            c.anchor = GridBagConstraints.NORTHEAST;
-
 
531
            panel.add(panelPoids, c);
-
 
532
            DefaultGridBagConstraints.lockMinimumSize(panelPoids);
-
 
533
 
-
 
534
            addSQLObject(textRemiseHT, "REMISE_HT");
597
            addSQLObject(textRemiseHT, "REMISE_HT");
535
            cPort.gridy++;
598
            c2.gridx = 0;
536
            cPort.gridx = 0;
599
            c2.gridy++;
537
            cPort.fill = GridBagConstraints.NONE;
-
 
538
            cPort.weightx = 0;
600
            c2.weightx = 0;
539
            panelPoids.add(new JLabel(getLabelFor("REMISE_HT")), cPort);
601
            column2.add(new JLabel(getLabelFor("REMISE_HT"), SwingConstants.RIGHT), c2);
540
            textRemiseHT.setHorizontalAlignment(JTextField.RIGHT);
602
            textRemiseHT.setHorizontalAlignment(JTextField.RIGHT);
541
            cPort.gridx++;
603
            c2.gridx++;
542
            cPort.weightx = 1;
604
            c2.weightx = 1;
543
            panelPoids.add(textRemiseHT, cPort);
605
            column2.add(textRemiseHT, c2);
544
 
606
 
545
        }
607
        }
-
 
608
        final JTextField textTvaAdujs;
-
 
609
        if (getTable().contains("TVA_ADJUSTMENT")) {
-
 
610
            textTvaAdujs = new JTextField(15);
-
 
611
            final JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT"), SwingConstants.RIGHT);
-
 
612
            c2.gridx = 0;
-
 
613
            c2.gridy++;
-
 
614
            c2.weightx = 0;
-
 
615
            column2.add(labelTvaAdujst, c2);
-
 
616
            c2.gridx++;
-
 
617
            c2.weightx = 1;
-
 
618
            column2.add(textTvaAdujs, c2);
-
 
619
            addView(textTvaAdujs, "TVA_ADJUSTMENT");
-
 
620
 
-
 
621
            DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs);
-
 
622
        } else {
-
 
623
            textTvaAdujs = null;
-
 
624
        }
-
 
625
 
-
 
626
        c2.gridy++;
-
 
627
        c2.gridx = 0;
-
 
628
        column2.add(new JLabel("Avoirs", SwingConstants.RIGHT), c2);
-
 
629
 
-
 
630
        c2.gridx++;
-
 
631
        c2.fill = GridBagConstraints.NONE;
-
 
632
        c2.anchor = GridBagConstraints.EAST;
-
 
633
        column2.add(createPanelAvoir(), c2);
-
 
634
 
-
 
635
        c2.gridy++;
-
 
636
        column2.add(getModuleTotalPanel(), c2);
-
 
637
        c2.gridy++;
-
 
638
        JPanel filler = new JPanel();
-
 
639
        filler.setOpaque(false);
-
 
640
        c2.weighty = 1;
-
 
641
        column2.add(filler, c2);
-
 
642
 
546
        // Total
643
        // Colonne 4 Total
547
 
644
 
548
        DeviseField fieldHT = new DeviseField();
645
        DeviseField fieldHT = new DeviseField();
549
        DeviseField fieldEco = new DeviseField();
646
        DeviseField fieldEco = new DeviseField();
550
        DeviseField fieldTVA = new DeviseField();
647
        DeviseField fieldTVA = new DeviseField();
551
        DeviseField fieldDevise = new DeviseField();
648
        DeviseField fieldDevise = new DeviseField();
552
        DeviseField fieldService = new DeviseField();
649
        DeviseField fieldService = new DeviseField();
553
        fieldHT.setOpaque(false);
650
        fieldHT.setOpaque(false);
554
        fieldTVA.setOpaque(false);
651
        fieldTVA.setOpaque(false);
555
        fieldTTC.setOpaque(false);
652
        this.fieldTTC.setOpaque(false);
556
        fieldService.setOpaque(false);
653
        fieldService.setOpaque(false);
557
        addRequiredSQLObject(fieldDevise, "T_DEVISE");
654
        addRequiredSQLObject(fieldDevise, "T_DEVISE");
558
        addRequiredSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
655
        addRequiredSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
559
        addRequiredSQLObject(fieldHT, "T_HT");
656
        addRequiredSQLObject(fieldHT, "T_HT");
560
        addRequiredSQLObject(fieldTVA, "T_TVA");
657
        addRequiredSQLObject(fieldTVA, "T_TVA");
561
 
658
 
562
        addRequiredSQLObject(fieldTTC, "T_TTC");
659
        addRequiredSQLObject(this.fieldTTC, "T_TTC");
563
        addRequiredSQLObject(fieldService, "T_SERVICE");
660
        addRequiredSQLObject(fieldService, "T_SERVICE");
564
 
661
 
565
        fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() {
662
        this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() {
566
            @Override
663
            @Override
567
            public void update(DocumentEvent e) {
664
            public void update(DocumentEvent e) {
568
                refreshText();
665
                refreshText();
569
            }
666
            }
570
 
667
 
Line 576... Line 673...
576
        this.allowEditable("T_TVA", false);
673
        this.allowEditable("T_TVA", false);
577
        this.allowEditable("T_TTC", false);
674
        this.allowEditable("T_TTC", false);
578
        this.allowEditable("T_SERVICE", false);
675
        this.allowEditable("T_SERVICE", false);
579
        this.allowEditable("T_POIDS", false);
676
        this.allowEditable("T_POIDS", false);
580
 
677
 
581
        final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
678
        final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, this.fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null,
582
                (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
679
                (getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null), null);
583
 
-
 
584
        if (getTable().contains("TVA_ADJUSTMENT")) {
-
 
585
            final JTextField textTvaAdujs = new JTextField(15);
-
 
586
 
-
 
587
            JLabel labelTvaAdujst = new JLabel(getLabelFor("TVA_ADJUSTMENT"));
-
 
588
            labelTvaAdujst.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
589
 
-
 
590
            cPort.gridx = 0;
-
 
591
            cPort.gridy++;
-
 
592
            panelPoids.add(labelTvaAdujst, cPort);
-
 
593
            cPort.gridx++;
-
 
594
            panelPoids.add(textTvaAdujs, cPort);
680
        if (textTvaAdujs != null) {
595
            addView(textTvaAdujs, "TVA_ADJUSTMENT");
-
 
596
            totalTTC.setTextFixTVA(textTvaAdujs);
681
            totalTTC.setTextFixTVA(textTvaAdujs);
597
            textTvaAdujs.getDocument().addDocumentListener(new SimpleDocumentListener() {
682
            textTvaAdujs.getDocument().addDocumentListener(new SimpleDocumentListener() {
598
                @Override
683
                @Override
599
                public void update(final DocumentEvent e) {
684
                public void update(final DocumentEvent e) {
600
                    final String text = textTvaAdujs.getText();
685
                    final String text = textTvaAdujs.getText();
Line 619... Line 704...
619
                        }
704
                        }
620
                    }
705
                    }
621
                    totalTTC.updateTotal();
706
                    totalTTC.updateTotal();
622
                }
707
                }
623
            });
708
            });
624
            DefaultGridBagConstraints.lockMinimumSize(textTvaAdujs);
-
 
625
        }
709
        }
626
 
-
 
627
        c.gridx++;
710
        c.gridx++;
628
        c.gridy--;
711
        c.gridy = 0;
629
        c.gridwidth = GridBagConstraints.REMAINDER;
712
        c.gridwidth = 1;
630
        c.gridheight = 2;
713
        c.gridheight = 1;
631
        c.anchor = GridBagConstraints.NORTHEAST;
714
        c.anchor = GridBagConstraints.NORTHEAST;
632
        c.fill = GridBagConstraints.BOTH;
715
        c.fill = GridBagConstraints.HORIZONTAL;
633
        c.weighty = 0;
716
        c.weighty = 0;
634
        DefaultGridBagConstraints.lockMinimumSize(totalTTC);
717
        DefaultGridBagConstraints.lockMinimumSize(totalTTC);
635
 
718
 
636
        panel.add(totalTTC, c);
719
        panel.add(totalTTC, c);
637
 
720
 
638
        c.gridy += 3;
-
 
639
        c.gridheight = 1;
-
 
640
        c.fill = GridBagConstraints.NONE;
-
 
641
        c.anchor = GridBagConstraints.EAST;
-
 
642
        panel.add(createPanelAvoir(), c);
-
 
643
 
-
 
644
        c.gridy += 4;
-
 
645
        c.gridheight = 2;
-
 
646
        c.fill = GridBagConstraints.NONE;
-
 
647
        c.anchor = GridBagConstraints.EAST;
-
 
648
        panel.add(getModuleTotalPanel(), c);
-
 
649
 
-
 
650
        table.getModel().addTableModelListener(new TableModelListener() {
-
 
651
 
-
 
652
            public void tableChanged(TableModelEvent e) {
-
 
653
                textPoidsTotal.setText(String.valueOf(table.getPoidsTotal()));
-
 
654
            }
-
 
655
        });
-
 
656
 
-
 
657
        this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
721
        this.fourn.addModelListener("wantedID", new PropertyChangeListener() {
658
 
722
 
659
            @Override
723
            @Override
660
            public void propertyChange(PropertyChangeEvent evt) {
724
            public void propertyChange(PropertyChangeEvent evt) {
661
                final SQLRow selectedRow2 = fourn.getSelectedRow();
725
                final SQLRow selectedRow2 = FactureFournisseurSQLComponent.this.fourn.getSelectedRow();
662
                if (selectedRow2 != null && !selectedRow2.isUndefined()) {
726
                if (selectedRow2 != null && !selectedRow2.isUndefined()) {
663
                    totalTTC.setIntraComm(selectedRow2.getBoolean("UE"));
727
                    totalTTC.setIntraComm(selectedRow2.getBoolean("UE"));
664
                } else {
728
                } else {
665
                    totalTTC.setIntraComm(false);
729
                    totalTTC.setIntraComm(false);
666
                }
730
                }
Line 684... Line 748...
684
 
748
 
685
        comboTaxePort.addValueListener(new PropertyChangeListener() {
749
        comboTaxePort.addValueListener(new PropertyChangeListener() {
686
 
750
 
687
            @Override
751
            @Override
688
            public void propertyChange(PropertyChangeEvent evt) {
752
            public void propertyChange(PropertyChangeEvent evt) {
689
                // TODO Raccord de méthode auto-généré
-
 
690
                totalTTC.updateTotal();
753
                totalTTC.updateTotal();
691
            }
754
            }
692
        });
755
        });
693
 
756
 
694
        textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
757
        textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
Line 715... Line 778...
715
        return AutoHideListener.listen(new JPanel());
778
        return AutoHideListener.listen(new JPanel());
716
    }
779
    }
717
 
780
 
718
    public int insert(SQLRow order) {
781
    public int insert(SQLRow order) {
719
 
782
 
-
 
783
        final SQLTable tableNum = getTable().getTable("NUMEROTATION_AUTO");
-
 
784
        // incrémentation du numéro auto
-
 
785
        if (tableNum.contains("FACTURE_FOURNISSEUR_START") && NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numero.getText().trim())) {
-
 
786
            SQLRowValues rowVals = new SQLRowValues(tableNum);
-
 
787
 
-
 
788
            final SQLRow rowNumAuto = tableNum.getRow(2);
-
 
789
            if (rowNumAuto.getObject("FACTURE_FOURNISSEUR_START") != null) {
-
 
790
                int val = rowNumAuto.getInt("FACTURE_FOURNISSEUR_START");
-
 
791
                val++;
-
 
792
                rowVals.put("FACTURE_FOURNISSEUR_START", new Integer(val));
-
 
793
 
-
 
794
                try {
-
 
795
                    rowVals.update(2);
-
 
796
                } catch (SQLException e) {
-
 
797
                    e.printStackTrace();
-
 
798
                }
-
 
799
            }
-
 
800
        }
720
        int idFacture = getSelectedID();
801
        int idFacture = getSelectedID();
721
        idFacture = super.insert(order);
802
        idFacture = super.insert(order);
722
        this.table.updateField("ID_FACTURE_FOURNISSEUR", idFacture);
803
        this.table.updateField("ID_FACTURE_FOURNISSEUR", idFacture);
723
 
804
 
724
        // Création des articles
805
        // Création des articles
Line 772... Line 853...
772
        sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
853
        sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true);
773
        commitAvoir(rowFactureOld, row);
854
        commitAvoir(rowFactureOld, row);
774
    }
855
    }
775
 
856
 
776
    public void commitAvoir(SQLRow rowFactureOld, SQLRow rowFacture) {
857
    public void commitAvoir(SQLRow rowFactureOld, SQLRow rowFacture) {
-
 
858
 
777
        try {
859
        try {
-
 
860
            List<String> fieldsAvoir = Arrays.asList("ID_AVOIR_FOURNISSEUR", "ID_AVOIR_FOURNISSEUR_2");
-
 
861
            for (String field : fieldsAvoir) {
-
 
862
 
778
            if (rowFactureOld != null && rowFactureOld.getObject("ID_AVOIR_FOURNISSEUR") != null && !rowFactureOld.isForeignEmpty("ID_AVOIR_FOURNISSEUR")
863
                if (rowFactureOld != null && rowFactureOld.getObject(field) != null && !rowFactureOld.isForeignEmpty(field)
779
                    && (rowFacture.getObject("ID_AVOIR_FOURNISSEUR") == null || rowFacture.isForeignEmpty("ID_AVOIR_FOURNISSEUR"))) {
864
                        && (rowFacture.getObject(field) == null || rowFacture.isForeignEmpty(field))) {
780
 
865
 
781
                SQLRow rowAvoir = rowFactureOld.getForeignRow("ID_AVOIR_FOURNISSEUR");
866
                    SQLRow rowAvoir = rowFactureOld.getForeignRow(field);
782
 
867
 
783
                SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
868
                    SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
784
 
869
 
785
                // Soldé
870
                    // Soldé
786
                rowVals.put("SOLDE", Boolean.FALSE);
871
                    rowVals.put("SOLDE", Boolean.FALSE);
Line 788... Line 873...
788
                rowVals.update();
873
                    rowVals.update();
789
 
874
 
790
            }
875
                }
791
 
876
 
792
            // on solde l'avoir
877
                // on solde l'avoir
793
            if (rowFacture.getObject("ID_AVOIR_FOURNISSEUR") != null && !rowFacture.isForeignEmpty("ID_AVOIR_FOURNISSEUR")) {
878
                if (rowFacture.getObject(field) != null && !rowFacture.isForeignEmpty(field)) {
794
 
879
 
795
                SQLRow rowAvoir = rowFacture.getForeignRow("ID_AVOIR_FOURNISSEUR");
880
                    SQLRow rowAvoir = rowFacture.getForeignRow(field);
796
 
881
 
797
                SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
882
                    SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
798
                rowVals.put("SOLDE", Boolean.TRUE);
883
                    rowVals.put("SOLDE", Boolean.TRUE);
799
 
884
 
800
                rowVals.update();
885
                    rowVals.update();
801
 
886
 
802
            }
887
                }
-
 
888
            }
803
        } catch (SQLException e) {
889
        } catch (SQLException e) {
804
            ExceptionHandler.handle("Erreur lors la mise à jour de l'avoir associée!", e);
890
            ExceptionHandler.handle("Erreur lors la mise à jour de l'avoir associée!", e);
805
        }
891
        }
806
    }
892
    }
807
 
893
 
Line 827... Line 913...
827
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
913
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
828
 
914
 
829
        if (rowsComm != null) {
915
        if (rowsComm != null) {
830
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
916
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
831
        }
917
        }
-
 
918
 
-
 
919
        if (getTable().getTable("NUMEROTATION_AUTO").contains("FACTURE_FOURNISSEUR_START")) {
-
 
920
            rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
-
 
921
        }
-
 
922
 
832
        rowVals.put("T_HT", Long.valueOf(0));
923
        rowVals.put("T_HT", Long.valueOf(0));
833
        rowVals.put("T_SERVICE", Long.valueOf(0));
924
        rowVals.put("T_SERVICE", Long.valueOf(0));
834
        rowVals.put("T_DEVISE", Long.valueOf(0));
925
        rowVals.put("T_DEVISE", Long.valueOf(0));
835
        rowVals.put("T_TVA", Long.valueOf(0));
926
        rowVals.put("T_TVA", Long.valueOf(0));
836
        rowVals.put("T_TTC", Long.valueOf(0));
927
        rowVals.put("T_TTC", Long.valueOf(0));
Line 869... Line 960...
869
        cA.weightx = 0;
960
        cA.weightx = 0;
870
        panelAvoir.add(labelTotalAvoir, cA);
961
        panelAvoir.add(labelTotalAvoir, cA);
871
        cA.gridx++;
962
        cA.gridx++;
872
        cA.weightx = 0;
963
        cA.weightx = 0;
873
        panelAvoir.add(this.textNetAPayer, cA);
964
        panelAvoir.add(this.textNetAPayer, cA);
874
        addView(textNetAPayer, "NET_A_PAYER");
965
        addView(this.textNetAPayer, "NET_A_PAYER");
875
        this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT);
966
        this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT);
876
 
967
 
-
 
968
        JLabel labelAvoir2 = new JLabel(getLabelFor("ID_AVOIR_FOURNISSEUR_2"));
-
 
969
        labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
970
        cA.gridx = 0;
-
 
971
        cA.gridy++;
-
 
972
        cA.weightx = 1;
-
 
973
        labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
974
        panelAvoir.add(labelAvoir2, cA);
-
 
975
        cA.weightx = 0;
-
 
976
        cA.gridx++;
-
 
977
        this.avoirFourn2 = new ElementComboBox();
-
 
978
        this.avoirFourn2.setAddIconVisible(false);
-
 
979
        panelAvoir.add(this.avoirFourn2, cA);
-
 
980
 
-
 
981
        addView(this.avoirFourn2, "ID_AVOIR_FOURNISSEUR_2");
877
        addView(this.avoirFourn, "ID_AVOIR_FOURNISSEUR");
982
        addView(this.avoirFourn, "ID_AVOIR_FOURNISSEUR");
878
        addView(avoirTTC, "AVOIR_TTC");
983
        addView(this.avoirTTC, "AVOIR_TTC");
879
        this.avoirFourn.addValueListener(new PropertyChangeListener() {
984
        this.avoirFourn.addModelListener("wantedID", new PropertyChangeListener() {
880
 
985
 
881
            public void propertyChange(PropertyChangeEvent evt) {
986
            public void propertyChange(PropertyChangeEvent evt) {
-
 
987
                if (!isFilling()) {
882
                refreshText();
988
                    refreshText();
883
            }
989
                }
-
 
990
            }
884
 
991
 
885
        });
992
        });
-
 
993
        this.avoirFourn2.addModelListener("wantedID", new PropertyChangeListener() {
-
 
994
 
-
 
995
            public void propertyChange(PropertyChangeEvent evt) {
-
 
996
                if (!isFilling()) {
-
 
997
                    refreshText();
-
 
998
                }
-
 
999
            }
886
 
1000
 
-
 
1001
        });
887
        return panelAvoir;
1002
        return panelAvoir;
888
    }
1003
    }
889
 
1004
 
890
    private void refreshText() {
1005
    private void refreshText() {
891
        Number n = this.fieldTTC.getValue();
1006
        Number n = this.fieldTTC.getValue();
892
        long totalAvoirTTC = 0;
1007
        long totalAvoirTTC = 0;
893
        long netAPayer = 0;
1008
        long netAPayer = 0;
894
        long ttc = 0;
-
 
895
        if (n != null) {
1009
        if (n != null) {
896
            netAPayer = n.longValue();
1010
            netAPayer = n.longValue();
897
            ttc = n.longValue();
-
 
898
        }
1011
        }
899
 
1012
 
-
 
1013
        List<ElementComboBox> boxAvoir = Arrays.asList(this.avoirFourn, this.avoirFourn2);
-
 
1014
        for (ElementComboBox elementComboBox : boxAvoir) {
900
        if (this.avoirFourn.getSelectedId() > 1) {
1015
            if (elementComboBox.getWantedID() > 1) {
901
            SQLTable tableAvoir = getTable().getForeignTable("ID_AVOIR_FOURNISSEUR");
1016
                SQLTable tableAvoir = getTable().getForeignTable("ID_AVOIR_FOURNISSEUR");
902
            if (n != null) {
1017
                if (n != null) {
903
                SQLRow rowAvoir = tableAvoir.getRow(this.avoirFourn.getSelectedId());
1018
                    SQLRow rowAvoir = tableAvoir.getRow(elementComboBox.getWantedID());
904
                long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue();
1019
                    long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue();
905
                if (getSelectedID() > 1) {
1020
                    if (getSelectedID() > 1) {
906
                    SQLRow row = getTable().getRow(getSelectedID());
1021
                        SQLRow row = getTable().getRow(getSelectedID());
907
                    int idAvoirOld = row.getInt("ID_AVOIR_FOURNISSEUR");
1022
                        int idAvoirOld = row.getInt("ID_AVOIR_FOURNISSEUR");
908
                    if (idAvoirOld == rowAvoir.getID()) {
1023
                        if (idAvoirOld == rowAvoir.getID()) {
909
                        totalAvoir += Long.valueOf(row.getObject("AVOIR_TTC").toString());
1024
                            totalAvoir += Long.valueOf(row.getObject("AVOIR_TTC").toString());
910
                    }
1025
                        }
911
                }
1026
                    }
912
 
1027
 
913
                long l = ttc - totalAvoir;
1028
                    long l = netAPayer - totalAvoir;
914
                if (l < 0) {
1029
                    if (l < 0) {
915
                    l = 0;
1030
                        l = 0;
916
                    totalAvoirTTC = ttc;
1031
                        totalAvoirTTC = netAPayer;
917
                } else {
1032
                    } else {
918
                    totalAvoirTTC = totalAvoir;
1033
                        totalAvoirTTC = totalAvoir;
919
                }
1034
                    }
920
                netAPayer = l;
1035
                    netAPayer = l;
921
            }
1036
                }
922
        }
1037
            }
-
 
1038
        }
923
 
1039
 
924
        this.textNetAPayer.setValue(netAPayer);
1040
        this.textNetAPayer.setValue(netAPayer);
925
        this.avoirTTC.setValue(totalAvoirTTC);
1041
        this.avoirTTC.setValue(totalAvoirTTC);
926
    }
1042
    }
927
 
1043
 
Line 945... Line 1061...
945
            SQLRowValues rowVals = new SQLRowValues(fact.getTable());
1061
            SQLRowValues rowVals = new SQLRowValues(fact.getTable());
946
            rowVals.put("ID_FOURNISSEUR", row.getForeignID("ID_FOURNISSEUR"));
1062
            rowVals.put("ID_FOURNISSEUR", row.getForeignID("ID_FOURNISSEUR"));
947
            if (!row.isForeignEmpty("ID_COMPTE_PCE")) {
1063
            if (!row.isForeignEmpty("ID_COMPTE_PCE")) {
948
                rowVals.put("ID_COMPTE_PCE", row.getForeignID("ID_COMPTE_PCE"));
1064
                rowVals.put("ID_COMPTE_PCE", row.getForeignID("ID_COMPTE_PCE"));
949
            }
1065
            }
950
            // if (getTable().contains("ID_NUMEROTATION_AUTO")) {
-
 
951
            // rowVals.put("NUMERO",
-
 
952
            // NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
-
 
953
            // Date(), row.getForeign("ID_NUMEROTATION_AUTO")));
-
 
954
            // } else {
-
 
955
            // rowVals.put("NUMERO",
-
 
956
            // NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new
-
 
957
            // Date()));
-
 
958
            // }
1066
 
959
            rowVals.put("NOM", row.getObject("NOM"));
1067
            rowVals.put("NOM", row.getObject("NOM"));
960
            this.select(rowVals);
1068
            this.select(rowVals);
961
        }
1069
        }
962
 
1070
 
963
        // On duplique les elements de facture
1071
        // On duplique les elements de facture
Line 968... Line 1076...
968
 
1076
 
969
            for (SQLRow rowElt : myListItem) {
1077
            for (SQLRow rowElt : myListItem) {
970
 
1078
 
971
                SQLRowValues rowVals = rowElt.createUpdateRow();
1079
                SQLRowValues rowVals = rowElt.createUpdateRow();
972
                rowVals.clearPrimaryKeys();
1080
                rowVals.clearPrimaryKeys();
-
 
1081
                if (rowVals.getTable().contains("ID_COMMANDE_ELEMENT")) {
-
 
1082
                    rowVals.putEmptyLink("ID_COMMANDE_ELEMENT");
-
 
1083
                }
-
 
1084
                if (rowVals.getTable().contains("ID_BON_RECEPTION_ELEMENT")) {
-
 
1085
                    rowVals.putEmptyLink("ID_BON_RECEPTION_ELEMENT");
-
 
1086
                }
973
                this.table.getModel().addRow(rowVals);
1087
                this.table.getModel().addRow(rowVals);
974
                int rowIndex = this.table.getModel().getRowCount() - 1;
1088
                int rowIndex = this.table.getModel().getRowCount() - 1;
975
                this.table.getModel().fireTableModelModified(rowIndex);
1089
                this.table.getModel().fireTableModelModified(rowIndex);
976
            }
1090
            }
977
        } else {
1091
        } else {