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