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.invoice.component;
|
14 |
package org.openconcerto.erp.core.sales.invoice.component;
|
15 |
|
15 |
|
16 |
import static org.openconcerto.utils.CollectionUtils.createSet;
|
16 |
import static org.openconcerto.utils.CollectionUtils.createSet;
|
17 |
|
17 |
|
18 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
18 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
19 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
19 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
20 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
20 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
21 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
21 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
22 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
22 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
23 |
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
|
23 |
import org.openconcerto.erp.core.common.ui.AbstractArticleItemTable;
|
24 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
24 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
25 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
25 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
26 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
26 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
27 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
27 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
28 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
28 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
29 |
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
|
29 |
import org.openconcerto.erp.core.finance.payment.component.ModeDeReglementSQLComponent;
|
30 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
30 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
31 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
31 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
32 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement.DoWithRow;
|
32 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement.DoWithRow;
|
33 |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
|
33 |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
|
34 |
import org.openconcerto.erp.core.sales.invoice.ui.SaisieVenteFactureItemTable;
|
34 |
import org.openconcerto.erp.core.sales.invoice.ui.SaisieVenteFactureItemTable;
|
35 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
35 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
36 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
36 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
37 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
37 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
38 |
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
|
38 |
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
|
39 |
import org.openconcerto.erp.model.BanqueModifiedListener;
|
39 |
import org.openconcerto.erp.model.BanqueModifiedListener;
|
40 |
import org.openconcerto.erp.model.ISQLCompteSelector;
|
40 |
import org.openconcerto.erp.model.ISQLCompteSelector;
|
41 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
41 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
42 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
42 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
43 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
43 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
44 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
44 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
45 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
45 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
46 |
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
|
46 |
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
|
47 |
import org.openconcerto.sql.Configuration;
|
47 |
import org.openconcerto.sql.Configuration;
|
48 |
import org.openconcerto.sql.element.ElementSQLObject;
|
48 |
import org.openconcerto.sql.element.ElementSQLObject;
|
49 |
import org.openconcerto.sql.element.SQLComponent;
|
49 |
import org.openconcerto.sql.element.SQLComponent;
|
50 |
import org.openconcerto.sql.element.SQLElement;
|
50 |
import org.openconcerto.sql.element.SQLElement;
|
51 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
51 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
52 |
import org.openconcerto.sql.model.SQLBase;
|
52 |
import org.openconcerto.sql.model.SQLBase;
|
53 |
import org.openconcerto.sql.model.SQLInjector;
|
53 |
import org.openconcerto.sql.model.SQLInjector;
|
54 |
import org.openconcerto.sql.model.SQLRow;
|
54 |
import org.openconcerto.sql.model.SQLRow;
|
55 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
55 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
56 |
import org.openconcerto.sql.model.SQLRowValues;
|
56 |
import org.openconcerto.sql.model.SQLRowValues;
|
57 |
import org.openconcerto.sql.model.SQLSelect;
|
57 |
import org.openconcerto.sql.model.SQLSelect;
|
58 |
import org.openconcerto.sql.model.SQLTable;
|
58 |
import org.openconcerto.sql.model.SQLTable;
|
59 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
59 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
60 |
import org.openconcerto.sql.model.Where;
|
60 |
import org.openconcerto.sql.model.Where;
|
61 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
61 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
62 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
62 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
63 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
63 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
64 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
64 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
65 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
65 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
66 |
import org.openconcerto.sql.users.UserManager;
|
66 |
import org.openconcerto.sql.users.UserManager;
|
- |
|
67 |
import org.openconcerto.sql.users.rights.UserRightsManager;
|
67 |
import org.openconcerto.sql.view.EditFrame;
|
68 |
import org.openconcerto.sql.view.EditFrame;
|
68 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
69 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
69 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
70 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
70 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
71 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
71 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
72 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
72 |
import org.openconcerto.ui.FormLayouter;
|
73 |
import org.openconcerto.ui.FormLayouter;
|
73 |
import org.openconcerto.ui.JDate;
|
74 |
import org.openconcerto.ui.JDate;
|
74 |
import org.openconcerto.ui.TitledSeparator;
|
75 |
import org.openconcerto.ui.TitledSeparator;
|
75 |
import org.openconcerto.ui.component.ITextArea;
|
76 |
import org.openconcerto.ui.component.ITextArea;
|
- |
|
77 |
import org.openconcerto.ui.component.InteractionMode;
|
76 |
import org.openconcerto.utils.ExceptionHandler;
|
78 |
import org.openconcerto.utils.ExceptionHandler;
|
77 |
import org.openconcerto.utils.GestionDevise;
|
79 |
import org.openconcerto.utils.GestionDevise;
|
78 |
import org.openconcerto.utils.ProductInfo;
|
- |
|
79 |
import org.openconcerto.utils.cc.IFactory;
|
80 |
import org.openconcerto.utils.cc.IFactory;
|
80 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
81 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
81 |
|
82 |
|
82 |
import java.awt.GridBagConstraints;
|
83 |
import java.awt.GridBagConstraints;
|
83 |
import java.awt.GridBagLayout;
|
84 |
import java.awt.GridBagLayout;
|
84 |
import java.awt.event.ActionEvent;
|
85 |
import java.awt.event.ActionEvent;
|
85 |
import java.awt.event.ActionListener;
|
86 |
import java.awt.event.ActionListener;
|
86 |
import java.awt.event.MouseEvent;
|
- |
|
87 |
import java.beans.PropertyChangeEvent;
|
87 |
import java.beans.PropertyChangeEvent;
|
88 |
import java.beans.PropertyChangeListener;
|
88 |
import java.beans.PropertyChangeListener;
|
89 |
import java.math.BigDecimal;
|
89 |
import java.math.BigDecimal;
|
90 |
import java.math.RoundingMode;
|
90 |
import java.math.RoundingMode;
|
91 |
import java.sql.SQLException;
|
91 |
import java.sql.SQLException;
|
92 |
import java.util.ArrayList;
|
92 |
import java.util.ArrayList;
|
93 |
import java.util.Date;
|
93 |
import java.util.Date;
|
94 |
import java.util.List;
|
94 |
import java.util.List;
|
95 |
import java.util.Map;
|
95 |
import java.util.Map;
|
96 |
|
96 |
|
97 |
import javax.swing.JCheckBox;
|
97 |
import javax.swing.JCheckBox;
|
98 |
import javax.swing.JLabel;
|
98 |
import javax.swing.JLabel;
|
99 |
import javax.swing.JOptionPane;
|
99 |
import javax.swing.JOptionPane;
|
100 |
import javax.swing.JPanel;
|
100 |
import javax.swing.JPanel;
|
101 |
import javax.swing.JScrollPane;
|
101 |
import javax.swing.JScrollPane;
|
102 |
import javax.swing.JTabbedPane;
|
102 |
import javax.swing.JTabbedPane;
|
103 |
import javax.swing.JTextField;
|
103 |
import javax.swing.JTextField;
|
104 |
import javax.swing.SwingConstants;
|
104 |
import javax.swing.SwingConstants;
|
105 |
import javax.swing.SwingUtilities;
|
105 |
import javax.swing.SwingUtilities;
|
106 |
import javax.swing.event.DocumentEvent;
|
106 |
import javax.swing.event.DocumentEvent;
|
107 |
|
107 |
|
108 |
public class SaisieVenteFactureSQLComponent extends TransfertBaseSQLComponent {
|
108 |
public class SaisieVenteFactureSQLComponent extends TransfertBaseSQLComponent {
|
109 |
private AbstractArticleItemTable tableFacture;
|
109 |
private AbstractArticleItemTable tableFacture;
|
110 |
private JLabel labelAffaire = new JLabel("Affaire");
|
110 |
private JLabel labelAffaire = new JLabel("Affaire");
|
111 |
private final JDate dateSaisie = new JDate(true);
|
111 |
private final JDate dateSaisie = new JDate(true);
|
112 |
private DeviseField textPortHT, textAcompte, textAvoirTTC, textRemiseHT, fieldTTC, textNetAPayer;
|
112 |
private DeviseField textPortHT, textAcompte, textAvoirTTC, textRemiseHT, fieldTTC, textNetAPayer;
|
113 |
private DeviseField totalTimbre, netPayer;
|
113 |
private DeviseField totalTimbre, netPayer;
|
114 |
private JTextField tauxTimbre;
|
114 |
private JTextField tauxTimbre;
|
115 |
|
115 |
|
116 |
private SQLElement factureElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
116 |
private SQLElement factureElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
117 |
private SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable();
|
117 |
private SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable();
|
118 |
public static final SQLTable TABLE_ADRESSE = Configuration.getInstance().getDirectory().getElement("ADRESSE").getTable();
|
118 |
public static final SQLTable TABLE_ADRESSE = Configuration.getInstance().getDirectory().getElement("ADRESSE").getTable();
|
119 |
private SQLTable tableClient = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT");
|
119 |
private SQLTable tableClient = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT");
|
120 |
private final SQLElement client = Configuration.getInstance().getDirectory().getElement(this.tableClient);
|
120 |
private final SQLElement client = Configuration.getInstance().getDirectory().getElement(this.tableClient);
|
121 |
private JUniqueTextField textNumeroUnique;
|
121 |
private JUniqueTextField textNumeroUnique;
|
122 |
private ElementComboBox comboClient;
|
122 |
private ElementComboBox comboClient;
|
123 |
private ISQLCompteSelector compteSel;
|
123 |
private ISQLCompteSelector compteSel;
|
124 |
private final SQLTable tableNum = this.factureElt.getTable().getBase().getTable("NUMEROTATION_AUTO");
|
124 |
private final SQLTable tableNum = this.factureElt.getTable().getBase().getTable("NUMEROTATION_AUTO");
|
125 |
private JCheckBox checkCompteServiceAuto, checkPrevisionnelle, checkComplement, checkAcompte, checkCT;
|
125 |
private JCheckBox checkCompteServiceAuto, checkPrevisionnelle, checkComplement, checkAcompte, checkCT;
|
126 |
|
126 |
|
127 |
protected PanelOOSQLComponent panelOO;
|
127 |
protected PanelOOSQLComponent panelOO;
|
128 |
private ElementComboBox selAvoir, selAffaire;
|
128 |
private ElementComboBox selAvoir, selAffaire;
|
129 |
private ElementSQLObject eltModeRegl;
|
129 |
private ElementSQLObject eltModeRegl;
|
130 |
private static final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
130 |
private static final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
131 |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
|
131 |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
|
132 |
private static final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
|
132 |
private static final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
|
133 |
private ElementComboBox contact;
|
133 |
private ElementComboBox contact;
|
134 |
private SQLRowAccessor rowSelected;
|
134 |
private SQLRowAccessor rowSelected;
|
135 |
private SQLElement eltContact = Configuration.getInstance().getDirectory().getElement("CONTACT");
|
135 |
private SQLElement eltContact = Configuration.getInstance().getDirectory().getElement("CONTACT");
|
136 |
private JTextField refClient = new JTextField();
|
136 |
private JTextField refClient = new JTextField();
|
137 |
|
137 |
|
138 |
protected TotalPanel totalTTC;
|
138 |
protected TotalPanel totalTTC;
|
139 |
private final boolean displayDpt;
|
139 |
private final boolean displayDpt;
|
140 |
private final ElementComboBox comboDpt = new ElementComboBox();
|
140 |
private final ElementComboBox comboDpt = new ElementComboBox();
|
141 |
private final boolean gestionTimbre;
|
141 |
private final boolean gestionTimbre;
|
142 |
|
142 |
|
143 |
// Type intervention
|
143 |
// Type intervention
|
144 |
private SQLTextCombo textTypeMission = new SQLTextCombo();
|
144 |
private SQLTextCombo textTypeMission = new SQLTextCombo();
|
145 |
|
145 |
|
146 |
private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
|
146 |
private PropertyChangeListener listenerModeReglDefaut = new PropertyChangeListener() {
|
147 |
public void propertyChange(PropertyChangeEvent arg0) {
|
147 |
public void propertyChange(PropertyChangeEvent arg0) {
|
148 |
int idCli = SaisieVenteFactureSQLComponent.this.comboClient.getWantedID();
|
148 |
int idCli = SaisieVenteFactureSQLComponent.this.comboClient.getWantedID();
|
149 |
if (idCli > 1) {
|
149 |
if (idCli > 1) {
|
150 |
SQLRow rowCli = SaisieVenteFactureSQLComponent.this.client.getTable().getRow(idCli);
|
150 |
SQLRow rowCli = SaisieVenteFactureSQLComponent.this.client.getTable().getRow(idCli);
|
151 |
if (!rowCli.isForeignEmpty("ID_COMMERCIAL")) {
|
151 |
if (!isFilling() && !rowCli.isForeignEmpty("ID_COMMERCIAL")) {
|
152 |
comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL"));
|
152 |
comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL"));
|
153 |
}
|
153 |
}
|
154 |
|
154 |
|
- |
|
155 |
if (rowCli.getFields().contains("ID_CATEGORIE_COMPTABLE") && rowCli.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowCli.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
- |
|
156 |
totalTTC.setCategorieComptable(rowCli.getForeign("ID_CATEGORIE_COMPTABLE"));
|
- |
|
157 |
tableFacture.setRowCatComptable(rowCli.getForeign("ID_CATEGORIE_COMPTABLE"));
|
- |
|
158 |
} else {
|
- |
|
159 |
totalTTC.setCategorieComptable(null);
|
- |
|
160 |
tableFacture.setRowCatComptable(null);
|
- |
|
161 |
}
|
- |
|
162 |
|
155 |
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) {
|
163 |
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) {
|
156 |
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
|
164 |
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
|
157 |
int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
|
165 |
int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT");
|
158 |
if (idModeRegl > 1) {
|
166 |
if (idModeRegl > 1) {
|
159 |
SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
|
167 |
SQLRow rowModeRegl = sqleltModeRegl.getTable().getRow(idModeRegl);
|
160 |
SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
|
168 |
SQLRowValues rowValsModeRegl = rowModeRegl.createUpdateRow();
|
161 |
rowValsModeRegl.clearPrimaryKeys();
|
169 |
rowValsModeRegl.clearPrimaryKeys();
|
162 |
SaisieVenteFactureSQLComponent.this.eltModeRegl.setValue(rowValsModeRegl);
|
170 |
SaisieVenteFactureSQLComponent.this.eltModeRegl.setValue(rowValsModeRegl);
|
163 |
}
|
171 |
}
|
164 |
}
|
172 |
}
|
- |
|
173 |
} else {
|
- |
|
174 |
totalTTC.setCategorieComptable(null);
|
- |
|
175 |
tableFacture.setRowCatComptable(null);
|
165 |
}
|
176 |
}
|
166 |
|
177 |
|
167 |
Where w = new Where(SaisieVenteFactureSQLComponent.this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE);
|
178 |
Where w = new Where(SaisieVenteFactureSQLComponent.this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE);
|
168 |
if (SaisieVenteFactureSQLComponent.this.comboClient.isEmpty()) {
|
179 |
if (SaisieVenteFactureSQLComponent.this.comboClient.isEmpty()) {
|
169 |
w = w.and(new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", -1));
|
180 |
w = w.and(new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", -1));
|
170 |
} else {
|
181 |
} else {
|
171 |
w = w.and(new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", idCli));
|
182 |
w = w.and(new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=", idCli));
|
172 |
}
|
183 |
}
|
173 |
if (getSelectedID() > 1) {
|
184 |
if (getSelectedID() > 1) {
|
174 |
SQLRow row = getTable().getRow(getSelectedID());
|
185 |
SQLRow row = getTable().getRow(getSelectedID());
|
175 |
w = w.or(new Where(SaisieVenteFactureSQLComponent.this.tableAvoir.getKey(), "=", row.getInt("ID_AVOIR_CLIENT")));
|
186 |
w = w.or(new Where(SaisieVenteFactureSQLComponent.this.tableAvoir.getKey(), "=", row.getInt("ID_AVOIR_CLIENT")));
|
176 |
}
|
187 |
}
|
177 |
|
188 |
|
178 |
SaisieVenteFactureSQLComponent.this.selAvoir.getRequest().setWhere(w);
|
189 |
SaisieVenteFactureSQLComponent.this.selAvoir.getRequest().setWhere(w);
|
179 |
SaisieVenteFactureSQLComponent.this.selAvoir.fillCombo();
|
190 |
SaisieVenteFactureSQLComponent.this.selAvoir.fillCombo();
|
180 |
}
|
191 |
}
|
181 |
};
|
192 |
};
|
182 |
|
193 |
|
183 |
private PropertyChangeListener changeCompteListener;
|
194 |
private PropertyChangeListener changeCompteListener;
|
184 |
private PropertyChangeListener changeClientListener;
|
195 |
private PropertyChangeListener changeClientListener;
|
185 |
private ISQLCompteSelector compteSelService;
|
196 |
private ISQLCompteSelector compteSelService;
|
186 |
private JLabel labelCompteServ;
|
197 |
private JLabel labelCompteServ;
|
187 |
private ElementComboBox comboCommercial;
|
198 |
private ElementComboBox comboCommercial, comboPoleProduit;
|
188 |
private ElementComboBox comboVerificateur = new ElementComboBox();;
|
199 |
private ElementComboBox comboVerificateur = new ElementComboBox();;
|
189 |
private SQLTable tableBanque = getTable().getTable(BanqueSQLElement.TABLENAME);
|
200 |
private SQLTable tableBanque = getTable().getTable(BanqueSQLElement.TABLENAME);
|
190 |
|
201 |
|
191 |
private final SQLRowAccessor defaultNum;
|
202 |
private final SQLRowAccessor defaultNum;
|
192 |
|
203 |
|
193 |
public SaisieVenteFactureSQLComponent(int defaultNum) {
|
204 |
public SaisieVenteFactureSQLComponent(int defaultNum) {
|
194 |
super(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE"));
|
205 |
super(Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE"));
|
195 |
this.defaultNum = this.tableNum.getRow(defaultNum);
|
206 |
this.defaultNum = this.tableNum.getRow(defaultNum);
|
196 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
207 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
197 |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
|
208 |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
|
198 |
this.gestionTimbre = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.GESTION_TIMBRE_FISCAL, false);
|
209 |
this.gestionTimbre = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.GESTION_TIMBRE_FISCAL, false);
|
199 |
}
|
210 |
}
|
200 |
|
211 |
|
201 |
public SaisieVenteFactureSQLComponent() {
|
212 |
public SaisieVenteFactureSQLComponent() {
|
202 |
this(2);
|
213 |
this(2);
|
203 |
|
214 |
|
204 |
}
|
215 |
}
|
205 |
|
216 |
|
206 |
|
217 |
|
207 |
private int previousClient = -1;
|
218 |
private int previousClient = -1;
|
208 |
private ElementComboBox comboNumAuto = null;
|
219 |
private ElementComboBox comboNumAuto = null;
|
209 |
|
220 |
|
210 |
public void addViews() {
|
221 |
public void addViews() {
|
211 |
this.setLayout(new GridBagLayout());
|
222 |
this.setLayout(new GridBagLayout());
|
212 |
|
223 |
|
213 |
if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
|
224 |
if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
|
214 |
this.addView(new JCheckBox(), "CREATE_VIRTUAL_STOCK");
|
225 |
this.addView(new JCheckBox(), "CREATE_VIRTUAL_STOCK");
|
215 |
}
|
226 |
}
|
216 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
227 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
217 |
|
228 |
|
218 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
229 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
219 |
this.comboNumAuto = new ElementComboBox();
|
230 |
this.comboNumAuto = new ElementComboBox();
|
220 |
this.addView(this.comboNumAuto, "ID_NUMEROTATION_AUTO");
|
231 |
this.addView(this.comboNumAuto, "ID_NUMEROTATION_AUTO");
|
221 |
}
|
232 |
}
|
222 |
|
233 |
|
223 |
this.checkPrevisionnelle = new JCheckBox();
|
234 |
this.checkPrevisionnelle = new JCheckBox();
|
224 |
this.checkComplement = new JCheckBox();
|
235 |
this.checkComplement = new JCheckBox();
|
225 |
this.fieldTTC = new DeviseField();
|
236 |
this.fieldTTC = new DeviseField();
|
226 |
|
237 |
|
227 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
238 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
228 |
|
239 |
|
229 |
this.textAvoirTTC = new DeviseField();
|
240 |
this.textAvoirTTC = new DeviseField();
|
230 |
this.textAcompte = new DeviseField();
|
241 |
this.textAcompte = new DeviseField();
|
231 |
|
242 |
|
232 |
// Champ Module
|
243 |
// Champ Module
|
233 |
c.gridx = 0;
|
244 |
c.gridx = 0;
|
234 |
c.gridy++;
|
245 |
c.gridy++;
|
235 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
246 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
236 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
247 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
237 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
|
248 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
|
238 |
this.add(addP, c);
|
249 |
this.add(addP, c);
|
239 |
|
250 |
|
240 |
c.gridy++;
|
251 |
c.gridy++;
|
241 |
c.gridwidth = 1;
|
252 |
c.gridwidth = 1;
|
242 |
|
253 |
|
243 |
|
- |
|
244 |
if (getTable().contains("ID_POLE_PRODUIT")) {
|
- |
|
245 |
JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
|
- |
|
246 |
labelPole.setHorizontalAlignment(SwingConstants.RIGHT);
|
- |
|
247 |
this.add(labelPole, c);
|
- |
|
248 |
c.gridx++;
|
- |
|
249 |
ElementComboBox pole = new ElementComboBox();
|
- |
|
250 |
|
- |
|
251 |
this.add(pole, c);
|
- |
|
252 |
this.addSQLObject(pole, "ID_POLE_PRODUIT");
|
- |
|
253 |
c.gridy++;
|
- |
|
254 |
c.gridwidth = 1;
|
- |
|
255 |
c.gridx = 0;
|
- |
|
256 |
}
|
- |
|
257 |
|
- |
|
258 |
/*******************************************************************************************
|
254 |
/*******************************************************************************************
|
259 |
* * RENSEIGNEMENTS
|
255 |
* * RENSEIGNEMENTS
|
260 |
******************************************************************************************/
|
256 |
******************************************************************************************/
|
261 |
// Ligne 1 : Numero de facture
|
257 |
// Ligne 1 : Numero de facture
|
262 |
JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
|
258 |
JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
|
263 |
labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
|
259 |
labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
|
264 |
c.gridx = 0;
|
260 |
c.gridx = 0;
|
265 |
c.gridy++;
|
261 |
c.gridy++;
|
266 |
c.weightx = 0;
|
262 |
c.weightx = 0;
|
267 |
this.add(labelNum, c);
|
263 |
this.add(labelNum, c);
|
268 |
|
264 |
|
269 |
this.textNumeroUnique = new JUniqueTextField(16) {
|
265 |
this.textNumeroUnique = new JUniqueTextField(16) {
|
270 |
@Override
|
266 |
@Override
|
271 |
public String getAutoRefreshNumber() {
|
267 |
public String getAutoRefreshNumber() {
|
272 |
if (getMode() == Mode.INSERTION) {
|
268 |
if (getMode() == Mode.INSERTION) {
|
273 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateSaisie.getDate(), defaultNum);
|
269 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateSaisie.getDate(), defaultNum);
|
274 |
} else {
|
270 |
} else {
|
275 |
return null;
|
271 |
return null;
|
276 |
}
|
272 |
}
|
277 |
}
|
273 |
}
|
278 |
};
|
274 |
};
|
279 |
c.gridx++;
|
275 |
c.gridx++;
|
280 |
c.weightx = 0;
|
276 |
c.weightx = 0;
|
281 |
c.fill = GridBagConstraints.NONE;
|
277 |
c.fill = GridBagConstraints.NONE;
|
282 |
DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
|
278 |
DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
|
283 |
this.add(textNumeroUnique, c);
|
279 |
this.add(textNumeroUnique, c);
|
284 |
|
280 |
|
285 |
// Date
|
281 |
// Date
|
286 |
c.gridx++;
|
282 |
c.gridx++;
|
287 |
c.weightx = 0;
|
283 |
c.weightx = 0;
|
288 |
c.fill = GridBagConstraints.HORIZONTAL;
|
284 |
c.fill = GridBagConstraints.HORIZONTAL;
|
289 |
this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);
|
285 |
this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);
|
290 |
|
286 |
|
291 |
c.gridx++;
|
287 |
c.gridx++;
|
292 |
c.weightx = 1;
|
288 |
c.weightx = 1;
|
293 |
c.fill = GridBagConstraints.NONE;
|
289 |
c.fill = GridBagConstraints.NONE;
|
294 |
|
290 |
|
295 |
// listener permettant la mise à jour du numéro de facture en fonction de la date
|
291 |
// listener permettant la mise à jour du numéro de facture en fonction de la date
|
296 |
// sélectionnée
|
292 |
// sélectionnée
|
297 |
dateSaisie.addValueListener(new PropertyChangeListener() {
|
293 |
dateSaisie.addValueListener(new PropertyChangeListener() {
|
298 |
|
294 |
|
299 |
@Override
|
295 |
@Override
|
300 |
public void propertyChange(PropertyChangeEvent evt) {
|
296 |
public void propertyChange(PropertyChangeEvent evt) {
|
301 |
if (!isFilling() && dateSaisie.getValue() != null) {
|
297 |
if (!isFilling() && dateSaisie.getValue() != null) {
|
302 |
|
298 |
|
303 |
final String nextNumero = NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue(), defaultNum);
|
299 |
final String nextNumero = NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue(), defaultNum);
|
304 |
|
300 |
|
305 |
if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) {
|
301 |
if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) {
|
306 |
|
302 |
|
307 |
int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this, "Voulez vous actualiser le numéro de la facture?", "Changement du numéro de facture",
|
303 |
int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this, "Voulez vous actualiser le numéro de la facture?", "Changement du numéro de facture",
|
308 |
JOptionPane.YES_NO_OPTION);
|
304 |
JOptionPane.YES_NO_OPTION);
|
309 |
if (answer == JOptionPane.NO_OPTION) {
|
305 |
if (answer == JOptionPane.NO_OPTION) {
|
310 |
return;
|
306 |
return;
|
311 |
}
|
307 |
}
|
312 |
}
|
308 |
}
|
313 |
|
309 |
|
314 |
textNumeroUnique.setText(nextNumero);
|
310 |
textNumeroUnique.setText(nextNumero);
|
315 |
tableFacture.setDateDevise(dateSaisie.getValue());
|
311 |
tableFacture.setDateDevise(dateSaisie.getValue());
|
316 |
}
|
312 |
}
|
317 |
}
|
313 |
}
|
318 |
});
|
314 |
});
|
319 |
this.add(dateSaisie, c);
|
315 |
this.add(dateSaisie, c);
|
320 |
|
316 |
|
321 |
// Ligne 2 : reference
|
317 |
// Ligne 2 : reference
|
322 |
c.gridx = 0;
|
318 |
c.gridx = 0;
|
323 |
c.gridwidth = 1;
|
319 |
c.gridwidth = 1;
|
324 |
c.gridy++;
|
320 |
c.gridy++;
|
325 |
c.weightx = 0;
|
321 |
c.weightx = 0;
|
326 |
c.fill = GridBagConstraints.HORIZONTAL;
|
322 |
c.fill = GridBagConstraints.HORIZONTAL;
|
327 |
|
323 |
|
328 |
JLabel labelLibelle = new JLabel(getLabelFor("NOM"));
|
324 |
JLabel labelLibelle = new JLabel(getLabelFor("NOM"));
|
329 |
labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT);
|
325 |
labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT);
|
330 |
this.add(labelLibelle, c);
|
326 |
this.add(labelLibelle, c);
|
331 |
|
327 |
|
332 |
SQLTextCombo textLibelle = new SQLTextCombo();
|
328 |
SQLTextCombo textLibelle = new SQLTextCombo();
|
333 |
c.gridx++;
|
329 |
c.gridx++;
|
334 |
c.weightx = 1;
|
330 |
c.weightx = 1;
|
335 |
c.fill = GridBagConstraints.BOTH;
|
331 |
c.fill = GridBagConstraints.BOTH;
|
336 |
this.add(textLibelle, c);
|
332 |
this.add(textLibelle, c);
|
337 |
|
333 |
|
338 |
this.addSQLObject(textLibelle, "NOM");
|
334 |
this.addSQLObject(textLibelle, "NOM");
|
339 |
c.fill = GridBagConstraints.HORIZONTAL;
|
335 |
c.fill = GridBagConstraints.HORIZONTAL;
|
340 |
this.comboCommercial = new ElementComboBox(false);
|
336 |
this.comboCommercial = new ElementComboBox(false);
|
341 |
// Commercial
|
337 |
// Commercial
|
342 |
String field;
|
- |
|
343 |
field = "ID_COMMERCIAL";
|
338 |
this.addRequiredSQLObject(this.comboCommercial, "ID_COMMERCIAL");
|
344 |
c.gridx++;
|
339 |
c.gridx++;
|
345 |
c.weightx = 0;
|
340 |
c.weightx = 0;
|
346 |
c.fill = GridBagConstraints.HORIZONTAL;
|
341 |
c.fill = GridBagConstraints.HORIZONTAL;
|
347 |
this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);
|
342 |
this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
|
348 |
|
343 |
|
349 |
c.gridx++;
|
344 |
c.gridx++;
|
350 |
c.weightx = 1;
|
345 |
c.weightx = 1;
|
351 |
c.fill = GridBagConstraints.NONE;
|
346 |
c.fill = GridBagConstraints.NONE;
|
352 |
|
347 |
|
353 |
this.add(this.comboCommercial, c);
|
348 |
this.add(this.comboCommercial, c);
|
354 |
this.addRequiredSQLObject(this.comboCommercial, field);
|
- |
|
- |
|
349 |
|
355 |
// Client
|
350 |
// Client
|
356 |
c.gridx = 0;
|
351 |
c.gridx = 0;
|
357 |
c.gridy++;
|
352 |
c.gridy++;
|
358 |
c.weightx = 0;
|
353 |
c.weightx = 0;
|
359 |
c.fill = GridBagConstraints.HORIZONTAL;
|
354 |
c.fill = GridBagConstraints.HORIZONTAL;
|
360 |
this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
|
355 |
this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
|
361 |
|
356 |
|
362 |
c.gridx++;
|
357 |
c.gridx++;
|
363 |
c.weightx = 1;
|
358 |
c.weightx = 1;
|
364 |
c.fill = GridBagConstraints.NONE;
|
359 |
c.fill = GridBagConstraints.NONE;
|
365 |
this.comboClient = new ElementComboBox();
|
360 |
this.comboClient = new ElementComboBox();
|
366 |
|
361 |
|
367 |
this.add(this.comboClient, c);
|
362 |
this.add(this.comboClient, c);
|
368 |
this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");
|
363 |
this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");
|
369 |
|
364 |
|
370 |
if (this.displayDpt) {
|
365 |
if (this.displayDpt) {
|
371 |
c.gridx++;
|
366 |
c.gridx++;
|
372 |
c.gridwidth = 1;
|
367 |
c.gridwidth = 1;
|
373 |
final JLabel labelDpt = new JLabel(getLabelFor("ID_CLIENT_DEPARTEMENT"));
|
368 |
final JLabel labelDpt = new JLabel(getLabelFor("ID_CLIENT_DEPARTEMENT"));
|
374 |
labelDpt.setHorizontalAlignment(SwingConstants.RIGHT);
|
369 |
labelDpt.setHorizontalAlignment(SwingConstants.RIGHT);
|
375 |
c.weightx = 0;
|
370 |
c.weightx = 0;
|
376 |
c.gridwidth = 1;
|
371 |
c.gridwidth = 1;
|
377 |
c.fill = GridBagConstraints.HORIZONTAL;
|
372 |
c.fill = GridBagConstraints.HORIZONTAL;
|
378 |
this.add(labelDpt, c);
|
373 |
this.add(labelDpt, c);
|
379 |
|
374 |
|
380 |
c.gridx++;
|
375 |
c.gridx++;
|
381 |
c.gridwidth = 1;
|
376 |
c.gridwidth = 1;
|
382 |
c.weightx = 0;
|
377 |
c.weightx = 0;
|
383 |
c.weighty = 0;
|
378 |
c.weighty = 0;
|
384 |
c.fill = GridBagConstraints.NONE;
|
379 |
c.fill = GridBagConstraints.NONE;
|
385 |
this.add(this.comboDpt, c);
|
380 |
this.add(this.comboDpt, c);
|
386 |
DefaultGridBagConstraints.lockMinimumSize(this.comboDpt);
|
381 |
DefaultGridBagConstraints.lockMinimumSize(this.comboDpt);
|
387 |
addSQLObject(this.comboDpt, "ID_CLIENT_DEPARTEMENT");
|
382 |
addSQLObject(this.comboDpt, "ID_CLIENT_DEPARTEMENT");
|
388 |
|
383 |
|
389 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
384 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
390 |
|
385 |
|
391 |
@Override
|
386 |
@Override
|
392 |
public void propertyChange(PropertyChangeEvent evt) {
|
387 |
public void propertyChange(PropertyChangeEvent evt) {
|
393 |
int wantedID = comboClient.getWantedID();
|
388 |
int wantedID = comboClient.getWantedID();
|
394 |
|
389 |
|
395 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
390 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
396 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
391 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
397 |
comboDpt.getRequest().setWhere(new Where(comboDpt.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", rowClient.getID()));
|
392 |
comboDpt.getRequest().setWhere(new Where(comboDpt.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", rowClient.getID()));
|
398 |
} else {
|
393 |
} else {
|
399 |
comboDpt.getRequest().setWhere(null);
|
394 |
comboDpt.getRequest().setWhere(null);
|
400 |
}
|
395 |
}
|
401 |
}
|
396 |
}
|
402 |
});
|
397 |
});
|
403 |
|
398 |
|
404 |
}
|
399 |
}
|
405 |
|
400 |
|
- |
|
401 |
if (getTable().contains("ID_POLE_PRODUIT")) {
|
- |
|
402 |
JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
|
- |
|
403 |
labelPole.setHorizontalAlignment(SwingConstants.RIGHT);
|
- |
|
404 |
c.gridx++;
|
- |
|
405 |
this.add(labelPole, c);
|
- |
|
406 |
|
- |
|
407 |
c.gridx++;
|
- |
|
408 |
this.comboPoleProduit = new ElementComboBox();
|
- |
|
409 |
this.add(this.comboPoleProduit, c);
|
- |
|
410 |
this.addSQLObject(this.comboPoleProduit, "ID_POLE_PRODUIT");
|
- |
|
411 |
DefaultGridBagConstraints.lockMinimumSize(this.comboPoleProduit);
|
- |
|
412 |
}
|
- |
|
413 |
|
406 |
if (
|
414 |
if (
|
407 |
|
415 |
|
408 |
getTable().contains("ID_ECHEANCIER_CCI")) {
|
416 |
getTable().contains("ID_ECHEANCIER_CCI")) {
|
409 |
// Echeancier
|
417 |
// Echeancier
|
410 |
c.gridy++;
|
418 |
c.gridy++;
|
411 |
c.gridx = 0;
|
419 |
c.gridx = 0;
|
412 |
c.weightx = 0;
|
420 |
c.weightx = 0;
|
413 |
c.fill = GridBagConstraints.HORIZONTAL;
|
421 |
c.fill = GridBagConstraints.HORIZONTAL;
|
414 |
this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c);
|
422 |
this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c);
|
415 |
|
423 |
|
416 |
c.gridx++;
|
424 |
c.gridx++;
|
417 |
c.weightx = 1;
|
425 |
c.weightx = 1;
|
418 |
c.fill = GridBagConstraints.NONE;
|
426 |
c.fill = GridBagConstraints.NONE;
|
419 |
final ElementComboBox echeancier = new ElementComboBox();
|
427 |
final ElementComboBox echeancier = new ElementComboBox();
|
420 |
final SQLElement contactElement = Configuration.getInstance().getDirectory().getElement("ECHEANCIER_CCI");
|
428 |
final SQLElement contactElement = Configuration.getInstance().getDirectory().getElement("ECHEANCIER_CCI");
|
421 |
echeancier.init(contactElement, contactElement.getComboRequest(true));
|
429 |
echeancier.init(contactElement, contactElement.getComboRequest(true));
|
422 |
DefaultGridBagConstraints.lockMinimumSize(echeancier);
|
430 |
DefaultGridBagConstraints.lockMinimumSize(echeancier);
|
423 |
this.addView(echeancier, "ID_ECHEANCIER_CCI");
|
431 |
this.addView(echeancier, "ID_ECHEANCIER_CCI");
|
424 |
|
432 |
|
425 |
selAffaire.addValueListener(new PropertyChangeListener() {
|
433 |
selAffaire.addValueListener(new PropertyChangeListener() {
|
426 |
|
434 |
|
427 |
@Override
|
435 |
@Override
|
428 |
public void propertyChange(PropertyChangeEvent arg0) {
|
436 |
public void propertyChange(PropertyChangeEvent arg0) {
|
429 |
// TODO Raccord de méthode auto-généré
|
437 |
// TODO Raccord de méthode auto-généré
|
430 |
if (selAffaire.getSelectedRow() != null) {
|
438 |
if (selAffaire.getSelectedRow() != null) {
|
431 |
echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"), "=", selAffaire.getSelectedRow().getID()));
|
439 |
echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"), "=", selAffaire.getSelectedRow().getID()));
|
432 |
|
440 |
|
433 |
if (!isFilling()) {
|
441 |
if (!isFilling()) {
|
434 |
SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT");
|
442 |
SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT");
|
435 |
comboCommercial.setValue(rowPole);
|
443 |
comboPoleProduit.setValue(rowPole);
|
436 |
}
|
444 |
}
|
437 |
} else {
|
445 |
} else {
|
438 |
echeancier.getRequest().setWhere(null);
|
446 |
echeancier.getRequest().setWhere(null);
|
439 |
}
|
447 |
}
|
440 |
}
|
448 |
}
|
441 |
});
|
449 |
});
|
442 |
this.add(echeancier, c);
|
450 |
this.add(echeancier, c);
|
443 |
|
451 |
|
444 |
}
|
452 |
}
|
445 |
|
453 |
|
446 |
this.comboClient.addValueListener(this.changeClientListener);
|
454 |
this.comboClient.addValueListener(this.changeClientListener);
|
447 |
|
455 |
|
448 |
// SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
456 |
// SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
449 |
// if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) {
|
457 |
// if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) {
|
450 |
|
458 |
|
451 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
459 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
452 |
final org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI addressUI = new org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI();
|
460 |
final org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI addressUI = new org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI();
|
453 |
|
461 |
|
454 |
addressUI.addToUI(this, c);
|
462 |
addressUI.addToUI(this, c);
|
455 |
|
463 |
|
456 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
464 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
457 |
|
465 |
|
458 |
@Override
|
466 |
@Override
|
459 |
public void propertyChange(PropertyChangeEvent evt) {
|
467 |
public void propertyChange(PropertyChangeEvent evt) {
|
460 |
int wantedID = comboClient.getWantedID();
|
468 |
int wantedID = comboClient.getWantedID();
|
461 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
469 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
462 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
470 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
463 |
|
471 |
|
464 |
addressUI.getComboAdrF().getRequest().setWhere(
|
472 |
addressUI.getComboAdrF().getRequest().setWhere(
|
465 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId())));
|
473 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId())));
|
466 |
addressUI.getComboAdrL().getRequest().setWhere(
|
474 |
addressUI.getComboAdrL().getRequest().setWhere(
|
467 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId())));
|
475 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId())));
|
468 |
} else {
|
476 |
} else {
|
469 |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE);
|
477 |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE);
|
470 |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
|
478 |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
|
471 |
}
|
479 |
}
|
472 |
}
|
480 |
}
|
473 |
});
|
481 |
});
|
474 |
// }
|
482 |
// }
|
475 |
// Contact
|
483 |
// Contact
|
476 |
this.contact = new ElementComboBox() {
|
484 |
this.contact = new ElementComboBox() {
|
477 |
@Override
|
485 |
@Override
|
478 |
protected SQLComponent createSQLComponent(EditMode mode) {
|
486 |
protected SQLComponent createSQLComponent(EditMode mode) {
|
479 |
final SQLComponent c = super.createSQLComponent(mode);
|
487 |
final SQLComponent c = super.createSQLComponent(mode);
|
480 |
if (mode.equals(EditMode.CREATION)) {
|
488 |
if (mode.equals(EditMode.CREATION)) {
|
481 |
c.setDefaultsFactory(new IFactory<SQLRowValues>() {
|
489 |
c.setDefaultsFactory(new IFactory<SQLRowValues>() {
|
482 |
|
490 |
|
483 |
@Override
|
491 |
@Override
|
484 |
public SQLRowValues createChecked() {
|
492 |
public SQLRowValues createChecked() {
|
485 |
final SQLRowValues defaultContactRowValues = new SQLRowValues(eltContact.getTable());
|
493 |
final SQLRowValues defaultContactRowValues = new SQLRowValues(eltContact.getTable());
|
486 |
final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
|
494 |
final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
|
487 |
defaultContactRowValues.putForeignID("ID_CLIENT", row);
|
495 |
defaultContactRowValues.putForeignID("ID_CLIENT", row);
|
488 |
|
496 |
|
489 |
return defaultContactRowValues;
|
497 |
return defaultContactRowValues;
|
490 |
}
|
498 |
}
|
491 |
});
|
499 |
});
|
492 |
}
|
500 |
}
|
493 |
return c;
|
501 |
return c;
|
494 |
}
|
502 |
}
|
495 |
};
|
503 |
};
|
496 |
|
504 |
|
497 |
JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"));
|
505 |
JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"));
|
498 |
c.gridy++;
|
506 |
c.gridy++;
|
499 |
c.gridx = 0;
|
507 |
c.gridx = 0;
|
500 |
c.gridwidth = 1;
|
508 |
c.gridwidth = 1;
|
501 |
c.weightx = 0;
|
509 |
c.weightx = 0;
|
502 |
c.fill = GridBagConstraints.HORIZONTAL;
|
510 |
c.fill = GridBagConstraints.HORIZONTAL;
|
503 |
labelContact.setHorizontalAlignment(SwingConstants.RIGHT);
|
511 |
labelContact.setHorizontalAlignment(SwingConstants.RIGHT);
|
504 |
this.add(labelContact, c);
|
512 |
this.add(labelContact, c);
|
505 |
|
513 |
|
506 |
c.gridx++;
|
514 |
c.gridx++;
|
507 |
c.gridwidth = 1;
|
515 |
c.gridwidth = 1;
|
508 |
c.weightx = 1;
|
516 |
c.weightx = 1;
|
509 |
this.add(this.contact, c);
|
517 |
this.add(this.contact, c);
|
510 |
SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
|
518 |
SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
|
511 |
this.contact.init(contactElement, contactElement.getComboRequest(true));
|
519 |
this.contact.init(contactElement, contactElement.getComboRequest(true));
|
512 |
this.contact.getRequest().setWhere(Where.FALSE);
|
520 |
this.contact.getRequest().setWhere(Where.FALSE);
|
513 |
this.addSQLObject(this.contact, "ID_CONTACT");
|
521 |
this.addSQLObject(this.contact, "ID_CONTACT");
|
514 |
// }
|
522 |
// }
|
515 |
|
523 |
|
516 |
if (
|
524 |
if (
|
517 |
|
525 |
|
518 |
getTable().contains("DATE_LIVRAISON")) {
|
526 |
getTable().contains("DATE_LIVRAISON")) {
|
519 |
JLabel labelDateLiv = new JLabel("Livraison le");
|
527 |
JLabel labelDateLiv = new JLabel("Livraison le");
|
520 |
c.gridx++;
|
528 |
c.gridx++;
|
521 |
c.gridwidth = 1;
|
529 |
c.gridwidth = 1;
|
522 |
c.weightx = 0;
|
530 |
c.weightx = 0;
|
523 |
c.fill = GridBagConstraints.HORIZONTAL;
|
531 |
c.fill = GridBagConstraints.HORIZONTAL;
|
524 |
labelDateLiv.setHorizontalAlignment(SwingConstants.RIGHT);
|
532 |
labelDateLiv.setHorizontalAlignment(SwingConstants.RIGHT);
|
525 |
this.add(labelDateLiv, c);
|
533 |
this.add(labelDateLiv, c);
|
526 |
|
534 |
|
527 |
c.gridx++;
|
535 |
c.gridx++;
|
528 |
c.gridwidth = 1;
|
536 |
c.gridwidth = 1;
|
529 |
c.weightx = 0;
|
537 |
c.weightx = 0;
|
530 |
c.fill = GridBagConstraints.NONE;
|
538 |
c.fill = GridBagConstraints.NONE;
|
531 |
JDate dateLiv = new JDate();
|
539 |
JDate dateLiv = new JDate();
|
532 |
this.add(dateLiv, c);
|
540 |
this.add(dateLiv, c);
|
533 |
c.fill = GridBagConstraints.HORIZONTAL;
|
541 |
c.fill = GridBagConstraints.HORIZONTAL;
|
534 |
this.addSQLObject(dateLiv, "DATE_LIVRAISON");
|
542 |
this.addSQLObject(dateLiv, "DATE_LIVRAISON");
|
535 |
}
|
543 |
}
|
536 |
|
544 |
|
537 |
// Acompte
|
545 |
// Acompte
|
538 |
this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE"));
|
546 |
this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE"));
|
539 |
c.gridx++;
|
547 |
c.gridx++;
|
540 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
548 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
541 |
// this.add(this.checkAcompte, c);
|
549 |
// this.add(this.checkAcompte, c);
|
542 |
c.gridwidth = 1;
|
550 |
c.gridwidth = 1;
|
543 |
this.addView(this.checkAcompte, "ACOMPTE");
|
551 |
this.addView(this.checkAcompte, "ACOMPTE");
|
544 |
|
552 |
|
545 |
// Compte Service
|
553 |
// Compte Service
|
546 |
this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO"));
|
554 |
this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO"));
|
547 |
this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO");
|
555 |
this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO");
|
548 |
this.compteSelService = new ISQLCompteSelector();
|
556 |
this.compteSelService = new ISQLCompteSelector();
|
549 |
|
557 |
|
550 |
this.labelCompteServ = new JLabel("Compte Service");
|
558 |
this.labelCompteServ = new JLabel("Compte Service");
|
551 |
c.gridy++;
|
559 |
c.gridy++;
|
552 |
c.gridx = 0;
|
560 |
c.gridx = 0;
|
553 |
c.gridwidth = 1;
|
561 |
c.gridwidth = 1;
|
554 |
c.weightx = 0;
|
562 |
c.weightx = 0;
|
555 |
this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT);
|
563 |
this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT);
|
556 |
this.add(this.labelCompteServ, c);
|
564 |
this.add(this.labelCompteServ, c);
|
557 |
|
565 |
|
558 |
c.gridx++;
|
566 |
c.gridx++;
|
559 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
567 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
560 |
c.weightx = 1;
|
568 |
c.weightx = 1;
|
561 |
this.add(this.compteSelService, c);
|
569 |
this.add(this.compteSelService, c);
|
562 |
|
570 |
|
563 |
String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService");
|
571 |
String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService");
|
564 |
Boolean bServ = Boolean.valueOf(valServ);
|
572 |
Boolean bServ = Boolean.valueOf(valServ);
|
565 |
|
573 |
|
566 |
this.checkCompteServiceAuto.addActionListener(new ActionListener() {
|
574 |
this.checkCompteServiceAuto.addActionListener(new ActionListener() {
|
567 |
@Override
|
575 |
@Override
|
568 |
public void actionPerformed(ActionEvent e) {
|
576 |
public void actionPerformed(ActionEvent e) {
|
569 |
setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected());
|
577 |
setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected());
|
570 |
}
|
578 |
}
|
571 |
});
|
579 |
});
|
572 |
|
580 |
|
573 |
// FIXME A checker si utile pour Preventec ou KD
|
581 |
// FIXME A checker si utile pour Preventec ou KD
|
574 |
setCompteServiceVisible(false);
|
582 |
setCompteServiceVisible(false);
|
575 |
setCompteServiceVisible(!(bServ != null && !bServ.booleanValue()));
|
583 |
setCompteServiceVisible(!(bServ != null && !bServ.booleanValue()));
|
576 |
|
584 |
|
577 |
|
585 |
|
578 |
final JPanel pAcompte = new JPanel();
|
586 |
final JPanel pAcompte = new JPanel();
|
579 |
final DeviseField textAcompteHT = new DeviseField();
|
587 |
final DeviseField textAcompteHT = new DeviseField();
|
580 |
pAcompte.add(new JLabel("Acompte HT"));
|
588 |
pAcompte.add(new JLabel("Acompte HT"));
|
581 |
pAcompte.add(textAcompteHT);
|
589 |
pAcompte.add(textAcompteHT);
|
582 |
|
590 |
|
583 |
pAcompte.add(new JLabel("soit"));
|
591 |
pAcompte.add(new JLabel("soit"));
|
584 |
final JTextField textAcompte = new JTextField(5);
|
592 |
final JTextField textAcompte = new JTextField(5);
|
585 |
pAcompte.add(textAcompte);
|
593 |
pAcompte.add(textAcompte);
|
586 |
pAcompte.add(new JLabel("%"));
|
594 |
pAcompte.add(new JLabel("%"));
|
587 |
c.gridx = 0;
|
595 |
c.gridx = 0;
|
588 |
c.gridy++;
|
596 |
c.gridy++;
|
589 |
c.anchor = GridBagConstraints.EAST;
|
597 |
c.anchor = GridBagConstraints.EAST;
|
590 |
c.fill = GridBagConstraints.NONE;
|
598 |
c.fill = GridBagConstraints.NONE;
|
591 |
this.add(pAcompte, c);
|
599 |
this.add(pAcompte, c);
|
592 |
c.anchor = GridBagConstraints.WEST;
|
600 |
c.anchor = GridBagConstraints.WEST;
|
593 |
this.addView(textAcompte, "POURCENT_ACOMPTE");
|
601 |
this.addView(textAcompte, "POURCENT_ACOMPTE");
|
594 |
|
602 |
|
595 |
pAcompte.setVisible(false);
|
603 |
pAcompte.setVisible(false);
|
596 |
|
604 |
|
597 |
/*******************************************************************************************
|
605 |
/*******************************************************************************************
|
598 |
* * DETAILS
|
606 |
* * DETAILS
|
599 |
******************************************************************************************/
|
607 |
******************************************************************************************/
|
600 |
this.tableFacture = new SaisieVenteFactureItemTable();
|
608 |
this.tableFacture = new SaisieVenteFactureItemTable();
|
601 |
|
609 |
|
602 |
final ElementComboBox boxTarif = new ElementComboBox();
|
610 |
final ElementComboBox boxTarif = new ElementComboBox();
|
603 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
611 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
604 |
// TARIF
|
612 |
// TARIF
|
605 |
c.gridy++;
|
613 |
c.gridy++;
|
606 |
c.gridx = 0;
|
614 |
c.gridx = 0;
|
607 |
c.weightx = 0;
|
615 |
c.weightx = 0;
|
608 |
c.weighty = 0;
|
616 |
c.weighty = 0;
|
609 |
c.gridwidth = 1;
|
617 |
c.gridwidth = 1;
|
610 |
c.fill = GridBagConstraints.HORIZONTAL;
|
618 |
c.fill = GridBagConstraints.HORIZONTAL;
|
611 |
this.add(new JLabel(getLabelFor("ID_TARIF"), SwingConstants.RIGHT), c);
|
619 |
this.add(new JLabel(getLabelFor("ID_TARIF"), SwingConstants.RIGHT), c);
|
612 |
c.gridx++;
|
620 |
c.gridx++;
|
613 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
621 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
614 |
c.fill = GridBagConstraints.NONE;
|
622 |
c.fill = GridBagConstraints.NONE;
|
615 |
c.weightx = 1;
|
623 |
c.weightx = 1;
|
616 |
DefaultGridBagConstraints.lockMinimumSize(boxTarif);
|
624 |
DefaultGridBagConstraints.lockMinimumSize(boxTarif);
|
617 |
this.add(boxTarif, c);
|
625 |
this.add(boxTarif, c);
|
618 |
this.addView(boxTarif, "ID_TARIF");
|
626 |
this.addView(boxTarif, "ID_TARIF");
|
619 |
boxTarif.addModelListener("wantedID", new PropertyChangeListener() {
|
627 |
boxTarif.addModelListener("wantedID", new PropertyChangeListener() {
|
620 |
|
628 |
|
621 |
@Override
|
629 |
@Override
|
622 |
public void propertyChange(PropertyChangeEvent evt) {
|
630 |
public void propertyChange(PropertyChangeEvent evt) {
|
623 |
SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
|
631 |
SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
|
624 |
tableFacture.setTarif(selectedRow, !isFilling());
|
632 |
tableFacture.setTarif(selectedRow, !isFilling());
|
625 |
}
|
633 |
}
|
626 |
});
|
634 |
});
|
627 |
}
|
635 |
}
|
628 |
if (this.getTable().getFieldsName().contains("ACOMPTE_COMMANDE")) {
|
636 |
if (this.getTable().getFieldsName().contains("ACOMPTE_COMMANDE")) {
|
629 |
// ACOMPTE
|
637 |
// ACOMPTE
|
630 |
c.gridy += (this.getTable().getFieldsName().contains("ID_TARIF") ? 0 : 1);
|
638 |
c.gridy += (this.getTable().getFieldsName().contains("ID_TARIF") ? 0 : 1);
|
631 |
c.gridx += (this.getTable().getFieldsName().contains("ID_TARIF") ? 1 : 2);
|
639 |
c.gridx += (this.getTable().getFieldsName().contains("ID_TARIF") ? 1 : 2);
|
632 |
c.weightx = 0;
|
640 |
c.weightx = 0;
|
633 |
c.weighty = 0;
|
641 |
c.weighty = 0;
|
634 |
c.gridwidth = 1;
|
642 |
c.gridwidth = 1;
|
635 |
c.fill = GridBagConstraints.HORIZONTAL;
|
643 |
c.fill = GridBagConstraints.HORIZONTAL;
|
636 |
this.add(new JLabel(getLabelFor("ACOMPTE_COMMANDE"), SwingConstants.RIGHT), c);
|
644 |
this.add(new JLabel(getLabelFor("ACOMPTE_COMMANDE"), SwingConstants.RIGHT), c);
|
637 |
c.gridx++;
|
645 |
c.gridx++;
|
638 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
646 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
639 |
c.fill = GridBagConstraints.NONE;
|
647 |
c.fill = GridBagConstraints.NONE;
|
640 |
c.weightx = 1;
|
648 |
c.weightx = 1;
|
641 |
JTextField acompteCmd = new JTextField(15);
|
649 |
JTextField acompteCmd = new JTextField(15);
|
642 |
DefaultGridBagConstraints.lockMinimumSize(acompteCmd);
|
650 |
DefaultGridBagConstraints.lockMinimumSize(acompteCmd);
|
643 |
this.add(acompteCmd, c);
|
651 |
this.add(acompteCmd, c);
|
644 |
this.addView(acompteCmd, "ACOMPTE_COMMANDE");
|
652 |
this.addView(acompteCmd, "ACOMPTE_COMMANDE");
|
645 |
}
|
653 |
}
|
646 |
|
654 |
|
647 |
c.gridy++;
|
655 |
c.gridy++;
|
648 |
c.gridx = 0;
|
656 |
c.gridx = 0;
|
649 |
c.weightx = 1;
|
657 |
c.weightx = 1;
|
650 |
c.weighty = 1;
|
658 |
c.weighty = 1;
|
651 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
659 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
652 |
c.fill = GridBagConstraints.BOTH;
|
660 |
c.fill = GridBagConstraints.BOTH;
|
653 |
|
661 |
|
654 |
ITextArea infos = new ITextArea(4, 4);
|
662 |
ITextArea infos = new ITextArea(4, 4);
|
655 |
this.add(this.tableFacture, c);
|
663 |
this.add(this.tableFacture, c);
|
656 |
|
664 |
|
657 |
// FIXME
|
665 |
// FIXME
|
658 |
this.addView(this.tableFacture.getRowValuesTable(), "");
|
666 |
this.addView(this.tableFacture.getRowValuesTable(), "");
|
659 |
|
667 |
|
660 |
/*******************************************************************************************
|
668 |
/*******************************************************************************************
|
661 |
* * MODE DE REGLEMENT
|
669 |
* * MODE DE REGLEMENT
|
662 |
******************************************************************************************/
|
670 |
******************************************************************************************/
|
663 |
JPanel panelBottom = new JPanel(new GridBagLayout());
|
671 |
JPanel panelBottom = new JPanel(new GridBagLayout());
|
664 |
GridBagConstraints cBottom = new DefaultGridBagConstraints();
|
672 |
GridBagConstraints cBottom = new DefaultGridBagConstraints();
|
665 |
cBottom.weightx = 1;
|
673 |
cBottom.weightx = 1;
|
666 |
cBottom.anchor = GridBagConstraints.NORTHWEST;
|
674 |
cBottom.anchor = GridBagConstraints.NORTHWEST;
|
667 |
// Mode de règlement
|
675 |
// Mode de règlement
|
668 |
this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
|
676 |
this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
|
669 |
this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
|
677 |
this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
|
670 |
panelBottom.add(this.eltModeRegl, cBottom);
|
678 |
panelBottom.add(this.eltModeRegl, cBottom);
|
671 |
|
679 |
|
672 |
/*******************************************************************************************
|
680 |
/*******************************************************************************************
|
673 |
* * FRAIS DE PORT ET REMISE
|
681 |
* * FRAIS DE PORT ET REMISE
|
674 |
******************************************************************************************/
|
682 |
******************************************************************************************/
|
675 |
JPanel panelFrais = new JPanel();
|
683 |
JPanel panelFrais = new JPanel();
|
676 |
panelFrais.setLayout(new GridBagLayout());
|
684 |
panelFrais.setLayout(new GridBagLayout());
|
677 |
|
685 |
|
678 |
final GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
686 |
final GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
679 |
|
687 |
|
680 |
this.textPortHT = new DeviseField(5);
|
688 |
this.textPortHT = new DeviseField(5);
|
681 |
DefaultGridBagConstraints.lockMinimumSize(textPortHT);
|
689 |
DefaultGridBagConstraints.lockMinimumSize(textPortHT);
|
682 |
addSQLObject(this.textPortHT, "PORT_HT");
|
690 |
addSQLObject(this.textPortHT, "PORT_HT");
|
683 |
this.textRemiseHT = new DeviseField(5);
|
691 |
this.textRemiseHT = new DeviseField(5);
|
684 |
DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
|
692 |
DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
|
685 |
addSQLObject(this.textRemiseHT, "REMISE_HT");
|
693 |
addSQLObject(this.textRemiseHT, "REMISE_HT");
|
686 |
|
694 |
|
687 |
// Frais de port
|
695 |
// Frais de port
|
688 |
cFrais.gridheight = 1;
|
696 |
cFrais.gridheight = 1;
|
689 |
cFrais.gridx = 1;
|
697 |
cFrais.gridx = 1;
|
690 |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
|
698 |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
|
691 |
if (getTable().contains("ID_TAXE_PORT")) {
|
699 |
if (getTable().contains("ID_TAXE_PORT")) {
|
692 |
|
700 |
|
693 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
|
701 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
|
694 |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
702 |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
695 |
cFrais.gridy++;
|
703 |
cFrais.gridy++;
|
696 |
panelFrais.add(labelPortHT, cFrais);
|
704 |
panelFrais.add(labelPortHT, cFrais);
|
697 |
cFrais.gridx++;
|
705 |
cFrais.gridx++;
|
698 |
panelFrais.add(this.textPortHT, cFrais);
|
706 |
panelFrais.add(this.textPortHT, cFrais);
|
699 |
|
707 |
|
700 |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
|
708 |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
|
701 |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
709 |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
702 |
cFrais.gridx = 1;
|
710 |
cFrais.gridx = 1;
|
703 |
cFrais.gridy++;
|
711 |
cFrais.gridy++;
|
704 |
panelFrais.add(labelTaxeHT, cFrais);
|
712 |
panelFrais.add(labelTaxeHT, cFrais);
|
705 |
cFrais.gridx++;
|
713 |
cFrais.gridx++;
|
706 |
panelFrais.add(boxTaxePort, cFrais);
|
714 |
panelFrais.add(boxTaxePort, cFrais);
|
707 |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);
|
715 |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);
|
708 |
|
716 |
|
709 |
boxTaxePort.addValueListener(new PropertyChangeListener() {
|
717 |
boxTaxePort.addValueListener(new PropertyChangeListener() {
|
710 |
|
718 |
|
711 |
@Override
|
719 |
@Override
|
712 |
public void propertyChange(PropertyChangeEvent evt) {
|
720 |
public void propertyChange(PropertyChangeEvent evt) {
|
713 |
// TODO Raccord de méthode auto-généré
|
721 |
// TODO Raccord de méthode auto-généré
|
714 |
totalTTC.updateTotal();
|
722 |
totalTTC.updateTotal();
|
715 |
}
|
723 |
}
|
716 |
});
|
724 |
});
|
717 |
}
|
725 |
}
|
- |
|
726 |
final DeviseField textFraisDocHT = new DeviseField();
|
- |
|
727 |
final SQLRequestComboBox boxTaxeFraisDoc = new SQLRequestComboBox(false, 8);
|
- |
|
728 |
|
- |
|
729 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
- |
|
730 |
final boolean showFrais = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.FRAIS_DOCUMENT, false);
|
- |
|
731 |
if (showFrais) {
|
- |
|
732 |
|
- |
|
733 |
JLabel labelFraisDocHT = new JLabel(getLabelFor("FRAIS_DOCUMENT_HT"));
|
- |
|
734 |
labelFraisDocHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
- |
|
735 |
cFrais.gridx = 1;
|
- |
|
736 |
cFrais.gridy++;
|
- |
|
737 |
panelFrais.add(labelFraisDocHT, cFrais);
|
- |
|
738 |
cFrais.gridx++;
|
- |
|
739 |
panelFrais.add(textFraisDocHT, cFrais);
|
- |
|
740 |
addView(textFraisDocHT, "FRAIS_DOCUMENT_HT");
|
- |
|
741 |
|
- |
|
742 |
JLabel labelTaxeFraisDocHT = new JLabel(getLabelFor("ID_TAXE_FRAIS_DOCUMENT"));
|
- |
|
743 |
labelTaxeFraisDocHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
- |
|
744 |
cFrais.gridx = 1;
|
- |
|
745 |
cFrais.gridy++;
|
- |
|
746 |
panelFrais.add(labelTaxeFraisDocHT, cFrais);
|
- |
|
747 |
cFrais.gridx++;
|
- |
|
748 |
panelFrais.add(boxTaxeFraisDoc, cFrais);
|
- |
|
749 |
this.addView(boxTaxeFraisDoc, "ID_TAXE_FRAIS_DOCUMENT", REQ);
|
- |
|
750 |
|
- |
|
751 |
boxTaxeFraisDoc.addValueListener(new PropertyChangeListener() {
|
- |
|
752 |
|
- |
|
753 |
@Override
|
- |
|
754 |
public void propertyChange(PropertyChangeEvent evt) {
|
- |
|
755 |
totalTTC.updateTotal();
|
- |
|
756 |
}
|
- |
|
757 |
});
|
- |
|
758 |
|
- |
|
759 |
textFraisDocHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
- |
|
760 |
|
- |
|
761 |
@Override
|
- |
|
762 |
public void update(final DocumentEvent e) {
|
- |
|
763 |
totalTTC.updateTotal();
|
- |
|
764 |
}
|
- |
|
765 |
});
|
- |
|
766 |
|
- |
|
767 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
- |
|
768 |
|
- |
|
769 |
@Override
|
- |
|
770 |
public void propertyChange(PropertyChangeEvent evt) {
|
- |
|
771 |
if (!isFilling()) {
|
- |
|
772 |
final int wantedID = comboClient.getWantedID();
|
- |
|
773 |
long l = 0;
|
- |
|
774 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
- |
|
775 |
|
- |
|
776 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
- |
|
777 |
SQLRow rowFrais = rowClient.getForeign("ID_FRAIS_DOCUMENT");
|
- |
|
778 |
if (rowFrais != null && !rowFrais.isUndefined()) {
|
- |
|
779 |
l = rowFrais.getLong("MONTANT_HT");
|
- |
|
780 |
boxTaxeFraisDoc.setValue(rowFrais.getForeignID("ID_TAXE"));
|
- |
|
781 |
}
|
- |
|
782 |
textFraisDocHT.setValue(l);
|
- |
|
783 |
}
|
- |
|
784 |
}
|
- |
|
785 |
}
|
- |
|
786 |
});
|
- |
|
787 |
}
|
718 |
|
788 |
|
719 |
// Remise
|
789 |
// Remise
|
720 |
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
|
790 |
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
|
721 |
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
791 |
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
722 |
cFrais.gridy++;
|
792 |
cFrais.gridy++;
|
723 |
cFrais.gridx = 1;
|
793 |
cFrais.gridx = 1;
|
724 |
panelFrais.add(labelRemiseHT, cFrais);
|
794 |
panelFrais.add(labelRemiseHT, cFrais);
|
725 |
cFrais.gridx++;
|
795 |
cFrais.gridx++;
|
726 |
panelFrais.add(this.textRemiseHT, cFrais);
|
796 |
panelFrais.add(this.textRemiseHT, cFrais);
|
727 |
cFrais.gridy++;
|
797 |
cFrais.gridy++;
|
728 |
|
798 |
|
729 |
cBottom.gridx++;
|
799 |
cBottom.gridx++;
|
730 |
cBottom.weightx = 1;
|
800 |
cBottom.weightx = 1;
|
731 |
cBottom.anchor = GridBagConstraints.NORTHEAST;
|
801 |
cBottom.anchor = GridBagConstraints.NORTHEAST;
|
732 |
cBottom.fill = GridBagConstraints.NONE;
|
802 |
cBottom.fill = GridBagConstraints.NONE;
|
733 |
panelBottom.add(panelFrais, cBottom);
|
803 |
panelBottom.add(panelFrais, cBottom);
|
734 |
|
804 |
|
735 |
/*******************************************************************************************
|
805 |
/*******************************************************************************************
|
736 |
* * CALCUL DES TOTAUX
|
806 |
* * CALCUL DES TOTAUX
|
737 |
******************************************************************************************/
|
807 |
******************************************************************************************/
|
738 |
DeviseField fieldHT = new DeviseField();
|
808 |
DeviseField fieldHT = new DeviseField();
|
739 |
final DeviseField fieldTVA = new DeviseField();
|
809 |
final DeviseField fieldTVA = new DeviseField();
|
740 |
DeviseField fieldService = new DeviseField();
|
810 |
DeviseField fieldService = new DeviseField();
|
741 |
DeviseField fieldTHA = new DeviseField();
|
811 |
DeviseField fieldTHA = new DeviseField();
|
742 |
DeviseField fieldTEco = new DeviseField();
|
812 |
DeviseField fieldTEco = new DeviseField();
|
743 |
|
813 |
|
744 |
DeviseField fieldDevise = null;
|
814 |
DeviseField fieldDevise = null;
|
745 |
if (getTable().getFieldsName().contains("T_DEVISE")) {
|
815 |
if (getTable().getFieldsName().contains("T_DEVISE")) {
|
746 |
fieldDevise = new DeviseField();
|
816 |
fieldDevise = new DeviseField();
|
747 |
addSQLObject(fieldDevise, "T_DEVISE");
|
817 |
addSQLObject(fieldDevise, "T_DEVISE");
|
748 |
}
|
818 |
}
|
749 |
// FIXME was required but not displayed for KD
|
819 |
// FIXME was required but not displayed for KD
|
750 |
addSQLObject(fieldTHA, "T_HA");
|
820 |
addSQLObject(fieldTHA, "T_HA");
|
751 |
addSQLObject(fieldTEco, "T_ECO_CONTRIBUTION");
|
821 |
addSQLObject(fieldTEco, "T_ECO_CONTRIBUTION");
|
752 |
addRequiredSQLObject(fieldHT, "T_HT");
|
822 |
addRequiredSQLObject(fieldHT, "T_HT");
|
753 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
823 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
754 |
addRequiredSQLObject(this.fieldTTC, "T_TTC");
|
824 |
addRequiredSQLObject(this.fieldTTC, "T_TTC");
|
755 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
825 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
756 |
JTextField poids = new JTextField();
|
826 |
JTextField poids = new JTextField();
|
757 |
addSQLObject(poids, "T_POIDS");
|
827 |
addSQLObject(poids, "T_POIDS");
|
758 |
|
828 |
|
759 |
// Disable
|
829 |
// Disable
|
760 |
this.allowEditable("T_HA", false);
|
830 |
this.allowEditable("T_HA", false);
|
761 |
this.allowEditable("T_ECO_CONTRIBUTION", false);
|
831 |
this.allowEditable("T_ECO_CONTRIBUTION", false);
|
762 |
this.allowEditable("T_HT", false);
|
832 |
this.allowEditable("T_HT", false);
|
763 |
this.allowEditable("T_TVA", false);
|
833 |
this.allowEditable("T_TVA", false);
|
764 |
this.allowEditable("T_TTC", false);
|
834 |
this.allowEditable("T_TTC", false);
|
765 |
this.allowEditable("T_SERVICE", false);
|
835 |
this.allowEditable("T_SERVICE", false);
|
766 |
this.allowEditable("T_POIDS", false);
|
836 |
this.allowEditable("T_POIDS", false);
|
767 |
|
837 |
|
768 |
totalTTC = new TotalPanel(this.tableFacture, fieldTEco, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null,
|
838 |
totalTTC = new TotalPanel(this.tableFacture, fieldTEco, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null,
|
769 |
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
839 |
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
- |
|
840 |
totalTTC.setTextFraisDoc(textFraisDocHT, boxTaxeFraisDoc);
|
770 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
841 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
771 |
cBottom.gridx++;
|
842 |
cBottom.gridx++;
|
772 |
cBottom.weightx = 1;
|
843 |
cBottom.weightx = 1;
|
773 |
cBottom.anchor = GridBagConstraints.EAST;
|
844 |
cBottom.anchor = GridBagConstraints.EAST;
|
774 |
cBottom.fill = GridBagConstraints.HORIZONTAL;
|
845 |
cBottom.fill = GridBagConstraints.HORIZONTAL;
|
775 |
panelBottom.add(totalTTC, cBottom);
|
846 |
panelBottom.add(totalTTC, cBottom);
|
776 |
|
847 |
|
777 |
c.anchor = GridBagConstraints.WEST;
|
848 |
c.anchor = GridBagConstraints.WEST;
|
778 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
849 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
779 |
c.fill = GridBagConstraints.HORIZONTAL;
|
850 |
c.fill = GridBagConstraints.HORIZONTAL;
|
780 |
c.gridx = 0;
|
851 |
c.gridx = 0;
|
781 |
c.gridy++;
|
852 |
c.gridy++;
|
782 |
c.weighty = 0;
|
853 |
c.weighty = 0;
|
783 |
this.add(panelBottom, c);
|
854 |
this.add(panelBottom, c);
|
784 |
|
855 |
|
785 |
// Ligne : Timbre
|
856 |
// Ligne : Timbre
|
786 |
c.gridy++;
|
857 |
c.gridy++;
|
787 |
c.gridx = 0;
|
858 |
c.gridx = 0;
|
788 |
c.weightx = 1;
|
859 |
c.weightx = 1;
|
789 |
c.weighty = 0;
|
860 |
c.weighty = 0;
|
790 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
861 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
791 |
c.anchor = GridBagConstraints.EAST;
|
862 |
c.anchor = GridBagConstraints.EAST;
|
792 |
c.fill = GridBagConstraints.HORIZONTAL;
|
863 |
c.fill = GridBagConstraints.HORIZONTAL;
|
793 |
final JPanel timbrePanel = createTimbrePanel();
|
864 |
final JPanel timbrePanel = createTimbrePanel();
|
794 |
this.add(timbrePanel, c);
|
865 |
this.add(timbrePanel, c);
|
795 |
|
866 |
|
796 |
timbrePanel.setVisible(this.gestionTimbre);
|
867 |
timbrePanel.setVisible(this.gestionTimbre);
|
797 |
|
868 |
|
798 |
// Ligne : Avoir
|
869 |
// Ligne : Avoir
|
799 |
c.gridy++;
|
870 |
c.gridy++;
|
800 |
c.gridx = 0;
|
871 |
c.gridx = 0;
|
801 |
c.weightx = 1;
|
872 |
c.weightx = 1;
|
802 |
c.weighty = 0;
|
873 |
c.weighty = 0;
|
803 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
874 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
804 |
c.anchor = GridBagConstraints.EAST;
|
875 |
c.anchor = GridBagConstraints.EAST;
|
805 |
c.fill = GridBagConstraints.HORIZONTAL;
|
876 |
c.fill = GridBagConstraints.HORIZONTAL;
|
806 |
this.add(createPanelAvoir(), c);
|
877 |
this.add(createPanelAvoir(), c);
|
807 |
|
878 |
|
808 |
// Infos
|
879 |
// Infos
|
809 |
c.gridy++;
|
880 |
c.gridy++;
|
810 |
c.gridx = 0;
|
881 |
c.gridx = 0;
|
811 |
c.gridwidth = 4;
|
882 |
c.gridwidth = 4;
|
812 |
c.fill = GridBagConstraints.BOTH;
|
883 |
c.fill = GridBagConstraints.BOTH;
|
813 |
this.add(new TitledSeparator(getLabelFor("INFOS")), c);
|
884 |
this.add(new TitledSeparator(getLabelFor("INFOS")), c);
|
814 |
|
885 |
|
815 |
c.gridy++;
|
886 |
c.gridy++;
|
816 |
|
887 |
|
817 |
final JScrollPane comp = new JScrollPane(infos);
|
888 |
final JScrollPane comp = new JScrollPane(infos);
|
818 |
infos.setBorder(null);
|
889 |
infos.setBorder(null);
|
819 |
DefaultGridBagConstraints.lockMinimumSize(comp);
|
890 |
DefaultGridBagConstraints.lockMinimumSize(comp);
|
820 |
this.add(comp, c);
|
891 |
this.add(comp, c);
|
821 |
|
892 |
|
822 |
this.panelOO = new PanelOOSQLComponent(this);
|
893 |
this.panelOO = new PanelOOSQLComponent(this);
|
823 |
c.gridy++;
|
894 |
c.gridy++;
|
824 |
c.gridx = 0;
|
895 |
c.gridx = 0;
|
825 |
c.weightx = 1;
|
896 |
c.weightx = 1;
|
826 |
c.fill = GridBagConstraints.NONE;
|
897 |
c.fill = GridBagConstraints.NONE;
|
827 |
c.anchor = GridBagConstraints.NORTHEAST;
|
898 |
c.anchor = GridBagConstraints.NORTHEAST;
|
828 |
this.add(this.panelOO, c);
|
899 |
this.add(this.panelOO, c);
|
829 |
|
900 |
|
830 |
this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC");
|
901 |
this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC");
|
831 |
this.addSQLObject(this.textAcompte, "T_ACOMPTE");
|
902 |
this.addSQLObject(this.textAcompte, "T_ACOMPTE");
|
832 |
|
903 |
|
833 |
this.addRequiredSQLObject(dateSaisie, "DATE");
|
904 |
this.addRequiredSQLObject(dateSaisie, "DATE");
|
834 |
this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
|
905 |
this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
|
835 |
this.addSQLObject(infos, "INFOS");
|
906 |
this.addSQLObject(infos, "INFOS");
|
836 |
this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE");
|
907 |
this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE");
|
837 |
this.addSQLObject(this.checkComplement, "COMPLEMENT");
|
908 |
this.addSQLObject(this.checkComplement, "COMPLEMENT");
|
838 |
this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT");
|
909 |
this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT");
|
839 |
this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE");
|
910 |
this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE");
|
840 |
ModeDeReglementSQLComponent modeReglComp;
|
911 |
ModeDeReglementSQLComponent modeReglComp;
|
841 |
|
912 |
|
842 |
modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
|
913 |
modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
|
843 |
this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE));
|
914 |
this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE));
|
844 |
this.selAvoir.fillCombo();
|
915 |
this.selAvoir.fillCombo();
|
845 |
|
916 |
|
846 |
// Selection du compte de service
|
917 |
// Selection du compte de service
|
847 |
int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE");
|
918 |
int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE");
|
848 |
if (idCompteVenteService <= 1) {
|
919 |
if (idCompteVenteService <= 1) {
|
849 |
try {
|
920 |
try {
|
850 |
idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices");
|
921 |
idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices");
|
851 |
} catch (Exception e) {
|
922 |
} catch (Exception e) {
|
852 |
e.printStackTrace();
|
923 |
e.printStackTrace();
|
853 |
}
|
924 |
}
|
854 |
}
|
925 |
}
|
855 |
this.compteSelService.setValue(idCompteVenteService);
|
926 |
this.compteSelService.setValue(idCompteVenteService);
|
856 |
|
927 |
|
857 |
// Lock
|
928 |
// Lock
|
858 |
|
929 |
|
859 |
DefaultGridBagConstraints.lockMinimumSize(this.comboClient);
|
930 |
DefaultGridBagConstraints.lockMinimumSize(this.comboClient);
|
860 |
DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial);
|
931 |
DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial);
|
861 |
|
932 |
|
862 |
// Listeners
|
933 |
// Listeners
|
863 |
|
934 |
|
864 |
this.comboClient.addValueListener(this.listenerModeReglDefaut);
|
935 |
this.comboClient.addValueListener(this.listenerModeReglDefaut);
|
865 |
this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
936 |
this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
866 |
@Override
|
937 |
@Override
|
867 |
public void update(DocumentEvent e) {
|
938 |
public void update(DocumentEvent e) {
|
868 |
calculTimbre();
|
939 |
calculTimbre();
|
869 |
refreshText();
|
940 |
refreshText();
|
870 |
}
|
941 |
}
|
871 |
|
942 |
|
872 |
});
|
943 |
});
|
873 |
|
944 |
|
874 |
if (this.checkTaux != null) {
|
945 |
if (this.checkTaux != null) {
|
875 |
this.checkTaux.addActionListener(new ActionListener() {
|
946 |
this.checkTaux.addActionListener(new ActionListener() {
|
876 |
@Override
|
947 |
@Override
|
877 |
public void actionPerformed(ActionEvent e) {
|
948 |
public void actionPerformed(ActionEvent e) {
|
878 |
calculTimbre();
|
949 |
calculTimbre();
|
879 |
refreshText();
|
950 |
refreshText();
|
880 |
}
|
951 |
}
|
881 |
|
952 |
|
882 |
});
|
953 |
});
|
883 |
}
|
954 |
}
|
884 |
this.tauxTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
955 |
this.tauxTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
885 |
@Override
|
956 |
@Override
|
886 |
public void update(DocumentEvent e) {
|
957 |
public void update(DocumentEvent e) {
|
887 |
calculTimbre();
|
958 |
calculTimbre();
|
888 |
refreshText();
|
959 |
refreshText();
|
889 |
}
|
960 |
}
|
890 |
|
961 |
|
891 |
});
|
962 |
});
|
892 |
|
963 |
|
893 |
this.totalTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
964 |
this.totalTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
894 |
@Override
|
965 |
@Override
|
895 |
public void update(DocumentEvent e) {
|
966 |
public void update(DocumentEvent e) {
|
896 |
refreshText();
|
967 |
refreshText();
|
897 |
}
|
968 |
}
|
898 |
|
969 |
|
899 |
});
|
970 |
});
|
900 |
|
971 |
|
901 |
this.selAvoir.addValueListener(new PropertyChangeListener() {
|
972 |
this.selAvoir.addValueListener(new PropertyChangeListener() {
|
902 |
|
973 |
|
903 |
public void propertyChange(PropertyChangeEvent evt) {
|
974 |
public void propertyChange(PropertyChangeEvent evt) {
|
904 |
refreshText();
|
975 |
refreshText();
|
905 |
}
|
976 |
}
|
906 |
|
977 |
|
907 |
});
|
978 |
});
|
908 |
|
979 |
|
909 |
this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() {
|
980 |
this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() {
|
910 |
|
981 |
|
911 |
public void propertyChange(PropertyChangeEvent evt) {
|
982 |
public void propertyChange(PropertyChangeEvent evt) {
|
912 |
|
983 |
|
913 |
pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected());
|
984 |
pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected());
|
914 |
}
|
985 |
}
|
915 |
});
|
986 |
});
|
916 |
|
987 |
|
917 |
this.changeClientListener = new PropertyChangeListener() {
|
988 |
this.changeClientListener = new PropertyChangeListener() {
|
918 |
|
989 |
|
919 |
public void propertyChange(PropertyChangeEvent evt) {
|
990 |
public void propertyChange(PropertyChangeEvent evt) {
|
920 |
|
991 |
|
921 |
if (SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow() != null) {
|
992 |
if (SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow() != null) {
|
922 |
final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
|
993 |
final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
|
923 |
final int id = (row == null) ? SQLRow.NONEXISTANT_ID : row.getID();
|
994 |
final int id = (row == null) ? SQLRow.NONEXISTANT_ID : row.getID();
|
924 |
if (row != null) {
|
995 |
if (row != null) {
|
925 |
if (row.getFields().contains("ID_COMPTE_PCE_SERVICE") && compteSelService != null && !row.isForeignEmpty("ID_COMPTE_PCE_SERVICE")) {
|
996 |
if (row.getFields().contains("ID_COMPTE_PCE_SERVICE") && compteSelService != null && !row.isForeignEmpty("ID_COMPTE_PCE_SERVICE")) {
|
926 |
compteSelService.setValue(row.getForeignID("ID_COMPTE_PCE_SERVICE"));
|
997 |
compteSelService.setValue(row.getForeignID("ID_COMPTE_PCE_SERVICE"));
|
927 |
}
|
998 |
}
|
928 |
if (row.getFields().contains("ID_COMPTE_PCE_PRODUIT") && !row.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
|
999 |
if (row.getFields().contains("ID_COMPTE_PCE_PRODUIT") && !row.isForeignEmpty("ID_COMPTE_PCE_PRODUIT")) {
|
929 |
totalTTC.setDefaultCompteProduit(row.getForeign("ID_COMPTE_PCE_PRODUIT"));
|
1000 |
totalTTC.setDefaultCompteProduit(row.getForeign("ID_COMPTE_PCE_PRODUIT"));
|
930 |
}
|
1001 |
}
|
931 |
}
|
1002 |
}
|
932 |
if (row != null) {
|
1003 |
if (row != null) {
|
933 |
if (SaisieVenteFactureSQLComponent.this.contact != null) {
|
1004 |
if (SaisieVenteFactureSQLComponent.this.contact != null) {
|
934 |
Where w = new Where(SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", SQLRow.NONEXISTANT_ID);
|
1005 |
Where w = new Where(SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", SQLRow.NONEXISTANT_ID);
|
935 |
w = w.or(new Where(SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", id));
|
1006 |
w = w.or(new Where(SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", id));
|
936 |
SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w);
|
1007 |
SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w);
|
937 |
}
|
1008 |
}
|
938 |
|
1009 |
|
939 |
} else {
|
1010 |
} else {
|
940 |
|
1011 |
|
941 |
}
|
1012 |
}
|
942 |
SaisieVenteFactureSQLComponent.this.previousClient = id;
|
1013 |
SaisieVenteFactureSQLComponent.this.previousClient = id;
|
943 |
}
|
1014 |
}
|
944 |
|
1015 |
|
945 |
}
|
1016 |
}
|
946 |
};
|
1017 |
};
|
947 |
|
1018 |
|
948 |
this.changeCompteListener = new PropertyChangeListener() {
|
1019 |
this.changeCompteListener = new PropertyChangeListener() {
|
949 |
public void propertyChange(PropertyChangeEvent evt) {
|
1020 |
public void propertyChange(PropertyChangeEvent evt) {
|
950 |
SQLSelect sel = new SQLSelect(getTable().getBase());
|
1021 |
SQLSelect sel = new SQLSelect(getTable().getBase());
|
951 |
sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey());
|
1022 |
sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey());
|
952 |
Where where = new Where(SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=", SaisieVenteFactureSQLComponent.this.compteSel.getValue());
|
1023 |
Where where = new Where(SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=", SaisieVenteFactureSQLComponent.this.compteSel.getValue());
|
953 |
sel.setWhere(where);
|
1024 |
sel.setWhere(where);
|
954 |
|
1025 |
|
955 |
String req = sel.asString();
|
1026 |
String req = sel.asString();
|
956 |
List l = getTable().getBase().getDataSource().execute(req);
|
1027 |
List l = getTable().getBase().getDataSource().execute(req);
|
957 |
if (l != null) {
|
1028 |
if (l != null) {
|
958 |
if (l.size() == 1) {
|
1029 |
if (l.size() == 1) {
|
959 |
Map<String, Object> m = (Map<String, Object>) l.get(0);
|
1030 |
Map<String, Object> m = (Map<String, Object>) l.get(0);
|
960 |
Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName());
|
1031 |
Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName());
|
961 |
System.err.println("Only one value match :: " + o);
|
1032 |
System.err.println("Only one value match :: " + o);
|
962 |
if (o != null) {
|
1033 |
if (o != null) {
|
963 |
SaisieVenteFactureSQLComponent.this.comboClient.setValue(Integer.valueOf(((Number) o).intValue()));
|
1034 |
SaisieVenteFactureSQLComponent.this.comboClient.setValue(Integer.valueOf(((Number) o).intValue()));
|
964 |
}
|
1035 |
}
|
965 |
}
|
1036 |
}
|
966 |
}
|
1037 |
}
|
967 |
}
|
1038 |
}
|
968 |
};
|
1039 |
};
|
969 |
|
1040 |
|
970 |
this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
1041 |
this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
971 |
@Override
|
1042 |
@Override
|
972 |
public void update(DocumentEvent e) {
|
1043 |
public void update(DocumentEvent e) {
|
973 |
totalTTC.updateTotal();
|
1044 |
totalTTC.updateTotal();
|
974 |
}
|
1045 |
}
|
975 |
});
|
1046 |
});
|
976 |
|
1047 |
|
977 |
this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
1048 |
this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
|
978 |
@Override
|
1049 |
@Override
|
979 |
public void update(DocumentEvent e) {
|
1050 |
public void update(DocumentEvent e) {
|
980 |
totalTTC.updateTotal();
|
1051 |
totalTTC.updateTotal();
|
981 |
}
|
1052 |
}
|
982 |
});
|
1053 |
});
|
983 |
this.comboClient.addValueListener(new PropertyChangeListener() {
|
1054 |
this.comboClient.addValueListener(new PropertyChangeListener() {
|
984 |
@Override
|
1055 |
@Override
|
985 |
public void propertyChange(PropertyChangeEvent evt) {
|
1056 |
public void propertyChange(PropertyChangeEvent evt) {
|
986 |
if (SaisieVenteFactureSQLComponent.this.isFilling())
|
1057 |
if (SaisieVenteFactureSQLComponent.this.isFilling())
|
987 |
return;
|
1058 |
return;
|
988 |
final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow();
|
1059 |
final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow();
|
989 |
if (row != null) {
|
1060 |
if (row != null) {
|
990 |
if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) {
|
1061 |
if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) {
|
991 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
1062 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
992 |
if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())) {
|
1063 |
if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())) {
|
993 |
boxTarif.setValue(foreignRow.getID());
|
1064 |
boxTarif.setValue(foreignRow.getID());
|
994 |
} else {
|
1065 |
} else {
|
995 |
boxTarif.setValue(foreignRow);
|
1066 |
boxTarif.setValue(foreignRow);
|
996 |
}
|
1067 |
}
|
997 |
|
1068 |
|
998 |
}
|
1069 |
}
|
999 |
|
1070 |
|
1000 |
int idCpt = row.getInt("ID_COMPTE_PCE");
|
1071 |
int idCpt = row.getInt("ID_COMPTE_PCE");
|
1001 |
|
1072 |
|
1002 |
if (idCpt <= 1) {
|
1073 |
if (idCpt <= 1) {
|
1003 |
// Select Compte client par defaut
|
1074 |
// Select Compte client par defaut
|
1004 |
idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
|
1075 |
idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
|
1005 |
if (idCpt <= 1) {
|
1076 |
if (idCpt <= 1) {
|
1006 |
try {
|
1077 |
try {
|
1007 |
idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients");
|
1078 |
idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients");
|
1008 |
} catch (Exception e) {
|
1079 |
} catch (Exception e) {
|
1009 |
e.printStackTrace();
|
1080 |
e.printStackTrace();
|
1010 |
}
|
1081 |
}
|
1011 |
}
|
1082 |
}
|
1012 |
}
|
1083 |
}
|
1013 |
if (SaisieVenteFactureSQLComponent.this.compteSel != null) {
|
1084 |
if (SaisieVenteFactureSQLComponent.this.compteSel != null) {
|
1014 |
Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue();
|
1085 |
Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue();
|
1015 |
if (i == null || i.intValue() != idCpt) {
|
1086 |
if (i == null || i.intValue() != idCpt) {
|
1016 |
SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt);
|
1087 |
SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt);
|
1017 |
}
|
1088 |
}
|
1018 |
}
|
1089 |
}
|
1019 |
}
|
1090 |
}
|
1020 |
|
1091 |
|
1021 |
}
|
1092 |
}
|
1022 |
});
|
1093 |
});
|
1023 |
|
1094 |
|
1024 |
}
|
1095 |
}
|
1025 |
|
1096 |
|
1026 |
private void calculTimbre() {
|
1097 |
private void calculTimbre() {
|
1027 |
totalTimbre.setValue(0L);
|
1098 |
totalTimbre.setValue(0L);
|
1028 |
if (gestionTimbre && this.checkTaux != null && this.checkTaux.isSelected()) {
|
1099 |
if (gestionTimbre && this.checkTaux != null && this.checkTaux.isSelected()) {
|
1029 |
if (tauxTimbre.getText().trim().length() != 0) {
|
1100 |
if (tauxTimbre.getText().trim().length() != 0) {
|
1030 |
BigDecimal taux = new BigDecimal(tauxTimbre.getText());
|
1101 |
BigDecimal taux = new BigDecimal(tauxTimbre.getText());
|
1031 |
Long ttc = fieldTTC.getValue();
|
1102 |
Long ttc = fieldTTC.getValue();
|
1032 |
if (ttc != null) {
|
1103 |
if (ttc != null) {
|
1033 |
long timbreValue = taux.multiply(new BigDecimal(ttc)).movePointLeft(2).setScale(0, RoundingMode.HALF_UP).longValue();
|
1104 |
long timbreValue = taux.multiply(new BigDecimal(ttc)).movePointLeft(2).setScale(0, RoundingMode.HALF_UP).longValue();
|
1034 |
totalTimbre.setValue(timbreValue);
|
1105 |
totalTimbre.setValue(timbreValue);
|
1035 |
}
|
1106 |
}
|
1036 |
}
|
1107 |
}
|
1037 |
}
|
1108 |
}
|
1038 |
}
|
1109 |
}
|
1039 |
|
1110 |
|
1040 |
private JPanel createPanelAvoir() {
|
1111 |
private JPanel createPanelAvoir() {
|
1041 |
JPanel panelAvoir = new JPanel(new GridBagLayout());
|
1112 |
JPanel panelAvoir = new JPanel(new GridBagLayout());
|
1042 |
panelAvoir.setOpaque(false);
|
1113 |
panelAvoir.setOpaque(false);
|
1043 |
GridBagConstraints cA = new DefaultGridBagConstraints();
|
1114 |
GridBagConstraints cA = new DefaultGridBagConstraints();
|
1044 |
JLabel labelAvoir = new JLabel(getLabelFor("ID_AVOIR_CLIENT"));
|
1115 |
JLabel labelAvoir = new JLabel(getLabelFor("ID_AVOIR_CLIENT"));
|
1045 |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
|
1116 |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
|
1046 |
cA.weightx = 1;
|
1117 |
cA.weightx = 1;
|
1047 |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
|
1118 |
labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
|
1048 |
panelAvoir.add(labelAvoir, cA);
|
1119 |
panelAvoir.add(labelAvoir, cA);
|
1049 |
cA.weightx = 0;
|
1120 |
cA.weightx = 0;
|
1050 |
cA.gridx++;
|
1121 |
cA.gridx++;
|
1051 |
this.selAvoir = new ElementComboBox();
|
1122 |
this.selAvoir = new ElementComboBox();
|
1052 |
this.selAvoir.setAddIconVisible(false);
|
1123 |
this.selAvoir.setAddIconVisible(false);
|
1053 |
panelAvoir.add(this.selAvoir, cA);
|
1124 |
panelAvoir.add(this.selAvoir, cA);
|
1054 |
final JLabel labelTotalAvoir = new JLabel("Total à régler");
|
1125 |
final JLabel labelTotalAvoir = new JLabel("Total à régler");
|
1055 |
this.textNetAPayer = new DeviseField();
|
1126 |
this.textNetAPayer = new DeviseField();
|
1056 |
this.textNetAPayer.setEditable(false);
|
1127 |
this.textNetAPayer.setEditable(false);
|
1057 |
cA.gridx++;
|
1128 |
cA.gridx++;
|
1058 |
cA.weightx = 0;
|
1129 |
cA.weightx = 0;
|
1059 |
panelAvoir.add(labelTotalAvoir, cA);
|
1130 |
panelAvoir.add(labelTotalAvoir, cA);
|
1060 |
cA.gridx++;
|
1131 |
cA.gridx++;
|
1061 |
cA.weightx = 0;
|
1132 |
cA.weightx = 0;
|
1062 |
panelAvoir.add(this.textNetAPayer, cA);
|
1133 |
panelAvoir.add(this.textNetAPayer, cA);
|
1063 |
addView(textNetAPayer, "NET_A_PAYER");
|
1134 |
addView(textNetAPayer, "NET_A_PAYER");
|
1064 |
this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT);
|
1135 |
this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT);
|
1065 |
|
1136 |
|
1066 |
return panelAvoir;
|
1137 |
return panelAvoir;
|
1067 |
}
|
1138 |
}
|
1068 |
|
1139 |
|
1069 |
private JCheckBox checkTaux;
|
1140 |
private JCheckBox checkTaux;
|
1070 |
|
1141 |
|
1071 |
private JPanel createTimbrePanel() {
|
1142 |
private JPanel createTimbrePanel() {
|
1072 |
JPanel panelTimbre = new JPanel(new GridBagLayout());
|
1143 |
JPanel panelTimbre = new JPanel(new GridBagLayout());
|
1073 |
panelTimbre.setOpaque(false);
|
1144 |
panelTimbre.setOpaque(false);
|
1074 |
GridBagConstraints cA = new DefaultGridBagConstraints();
|
1145 |
GridBagConstraints cA = new DefaultGridBagConstraints();
|
1075 |
this.checkTaux = new JCheckBox(getLabelFor("SOUMIS_TIMBRE_FISCAL") + " " + getLabelFor("TAUX_TIMBRE_FISCAL"));
|
1146 |
this.checkTaux = new JCheckBox(getLabelFor("SOUMIS_TIMBRE_FISCAL") + " " + getLabelFor("TAUX_TIMBRE_FISCAL"));
|
1076 |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT);
|
1147 |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT);
|
1077 |
cA.weightx = 1;
|
1148 |
cA.weightx = 1;
|
1078 |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT);
|
1149 |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT);
|
1079 |
panelTimbre.add(checkTaux, cA);
|
1150 |
panelTimbre.add(checkTaux, cA);
|
1080 |
cA.weightx = 0;
|
1151 |
cA.weightx = 0;
|
1081 |
cA.gridx++;
|
1152 |
cA.gridx++;
|
1082 |
this.tauxTimbre = new JTextField(8);
|
1153 |
this.tauxTimbre = new JTextField(8);
|
1083 |
panelTimbre.add(this.tauxTimbre, cA);
|
1154 |
panelTimbre.add(this.tauxTimbre, cA);
|
1084 |
final JLabel labelTotalTimbre = new JLabel(getLabelFor("TOTAL_TIMBRE_FISCAL"));
|
1155 |
final JLabel labelTotalTimbre = new JLabel(getLabelFor("TOTAL_TIMBRE_FISCAL"));
|
1085 |
this.totalTimbre = new DeviseField();
|
1156 |
this.totalTimbre = new DeviseField();
|
1086 |
this.totalTimbre.setEditable(false);
|
1157 |
this.totalTimbre.setEditable(false);
|
1087 |
cA.gridx++;
|
1158 |
cA.gridx++;
|
1088 |
cA.weightx = 0;
|
1159 |
cA.weightx = 0;
|
1089 |
panelTimbre.add(labelTotalTimbre, cA);
|
1160 |
panelTimbre.add(labelTotalTimbre, cA);
|
1090 |
cA.gridx++;
|
1161 |
cA.gridx++;
|
1091 |
cA.weightx = 0;
|
1162 |
cA.weightx = 0;
|
1092 |
panelTimbre.add(this.totalTimbre, cA);
|
1163 |
panelTimbre.add(this.totalTimbre, cA);
|
1093 |
this.totalTimbre.setHorizontalAlignment(SwingConstants.RIGHT);
|
1164 |
this.totalTimbre.setHorizontalAlignment(SwingConstants.RIGHT);
|
1094 |
|
1165 |
|
1095 |
this.addView(checkTaux, "SOUMIS_TIMBRE_FISCAL");
|
1166 |
this.addView(checkTaux, "SOUMIS_TIMBRE_FISCAL");
|
1096 |
this.addView(tauxTimbre, "TAUX_TIMBRE_FISCAL");
|
1167 |
this.addView(tauxTimbre, "TAUX_TIMBRE_FISCAL");
|
1097 |
this.addView(totalTimbre, "TOTAL_TIMBRE_FISCAL");
|
1168 |
this.addView(totalTimbre, "TOTAL_TIMBRE_FISCAL");
|
1098 |
return panelTimbre;
|
1169 |
return panelTimbre;
|
1099 |
}
|
1170 |
}
|
1100 |
|
1171 |
|
1101 |
private void setCompteServiceVisible(boolean b) {
|
1172 |
private void setCompteServiceVisible(boolean b) {
|
1102 |
this.compteSelService.setVisible(b);
|
1173 |
this.compteSelService.setVisible(b);
|
1103 |
this.labelCompteServ.setVisible(b);
|
1174 |
this.labelCompteServ.setVisible(b);
|
1104 |
}
|
1175 |
}
|
1105 |
|
1176 |
|
1106 |
private void refreshText() {
|
1177 |
private void refreshText() {
|
1107 |
Number n = this.fieldTTC.getValue();
|
1178 |
Number n = this.fieldTTC.getValue();
|
1108 |
long totalAvoirTTC = 0;
|
1179 |
long totalAvoirTTC = 0;
|
1109 |
long netAPayer = 0;
|
1180 |
long netAPayer = 0;
|
1110 |
long ttc = 0;
|
1181 |
long ttc = 0;
|
1111 |
if (n != null) {
|
1182 |
if (n != null) {
|
1112 |
netAPayer = n.longValue();
|
1183 |
netAPayer = n.longValue();
|
1113 |
ttc = n.longValue();
|
1184 |
ttc = n.longValue();
|
1114 |
}
|
1185 |
}
|
1115 |
|
1186 |
|
1116 |
if (this.selAvoir.getSelectedId() > 1) {
|
1187 |
if (this.selAvoir.getSelectedId() > 1) {
|
1117 |
SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable();
|
1188 |
SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable();
|
1118 |
if (n != null) {
|
1189 |
if (n != null) {
|
1119 |
SQLRow rowAvoir = tableAvoir.getRow(this.selAvoir.getSelectedId());
|
1190 |
SQLRow rowAvoir = tableAvoir.getRow(this.selAvoir.getSelectedId());
|
1120 |
long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue();
|
1191 |
long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue();
|
1121 |
totalAvoir -= ((Number) rowAvoir.getObject("MONTANT_SOLDE")).longValue();
|
1192 |
totalAvoir -= ((Number) rowAvoir.getObject("MONTANT_SOLDE")).longValue();
|
1122 |
if (getSelectedID() > 1) {
|
1193 |
if (getSelectedID() > 1) {
|
1123 |
SQLRow row = getTable().getRow(getSelectedID());
|
1194 |
SQLRow row = getTable().getRow(getSelectedID());
|
1124 |
int idAvoirOld = row.getInt("ID_AVOIR_CLIENT");
|
1195 |
int idAvoirOld = row.getInt("ID_AVOIR_CLIENT");
|
1125 |
if (idAvoirOld == rowAvoir.getID()) {
|
1196 |
if (idAvoirOld == rowAvoir.getID()) {
|
1126 |
totalAvoir += Long.valueOf(row.getObject("T_AVOIR_TTC").toString());
|
1197 |
totalAvoir += Long.valueOf(row.getObject("T_AVOIR_TTC").toString());
|
1127 |
}
|
1198 |
}
|
1128 |
}
|
1199 |
}
|
1129 |
|
1200 |
|
1130 |
long l = ttc - totalAvoir;
|
1201 |
long l = ttc - totalAvoir;
|
1131 |
if (l < 0) {
|
1202 |
if (l < 0) {
|
1132 |
l = 0;
|
1203 |
l = 0;
|
1133 |
totalAvoirTTC = ttc;
|
1204 |
totalAvoirTTC = ttc;
|
1134 |
} else {
|
1205 |
} else {
|
1135 |
totalAvoirTTC = totalAvoir;
|
1206 |
totalAvoirTTC = totalAvoir;
|
1136 |
}
|
1207 |
}
|
1137 |
netAPayer = l;
|
1208 |
netAPayer = l;
|
1138 |
}
|
1209 |
}
|
1139 |
}
|
1210 |
}
|
1140 |
if (this.gestionTimbre) {
|
1211 |
if (this.gestionTimbre) {
|
1141 |
Long timbre = this.totalTimbre.getValue();
|
1212 |
Long timbre = this.totalTimbre.getValue();
|
1142 |
if (timbre != null) {
|
1213 |
if (timbre != null) {
|
1143 |
netAPayer += timbre;
|
1214 |
netAPayer += timbre;
|
1144 |
}
|
1215 |
}
|
1145 |
}
|
1216 |
}
|
1146 |
Long acompte = this.textAcompte.getValue();
|
1217 |
Long acompte = this.textAcompte.getValue();
|
1147 |
if (acompte != null) {
|
1218 |
if (acompte != null) {
|
1148 |
netAPayer -= acompte;
|
1219 |
netAPayer -= acompte;
|
1149 |
}
|
1220 |
}
|
1150 |
this.textNetAPayer.setValue(netAPayer);
|
1221 |
this.textNetAPayer.setValue(netAPayer);
|
1151 |
this.textAvoirTTC.setValue(totalAvoirTTC);
|
1222 |
this.textAvoirTTC.setValue(totalAvoirTTC);
|
1152 |
}
|
1223 |
}
|
1153 |
|
1224 |
|
1154 |
public int insert(SQLRow order) {
|
1225 |
public int insert(SQLRow order) {
|
1155 |
return commit(order);
|
1226 |
return commit(order);
|
1156 |
}
|
1227 |
}
|
1157 |
|
1228 |
|
1158 |
private void createCompteServiceAuto(int id) throws SQLException {
|
1229 |
private void createCompteServiceAuto(int id) throws SQLException {
|
1159 |
SQLRow rowPole = this.comboCommercial.getSelectedRow();
|
1230 |
SQLRow rowPole = this.comboPoleProduit.getSelectedRow();
|
1160 |
SQLRow rowVerif = this.comboVerificateur.getSelectedRow();
|
1231 |
SQLRow rowVerif = this.comboVerificateur.getSelectedRow();
|
1161 |
String verifInitiale = getInitialesFromVerif(rowVerif);
|
1232 |
String verifInitiale = getInitialesFromVerif(rowVerif);
|
1162 |
int idCpt = ComptePCESQLElement.getId("706" + rowPole.getString("CODE") + verifInitiale, "Service " + rowPole.getString("NOM") + " " + rowVerif.getString("NOM"));
|
1233 |
int idCpt = ComptePCESQLElement.getId("706" + rowPole.getString("CODE") + verifInitiale, "Service " + rowPole.getString("NOM") + " " + rowVerif.getString("NOM"));
|
1163 |
SQLRowValues rowVals = this.getTable().getRow(id).createEmptyUpdateRow();
|
1234 |
SQLRowValues rowVals = this.getTable().getRow(id).createEmptyUpdateRow();
|
1164 |
rowVals.put("ID_COMPTE_PCE_SERVICE", idCpt);
|
1235 |
rowVals.put("ID_COMPTE_PCE_SERVICE", idCpt);
|
1165 |
rowVals.update();
|
1236 |
rowVals.update();
|
1166 |
}
|
1237 |
}
|
1167 |
|
1238 |
|
1168 |
@Override
|
1239 |
@Override
|
1169 |
public void select(SQLRowAccessor r) {
|
1240 |
public void select(SQLRowAccessor r) {
|
1170 |
|
1241 |
|
1171 |
this.panelOO.getCheckAbo().setSelected(false);
|
1242 |
this.panelOO.getCheckAbo().setSelected(false);
|
1172 |
|
1243 |
|
1173 |
boolean isPartial = false;
|
1244 |
boolean isPartial = false;
|
1174 |
if (r != null && r.getBoolean("PARTIAL") != null) {
|
1245 |
if (r != null && r.getBoolean("PARTIAL") != null) {
|
1175 |
isPartial = r.getBoolean("PARTIAL").booleanValue();
|
1246 |
isPartial = r.getBoolean("PARTIAL").booleanValue();
|
1176 |
}
|
1247 |
}
|
1177 |
|
1248 |
|
1178 |
boolean isSolde = false;
|
1249 |
boolean isSolde = false;
|
1179 |
if (r != null && r.getBoolean("SOLDE") != null) {
|
1250 |
if (r != null && r.getBoolean("SOLDE") != null) {
|
1180 |
isSolde = r.getBoolean("SOLDE").booleanValue();
|
1251 |
isSolde = r.getBoolean("SOLDE").booleanValue();
|
1181 |
}
|
1252 |
}
|
1182 |
|
1253 |
|
1183 |
if (getMode() == Mode.MODIFICATION && r != null && !r.isUndefined() && (isPartial || isSolde)) {
|
1254 |
if (getMode() == Mode.MODIFICATION && r != null && !r.isUndefined() && (isPartial || isSolde)) {
|
1184 |
throw new IllegalArgumentException("Impossible de modifier une facturation intermédiaire");
|
1255 |
throw new IllegalArgumentException("Impossible de modifier une facturation intermédiaire");
|
1185 |
}
|
1256 |
}
|
1186 |
|
1257 |
|
1187 |
if (compteSel != null) {
|
1258 |
if (compteSel != null) {
|
1188 |
this.compteSel.rmValueListener(this.changeCompteListener);
|
1259 |
this.compteSel.rmValueListener(this.changeCompteListener);
|
1189 |
}
|
1260 |
}
|
1190 |
|
1261 |
|
1191 |
this.rowSelected = r;
|
1262 |
this.rowSelected = r;
|
1192 |
if (r != null) {
|
1263 |
if (r != null) {
|
1193 |
// FIXME Mettre un droit pour autoriser la modification d'une facture lettrée ou pointée
|
1264 |
// FIXME Mettre un droit pour autoriser la modification d'une facture lettrée ou pointée
|
1194 |
if (!r.isUndefined() && r.getObject("ID_MOUVEMENT") != null && !r.isForeignEmpty("ID_MOUVEMENT")) {
|
1265 |
if (!r.isUndefined() && r.getObject("ID_MOUVEMENT") != null && !r.isForeignEmpty("ID_MOUVEMENT")) {
|
1195 |
SQLTable tableEcr = getTable().getTable("ECRITURE");
|
1266 |
SQLTable tableEcr = getTable().getTable("ECRITURE");
|
1196 |
SQLTable tableMvt = getTable().getTable("MOUVEMENT");
|
1267 |
SQLTable tableMvt = getTable().getTable("MOUVEMENT");
|
1197 |
SQLTable tablePiece = getTable().getTable("PIECE");
|
1268 |
SQLTable tablePiece = getTable().getTable("PIECE");
|
1198 |
{
|
1269 |
{
|
1199 |
SQLSelect sel = new SQLSelect();
|
1270 |
SQLSelect sel = new SQLSelect();
|
1200 |
sel.addSelect(tableEcr.getKey(), "COUNT");
|
1271 |
sel.addSelect(tableEcr.getKey(), "COUNT");
|
1201 |
int idPiece = r.getForeign("ID_MOUVEMENT").getInt("ID_PIECE");
|
1272 |
int idPiece = r.getForeign("ID_MOUVEMENT").getInt("ID_PIECE");
|
1202 |
Where w = new Where(tableMvt.getKey(), "=", tableEcr.getField("ID_MOUVEMENT"));
|
1273 |
Where w = new Where(tableMvt.getKey(), "=", tableEcr.getField("ID_MOUVEMENT"));
|
1203 |
w = w.and(new Where(tablePiece.getKey(), "=", tableMvt.getField("ID_PIECE")));
|
1274 |
w = w.and(new Where(tablePiece.getKey(), "=", tableMvt.getField("ID_PIECE")));
|
1204 |
w = w.and(new Where(tablePiece.getKey(), "=", idPiece));
|
1275 |
w = w.and(new Where(tablePiece.getKey(), "=", idPiece));
|
1205 |
w = w.and(new Where(tableEcr.getField("POINTEE"), "!=", "").or(new Where(tableEcr.getField("LETTRAGE"), "!=", "")));
|
1276 |
w = w.and(new Where(tableEcr.getField("POINTEE"), "!=", "").or(new Where(tableEcr.getField("LETTRAGE"), "!=", "")));
|
1206 |
sel.setWhere(w);
|
1277 |
sel.setWhere(w);
|
1207 |
Object o = Configuration.getInstance().getRoot().getBase().getDataSource().executeScalar(sel.asString());
|
1278 |
Object o = Configuration.getInstance().getRoot().getBase().getDataSource().executeScalar(sel.asString());
|
1208 |
if (o != null && ((Number) o).longValue() > 0) {
|
1279 |
if (o != null && ((Number) o).longValue() > 0) {
|
1209 |
SwingUtilities.invokeLater(new Runnable() {
|
1280 |
SwingUtilities.invokeLater(new Runnable() {
|
1210 |
|
1281 |
|
1211 |
@Override
|
1282 |
@Override
|
1212 |
public void run() {
|
1283 |
public void run() {
|
1213 |
JOptionPane.showMessageDialog(null, "Attention cette facture est pointée ou lettrée en comptabilité. \nToute modification écrasera ces informations comptables.");
|
1284 |
JOptionPane.showMessageDialog(null, "Attention cette facture est pointée ou lettrée en comptabilité. \nToute modification écrasera ces informations comptables.");
|
1214 |
}
|
1285 |
}
|
1215 |
});
|
1286 |
});
|
1216 |
}
|
1287 |
}
|
1217 |
}
|
1288 |
}
|
1218 |
{
|
1289 |
{
|
1219 |
SQLSelect sel = new SQLSelect();
|
1290 |
SQLSelect sel = new SQLSelect();
|
1220 |
SQLTable tableAssoc = getTable().getTable("ASSOCIATION_ANALYTIQUE");
|
1291 |
SQLTable tableAssoc = getTable().getTable("ASSOCIATION_ANALYTIQUE");
|
1221 |
sel.addSelect(tableAssoc.getKey(), "COUNT");
|
1292 |
sel.addSelect(tableAssoc.getKey(), "COUNT");
|
1222 |
int idPiece = r.getForeign("ID_MOUVEMENT").getInt("ID_PIECE");
|
1293 |
int idPiece = r.getForeign("ID_MOUVEMENT").getInt("ID_PIECE");
|
1223 |
Where w = new Where(tableMvt.getKey(), "=", tableEcr.getField("ID_MOUVEMENT"));
|
1294 |
Where w = new Where(tableMvt.getKey(), "=", tableEcr.getField("ID_MOUVEMENT"));
|
1224 |
w = w.and(new Where(tableAssoc.getField("ID_ECRITURE"), "=", tableEcr.getKey()));
|
1295 |
w = w.and(new Where(tableAssoc.getField("ID_ECRITURE"), "=", tableEcr.getKey()));
|
1225 |
w = w.and(new Where(tablePiece.getKey(), "=", tableMvt.getField("ID_PIECE")));
|
1296 |
w = w.and(new Where(tablePiece.getKey(), "=", tableMvt.getField("ID_PIECE")));
|
1226 |
w = w.and(new Where(tablePiece.getKey(), "=", idPiece));
|
1297 |
w = w.and(new Where(tablePiece.getKey(), "=", idPiece));
|
1227 |
w = w.and(new Where(tableAssoc.getField("GESTION_AUTO"), "=", Boolean.FALSE));
|
1298 |
w = w.and(new Where(tableAssoc.getField("GESTION_AUTO"), "=", Boolean.FALSE));
|
1228 |
sel.setWhere(w);
|
1299 |
sel.setWhere(w);
|
1229 |
System.err.println(sel.asString());
|
1300 |
System.err.println(sel.asString());
|
1230 |
Object o = Configuration.getInstance().getRoot().getBase().getDataSource().executeScalar(sel.asString());
|
1301 |
Object o = Configuration.getInstance().getRoot().getBase().getDataSource().executeScalar(sel.asString());
|
1231 |
if (o != null && ((Number) o).longValue() > 0) {
|
1302 |
if (o != null && ((Number) o).longValue() > 0) {
|
1232 |
SwingUtilities.invokeLater(new Runnable() {
|
1303 |
SwingUtilities.invokeLater(new Runnable() {
|
1233 |
|
1304 |
|
1234 |
@Override
|
1305 |
@Override
|
1235 |
public void run() {
|
1306 |
public void run() {
|
1236 |
JOptionPane.showMessageDialog(null,
|
1307 |
JOptionPane.showMessageDialog(null,
|
1237 |
"Attention la répartition analytique a été modifié manuellement sur cette facture. \nToute modification écrasera ces informations comptables.");
|
1308 |
"Attention la répartition analytique a été modifié manuellement sur cette facture. \nToute modification écrasera ces informations comptables.");
|
1238 |
}
|
1309 |
}
|
1239 |
});
|
1310 |
});
|
1240 |
}
|
1311 |
}
|
1241 |
}
|
1312 |
}
|
1242 |
}
|
1313 |
}
|
1243 |
}
|
1314 |
}
|
1244 |
super.select(r);
|
1315 |
super.select(r);
|
1245 |
|
1316 |
|
1246 |
if (r != null)
|
1317 |
if (r != null)
|
1247 |
|
1318 |
|
1248 |
{
|
1319 |
{
|
1249 |
// this.tableFacture.getModel().clearRows();
|
1320 |
// this.tableFacture.getModel().clearRows();
|
1250 |
// this.tableFacture.insertFrom("ID_SAISIE_VENTE_FACTURE", r.getID());
|
1321 |
// this.tableFacture.insertFrom("ID_SAISIE_VENTE_FACTURE", r.getID());
|
1251 |
Boolean b = (Boolean) r.getObject("ACOMPTE");
|
1322 |
Boolean b = (Boolean) r.getObject("ACOMPTE");
|
1252 |
if (b != null) {
|
1323 |
if (b != null) {
|
1253 |
setAcompte(b);
|
1324 |
setAcompte(b);
|
1254 |
} else {
|
1325 |
} else {
|
1255 |
setAcompte(false);
|
1326 |
setAcompte(false);
|
1256 |
}
|
1327 |
}
|
1257 |
}
|
1328 |
}
|
1258 |
|
1329 |
|
1259 |
if (this.comboClient != null) {
|
1330 |
if (this.comboClient != null) {
|
1260 |
|
1331 |
|
1261 |
this.comboClient.addValueListener(this.changeClientListener);
|
1332 |
this.comboClient.addValueListener(this.changeClientListener);
|
1262 |
}
|
1333 |
}
|
1263 |
if (this.compteSel != null) {
|
1334 |
if (this.compteSel != null) {
|
1264 |
this.compteSel.addValueListener(this.changeCompteListener);
|
1335 |
this.compteSel.addValueListener(this.changeCompteListener);
|
1265 |
} // nomClient.addValueListener(changeClientListener);
|
1336 |
} // nomClient.addValueListener(changeClientListener);
|
1266 |
}
|
1337 |
}
|
1267 |
|
1338 |
|
1268 |
private String getInitialesFromVerif(SQLRow row) {
|
1339 |
private String getInitialesFromVerif(SQLRow row) {
|
1269 |
String s = "";
|
1340 |
String s = "";
|
1270 |
|
1341 |
|
1271 |
if (row != null) {
|
1342 |
if (row != null) {
|
1272 |
String prenom = row.getString("PRENOM");
|
1343 |
String prenom = row.getString("PRENOM");
|
1273 |
if (prenom != null && prenom.length() > 0) {
|
1344 |
if (prenom != null && prenom.length() > 0) {
|
1274 |
s += prenom.toUpperCase().charAt(0);
|
1345 |
s += prenom.toUpperCase().charAt(0);
|
1275 |
}
|
1346 |
}
|
1276 |
String nom = row.getString("NOM");
|
1347 |
String nom = row.getString("NOM");
|
1277 |
if (nom != null && nom.length() > 0) {
|
1348 |
if (nom != null && nom.length() > 0) {
|
1278 |
s += nom.toUpperCase().charAt(0);
|
1349 |
s += nom.toUpperCase().charAt(0);
|
1279 |
}
|
1350 |
}
|
1280 |
}
|
1351 |
}
|
1281 |
|
1352 |
|
1282 |
return s;
|
1353 |
return s;
|
1283 |
}
|
1354 |
}
|
1284 |
|
1355 |
|
1285 |
public int commit(SQLRow order) {
|
1356 |
public int commit(SQLRow order) {
|
1286 |
|
1357 |
|
1287 |
int idSaisieVF = -1;
|
1358 |
int idSaisieVF = -1;
|
1288 |
long lFactureOld = 0;
|
1359 |
long lFactureOld = 0;
|
1289 |
SQLRow rowFactureOld = null;
|
1360 |
SQLRow rowFactureOld = null;
|
1290 |
SQLRow rowFacture = null;
|
1361 |
SQLRow rowFacture = null;
|
1291 |
int attempt = 0;
|
1362 |
int attempt = 0;
|
1292 |
// on vérifie qu'une facture de même numero n'a pas été insérée entre temps
|
1363 |
// on vérifie qu'une facture de même numero n'a pas été insérée entre temps
|
1293 |
boolean validated = this.textNumeroUnique.checkValidation(false);
|
1364 |
boolean validated = this.textNumeroUnique.checkValidation(false);
|
1294 |
while (!validated && attempt < JUniqueTextField.RETRY_COUNT) {
|
1365 |
while (!validated && attempt < JUniqueTextField.RETRY_COUNT) {
|
1295 |
try {
|
1366 |
try {
|
1296 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
1367 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
1297 |
} catch (InterruptedException e) {
|
1368 |
} catch (InterruptedException e) {
|
1298 |
e.printStackTrace();
|
1369 |
e.printStackTrace();
|
1299 |
}
|
1370 |
}
|
1300 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateSaisie.getDate(), defaultNum);
|
1371 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateSaisie.getDate(), defaultNum);
|
1301 |
this.textNumeroUnique.setText(num);
|
1372 |
this.textNumeroUnique.setText(num);
|
1302 |
validated = this.textNumeroUnique.checkValidation(false);
|
1373 |
validated = this.textNumeroUnique.checkValidation(false);
|
1303 |
System.err.println("ATTEMPT " + attempt + " WITH NUMERO " + num + " validated : " + validated);
|
1374 |
System.err.println("ATTEMPT " + attempt + " WITH NUMERO " + num + " validated : " + validated);
|
1304 |
attempt++;
|
1375 |
attempt++;
|
1305 |
}
|
1376 |
}
|
1306 |
final String num = this.textNumeroUnique.getText();
|
1377 |
final String num = this.textNumeroUnique.getText();
|
1307 |
if (!validated) {
|
1378 |
if (!validated) {
|
1308 |
idSaisieVF = getSelectedID();
|
1379 |
idSaisieVF = getSelectedID();
|
1309 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de facture existant.");
|
1380 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de facture existant.");
|
1310 |
final Object root = SwingUtilities.getRoot(this);
|
1381 |
final Object root = SwingUtilities.getRoot(this);
|
1311 |
if (root instanceof EditFrame) {
|
1382 |
if (root instanceof EditFrame) {
|
1312 |
final EditFrame frame = (EditFrame) root;
|
1383 |
final EditFrame frame = (EditFrame) root;
|
1313 |
frame.getPanel().setAlwaysVisible(true);
|
1384 |
frame.getPanel().setAlwaysVisible(true);
|
1314 |
}
|
1385 |
}
|
1315 |
} else {
|
1386 |
} else {
|
1316 |
try {
|
1387 |
try {
|
1317 |
if (getMode() == Mode.INSERTION) {
|
1388 |
if (getMode() == Mode.INSERTION) {
|
1318 |
idSaisieVF = super.insert(order);
|
1389 |
idSaisieVF = super.insert(order);
|
1319 |
rowFacture = getTable().getRow(idSaisieVF);
|
1390 |
rowFacture = getTable().getRow(idSaisieVF);
|
1320 |
// incrémentation du numéro auto
|
1391 |
// incrémentation du numéro auto
|
1321 |
final SQLRow rowNum = comboNumAuto == null ? this.tableNum.getRow(2) : comboNumAuto.getSelectedRow();
|
1392 |
final SQLRow rowNum = comboNumAuto == null ? this.tableNum.getRow(2) : comboNumAuto.getSelectedRow();
|
1322 |
if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime(), rowNum)
|
1393 |
if (NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, rowFacture.getDate("DATE").getTime(), rowNum)
|
1323 |
.equalsIgnoreCase(this.textNumeroUnique.getText().trim())) {
|
1394 |
.equalsIgnoreCase(this.textNumeroUnique.getText().trim())) {
|
1324 |
SQLRowValues rowVals = rowNum.createEmptyUpdateRow();
|
1395 |
SQLRowValues rowVals = rowNum.createEmptyUpdateRow();
|
1325 |
|
1396 |
|
1326 |
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
|
1397 |
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
|
1327 |
int val = rowNum.getInt(labelNumberFor);
|
1398 |
int val = rowNum.getInt(labelNumberFor);
|
1328 |
val++;
|
1399 |
val++;
|
1329 |
rowVals.put(labelNumberFor, Integer.valueOf(val));
|
1400 |
rowVals.put(labelNumberFor, Integer.valueOf(val));
|
1330 |
rowVals.update();
|
1401 |
rowVals.update();
|
1331 |
}
|
1402 |
}
|
1332 |
} else {
|
1403 |
} else {
|
1333 |
if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette facture, vous supprimerez les chéques et les échéances associés. Continuer?", "Modification de facture",
|
1404 |
if (JOptionPane.showConfirmDialog(this, "Attention en modifiant cette facture, vous supprimerez les chéques et les échéances associés. Continuer?", "Modification de facture",
|
1334 |
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
1405 |
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
1335 |
// On recupere l'ancien total HT
|
1406 |
// On recupere l'ancien total HT
|
1336 |
rowFactureOld = this.getTable().getRow(getSelectedID());
|
1407 |
rowFactureOld = this.getTable().getRow(getSelectedID());
|
1337 |
lFactureOld = ((Number) rowFactureOld.getObject("T_HT")).longValue();
|
1408 |
lFactureOld = ((Number) rowFactureOld.getObject("T_HT")).longValue();
|
1338 |
|
1409 |
|
1339 |
super.update();
|
1410 |
super.update();
|
1340 |
|
1411 |
|
1341 |
idSaisieVF = getSelectedID();
|
1412 |
idSaisieVF = getSelectedID();
|
1342 |
} else {
|
1413 |
} else {
|
1343 |
// Annulation par l'utilisateur
|
1414 |
// Annulation par l'utilisateur
|
1344 |
return idSaisieVF;
|
1415 |
return idSaisieVF;
|
1345 |
}
|
1416 |
}
|
1346 |
}
|
1417 |
}
|
1347 |
|
1418 |
|
1348 |
rowFacture = getTable().getRow(idSaisieVF);
|
1419 |
rowFacture = getTable().getRow(idSaisieVF);
|
1349 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
1420 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
1350 |
|
1421 |
|
1351 |
// Mise à jour des tables liées
|
1422 |
// Mise à jour des tables liées
|
1352 |
this.tableFacture.updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
|
1423 |
this.tableFacture.updateField("ID_SAISIE_VENTE_FACTURE", idSaisieVF);
|
1353 |
|
1424 |
|
1354 |
this.tableFacture.createArticle(idSaisieVF, this.getElement());
|
1425 |
this.tableFacture.createArticle(idSaisieVF, this.getElement());
|
1355 |
|
1426 |
|
1356 |
|
1427 |
|
1357 |
int idMvt = -1;
|
1428 |
int idMvt = -1;
|
1358 |
if (!this.checkPrevisionnelle.isSelected()) {
|
1429 |
if (!this.checkPrevisionnelle.isSelected()) {
|
1359 |
if (getMode() == Mode.MODIFICATION) {
|
1430 |
if (getMode() == Mode.MODIFICATION) {
|
1360 |
idMvt = rowFacture.getInt("ID_MOUVEMENT");
|
1431 |
idMvt = rowFacture.getInt("ID_MOUVEMENT");
|
1361 |
// on supprime tout ce qui est lié à la facture
|
1432 |
// on supprime tout ce qui est lié à la facture
|
1362 |
System.err.println("Archivage des fils");
|
1433 |
System.err.println("Archivage des fils");
|
1363 |
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
|
1434 |
EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE");
|
1364 |
eltEcr.archiveMouvementProfondeur(idMvt, false);
|
1435 |
eltEcr.archiveMouvementProfondeur(idMvt, false);
|
1365 |
}
|
1436 |
}
|
1366 |
|
1437 |
|
1367 |
System.err.println("Regeneration des ecritures");
|
1438 |
System.err.println("Regeneration des ecritures");
|
1368 |
if (idMvt > 1) {
|
1439 |
if (idMvt > 1) {
|
1369 |
new GenerationMvtSaisieVenteFacture(idSaisieVF, idMvt);
|
1440 |
new GenerationMvtSaisieVenteFacture(idSaisieVF, idMvt);
|
1370 |
} else {
|
1441 |
} else {
|
1371 |
new GenerationMvtSaisieVenteFacture(idSaisieVF);
|
1442 |
new GenerationMvtSaisieVenteFacture(idSaisieVF);
|
1372 |
}
|
1443 |
}
|
1373 |
System.err.println("Fin regeneration");
|
1444 |
System.err.println("Fin regeneration");
|
1374 |
|
1445 |
|
1375 |
// Mise à jour des stocks
|
1446 |
// Mise à jour des stocks
|
1376 |
|
1447 |
|
1377 |
updateStock(idSaisieVF);
|
1448 |
updateStock(idSaisieVF);
|
1378 |
|
1449 |
|
1379 |
// On retire l'avoir
|
1450 |
// On retire l'avoir
|
1380 |
if (rowFactureOld != null && rowFactureOld.getInt("ID_AVOIR_CLIENT") > 1) {
|
1451 |
if (rowFactureOld != null && rowFactureOld.getInt("ID_AVOIR_CLIENT") > 1) {
|
1381 |
|
1452 |
|
1382 |
SQLRow rowAvoir = rowFactureOld.getForeignRow("ID_AVOIR_CLIENT");
|
1453 |
SQLRow rowAvoir = rowFactureOld.getForeignRow("ID_AVOIR_CLIENT");
|
1383 |
|
1454 |
|
1384 |
Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE");
|
1455 |
Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE");
|
1385 |
Long avoirTTC = (Long) rowFactureOld.getObject("T_AVOIR_TTC");
|
1456 |
Long avoirTTC = (Long) rowFactureOld.getObject("T_AVOIR_TTC");
|
1386 |
|
1457 |
|
1387 |
long montant = montantSolde - avoirTTC;
|
1458 |
long montant = montantSolde - avoirTTC;
|
1388 |
if (montant < 0) {
|
1459 |
if (montant < 0) {
|
1389 |
montant = 0;
|
1460 |
montant = 0;
|
1390 |
}
|
1461 |
}
|
1391 |
|
1462 |
|
1392 |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
|
1463 |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
|
1393 |
|
1464 |
|
1394 |
// Soldé
|
1465 |
// Soldé
|
1395 |
rowVals.put("SOLDE", Boolean.FALSE);
|
1466 |
rowVals.put("SOLDE", Boolean.FALSE);
|
1396 |
rowVals.put("MONTANT_SOLDE", montant);
|
1467 |
rowVals.put("MONTANT_SOLDE", montant);
|
1397 |
Long restant = (Long) rowAvoir.getObject("MONTANT_TTC") - montantSolde;
|
1468 |
Long restant = (Long) rowAvoir.getObject("MONTANT_TTC") - montantSolde;
|
1398 |
rowVals.put("MONTANT_RESTANT", restant);
|
1469 |
rowVals.put("MONTANT_RESTANT", restant);
|
1399 |
|
1470 |
|
1400 |
rowVals.update();
|
1471 |
rowVals.update();
|
1401 |
|
1472 |
|
1402 |
}
|
1473 |
}
|
1403 |
|
1474 |
|
1404 |
final int idAvoir = rowFacture.getInt("ID_AVOIR_CLIENT");
|
1475 |
final int idAvoir = rowFacture.getInt("ID_AVOIR_CLIENT");
|
1405 |
// on solde l'avoir
|
1476 |
// on solde l'avoir
|
1406 |
if (idAvoir > 1) {
|
1477 |
if (idAvoir > 1) {
|
1407 |
|
1478 |
|
1408 |
SQLRow rowAvoir = rowFacture.getForeignRow("ID_AVOIR_CLIENT");
|
1479 |
SQLRow rowAvoir = rowFacture.getForeignRow("ID_AVOIR_CLIENT");
|
1409 |
|
1480 |
|
1410 |
Long montantTTC = (Long) rowAvoir.getObject("MONTANT_TTC");
|
1481 |
Long montantTTC = (Long) rowAvoir.getObject("MONTANT_TTC");
|
1411 |
Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE");
|
1482 |
Long montantSolde = (Long) rowAvoir.getObject("MONTANT_SOLDE");
|
1412 |
Long factTTC = (Long) rowFacture.getObject("T_TTC");
|
1483 |
Long factTTC = (Long) rowFacture.getObject("T_TTC");
|
1413 |
|
1484 |
|
1414 |
long restant = montantTTC - montantSolde;
|
1485 |
long restant = montantTTC - montantSolde;
|
1415 |
|
1486 |
|
1416 |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
|
1487 |
SQLRowValues rowVals = rowAvoir.createEmptyUpdateRow();
|
1417 |
final long l2 = factTTC - restant;
|
1488 |
final long l2 = factTTC - restant;
|
1418 |
// Soldé
|
1489 |
// Soldé
|
1419 |
if (l2 >= 0) {
|
1490 |
if (l2 >= 0) {
|
1420 |
rowVals.put("SOLDE", Boolean.TRUE);
|
1491 |
rowVals.put("SOLDE", Boolean.TRUE);
|
1421 |
rowVals.put("MONTANT_SOLDE", montantTTC);
|
1492 |
rowVals.put("MONTANT_SOLDE", montantTTC);
|
1422 |
rowVals.put("MONTANT_RESTANT", 0);
|
1493 |
rowVals.put("MONTANT_RESTANT", 0);
|
1423 |
} else {
|
1494 |
} else {
|
1424 |
// Il reste encore de l'argent pour l'avoir
|
1495 |
// Il reste encore de l'argent pour l'avoir
|
1425 |
final long m = montantSolde + factTTC;
|
1496 |
final long m = montantSolde + factTTC;
|
1426 |
rowVals.put("MONTANT_SOLDE", m);
|
1497 |
rowVals.put("MONTANT_SOLDE", m);
|
1427 |
rowVals.put("MONTANT_RESTANT", montantTTC - m);
|
1498 |
rowVals.put("MONTANT_RESTANT", montantTTC - m);
|
1428 |
}
|
1499 |
}
|
1429 |
|
1500 |
|
1430 |
rowVals.update();
|
1501 |
rowVals.update();
|
1431 |
|
1502 |
|
1432 |
}
|
1503 |
}
|
1433 |
|
1504 |
|
1434 |
|
1505 |
|
1435 |
if (getTable().getDBRoot().contains("ABONNEMENT") && panelOO.isCheckAboSelected()) {
|
1506 |
if (getTable().getDBRoot().contains("ABONNEMENT") && panelOO.isCheckAboSelected()) {
|
1436 |
DoWithRow doWithRow = ((SaisieVenteFactureSQLElement) getElement()).getSpecialAction("subscription.autocreate");
|
1507 |
DoWithRow doWithRow = ((SaisieVenteFactureSQLElement) getElement()).getSpecialAction("subscription.autocreate");
|
1437 |
if (doWithRow != null) {
|
1508 |
if (doWithRow != null) {
|
1438 |
doWithRow.process(rowFacture);
|
1509 |
doWithRow.process(rowFacture);
|
1439 |
}
|
1510 |
}
|
1440 |
}
|
1511 |
}
|
1441 |
createDocument(rowFacture);
|
1512 |
createDocument(rowFacture);
|
1442 |
|
1513 |
|
1443 |
}
|
1514 |
}
|
1444 |
if (attempt > 0) {
|
1515 |
if (attempt > 0) {
|
1445 |
SwingUtilities.invokeLater(new Runnable() {
|
1516 |
SwingUtilities.invokeLater(new Runnable() {
|
1446 |
public void run() {
|
1517 |
public void run() {
|
1447 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
1518 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
1448 |
}
|
1519 |
}
|
1449 |
});
|
1520 |
});
|
1450 |
}
|
1521 |
}
|
1451 |
} catch (Exception e) {
|
1522 |
} catch (Exception e) {
|
1452 |
ExceptionHandler.handle("", e);
|
1523 |
ExceptionHandler.handle("", e);
|
1453 |
}
|
1524 |
}
|
1454 |
}
|
1525 |
}
|
1455 |
return idSaisieVF;
|
1526 |
return idSaisieVF;
|
1456 |
}
|
1527 |
}
|
1457 |
|
1528 |
|
1458 |
public void createDocument(SQLRow row) {
|
1529 |
public void createDocument(SQLRow row) {
|
1459 |
// generation du document
|
1530 |
// generation du document
|
1460 |
final VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(row);
|
1531 |
final VenteFactureXmlSheet sheet = new VenteFactureXmlSheet(row);
|
1461 |
|
1532 |
|
1462 |
try {
|
1533 |
try {
|
1463 |
sheet.createDocumentAsynchronous();
|
1534 |
sheet.createDocumentAsynchronous();
|
1464 |
sheet.showPrintAndExportAsynchronous(panelOO.isVisualisationSelected(), panelOO.isImpressionSelected(), true);
|
1535 |
sheet.showPrintAndExportAsynchronous(panelOO.isVisualisationSelected(), panelOO.isImpressionSelected(), true);
|
1465 |
} catch (Exception e) {
|
1536 |
} catch (Exception e) {
|
1466 |
ExceptionHandler.handle("Impossible de générer la facture", e);
|
1537 |
ExceptionHandler.handle("Impossible de générer la facture", e);
|
1467 |
}
|
1538 |
}
|
1468 |
}
|
1539 |
}
|
1469 |
|
1540 |
|
1470 |
@Override
|
1541 |
@Override
|
1471 |
public void update() {
|
1542 |
public void update() {
|
1472 |
commit(null);
|
1543 |
commit(null);
|
1473 |
}
|
1544 |
}
|
1474 |
|
1545 |
|
1475 |
/**
|
1546 |
/**
|
1476 |
* Création d'une facture à partir d'un devis
|
1547 |
* Création d'une facture à partir d'un devis
|
1477 |
*
|
1548 |
*
|
1478 |
* @param idDevis
|
1549 |
* @param idDevis
|
1479 |
*
|
1550 |
*
|
1480 |
*/
|
1551 |
*/
|
1481 |
public void loadDevis(int idDevis) {
|
1552 |
public void loadDevis(int idDevis) {
|
1482 |
|
1553 |
|
1483 |
SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
1554 |
SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
1484 |
SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
1555 |
SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
1485 |
|
1556 |
|
1486 |
if (idDevis > 1) {
|
1557 |
if (idDevis > 1) {
|
1487 |
SQLInjector injector = SQLInjector.getInjector(devis.getTable(), this.getTable());
|
1558 |
SQLInjector injector = SQLInjector.getInjector(devis.getTable(), this.getTable());
|
1488 |
SQLRow rowDevis = devis.getTable().getRow(idDevis);
|
1559 |
SQLRow rowDevis = devis.getTable().getRow(idDevis);
|
1489 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idDevis);
|
1560 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idDevis);
|
1490 |
String string = rowDevis.getString("OBJET");
|
1561 |
String string = rowDevis.getString("OBJET");
|
1491 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowDevis.getString("NUMERO"));
|
1562 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowDevis.getString("NUMERO"));
|
1492 |
this.select(createRowValuesFrom);
|
1563 |
this.select(createRowValuesFrom);
|
1493 |
}
|
1564 |
}
|
1494 |
|
1565 |
|
1495 |
loadItem(this.tableFacture, devis, idDevis, devisElt);
|
1566 |
loadItem(this.tableFacture, devis, idDevis, devisElt);
|
1496 |
}
|
1567 |
}
|
1497 |
|
1568 |
|
1498 |
/**
|
1569 |
/**
|
1499 |
* Création d'une facture à partir d'une facture existante
|
1570 |
* Création d'une facture à partir d'une facture existante
|
1500 |
*
|
1571 |
*
|
1501 |
* @param idFacture
|
1572 |
* @param idFacture
|
1502 |
*
|
1573 |
*
|
1503 |
*/
|
1574 |
*/
|
1504 |
public void loadFactureExistante(int idFacture) {
|
1575 |
public void loadFactureExistante(int idFacture) {
|
1505 |
|
1576 |
|
1506 |
SQLElement fact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
1577 |
SQLElement fact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
1507 |
SQLElement factElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
1578 |
SQLElement factElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
1508 |
|
1579 |
|
1509 |
// On duplique la facture
|
1580 |
// On duplique la facture
|
1510 |
if (idFacture > 1) {
|
1581 |
if (idFacture > 1) {
|
1511 |
SQLRow row = fact.getTable().getRow(idFacture);
|
1582 |
SQLRow row = fact.getTable().getRow(idFacture);
|
1512 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable());
|
1583 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable());
|
1513 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
1584 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
1514 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
1585 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
1515 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), row.getForeign("ID_NUMEROTATION_AUTO")));
|
1586 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), row.getForeign("ID_NUMEROTATION_AUTO")));
|
1516 |
} else {
|
1587 |
} else {
|
1517 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1588 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1518 |
}
|
1589 |
}
|
1519 |
rowVals.put("NOM", row.getObject("NOM"));
|
1590 |
rowVals.put("NOM", row.getObject("NOM"));
|
1520 |
this.select(rowVals);
|
1591 |
this.select(rowVals);
|
1521 |
}
|
1592 |
}
|
1522 |
|
1593 |
|
1523 |
// On duplique les elements de facture
|
1594 |
// On duplique les elements de facture
|
1524 |
List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
|
1595 |
List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
|
1525 |
|
1596 |
|
1526 |
if (myListItem.size() != 0) {
|
1597 |
if (myListItem.size() != 0) {
|
1527 |
this.tableFacture.getModel().clearRows();
|
1598 |
this.tableFacture.getModel().clearRows();
|
1528 |
|
1599 |
|
1529 |
for (SQLRow rowElt : myListItem) {
|
1600 |
for (SQLRow rowElt : myListItem) {
|
1530 |
|
1601 |
|
1531 |
SQLRowValues rowVals = rowElt.createUpdateRow();
|
1602 |
SQLRowValues rowVals = rowElt.createUpdateRow();
|
1532 |
rowVals.clearPrimaryKeys();
|
1603 |
rowVals.clearPrimaryKeys();
|
1533 |
this.tableFacture.getModel().addRow(rowVals);
|
1604 |
this.tableFacture.getModel().addRow(rowVals);
|
1534 |
int rowIndex = this.tableFacture.getModel().getRowCount() - 1;
|
1605 |
int rowIndex = this.tableFacture.getModel().getRowCount() - 1;
|
1535 |
this.tableFacture.getModel().fireTableModelModified(rowIndex);
|
1606 |
this.tableFacture.getModel().fireTableModelModified(rowIndex);
|
1536 |
}
|
1607 |
}
|
1537 |
} else {
|
1608 |
} else {
|
1538 |
this.tableFacture.getModel().clearRows();
|
1609 |
this.tableFacture.getModel().clearRows();
|
1539 |
}
|
1610 |
}
|
1540 |
this.tableFacture.getModel().fireTableDataChanged();
|
1611 |
this.tableFacture.getModel().fireTableDataChanged();
|
1541 |
this.tableFacture.repaint();
|
1612 |
this.tableFacture.repaint();
|
1542 |
}
|
1613 |
}
|
1543 |
|
1614 |
|
1544 |
public List<SQLRowValues> createFactureAcompte(int idFacture, long acompte) {
|
1615 |
public List<SQLRowValues> createFactureAcompte(int idFacture, long acompte) {
|
1545 |
|
1616 |
|
1546 |
SQLElement fact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
1617 |
SQLElement fact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
|
1547 |
SQLElement factElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
1618 |
SQLElement factElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE_ELEMENT");
|
1548 |
|
1619 |
|
1549 |
// On duplique la facture
|
1620 |
// On duplique la facture
|
1550 |
if (idFacture > 1) {
|
1621 |
if (idFacture > 1) {
|
1551 |
SQLRow row = fact.getTable().getRow(idFacture);
|
1622 |
SQLRow row = fact.getTable().getRow(idFacture);
|
1552 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable());
|
1623 |
SQLRowValues rowVals = new SQLRowValues(fact.getTable());
|
1553 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
1624 |
rowVals.put("ID_CLIENT", row.getInt("ID_CLIENT"));
|
1554 |
rowVals.put("ID_AFFAIRE", row.getInt("ID_AFFAIRE"));
|
1625 |
rowVals.put("ID_AFFAIRE", row.getInt("ID_AFFAIRE"));
|
1555 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1626 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1556 |
rowVals.put("NOM", "Acompte de " + GestionDevise.currencyToString(acompte) + "€");
|
1627 |
rowVals.put("NOM", "Acompte de " + GestionDevise.currencyToString(acompte) + "€");
|
1557 |
this.select(rowVals);
|
1628 |
this.select(rowVals);
|
1558 |
}
|
1629 |
}
|
1559 |
|
1630 |
|
1560 |
// On duplique les elements de facture
|
1631 |
// On duplique les elements de facture
|
1561 |
List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
|
1632 |
List<SQLRow> myListItem = fact.getTable().getRow(idFacture).getReferentRows(factElt.getTable());
|
1562 |
List<SQLRowValues> result = new ArrayList<SQLRowValues>(myListItem.size());
|
1633 |
List<SQLRowValues> result = new ArrayList<SQLRowValues>(myListItem.size());
|
1563 |
if (myListItem.size() != 0) {
|
1634 |
if (myListItem.size() != 0) {
|
1564 |
this.tableFacture.getModel().clearRows();
|
1635 |
this.tableFacture.getModel().clearRows();
|
1565 |
|
1636 |
|
1566 |
double acc = ((double) acompte / (double) myListItem.size());
|
1637 |
double acc = ((double) acompte / (double) myListItem.size());
|
1567 |
long toAdd = 0;
|
1638 |
long toAdd = 0;
|
1568 |
SQLTable tablePourcentCCIP = Configuration.getInstance().getRoot().findTable("POURCENT_CCIP");
|
1639 |
SQLTable tablePourcentCCIP = Configuration.getInstance().getRoot().findTable("POURCENT_CCIP");
|
1569 |
for (SQLRow rowElt : myListItem) {
|
1640 |
for (SQLRow rowElt : myListItem) {
|
1570 |
|
1641 |
|
1571 |
SQLRowValues rowValsUp = rowElt.createUpdateRow();
|
1642 |
SQLRowValues rowValsUp = rowElt.createUpdateRow();
|
1572 |
SQLRowValues rowVals = rowElt.createUpdateRow();
|
1643 |
SQLRowValues rowVals = rowElt.createUpdateRow();
|
1573 |
rowVals.clearPrimaryKeys();
|
1644 |
rowVals.clearPrimaryKeys();
|
1574 |
|
1645 |
|
1575 |
long val = rowVals.getLong("T_PV_HT");
|
1646 |
long val = rowVals.getLong("T_PV_HT");
|
1576 |
double value = (acc + toAdd) / val * 100.0;
|
1647 |
double value = (acc + toAdd) / val * 100.0;
|
1577 |
// Si l'acompte est supérieur au montant
|
1648 |
// Si l'acompte est supérieur au montant
|
1578 |
if (value > 100) {
|
1649 |
if (value > 100) {
|
1579 |
value = 100;
|
1650 |
value = 100;
|
1580 |
toAdd += (acc - val);
|
1651 |
toAdd += (acc - val);
|
1581 |
} else {
|
1652 |
} else {
|
1582 |
toAdd = 0;
|
1653 |
toAdd = 0;
|
1583 |
}
|
1654 |
}
|
1584 |
BigDecimal pourcentAcompte = new BigDecimal(rowValsUp.getLong("POURCENT_ACOMPTE") - value);
|
1655 |
BigDecimal pourcentAcompte = new BigDecimal(rowValsUp.getLong("POURCENT_ACOMPTE") - value);
|
1585 |
rowValsUp.put("POURCENT_ACOMPTE", pourcentAcompte);
|
1656 |
rowValsUp.put("POURCENT_ACOMPTE", pourcentAcompte);
|
1586 |
BigDecimal pourcentCurrentAcompte = new BigDecimal(value);
|
1657 |
BigDecimal pourcentCurrentAcompte = new BigDecimal(value);
|
1587 |
rowVals.put("POURCENT_ACOMPTE", pourcentCurrentAcompte);
|
1658 |
rowVals.put("POURCENT_ACOMPTE", pourcentCurrentAcompte);
|
1588 |
List<SQLRow> rowsCCIP = rowElt.getReferentRows(tablePourcentCCIP);
|
1659 |
List<SQLRow> rowsCCIP = rowElt.getReferentRows(tablePourcentCCIP);
|
1589 |
if (rowsCCIP.size() > 0) {
|
1660 |
if (rowsCCIP.size() > 0) {
|
1590 |
SQLRowValues rowValsCCIP = rowsCCIP.get(0).createUpdateRow();
|
1661 |
SQLRowValues rowValsCCIP = rowsCCIP.get(0).createUpdateRow();
|
1591 |
rowValsCCIP.clearPrimaryKeys();
|
1662 |
rowValsCCIP.clearPrimaryKeys();
|
1592 |
rowValsCCIP.put("ID_SAISIE_VENTE_FACTURE_ELEMENT", rowVals);
|
1663 |
rowValsCCIP.put("ID_SAISIE_VENTE_FACTURE_ELEMENT", rowVals);
|
1593 |
rowValsCCIP.put("NOM", "Acompte");
|
1664 |
rowValsCCIP.put("NOM", "Acompte");
|
1594 |
rowValsCCIP.put("POURCENT", pourcentCurrentAcompte);
|
1665 |
rowValsCCIP.put("POURCENT", pourcentCurrentAcompte);
|
1595 |
}
|
1666 |
}
|
1596 |
System.err.println(value);
|
1667 |
System.err.println(value);
|
1597 |
this.tableFacture.getModel().addRow(rowVals);
|
1668 |
this.tableFacture.getModel().addRow(rowVals);
|
1598 |
int rowIndex = this.tableFacture.getModel().getRowCount() - 1;
|
1669 |
int rowIndex = this.tableFacture.getModel().getRowCount() - 1;
|
1599 |
this.tableFacture.getModel().fireTableModelModified(rowIndex);
|
1670 |
this.tableFacture.getModel().fireTableModelModified(rowIndex);
|
1600 |
}
|
1671 |
}
|
1601 |
if (toAdd > 0) {
|
1672 |
if (toAdd > 0) {
|
1602 |
for (int i = 0; i < this.tableFacture.getModel().getRowCount() && toAdd > 0; i++) {
|
1673 |
for (int i = 0; i < this.tableFacture.getModel().getRowCount() && toAdd > 0; i++) {
|
1603 |
SQLRowValues rowVals = this.tableFacture.getModel().getRowValuesAt(i);
|
1674 |
SQLRowValues rowVals = this.tableFacture.getModel().getRowValuesAt(i);
|
1604 |
if (rowVals.getFloat("POURCENT_ACOMPTE") < 100) {
|
1675 |
if (rowVals.getFloat("POURCENT_ACOMPTE") < 100) {
|
1605 |
long val = rowVals.getLong("T_PV_HT");
|
1676 |
long val = rowVals.getLong("T_PV_HT");
|
1606 |
double value = (acc + toAdd) / val * 100.0;
|
1677 |
double value = (acc + toAdd) / val * 100.0;
|
1607 |
// Si l'acompte est supérieur au montant
|
1678 |
// Si l'acompte est supérieur au montant
|
1608 |
if (value > 100) {
|
1679 |
if (value > 100) {
|
1609 |
value = 100;
|
1680 |
value = 100;
|
1610 |
toAdd += (acc - val);
|
1681 |
toAdd += (acc - val);
|
1611 |
} else {
|
1682 |
} else {
|
1612 |
toAdd = 0;
|
1683 |
toAdd = 0;
|
1613 |
}
|
1684 |
}
|
1614 |
rowVals.put("POURCENT_ACOMPTE", new BigDecimal(value));
|
1685 |
rowVals.put("POURCENT_ACOMPTE", new BigDecimal(value));
|
1615 |
this.tableFacture.getModel().fireTableModelModified(i);
|
1686 |
this.tableFacture.getModel().fireTableModelModified(i);
|
1616 |
}
|
1687 |
}
|
1617 |
}
|
1688 |
}
|
1618 |
}
|
1689 |
}
|
1619 |
|
1690 |
|
1620 |
// FIXME Check total if pb with round
|
1691 |
// FIXME Check total if pb with round
|
1621 |
} else {
|
1692 |
} else {
|
1622 |
this.tableFacture.getModel().clearRows();
|
1693 |
this.tableFacture.getModel().clearRows();
|
1623 |
}
|
1694 |
}
|
1624 |
this.tableFacture.getModel().fireTableDataChanged();
|
1695 |
this.tableFacture.getModel().fireTableDataChanged();
|
1625 |
this.tableFacture.repaint();
|
1696 |
this.tableFacture.repaint();
|
1626 |
return result;
|
1697 |
return result;
|
1627 |
}
|
1698 |
}
|
1628 |
|
1699 |
|
1629 |
/**
|
1700 |
/**
|
1630 |
* Création d'une facture à partir d'une commande
|
1701 |
* Création d'une facture à partir d'une commande
|
1631 |
*
|
1702 |
*
|
1632 |
* @param idCmd
|
1703 |
* @param idCmd
|
1633 |
*
|
1704 |
*
|
1634 |
*/
|
1705 |
*/
|
1635 |
public void loadCommande(int idCmd) {
|
1706 |
public void loadCommande(int idCmd) {
|
1636 |
|
1707 |
|
1637 |
SQLElement cmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
|
1708 |
SQLElement cmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
|
1638 |
SQLElement cmdElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
|
1709 |
SQLElement cmdElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT_ELEMENT");
|
1639 |
|
1710 |
|
1640 |
if (idCmd > 1) {
|
1711 |
if (idCmd > 1) {
|
1641 |
SQLInjector injector = SQLInjector.getInjector(cmd.getTable(), this.getTable());
|
1712 |
SQLInjector injector = SQLInjector.getInjector(cmd.getTable(), this.getTable());
|
1642 |
SQLRow rowCmd = cmd.getTable().getRow(idCmd);
|
1713 |
SQLRow rowCmd = cmd.getTable().getRow(idCmd);
|
1643 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idCmd);
|
1714 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idCmd);
|
1644 |
String string = rowCmd.getString("NOM");
|
1715 |
String string = rowCmd.getString("NOM");
|
1645 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowCmd.getString("NUMERO"));
|
1716 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowCmd.getString("NUMERO"));
|
1646 |
this.select(createRowValuesFrom);
|
1717 |
this.select(createRowValuesFrom);
|
1647 |
this.listenerModeReglDefaut.propertyChange(null);
|
1718 |
this.listenerModeReglDefaut.propertyChange(null);
|
1648 |
}
|
1719 |
}
|
1649 |
loadItem(this.tableFacture, cmd, idCmd, cmdElt);
|
1720 |
loadItem(this.tableFacture, cmd, idCmd, cmdElt);
|
1650 |
}
|
1721 |
}
|
1651 |
|
1722 |
|
1652 |
/**
|
1723 |
/**
|
1653 |
* Création d'une facture à partir d'un bon de livraison
|
1724 |
* Création d'une facture à partir d'un bon de livraison
|
1654 |
*
|
1725 |
*
|
1655 |
* @param idBl
|
1726 |
* @param idBl
|
1656 |
*
|
1727 |
*
|
1657 |
*/
|
1728 |
*/
|
1658 |
public void loadBonItems(SQLRowAccessor rowBL, boolean clear) {
|
1729 |
public void loadBonItems(SQLRowAccessor rowBL, boolean clear) {
|
1659 |
|
1730 |
|
1660 |
SQLElement bon = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
1731 |
SQLElement bon = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON");
|
1661 |
SQLElement bonElt = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON_ELEMENT");
|
1732 |
SQLElement bonElt = Configuration.getInstance().getDirectory().getElement("BON_DE_LIVRAISON_ELEMENT");
|
1662 |
|
1733 |
|
1663 |
loadItem(this.tableFacture, bon, rowBL.getID(), bonElt, clear);
|
1734 |
loadItem(this.tableFacture, bon, rowBL.getID(), bonElt, clear);
|
1664 |
}
|
1735 |
}
|
1665 |
|
1736 |
|
1666 |
public void addRowItem(SQLRowValues row) {
|
1737 |
public void addRowItem(SQLRowValues row) {
|
1667 |
this.tableFacture.getModel().addRow(row);
|
1738 |
this.tableFacture.getModel().addRow(row);
|
1668 |
}
|
1739 |
}
|
1669 |
|
1740 |
|
1670 |
private static final SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
|
1741 |
private static final SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
|
1671 |
|
1742 |
|
1672 |
@Override
|
1743 |
@Override
|
1673 |
protected SQLRowValues createDefaults() {
|
1744 |
protected SQLRowValues createDefaults() {
|
1674 |
SQLRowValues vals = new SQLRowValues(this.getTable());
|
1745 |
SQLRowValues vals = new SQLRowValues(this.getTable());
|
1675 |
SQLRow r;
|
1746 |
SQLRow r;
|
1676 |
|
1747 |
|
1677 |
try {
|
1748 |
try {
|
1678 |
r = ModeReglementDefautPrefPanel.getDefaultRow(true);
|
1749 |
r = ModeReglementDefautPrefPanel.getDefaultRow(true);
|
1679 |
if (r.getID() > 1) {
|
1750 |
if (r.getID() > 1) {
|
1680 |
SQLRowValues rowVals = eltModeReglement.createCopy(r, null);
|
1751 |
SQLRowValues rowVals = eltModeReglement.createCopy(r, null);
|
1681 |
System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
|
1752 |
System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
|
1682 |
vals.put("ID_MODE_REGLEMENT", rowVals);
|
1753 |
vals.put("ID_MODE_REGLEMENT", rowVals);
|
1683 |
}
|
1754 |
}
|
1684 |
} catch (SQLException e) {
|
1755 |
} catch (SQLException e) {
|
1685 |
System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
|
1756 |
System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
|
1686 |
e.printStackTrace();
|
1757 |
e.printStackTrace();
|
1687 |
}
|
1758 |
}
|
1688 |
this.tableFacture.getModel().clearRows();
|
1759 |
this.tableFacture.getModel().clearRows();
|
1689 |
|
1760 |
|
1690 |
// User
|
1761 |
// User
|
1691 |
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
1762 |
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
1692 |
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
1763 |
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
1693 |
int idUser = UserManager.getInstance().getCurrentUser().getId();
|
1764 |
int idUser = UserManager.getInstance().getCurrentUser().getId();
|
1694 |
|
1765 |
|
1695 |
// sel.addSelect(eltComm.getTable().getKey());
|
1766 |
// sel.addSelect(eltComm.getTable().getKey());
|
1696 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
1767 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
1697 |
// List<SQLRow> rowsComm = (List<SQLRow>)
|
1768 |
// List<SQLRow> rowsComm = (List<SQLRow>)
|
1698 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
1769 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
1699 |
// SQLRowListRSH(eltComm.getTable()));
|
1770 |
// SQLRowListRSH(eltComm.getTable()));
|
1700 |
|
1771 |
|
1701 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
1772 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
1702 |
|
1773 |
|
1703 |
if (rowsComm != null) {
|
1774 |
if (rowsComm != null) {
|
1704 |
vals.put("ID_COMMERCIAL", rowsComm.getID());
|
1775 |
vals.put("ID_COMMERCIAL", rowsComm.getID());
|
1705 |
}
|
1776 |
}
|
1706 |
|
1777 |
|
1707 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
1778 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
1708 |
Double d = prefs.getDouble(GestionCommercialeGlobalPreferencePanel.TAUX_TIMBRE_FISCAL, Double.valueOf(1));
|
1779 |
Double d = prefs.getDouble(GestionCommercialeGlobalPreferencePanel.TAUX_TIMBRE_FISCAL, Double.valueOf(1));
|
1709 |
vals.put("TAUX_TIMBRE_FISCAL", new BigDecimal(d));
|
1780 |
vals.put("TAUX_TIMBRE_FISCAL", new BigDecimal(d));
|
1710 |
vals.put("TOTAL_TIMBRE_FISCAL", 0L);
|
1781 |
vals.put("TOTAL_TIMBRE_FISCAL", 0L);
|
1711 |
// User
|
1782 |
// User
|
1712 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
1783 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
1713 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
1784 |
if (getTable().contains("ID_NUMEROTATION_AUTO")) {
|
1714 |
vals.put("ID_NUMEROTATION_AUTO", this.defaultNum.getID());
|
1785 |
vals.put("ID_NUMEROTATION_AUTO", this.defaultNum.getID());
|
1715 |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), vals.getForeign("ID_NUMEROTATION_AUTO")));
|
1786 |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date(), vals.getForeign("ID_NUMEROTATION_AUTO")));
|
1716 |
} else {
|
1787 |
} else {
|
1717 |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1788 |
vals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1718 |
}
|
1789 |
}
|
1719 |
int idCompteVenteProduit = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_PRODUIT");
|
1790 |
int idCompteVenteProduit = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_PRODUIT");
|
1720 |
if (idCompteVenteProduit <= 1) {
|
1791 |
if (idCompteVenteProduit <= 1) {
|
1721 |
try {
|
1792 |
try {
|
1722 |
idCompteVenteProduit = ComptePCESQLElement.getIdComptePceDefault("VentesProduits");
|
1793 |
idCompteVenteProduit = ComptePCESQLElement.getIdComptePceDefault("VentesProduits");
|
1723 |
} catch (Exception e) {
|
1794 |
} catch (Exception e) {
|
1724 |
e.printStackTrace();
|
1795 |
e.printStackTrace();
|
1725 |
}
|
1796 |
}
|
1726 |
}
|
1797 |
}
|
1727 |
|
1798 |
|
1728 |
vals.put("ID_COMPTE_PCE_VENTE", idCompteVenteProduit);
|
1799 |
vals.put("ID_COMPTE_PCE_VENTE", idCompteVenteProduit);
|
1729 |
if (this.checkCT != null) {
|
1800 |
if (this.checkCT != null) {
|
1730 |
vals.put("CONTROLE_TECHNIQUE", this.checkCT.isSelected());
|
1801 |
vals.put("CONTROLE_TECHNIQUE", this.checkCT.isSelected());
|
1731 |
}
|
1802 |
}
|
1732 |
if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
|
1803 |
if (getTable().contains("CREATE_VIRTUAL_STOCK")) {
|
1733 |
vals.put("CREATE_VIRTUAL_STOCK", Boolean.TRUE);
|
1804 |
vals.put("CREATE_VIRTUAL_STOCK", Boolean.TRUE);
|
1734 |
}
|
1805 |
}
|
1735 |
int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE");
|
1806 |
int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE");
|
1736 |
if (idCompteVenteService <= 1) {
|
1807 |
if (idCompteVenteService <= 1) {
|
1737 |
try {
|
1808 |
try {
|
1738 |
idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices");
|
1809 |
idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices");
|
1739 |
} catch (Exception e) {
|
1810 |
} catch (Exception e) {
|
1740 |
e.printStackTrace();
|
1811 |
e.printStackTrace();
|
1741 |
}
|
1812 |
}
|
1742 |
}
|
1813 |
}
|
1743 |
if (getTable().contains("ID_TAXE_PORT")) {
|
1814 |
if (getTable().contains("ID_TAXE_PORT")) {
|
1744 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
1815 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
1745 |
vals.put("ID_TAXE_PORT", taxeDefault.getID());
|
1816 |
vals.put("ID_TAXE_PORT", taxeDefault.getID());
|
1746 |
}
|
1817 |
}
|
- |
|
1818 |
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
|
- |
|
1819 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
- |
|
1820 |
vals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
|
- |
|
1821 |
}
|
1747 |
vals.put("ID_COMPTE_PCE_SERVICE", idCompteVenteService);
|
1822 |
vals.put("ID_COMPTE_PCE_SERVICE", idCompteVenteService);
|
1748 |
System.err.println("Defaults " + vals);
|
1823 |
System.err.println("Defaults " + vals);
|
1749 |
return vals;
|
1824 |
return vals;
|
1750 |
}
|
1825 |
}
|
1751 |
|
1826 |
|
1752 |
public void setDefaults() {
|
1827 |
public void setDefaults() {
|
1753 |
this.resetValue();
|
1828 |
this.resetValue();
|
1754 |
|
1829 |
|
1755 |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new java.util.Date(), defaultNum));
|
1830 |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new java.util.Date(), defaultNum));
|
1756 |
this.tableFacture.getModel().clearRows();
|
1831 |
this.tableFacture.getModel().clearRows();
|
1757 |
}
|
1832 |
}
|
1758 |
|
1833 |
|
1759 |
public RowValuesTableModel getRowValuesTableModel() {
|
1834 |
public RowValuesTableModel getRowValuesTableModel() {
|
1760 |
return this.tableFacture.getModel();
|
1835 |
return this.tableFacture.getModel();
|
1761 |
}
|
1836 |
}
|
1762 |
|
1837 |
|
1763 |
/**
|
1838 |
/**
|
1764 |
* Définir la facture comme prévisionnelle. Pas de génération comptable, ni de mode de règlement
|
1839 |
* Définir la facture comme prévisionnelle. Pas de génération comptable, ni de mode de règlement
|
1765 |
*
|
1840 |
*
|
1766 |
* @deprecated mettre les valeurs dans une RowValues
|
1841 |
* @deprecated mettre les valeurs dans une RowValues
|
1767 |
* @param b
|
1842 |
* @param b
|
1768 |
*/
|
1843 |
*/
|
1769 |
@Deprecated
|
1844 |
@Deprecated
|
1770 |
public void setPrevisonnelle(boolean b) {
|
1845 |
public void setPrevisonnelle(boolean b) {
|
1771 |
this.checkPrevisionnelle.setSelected(b);
|
1846 |
this.checkPrevisionnelle.setSelected(b);
|
1772 |
if (!b) {
|
1847 |
if (!b) {
|
1773 |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1848 |
this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class, new Date()));
|
1774 |
}
|
1849 |
}
|
1775 |
}
|
1850 |
}
|
1776 |
|
1851 |
|
1777 |
/**
|
1852 |
/**
|
1778 |
* Définir la facture comme complémentaire. Règlement supérieur au montant de la facture
|
1853 |
* Définir la facture comme complémentaire. Règlement supérieur au montant de la facture
|
1779 |
* initiale
|
1854 |
* initiale
|
1780 |
*
|
1855 |
*
|
1781 |
* @param b
|
1856 |
* @param b
|
1782 |
*/
|
1857 |
*/
|
1783 |
public void setComplement(boolean b) {
|
1858 |
public void setComplement(boolean b) {
|
1784 |
this.checkComplement.setSelected(b);
|
1859 |
this.checkComplement.setSelected(b);
|
1785 |
}
|
1860 |
}
|
1786 |
|
1861 |
|
1787 |
/**
|
1862 |
/**
|
1788 |
* Définir la facture comme acompte.
|
1863 |
* Définir la facture comme acompte.
|
1789 |
*
|
1864 |
*
|
1790 |
* @param b
|
1865 |
* @param b
|
1791 |
*/
|
1866 |
*/
|
1792 |
public void setAcompte(boolean b) {
|
1867 |
public void setAcompte(boolean b) {
|
1793 |
this.checkAcompte.setSelected(b);
|
1868 |
this.checkAcompte.setSelected(b);
|
1794 |
this.checkAcompte.firePropertyChange("ValueChanged", !b, b);
|
1869 |
this.checkAcompte.firePropertyChange("ValueChanged", !b, b);
|
1795 |
}
|
1870 |
}
|
1796 |
|
1871 |
|
1797 |
public void setTypeInterventionText(String text) {
|
1872 |
public void setTypeInterventionText(String text) {
|
1798 |
this.textTypeMission.setValue(text);
|
1873 |
this.textTypeMission.setValue(text);
|
1799 |
}
|
1874 |
}
|
1800 |
|
1875 |
|
1801 |
public void setReferenceClientText(String text) {
|
1876 |
public void setReferenceClientText(String text) {
|
1802 |
this.refClient.setText(text);
|
1877 |
this.refClient.setText(text);
|
1803 |
}
|
1878 |
}
|
1804 |
|
1879 |
|
1805 |
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
|
1880 |
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
|
1806 |
return "Saisie vente facture N°" + row.getString("NUMERO");
|
1881 |
return "Saisie vente facture N°" + row.getString("NUMERO");
|
1807 |
}
|
1882 |
}
|
1808 |
|
1883 |
|
1809 |
/**
|
1884 |
/**
|
1810 |
* Mise à jour des stocks pour chaque article composant la facture
|
1885 |
* Mise à jour des stocks pour chaque article composant la facture
|
1811 |
*
|
1886 |
*
|
1812 |
* @throws SQLException
|
1887 |
* @throws SQLException
|
1813 |
*/
|
1888 |
*/
|
1814 |
private void updateStock(int id) throws SQLException {
|
1889 |
private void updateStock(int id) throws SQLException {
|
1815 |
|
1890 |
|
1816 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
1891 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
1817 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
|
1892 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.STOCK_FACT, true)) {
|
1818 |
SQLRow row = getTable().getRow(id);
|
1893 |
SQLRow row = getTable().getRow(id);
|
1819 |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
|
1894 |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
|
1820 |
|
1895 |
|
1821 |
@Override
|
1896 |
@Override
|
1822 |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
|
1897 |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
|
1823 |
return getLibelleStock(rowOrigin, rowElt);
|
1898 |
return getLibelleStock(rowOrigin, rowElt);
|
1824 |
}
|
1899 |
}
|
1825 |
}, row, row.getReferentRows(getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT")),
|
1900 |
}, row, row.getReferentRows(getTable().getTable("SAISIE_VENTE_FACTURE_ELEMENT")),
|
1826 |
getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_DELIVER : TypeStockUpdate.REAL_DELIVER);
|
1901 |
getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_DELIVER : TypeStockUpdate.REAL_DELIVER);
|
1827 |
|
1902 |
|
1828 |
stockUpdater.update();
|
1903 |
stockUpdater.update();
|
1829 |
|
1904 |
|
1830 |
}
|
1905 |
}
|
1831 |
}
|
1906 |
}
|
1832 |
|
1907 |
|
1833 |
@Override
|
1908 |
@Override
|
1834 |
protected RowValuesTable getRowValuesTable() {
|
1909 |
protected RowValuesTable getRowValuesTable() {
|
1835 |
return this.tableFacture.getRowValuesTable();
|
1910 |
return this.tableFacture.getRowValuesTable();
|
1836 |
}
|
1911 |
}
|
1837 |
|
1912 |
|
1838 |
@Override
|
1913 |
@Override
|
1839 |
protected void refreshAfterSelect(SQLRowAccessor r) {
|
1914 |
protected void refreshAfterSelect(SQLRowAccessor r) {
|
1840 |
this.tableFacture.setDateDevise(this.dateSaisie.getValue());
|
1915 |
this.tableFacture.setDateDevise(this.dateSaisie.getValue());
|
1841 |
}
|
1916 |
}
|
1842 |
|
1917 |
|
1843 |
}
|
1918 |
}
|