OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Rev 94 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 83
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.sales.account;
14
 package org.openconcerto.erp.core.sales.account;
15
 
15
 
16
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent;
16
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
18
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
19
import org.openconcerto.erp.core.common.ui.Acompte;
19
import org.openconcerto.erp.core.common.ui.Acompte;
20
import org.openconcerto.erp.core.common.ui.AcompteField;
20
import org.openconcerto.erp.core.common.ui.AcompteField;
21
import org.openconcerto.erp.core.common.ui.AcompteRowItemView;
21
import org.openconcerto.erp.core.common.ui.AcompteRowItemView;
22
import org.openconcerto.erp.core.common.ui.DeviseField;
22
import org.openconcerto.erp.core.common.ui.DeviseField;
23
import org.openconcerto.erp.core.common.ui.TotalPanel;
23
import org.openconcerto.erp.core.common.ui.TotalPanel;
-
 
24
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable.TypeCalcul;
24
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
25
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
25
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
26
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
26
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
27
import org.openconcerto.erp.core.sales.invoice.ui.FactureSituationItemTable;
27
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
28
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
28
import org.openconcerto.sql.Configuration;
29
import org.openconcerto.sql.Configuration;
29
import org.openconcerto.sql.element.ElementSQLObject;
30
import org.openconcerto.sql.element.ElementSQLObject;
-
 
31
import org.openconcerto.sql.element.GlobalMapper;
30
import org.openconcerto.sql.element.SQLElement;
32
import org.openconcerto.sql.element.SQLElement;
31
import org.openconcerto.sql.model.SQLRow;
33
import org.openconcerto.sql.model.SQLRow;
32
import org.openconcerto.sql.model.SQLRowValues;
34
import org.openconcerto.sql.model.SQLRowValues;
33
import org.openconcerto.sql.model.SQLTable;
35
import org.openconcerto.sql.model.SQLTable;
34
import org.openconcerto.sql.sqlobject.JUniqueTextField;
36
import org.openconcerto.sql.sqlobject.JUniqueTextField;
35
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
37
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
36
import org.openconcerto.sql.view.EditFrame;
38
import org.openconcerto.sql.view.EditFrame;
37
import org.openconcerto.sql.view.list.RowValuesTable;
39
import org.openconcerto.sql.view.list.RowValuesTable;
38
import org.openconcerto.sql.view.list.SQLTableElement;
40
import org.openconcerto.sql.view.list.SQLTableElement;
39
import org.openconcerto.ui.JDate;
41
import org.openconcerto.ui.JDate;
40
import org.openconcerto.ui.component.ITextArea;
42
import org.openconcerto.ui.component.ITextArea;
41
import org.openconcerto.ui.group.Group;
43
import org.openconcerto.ui.group.Group;
42
import org.openconcerto.utils.ExceptionHandler;
44
import org.openconcerto.utils.ExceptionHandler;
43
import org.openconcerto.utils.text.SimpleDocumentListener;
45
import org.openconcerto.utils.text.SimpleDocumentListener;
44
 
46
 
45
import java.awt.Component;
47
import java.awt.Component;
46
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeListener;
49
import java.beans.PropertyChangeListener;
48
import java.math.BigDecimal;
50
import java.math.BigDecimal;
49
import java.sql.SQLException;
51
import java.sql.SQLException;
50
import java.util.Date;
52
import java.util.Date;
51
import java.util.HashSet;
53
import java.util.HashSet;
52
import java.util.Set;
54
import java.util.Set;
53
 
55
 
54
import javax.swing.JCheckBox;
56
import javax.swing.JCheckBox;
55
import javax.swing.JComponent;
57
import javax.swing.JComponent;
56
import javax.swing.JLabel;
58
import javax.swing.JLabel;
57
import javax.swing.JTextField;
59
import javax.swing.JTextField;
58
import javax.swing.SwingConstants;
60
import javax.swing.SwingConstants;
59
import javax.swing.SwingUtilities;
61
import javax.swing.SwingUtilities;
60
import javax.swing.event.DocumentEvent;
62
import javax.swing.event.DocumentEvent;
61
 
63
 
62
public class VenteFactureSituationSQLComponent extends TransfertGroupSQLComponent {
64
public class VenteFactureSituationSQLComponent extends TransfertGroupSQLComponent {
63
    public static final String ID = "sales.invoice.partial";
65
    public static final String ID = "sales.invoice.partial";
64
 
66
 
65
    public VenteFactureSituationSQLComponent(SQLElement element) {
67
    public VenteFactureSituationSQLComponent(SQLElement element) {
66
        super(element, new PartialInvoiceEditGroup());
68
        super(element, (Group) GlobalMapper.getInstance().get(ID));
67
    }
69
    }
68
 
70
 
69
    public VenteFactureSituationSQLComponent(SQLElement element, Group p) {
71
    public VenteFactureSituationSQLComponent(SQLElement element, Group p) {
70
        super(element, p);
72
        super(element, p);
71
    }
73
    }
72
 
74
 
73
    @Override
75
    @Override
74
    protected Set<String> createRequiredNames() {
76
    protected Set<String> createRequiredNames() {
75
        final Set<String> s = new HashSet<String>(1);
77
        final Set<String> s = new HashSet<String>(1);
76
        s.add("ID_CLIENT");
78
        s.add("ID_CLIENT");
77
        s.add("NUMERO");
79
        s.add("NUMERO");
78
        s.add("DATE");
80
        s.add("DATE");
79
        s.add("MONTANT_FACTURABLE");
81
        s.add("MONTANT_FACTURABLE");
80
        s.add("ID_MODE_REGLEMENT");
82
        s.add("ID_MODE_REGLEMENT");
81
        return s;
83
        return s;
82
    }
84
    }
83
 
85
 
84
    @Override
86
    @Override
85
    protected RowValuesTable getRowValuesTable() {
87
    protected RowValuesTable getRowValuesTable() {
86
 
88
 
87
        return ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).getRowValuesTable();
89
        return ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).getRowValuesTable();
88
    }
90
    }
89
 
91
 
90
    JCheckBox box = new JCheckBox("partial");
92
    JCheckBox box = new JCheckBox("partial");
91
 
93
 
92
    @Override
94
    @Override
93
    protected void addViews() {
95
    protected void addViews() {
94
 
96
 
95
        super.addViews();
97
        super.addViews();
96
 
98
 
97
        box.setSelected(true);
99
        box.setSelected(true);
98
        this.addView(box, "PARTIAL", REQ);
100
        this.addView(box, "PARTIAL", REQ);
99
 
101
 
100
        final DeviseField totalHT = (DeviseField) getEditor("T_HT");
102
        final DeviseField totalHT = (DeviseField) getEditor("T_HT");
101
        final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
103
        final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
102
        final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
104
        final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
103
        final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
105
        final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
104
        final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
106
        final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
105
        final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
107
        final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
106
        final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
108
        final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
107
        final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
109
        final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
108
        final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
110
        final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
109
        this.addView(totalPORT, "PORT_HT");
111
        this.addView(totalPORT, "PORT_HT");
110
        this.addView(totalRemise, "REMISE_HT");
112
        this.addView(totalRemise, "REMISE_HT");
111
        this.addView(totalTVA, "T_TVA");
113
        this.addView(totalTVA, "T_TVA");
112
        this.addView(totalTTC, "T_TTC");
114
        this.addView(totalTTC, "T_TTC");
113
        this.addView(totalWeight, "T_POIDS");
115
        this.addView(totalWeight, "T_POIDS");
114
        this.addView(totalDevise, "T_DEVISE");
116
        this.addView(totalDevise, "T_DEVISE");
115
        this.addView(totalSupply, "T_HA");
117
        this.addView(totalSupply, "T_HA");
116
        this.addView(totalService, "T_SERVICE");
118
        this.addView(totalService, "T_SERVICE");
117
        this.addView(totalHT, "T_HT");
119
        this.addView(totalHT, "T_HT");
118
 
120
 
119
        final SQLRequestComboBox sqlRequestComboBox = (SQLRequestComboBox) getEditor("sales.invoice.customer");
121
        final SQLRequestComboBox sqlRequestComboBox = (SQLRequestComboBox) getEditor("sales.invoice.customer");
120
        sqlRequestComboBox.addModelListener("wantedID", new PropertyChangeListener() {
122
        sqlRequestComboBox.addModelListener("wantedID", new PropertyChangeListener() {
121
 
123
 
122
            @Override
124
            @Override
123
            public void propertyChange(PropertyChangeEvent evt) {
125
            public void propertyChange(PropertyChangeEvent evt) {
124
 
126
 
125
                SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
127
                SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
126
                final SQLRow client = sqlRequestComboBox.getSelectedRow();
128
                final SQLRow client = sqlRequestComboBox.getSelectedRow();
127
                if (client != null && !client.isUndefined()) {
129
                if (client != null && !client.isUndefined()) {
128
                    int idModeRegl = client.getInt("ID_MODE_REGLEMENT");
130
                    int idModeRegl = client.getInt("ID_MODE_REGLEMENT");
129
                    if (idModeRegl > 1) {
131
                    if (idModeRegl > 1) {
130
                        SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
132
                        SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
131
                        SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
133
                        SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
132
                        rowValsModeRegl.clearPrimaryKeys();
134
                        rowValsModeRegl.clearPrimaryKeys();
133
                        ((ElementSQLObject) getEditor("ID_MODE_REGLEMENT")).setValue(rowValsModeRegl);
135
                        ((ElementSQLObject) getEditor("ID_MODE_REGLEMENT")).setValue(rowValsModeRegl);
134
                    }
136
                    }
135
                }
137
                }
136
 
138
 
137
            }
139
            }
138
        });
140
        });
139
        sqlRequestComboBox.setEnabled(false);
141
        sqlRequestComboBox.setEnabled(false);
140
 
142
 
141
        final AcompteField acompteField = ((AcompteField) getEditor("sales.invoice.partial.amount"));
143
        final AcompteField acompteField = ((AcompteField) getEditor("sales.invoice.partial.amount"));
142
        final FactureSituationItemTable table = ((FactureSituationItemTable) getEditor("sales.invoice.partial.items.list"));
144
        final FactureSituationItemTable table = ((FactureSituationItemTable) getEditor("sales.invoice.partial.items.list"));
143
        acompteField.getDocument().addDocumentListener(new SimpleDocumentListener() {
145
        acompteField.getDocument().addDocumentListener(new SimpleDocumentListener() {
144
 
146
 
145
            @Override
147
            @Override
146
            public void update(DocumentEvent e) {
148
            public void update(DocumentEvent e) {
147
                Acompte a = acompteField.getValue();
149
                Acompte a = acompteField.getValue();
148
                table.calculPourcentage(a);
150
                table.calculPourcentage(a,TypeCalcul.CALCUL_FACTURABLE);
149
            }
151
            }
150
        });
152
        });
151
        final TotalPanel total = ((TotalPanel) getEditor("sales.invoice.partial.total.amount"));
153
        final TotalPanel total = ((TotalPanel) getEditor("sales.invoice.partial.total.amount"));
152
        total.addValueListener(new PropertyChangeListener() {
154
        total.addValueListener(new PropertyChangeListener() {
153
 
155
 
154
            @Override
156
            @Override
155
            public void propertyChange(PropertyChangeEvent evt) {
157
            public void propertyChange(PropertyChangeEvent evt) {
156
                acompteField.setTotal(new BigDecimal(total.getTotalHT()).movePointLeft(2));
158
                acompteField.setTotal(new BigDecimal(total.getTotalHT()).movePointLeft(2));
157
 
159
 
158
            }
160
            }
159
        });
161
        });
160
 
162
 
161
    }
163
    }
162
 
164
 
-
 
165
    int countPole = 0;
-
 
166
 
-
 
167
    // @Override
-
 
168
    // public Component addView(MutableRowItemView rowItemView, String fields, Object specObj) {
-
 
169
    //
-
 
170
    // if (fields.contains("ID_POLE_PRODUIT") && countPole == 0) {
-
 
171
    // countPole++;
-
 
172
    // return null;
-
 
173
    // } else {
-
 
174
    // return super.addView(rowItemView, fields, specObj);
-
 
175
    // }
-
 
176
    // }
-
 
177
 
163
    @Override
178
    @Override
164
    public JComponent getLabel(String id) {
179
    public JComponent getLabel(String id) {
165
        if (id.equals("sales.invoice.partial.amount")) {
180
        if (id.equals("sales.invoice.partial.amount")) {
166
            final JLabel jLabel = new JLabel("Montant à facturer");
181
            final JLabel jLabel = new JLabel("Montant à facturer");
167
            jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
182
            jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
168
            return jLabel;
183
            return jLabel;
169
        } else if (id.equals("sales.invoice.partial.total.amount")) {
184
        } else if (id.equals("sales.invoice.partial.total.amount")) {
170
            return new JLabel();
185
            return new JLabel();
171
        } else {
186
        } else {
172
            return super.getLabel(id);
187
            return super.getLabel(id);
173
        }
188
        }
174
    }
189
    }
175
 
190
 
176
    JUniqueTextField numberField;
191
    JUniqueTextField numberField;
177
 
192
 
178
    @Override
193
    @Override
179
    public JComponent createEditor(String id) {
194
    public JComponent createEditor(String id) {
180
 
195
 
181
        if (id.equals("sales.invoice.number")) {
196
        if (id.equals("sales.invoice.number")) {
182
            this.numberField = new JUniqueTextField(20);
197
            this.numberField = new JUniqueTextField(20);
183
            return this.numberField;
198
            return this.numberField;
184
        } else if (id.equals("INFOS")) {
199
        } else if (id.equals("INFOS")) {
185
            final ITextArea jTextArea = new ITextArea();
200
            final ITextArea jTextArea = new ITextArea();
186
            jTextArea.setFont(new JLabel().getFont());
201
            jTextArea.setFont(new JLabel().getFont());
187
            return jTextArea;
202
            return jTextArea;
188
        } else if (id.equals("sales.invoice.partial.items.list")) {
203
        } else if (id.equals("sales.invoice.partial.items.list")) {
189
            return new FactureSituationItemTable();
204
            return new FactureSituationItemTable();
190
        } else if (id.equals("DATE")) {
205
        } else if (id.equals("DATE")) {
191
            return new JDate(true);
206
            return new JDate(true);
192
        } else if (id.equals("T_POIDS")) {
207
        } else if (id.equals("T_POIDS")) {
193
            return new JTextField();
208
            return new JTextField();
194
        } else if (id.equals("sales.invoice.partial.total.amount")) {
209
        } else if (id.equals("sales.invoice.partial.total.amount")) {
195
            final AbstractArticleItemTable items = (AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list");
210
            final AbstractArticleItemTable items = (AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list");
196
            // Set only VAT Editable
211
            // Set only VAT Editable
197
            for (int i = 0; i < items.getRowValuesTable().getColumnModel().getColumnCount(false); i++) {
212
            for (int i = 0; i < items.getRowValuesTable().getColumnModel().getColumnCount(false); i++) {
198
                final SQLTableElement sqlTableElementAt = items.getRowValuesTable().getRowValuesTableModel().getSQLTableElementAt(i);
213
                final SQLTableElement sqlTableElementAt = items.getRowValuesTable().getRowValuesTableModel().getSQLTableElementAt(i);
199
                if (sqlTableElementAt.getField() == null || !sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_TAXE")) {
214
                if (sqlTableElementAt.getField() == null || !sqlTableElementAt.getField().getName().equalsIgnoreCase("ID_TAXE")) {
200
                    sqlTableElementAt.setEditable(false);
215
                    sqlTableElementAt.setEditable(false);
201
                } else {
216
                } else {
202
                    sqlTableElementAt.setEditable(true);
217
                    sqlTableElementAt.setEditable(true);
203
                }
218
                }
204
            }
219
            }
205
 
220
 
206
            final DeviseField totalHT = (DeviseField) getEditor("T_HT");
221
            final DeviseField totalHT = (DeviseField) getEditor("T_HT");
207
            final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
222
            final DeviseField totalService = (DeviseField) getEditor("T_SERVICE");
208
            final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
223
            final DeviseField totalSupply = (DeviseField) getEditor("T_HA");
209
            final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
224
            final DeviseField totalDevise = (DeviseField) getEditor("T_DEVISE");
210
            final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
225
            final JTextField totalWeight = (JTextField) getEditor("T_POIDS");
211
            final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
226
            final DeviseField totalTTC = (DeviseField) getEditor("T_TTC");
212
            final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
227
            final DeviseField totalTVA = (DeviseField) getEditor("T_TVA");
213
            final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
228
            final DeviseField totalRemise = (DeviseField) getEditor("REMISE_HT");
214
            final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
229
            final DeviseField totalPORT = (DeviseField) getEditor("PORT_HT");
215
 
230
 
216
            return new TotalPanel(items, totalHT, totalTVA, totalTTC, totalRemise, totalPORT, totalService, totalSupply, totalDevise, totalWeight, null);
231
            return new TotalPanel(items, totalHT, totalTVA, totalTTC, totalRemise, totalPORT, totalService, totalSupply, totalDevise, totalWeight, null);
217
        } else if (id.startsWith("T_")) {
232
        } else if (id.startsWith("T_")) {
218
            return new DeviseField();
233
            return new DeviseField();
219
        } else if (id.equals("REMISE_HT") || id.equals("PORT_HT")) {
234
        } else if (id.equals("REMISE_HT") || id.equals("PORT_HT")) {
220
            return new DeviseField();
235
            return new DeviseField();
221
        } else if (id.equals("sales.invoice.partial.amount")) {
236
        } else if (id.equals("sales.invoice.partial.amount")) {
222
            return new AcompteField();
237
            return new AcompteField();
223
        }
238
        }
224
        return super.createEditor(id);
239
        return super.createEditor(id);
225
    }
240
    }
226
 
241
 
227
    private final SQLTable tableNum = getElement().getTable().getTable("NUMEROTATION_AUTO");
242
    private final SQLTable tableNum = getElement().getTable().getTable("NUMEROTATION_AUTO");
228
 
243
 
229
    @Override
244
    @Override
230
    public int insert(SQLRow order) {
245
    public int insert(SQLRow order) {
231
 
246
 
232
        int idSaisieVF = SQLRow.NONEXISTANT_ID;
247
        int idSaisieVF = SQLRow.NONEXISTANT_ID;
233
 
248
 
234
        if (this.numberField.checkValidation()) {
249
        if (this.numberField.checkValidation()) {
235
 
250
 
236
            idSaisieVF = super.insert(order);
251
            idSaisieVF = super.insert(order);
237
            SQLRow rowFacture = getTable().getRow(idSaisieVF);
252
            SQLRow rowFacture = getTable().getRow(idSaisieVF);
238
            // incrémentation du numéro auto
253
            // incrémentation du numéro auto
239
            if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime()).equalsIgnoreCase(this.numberField.getText().trim())) {
254
            if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime()).equalsIgnoreCase(this.numberField.getText().trim())) {
240
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
255
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
241
 
256
 
242
                String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
257
                String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
243
                int val = this.tableNum.getRow(2).getInt(labelNumberFor);
258
                int val = this.tableNum.getRow(2).getInt(labelNumberFor);
244
                val++;
259
                val++;
245
                rowVals.put(labelNumberFor, Integer.valueOf(val));
260
                rowVals.put(labelNumberFor, Integer.valueOf(val));
246
                try {
261
                try {
247
                    rowVals.update(2);
262
                    rowVals.update(2);
248
                } catch (SQLException e1) {
263
                } catch (SQLException e1) {
249
                    e1.printStackTrace();
264
                    e1.printStackTrace();
250
                }
265
                }
251
 
266
 
252
                ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
267
                ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
253
 
268
 
254
                new GenerationMvtSaisieVenteFacture(idSaisieVF);
269
                new GenerationMvtSaisieVenteFacture(idSaisieVF);
255
 
270
 
256
                try {
271
                try {
257
                    VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowFacture);
272
                    VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(rowFacture);
258
                    sheet.createDocument();
273
                    sheet.createDocument();
259
                    sheet.showPrintAndExport(true, false, false);
274
                    sheet.showPrintAndExport(true, false, false);
260
                } catch (Exception e) {
275
                } catch (Exception e) {
261
                    ExceptionHandler.handle("Une erreur est survenue lors de la création du document.", e);
276
                    ExceptionHandler.handle("Une erreur est survenue lors de la création du document.", e);
262
                }
277
                }
263
 
278
 
264
            }
279
            }
265
        } else {
280
        } else {
266
            ExceptionHandler.handle("Impossible d'ajouter, numéro de facture existant.");
281
            ExceptionHandler.handle("Impossible d'ajouter, numéro de facture existant.");
267
            Object root = SwingUtilities.getRoot(this);
282
            Object root = SwingUtilities.getRoot(this);
268
            if (root instanceof EditFrame) {
283
            if (root instanceof EditFrame) {
269
                EditFrame frame = (EditFrame) root;
284
                EditFrame frame = (EditFrame) root;
270
                frame.getPanel().setAlwaysVisible(true);
285
                frame.getPanel().setAlwaysVisible(true);
271
            }
286
            }
272
        }
287
        }
273
        return idSaisieVF;
288
        return idSaisieVF;
274
    }
289
    }
275
 
290
 
276
    @Override
291
    @Override
277
    public void update() {
292
    public void update() {
278
 
293
 
279
        super.update();
294
        super.update();
280
        int id = getSelectedID();
295
        int id = getSelectedID();
281
        ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", id);
296
        ((AbstractArticleItemTable) getEditor("sales.invoice.partial.items.list")).updateField("ID_SAISIE_VENTE_FACTURE", id);
282
 
297
 
283
    }
298
    }
284
 
299
 
285
    @Override
300
    @Override
286
    protected SQLRowValues createDefaults() {
301
    protected SQLRowValues createDefaults() {
287
        SQLRowValues rowVals = new SQLRowValues(getTable());
302
        SQLRowValues rowVals = new SQLRowValues(getTable());
288
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
303
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
289
        rowVals.put("PARTIAL", Boolean.TRUE);
304
        rowVals.put("PARTIAL", Boolean.TRUE);
290
        return rowVals;
305
        return rowVals;
291
    }
306
    }
292
 
307
 
293
    @Override
308
    @Override
294
    public Component addView(JComponent comp, String id) {
309
    public Component addView(JComponent comp, String id) {
295
        if (id.equals("sales.invoice.partial.amount")) {
310
        if (id.equals("sales.invoice.partial.amount")) {
296
            return super.addView(new AcompteRowItemView((AcompteField) comp), "MONTANT_FACTURABLE,POURCENT_FACTURABLE", REQ);
311
            return super.addView(new AcompteRowItemView((AcompteField) comp), "MONTANT_FACTURABLE,POURCENT_FACTURABLE", REQ);
297
        } else {
312
        } else {
298
            return super.addView(comp, id);
313
            return super.addView(comp, id);
299
        }
314
        }
300
    }
315
    }
301
}
316
}