Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
Line 18... |
Line 18... |
18 |
import org.openconcerto.erp.core.common.ui.Acompte;
|
18 |
import org.openconcerto.erp.core.common.ui.Acompte;
|
19 |
import org.openconcerto.erp.core.common.ui.AcompteCellEditor;
|
19 |
import org.openconcerto.erp.core.common.ui.AcompteCellEditor;
|
20 |
import org.openconcerto.erp.core.common.ui.DeviseNumericCellEditor;
|
20 |
import org.openconcerto.erp.core.common.ui.DeviseNumericCellEditor;
|
21 |
import org.openconcerto.erp.core.common.ui.DeviseNumericHTConvertorCellEditor;
|
21 |
import org.openconcerto.erp.core.common.ui.DeviseNumericHTConvertorCellEditor;
|
22 |
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
|
22 |
import org.openconcerto.erp.core.common.ui.DeviseTableCellRenderer;
|
- |
|
23 |
import org.openconcerto.erp.core.common.ui.ItemAutoCompletionManager;
|
- |
|
24 |
import org.openconcerto.erp.core.common.ui.NiveauTableCellEditor;
|
- |
|
25 |
import org.openconcerto.erp.core.common.ui.NiveauTableCellRender;
|
23 |
import org.openconcerto.erp.core.common.ui.QteCellEditor;
|
26 |
import org.openconcerto.erp.core.common.ui.QteCellEditor;
|
24 |
import org.openconcerto.erp.core.common.ui.Remise;
|
27 |
import org.openconcerto.erp.core.common.ui.Remise;
|
25 |
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
|
28 |
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
|
26 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
29 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
27 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
|
30 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
|
Line 62... |
Line 65... |
62 |
import org.openconcerto.sql.view.list.SQLTableElement;
|
65 |
import org.openconcerto.sql.view.list.SQLTableElement;
|
63 |
import org.openconcerto.sql.view.list.SQLTextComboTableCellEditor;
|
66 |
import org.openconcerto.sql.view.list.SQLTextComboTableCellEditor;
|
64 |
import org.openconcerto.sql.view.list.ValidStateChecker;
|
67 |
import org.openconcerto.sql.view.list.ValidStateChecker;
|
65 |
import org.openconcerto.ui.table.XTableColumnModel;
|
68 |
import org.openconcerto.ui.table.XTableColumnModel;
|
66 |
import org.openconcerto.utils.DecimalUtils;
|
69 |
import org.openconcerto.utils.DecimalUtils;
|
- |
|
70 |
import org.openconcerto.utils.ExceptionHandler;
|
67 |
import org.openconcerto.utils.Tuple3;
|
71 |
import org.openconcerto.utils.Tuple3;
|
68 |
import org.openconcerto.utils.cc.ITransformer;
|
72 |
import org.openconcerto.utils.cc.ITransformer;
|
69 |
import org.openconcerto.utils.i18n.TranslationManager;
|
73 |
import org.openconcerto.utils.i18n.TranslationManager;
|
70 |
|
74 |
|
71 |
import java.awt.Component;
|
75 |
import java.awt.Component;
|
Line 76... |
Line 80... |
76 |
import java.awt.event.KeyEvent;
|
80 |
import java.awt.event.KeyEvent;
|
77 |
import java.awt.event.MouseAdapter;
|
81 |
import java.awt.event.MouseAdapter;
|
78 |
import java.awt.event.MouseEvent;
|
82 |
import java.awt.event.MouseEvent;
|
79 |
import java.math.BigDecimal;
|
83 |
import java.math.BigDecimal;
|
80 |
import java.math.RoundingMode;
|
84 |
import java.math.RoundingMode;
|
- |
|
85 |
import java.sql.SQLException;
|
81 |
import java.util.ArrayList;
|
86 |
import java.util.ArrayList;
|
82 |
import java.util.Date;
|
87 |
import java.util.Date;
|
83 |
import java.util.HashMap;
|
88 |
import java.util.HashMap;
|
84 |
import java.util.List;
|
89 |
import java.util.List;
|
85 |
import java.util.Map;
|
90 |
import java.util.Map;
|
- |
|
91 |
import java.util.Set;
|
86 |
import java.util.Vector;
|
92 |
import java.util.Vector;
|
87 |
|
93 |
|
88 |
import javax.swing.AbstractAction;
|
94 |
import javax.swing.AbstractAction;
|
89 |
import javax.swing.JButton;
|
95 |
import javax.swing.JButton;
|
90 |
import javax.swing.JFrame;
|
96 |
import javax.swing.JFrame;
|
Line 128... |
Line 134... |
128 |
final boolean activeCalculM2 = prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVE_CALCUL_M2, false);
|
134 |
final boolean activeCalculM2 = prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVE_CALCUL_M2, false);
|
129 |
final boolean createAuto = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
|
135 |
final boolean createAuto = prefs.getBoolean(GestionArticleGlobalPreferencePanel.CREATE_ARTICLE_AUTO, true);
|
130 |
final boolean filterFamilleArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.FILTER_BY_FAMILY, false);
|
136 |
final boolean filterFamilleArticle = prefs.getBoolean(GestionArticleGlobalPreferencePanel.FILTER_BY_FAMILY, false);
|
131 |
final boolean showEco = prefs.getBoolean(AbstractVenteArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS, false);
|
137 |
final boolean showEco = prefs.getBoolean(AbstractVenteArticleItemTable.SHOW_ECO_CONTRIBUTION_COLUMNS, false);
|
132 |
final boolean showDevise = prefs.getBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false);
|
138 |
final boolean showDevise = prefs.getBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false);
|
- |
|
139 |
final boolean withDeclinaison = prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVER_DECLINAISON, false);
|
133 |
|
140 |
|
134 |
final UserRights rights = UserRightsManager.getCurrentUserRights();
|
141 |
final UserRights rights = UserRightsManager.getCurrentUserRights();
|
135 |
final boolean editVTPrice = rights.haveRight(EDIT_PRIX_VENTE_CODE);
|
142 |
final boolean editVTPrice = rights.haveRight(EDIT_PRIX_VENTE_CODE);
|
136 |
final boolean showHAPrice = rights.haveRight(SHOW_PRIX_ACHAT_CODE);
|
143 |
final boolean showHAPrice = rights.haveRight(SHOW_PRIX_ACHAT_CODE);
|
137 |
final boolean lockVTMinPrice = rights.haveRight(LOCK_PRIX_MIN_VENTE_CODE);
|
144 |
final boolean lockVTMinPrice = rights.haveRight(LOCK_PRIX_MIN_VENTE_CODE);
|
138 |
|
145 |
|
139 |
final List<SQLTableElement> list = new Vector<SQLTableElement>();
|
146 |
final List<SQLTableElement> list = new Vector<SQLTableElement>();
|
- |
|
147 |
final SQLTableElement eNiveau = new SQLTableElement(e.getTable().getField("NIVEAU")) {
|
- |
|
148 |
@Override
|
- |
|
149 |
public void setValueFrom(SQLRowValues row, Object value) {
|
- |
|
150 |
super.setValueFrom(row, value);
|
- |
|
151 |
}
|
- |
|
152 |
};
|
- |
|
153 |
eNiveau.setRenderer(new NiveauTableCellRender());
|
- |
|
154 |
eNiveau.setEditor(new NiveauTableCellEditor());
|
- |
|
155 |
list.add(eNiveau);
|
- |
|
156 |
|
140 |
list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
|
157 |
list.add(new SQLTableElement(e.getTable().getField("ID_STYLE")));
|
141 |
|
158 |
|
142 |
final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
|
159 |
final SQLTableElement tableFamille = new SQLTableElement(e.getTable().getField("ID_FAMILLE_ARTICLE"));
|
143 |
list.add(tableFamille);
|
160 |
list.add(tableFamille);
|
144 |
|
161 |
|
Line 166... |
Line 183... |
166 |
list.add(this.tableElementEcoID);
|
183 |
list.add(this.tableElementEcoID);
|
167 |
}
|
184 |
}
|
168 |
|
185 |
|
169 |
// Code article
|
186 |
// Code article
|
170 |
final SQLTableElement tableElementCode = new SQLTableElement(e.getTable().getField("CODE"), String.class,
|
187 |
final SQLTableElement tableElementCode = new SQLTableElement(e.getTable().getField("CODE"), String.class,
|
171 |
new ITextArticleWithCompletionCellEditor(e.getTable().getTable("ARTICLE"), e.getTable().getTable("ARTICLE_FOURNISSEUR"))) {
|
188 |
new ITextArticleWithCompletionCellEditor(e.getTable().getTable("ARTICLE"), e.getTable().getTable("ARTICLE_FOURNISSEUR"), withDeclinaison)) {
|
172 |
@Override
|
189 |
@Override
|
173 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
190 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
174 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
191 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
175 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
192 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
176 |
boolean noCmdElt = vals.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
193 |
boolean noCmdElt = vals.getObject("ID_COMMANDE_CLIENT_ELEMENT") == null || vals.isForeignEmpty("ID_COMMANDE_CLIENT_ELEMENT");
|
Line 197... |
Line 214... |
197 |
|
214 |
|
198 |
}
|
215 |
}
|
199 |
};
|
216 |
};
|
200 |
list.add(tableElementNom);
|
217 |
list.add(tableElementNom);
|
201 |
|
218 |
|
- |
|
219 |
Set<String> fieldsName = e.getTable().getFieldsName();
|
- |
|
220 |
List<String> fieldDecl = new ArrayList<>();
|
- |
|
221 |
|
- |
|
222 |
if (withDeclinaison) {
|
- |
|
223 |
|
- |
|
224 |
for (String string : fieldsName) {
|
- |
|
225 |
if (string.startsWith("ID_ARTICLE_DECLINAISON")) {
|
- |
|
226 |
final SQLTableElement tableElementDeclinaison = new SQLTableElement(e.getTable().getField(string));
|
- |
|
227 |
tableElementDeclinaison.setEditable(false);
|
- |
|
228 |
fieldDecl.add(string);
|
- |
|
229 |
list.add(tableElementDeclinaison);
|
- |
|
230 |
}
|
- |
|
231 |
}
|
- |
|
232 |
}
|
- |
|
233 |
|
202 |
// Désignation de l'article
|
234 |
// Désignation de l'article
|
203 |
final SQLTableElement tableElementDesc = new SQLTableElement(e.getTable().getField("DESCRIPTIF"));
|
235 |
final SQLTableElement tableElementDesc = new SQLTableElement(e.getTable().getField("DESCRIPTIF"));
|
204 |
list.add(tableElementDesc);
|
236 |
list.add(tableElementDesc);
|
205 |
|
237 |
|
206 |
if (e.getTable().getFieldsName().contains("DELAI")) {
|
238 |
if (e.getTable().getFieldsName().contains("DELAI")) {
|
207 |
final SQLTableElement tableElementDelai = new SQLTableElement(e.getTable().getField("DELAI"));
|
239 |
final SQLTableElement tableElementDelai = new SQLTableElement(e.getTable().getField("DELAI"));
|
208 |
list.add(tableElementDelai);
|
240 |
list.add(tableElementDelai);
|
209 |
}
|
241 |
}
|
210 |
|
242 |
|
- |
|
243 |
SQLTableElement eltLongueur = new SQLTableElement(e.getTable().getField("LONGUEUR")) {
|
- |
|
244 |
@Override
|
- |
|
245 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
246 |
|
- |
|
247 |
int idUv = vals.getForeignID("ID_UNITE_VENTE");
|
- |
|
248 |
return idUv == UniteVenteArticleSQLElement.M2;
|
- |
|
249 |
}
|
- |
|
250 |
};
|
- |
|
251 |
list.add(eltLongueur);
|
- |
|
252 |
|
- |
|
253 |
SQLTableElement eltLargeur = new SQLTableElement(e.getTable().getField("LARGEUR")) {
|
- |
|
254 |
@Override
|
- |
|
255 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
256 |
|
- |
|
257 |
int idUv = vals.getForeignID("ID_UNITE_VENTE");
|
- |
|
258 |
return idUv == UniteVenteArticleSQLElement.M2;
|
- |
|
259 |
}
|
- |
|
260 |
};
|
- |
|
261 |
list.add(eltLargeur);
|
- |
|
262 |
|
- |
|
263 |
SQLTableElement eltHauteur = new SQLTableElement(e.getTable().getField("HAUTEUR"));
|
- |
|
264 |
list.add(eltHauteur);
|
- |
|
265 |
|
- |
|
266 |
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
|
- |
|
267 |
@Override
|
- |
|
268 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
269 |
|
- |
|
270 |
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
|
- |
|
271 |
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
|
- |
|
272 |
return false;
|
- |
|
273 |
} else if (activeCalculM2 && row != null && !row.isUndefined() && row.getID() == UniteVenteArticleSQLElement.M2) {
|
- |
|
274 |
return false;
|
- |
|
275 |
} else {
|
- |
|
276 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
- |
|
277 |
}
|
- |
|
278 |
}
|
- |
|
279 |
|
- |
|
280 |
protected Object getDefaultNullValue() {
|
- |
|
281 |
return BigDecimal.ZERO;
|
- |
|
282 |
}
|
- |
|
283 |
|
- |
|
284 |
@Override
|
- |
|
285 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
286 |
return new QteUnitRowValuesRenderer();
|
- |
|
287 |
}
|
- |
|
288 |
};
|
- |
|
289 |
list.add(qteU);
|
- |
|
290 |
|
- |
|
291 |
SQLTableElement uniteVente = new SQLTableElement(e.getTable().getField("ID_UNITE_VENTE"));
|
- |
|
292 |
list.add(uniteVente);
|
- |
|
293 |
|
- |
|
294 |
// Quantité
|
- |
|
295 |
this.qte = new SQLTableElement(e.getTable().getField("QTE"), Integer.class, new QteCellEditor()) {
|
- |
|
296 |
protected Object getDefaultNullValue() {
|
- |
|
297 |
return Integer.valueOf(0);
|
- |
|
298 |
}
|
- |
|
299 |
|
- |
|
300 |
@Override
|
- |
|
301 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
302 |
|
- |
|
303 |
return new QtyToDeliverRowValuesRenderer();
|
- |
|
304 |
}
|
- |
|
305 |
|
- |
|
306 |
};
|
- |
|
307 |
list.add(this.qte);
|
- |
|
308 |
|
- |
|
309 |
// Quantité Livrée
|
- |
|
310 |
final SQLTableElement tableElement_QuantiteLivree = new SQLTableElement(e.getTable().getField("QTE_LIVREE"), Integer.class) {
|
- |
|
311 |
@Override
|
- |
|
312 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
313 |
|
- |
|
314 |
return new DeliveredQtyRowValuesRenderer();
|
- |
|
315 |
}
|
- |
|
316 |
|
- |
|
317 |
protected Object getDefaultNullValue() {
|
- |
|
318 |
return Integer.valueOf(0);
|
- |
|
319 |
}
|
- |
|
320 |
};
|
- |
|
321 |
list.add(tableElement_QuantiteLivree);
|
- |
|
322 |
|
211 |
// Valeur des métriques
|
323 |
// Valeur des métriques
|
212 |
final SQLTableElement tableElement_ValeurMetrique2 = new SQLTableElement(e.getTable().getField("VALEUR_METRIQUE_2"), Float.class) {
|
324 |
final SQLTableElement tableElement_ValeurMetrique2 = new SQLTableElement(e.getTable().getField("VALEUR_METRIQUE_2"), Float.class) {
|
213 |
@Override
|
325 |
@Override
|
214 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
326 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
215 |
Number modeNumber = (Number) vals.getObject("ID_MODE_VENTE_ARTICLE");
|
327 |
Number modeNumber = (Number) vals.getObject("ID_MODE_VENTE_ARTICLE");
|
Line 338... |
Line 450... |
338 |
};
|
450 |
};
|
339 |
eltUnitDevise.setRenderer(new DeviseTableCellRenderer());
|
451 |
eltUnitDevise.setRenderer(new DeviseTableCellRenderer());
|
340 |
list.add(eltUnitDevise);
|
452 |
list.add(eltUnitDevise);
|
341 |
}
|
453 |
}
|
342 |
|
454 |
|
343 |
SQLTableElement eltLongueur = new SQLTableElement(e.getTable().getField("LONGUEUR")) {
|
- |
|
344 |
@Override
|
- |
|
345 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
346 |
|
- |
|
347 |
int idUv = vals.getForeignID("ID_UNITE_VENTE");
|
- |
|
348 |
return idUv == UniteVenteArticleSQLElement.M2;
|
- |
|
349 |
}
|
- |
|
350 |
};
|
- |
|
351 |
list.add(eltLongueur);
|
- |
|
352 |
|
- |
|
353 |
SQLTableElement eltLargeur = new SQLTableElement(e.getTable().getField("LARGEUR")) {
|
- |
|
354 |
@Override
|
- |
|
355 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
356 |
|
- |
|
357 |
int idUv = vals.getForeignID("ID_UNITE_VENTE");
|
- |
|
358 |
return idUv == UniteVenteArticleSQLElement.M2;
|
- |
|
359 |
}
|
- |
|
360 |
};
|
- |
|
361 |
list.add(eltLargeur);
|
- |
|
362 |
|
- |
|
363 |
SQLTableElement eltHauteur = new SQLTableElement(e.getTable().getField("HAUTEUR"));
|
- |
|
364 |
list.add(eltHauteur);
|
- |
|
365 |
|
- |
|
366 |
SQLTableElement qteU = new SQLTableElement(e.getTable().getField("QTE_UNITAIRE"), BigDecimal.class) {
|
- |
|
367 |
@Override
|
- |
|
368 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
369 |
|
- |
|
370 |
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
|
- |
|
371 |
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
|
- |
|
372 |
return false;
|
- |
|
373 |
} else if (activeCalculM2 && row != null && !row.isUndefined() && row.getID() == UniteVenteArticleSQLElement.M2) {
|
- |
|
374 |
return false;
|
- |
|
375 |
} else {
|
- |
|
376 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
- |
|
377 |
}
|
- |
|
378 |
}
|
- |
|
379 |
|
- |
|
380 |
protected Object getDefaultNullValue() {
|
- |
|
381 |
return BigDecimal.ZERO;
|
- |
|
382 |
}
|
- |
|
383 |
|
- |
|
384 |
@Override
|
- |
|
385 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
386 |
return new QteUnitRowValuesRenderer();
|
- |
|
387 |
}
|
- |
|
388 |
};
|
- |
|
389 |
list.add(qteU);
|
- |
|
390 |
|
- |
|
391 |
SQLTableElement uniteVente = new SQLTableElement(e.getTable().getField("ID_UNITE_VENTE"));
|
- |
|
392 |
list.add(uniteVente);
|
- |
|
393 |
|
- |
|
394 |
// Quantité
|
- |
|
395 |
this.qte = new SQLTableElement(e.getTable().getField("QTE"), Integer.class, new QteCellEditor()) {
|
- |
|
396 |
protected Object getDefaultNullValue() {
|
- |
|
397 |
return Integer.valueOf(0);
|
- |
|
398 |
}
|
- |
|
399 |
|
- |
|
400 |
@Override
|
- |
|
401 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
402 |
|
- |
|
403 |
return new QtyToDeliverRowValuesRenderer();
|
- |
|
404 |
}
|
- |
|
405 |
|
- |
|
406 |
};
|
- |
|
407 |
list.add(this.qte);
|
- |
|
408 |
|
- |
|
409 |
// Mode de vente
|
455 |
// Mode de vente
|
410 |
final SQLTableElement tableElement_ModeVente = new SQLTableElement(e.getTable().getField("ID_MODE_VENTE_ARTICLE"));
|
456 |
final SQLTableElement tableElement_ModeVente = new SQLTableElement(e.getTable().getField("ID_MODE_VENTE_ARTICLE"));
|
411 |
list.add(tableElement_ModeVente);
|
457 |
list.add(tableElement_ModeVente);
|
412 |
final SQLField prixAchatHTField = e.getTable().getField("PA_HT");
|
458 |
final SQLField prixAchatHTField = e.getTable().getField("PA_HT");
|
413 |
final DeviseNumericCellEditor editorPAchatHT = new DeviseNumericCellEditor(prixAchatHTField);
|
459 |
final DeviseNumericCellEditor editorPAchatHT = new DeviseNumericCellEditor(prixAchatHTField);
|
Line 445... |
Line 491... |
445 |
|
491 |
|
446 |
// TVA
|
492 |
// TVA
|
447 |
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
|
493 |
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
|
448 |
list.add(this.tableElementTVA);
|
494 |
list.add(this.tableElementTVA);
|
449 |
|
495 |
|
450 |
// Quantité Livrée
|
- |
|
451 |
final SQLTableElement tableElement_QuantiteLivree = new SQLTableElement(e.getTable().getField("QTE_LIVREE"), Integer.class) {
|
- |
|
452 |
@Override
|
- |
|
453 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
454 |
|
- |
|
455 |
return new DeliveredQtyRowValuesRenderer();
|
- |
|
456 |
}
|
- |
|
457 |
|
- |
|
458 |
protected Object getDefaultNullValue() {
|
- |
|
459 |
return Integer.valueOf(0);
|
- |
|
460 |
}
|
- |
|
461 |
};
|
- |
|
462 |
list.add(tableElement_QuantiteLivree);
|
- |
|
463 |
|
- |
|
464 |
// Poids piece
|
496 |
// Poids piece
|
465 |
SQLTableElement tableElementPoids = new SQLTableElement(e.getTable().getField("POIDS"), Float.class);
|
497 |
SQLTableElement tableElementPoids = new SQLTableElement(e.getTable().getField("POIDS"), Float.class);
|
466 |
list.add(tableElementPoids);
|
498 |
list.add(tableElementPoids);
|
467 |
|
499 |
|
468 |
// Poids total
|
500 |
// Poids total
|
Line 622... |
Line 654... |
622 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
654 |
if (e.getTable().contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
623 |
final SQLTableElement tableCmdElt = new SQLTableElement(e.getTable().getField("ID_COMMANDE_CLIENT_ELEMENT"));
|
655 |
final SQLTableElement tableCmdElt = new SQLTableElement(e.getTable().getField("ID_COMMANDE_CLIENT_ELEMENT"));
|
624 |
list.add(tableCmdElt);
|
656 |
list.add(tableCmdElt);
|
625 |
}
|
657 |
}
|
626 |
|
658 |
|
627 |
SQLRowValues defautRow = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
|
659 |
this.defaultRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(e.getTable()));
|
628 |
defautRow.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
|
660 |
this.defaultRowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID());
|
629 |
defautRow.put("CODE", "");
|
661 |
this.defaultRowVals.put("CODE", "");
|
630 |
defautRow.put("NOM", "");
|
662 |
this.defaultRowVals.put("NOM", "");
|
631 |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, defautRow) {
|
663 |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("NOM"), false, this.defaultRowVals) {
|
632 |
@Override
|
664 |
@Override
|
633 |
public void commitData() {
|
665 |
public void commitData() {
|
634 |
int size = getRowCount();
|
666 |
int size = getRowCount();
|
635 |
for (int i = 0; i < size; i++) {
|
667 |
for (int i = 0; i < size; i++) {
|
636 |
SQLRowValues rowVals = getRowValuesAt(i);
|
668 |
SQLRowValues rowVals = getRowValuesAt(i);
|
Line 682... |
Line 714... |
682 |
completionField.add("SERVICE");
|
714 |
completionField.add("SERVICE");
|
683 |
completionField.add("ID_FAMILLE_ARTICLE");
|
715 |
completionField.add("ID_FAMILLE_ARTICLE");
|
684 |
completionField.add("LONGUEUR");
|
716 |
completionField.add("LONGUEUR");
|
685 |
completionField.add("LARGEUR");
|
717 |
completionField.add("LARGEUR");
|
686 |
completionField.add("HAUTEUR");
|
718 |
completionField.add("HAUTEUR");
|
- |
|
719 |
completionField.addAll(fieldDecl);
|
687 |
if (getSQLElement().getTable().getFieldsName().contains("DESCRIPTIF")) {
|
720 |
if (getSQLElement().getTable().getFieldsName().contains("DESCRIPTIF")) {
|
688 |
completionField.add("DESCRIPTIF");
|
721 |
completionField.add("DESCRIPTIF");
|
689 |
}
|
722 |
}
|
690 |
if (showDevise) {
|
723 |
if (showDevise) {
|
691 |
completionField.add("ID_DEVISE");
|
724 |
completionField.add("ID_DEVISE");
|
Line 694... |
Line 727... |
694 |
if (getSQLElement().getTable().getFieldsName().contains("QTE_ACHAT") && sqlTableArticle.getTable().getFieldsName().contains("QTE_ACHAT")) {
|
727 |
if (getSQLElement().getTable().getFieldsName().contains("QTE_ACHAT") && sqlTableArticle.getTable().getFieldsName().contains("QTE_ACHAT")) {
|
695 |
completionField.add("QTE_ACHAT");
|
728 |
completionField.add("QTE_ACHAT");
|
696 |
}
|
729 |
}
|
697 |
|
730 |
|
698 |
// Autocompletion
|
731 |
// Autocompletion
|
699 |
final AutoCompletionManager m = new AutoCompletionManager(tableElementCode, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.CODE"), this.table,
|
732 |
this.codeCompletionManager = new ItemAutoCompletionManager(this, tableElementCode, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.CODE"),
|
700 |
this.table.getRowValuesTableModel()) {
|
733 |
this.table, this.table.getRowValuesTableModel());
|
701 |
@Override
|
- |
|
702 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
- |
|
703 |
Object res = tarifCompletion(row, field, rowDest, true);
|
- |
|
704 |
if (res == null) {
|
- |
|
705 |
res = super.getValueFrom(row, field, rowDest);
|
- |
|
706 |
}
|
- |
|
707 |
if (field.equals("POURCENT_REMISE")) {
|
- |
|
708 |
return getRemiseClient(row);
|
- |
|
709 |
}
|
- |
|
710 |
return res;
|
- |
|
711 |
}
|
- |
|
712 |
};
|
- |
|
713 |
m.fill("NOM", "NOM");
|
734 |
this.codeCompletionManager.fill("NOM", "NOM");
|
714 |
m.fill("ID", "ID_ARTICLE");
|
735 |
this.codeCompletionManager.fill("ID", "ID_ARTICLE");
|
715 |
for (String string : completionField) {
|
736 |
for (String string : completionField) {
|
716 |
m.fill(string, string);
|
737 |
this.codeCompletionManager.fill(string, string);
|
717 |
}
|
738 |
}
|
718 |
// final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
739 |
// final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
719 |
// m.setWhere(w);
|
740 |
// m.setWhere(w);
|
720 |
ITransformer<SQLSelect, SQLSelect> selTrans = new ITransformer<SQLSelect, SQLSelect>() {
|
741 |
ITransformer<SQLSelect, SQLSelect> selTrans = new ITransformer<SQLSelect, SQLSelect>() {
|
721 |
@Override
|
742 |
@Override
|
Line 737... |
Line 758... |
737 |
input.asString();
|
758 |
input.asString();
|
738 |
return input;
|
759 |
return input;
|
739 |
}
|
760 |
}
|
740 |
};
|
761 |
};
|
741 |
|
762 |
|
742 |
m.setSelectTransformer(selTrans);
|
763 |
this.codeCompletionManager.setSelectTransformer(selTrans);
|
743 |
|
764 |
|
744 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.CAN_EXPAND_NOMENCLATURE_VT, true)) {
|
765 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.CAN_EXPAND_NOMENCLATURE_VT, true)) {
|
745 |
|
766 |
|
746 |
table.addMouseListener(new MouseAdapter() {
|
767 |
table.addMouseListener(new MouseAdapter() {
|
747 |
|
768 |
|
Line 765... |
Line 786... |
765 |
JPopupMenu popup = new JPopupMenu();
|
786 |
JPopupMenu popup = new JPopupMenu();
|
766 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expand")) {
|
787 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expand")) {
|
767 |
|
788 |
|
768 |
@Override
|
789 |
@Override
|
769 |
public void actionPerformed(ActionEvent arg0) {
|
790 |
public void actionPerformed(ActionEvent arg0) {
|
770 |
expandNomenclature(rowindex, m, EXPAND_TYPE.EXPAND);
|
791 |
expandNomenclature(rowindex, codeCompletionManager, EXPAND_TYPE.EXPAND);
|
771 |
}
|
792 |
}
|
772 |
});
|
793 |
});
|
773 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expose")) {
|
794 |
popup.add(new AbstractAction(TranslationManager.getInstance().getTranslationForItem("product.bom.expose")) {
|
774 |
|
795 |
|
775 |
@Override
|
796 |
@Override
|
776 |
public void actionPerformed(ActionEvent arg0) {
|
797 |
public void actionPerformed(ActionEvent arg0) {
|
777 |
expandNomenclature(rowindex, m, EXPAND_TYPE.VIEW_ONLY);
|
798 |
expandNomenclature(rowindex, codeCompletionManager, EXPAND_TYPE.VIEW_ONLY);
|
778 |
}
|
799 |
}
|
779 |
});
|
800 |
});
|
780 |
|
801 |
|
781 |
for (AbstractAction action : getAdditionnalMouseAction(rowindex)) {
|
802 |
for (AbstractAction action : getAdditionnalMouseAction(rowindex)) {
|
782 |
popup.add(action);
|
803 |
popup.add(action);
|
Line 786... |
Line 807... |
786 |
}
|
807 |
}
|
787 |
}
|
808 |
}
|
788 |
});
|
809 |
});
|
789 |
}
|
810 |
}
|
790 |
|
811 |
|
791 |
final AutoCompletionManager m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
|
812 |
final AutoCompletionManager m2 = new ItemAutoCompletionManager(this, tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"),
|
792 |
this.table.getRowValuesTableModel()) {
|
813 |
this.table, this.table.getRowValuesTableModel());
|
793 |
@Override
|
- |
|
794 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
- |
|
795 |
Object res = tarifCompletion(row, field, rowDest, true);
|
- |
|
796 |
if (res == null) {
|
- |
|
797 |
res = super.getValueFrom(row, field, rowDest);
|
- |
|
798 |
}
|
- |
|
799 |
if (field.equals("POURCENT_REMISE")) {
|
- |
|
800 |
return getRemiseClient(row);
|
- |
|
801 |
}
|
- |
|
802 |
return res;
|
- |
|
803 |
}
|
- |
|
804 |
};
|
- |
|
805 |
m2.fill("CODE", "CODE");
|
814 |
m2.fill("CODE", "CODE");
|
806 |
m2.fill("ID", "ID_ARTICLE");
|
815 |
m2.fill("ID", "ID_ARTICLE");
|
807 |
for (String string : completionField) {
|
816 |
for (String string : completionField) {
|
808 |
m2.fill(string, string);
|
817 |
m2.fill(string, string);
|
809 |
}
|
818 |
}
|
810 |
|
819 |
|
811 |
// m2.setWhere(w);
|
820 |
// m2.setWhere(w);
|
812 |
m2.setSelectTransformer(selTrans);
|
821 |
m2.setSelectTransformer(selTrans);
|
813 |
|
822 |
|
814 |
final AutoCompletionManager m3 = new AutoCompletionManager(tableElementArticle, sqlTableArticle.getField("NOM"), this.table, this.table.getRowValuesTableModel(),
|
823 |
final AutoCompletionManager m3 = new ItemAutoCompletionManager(this, tableElementArticle, sqlTableArticle.getField("NOM"), this.table, this.table.getRowValuesTableModel(),
|
815 |
ITextWithCompletion.MODE_CONTAINS, true, true, new ValidStateChecker()) {
|
824 |
ITextWithCompletion.MODE_CONTAINS, true, true, new ValidStateChecker());
|
816 |
@Override
|
- |
|
817 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
- |
|
818 |
Object res = tarifCompletion(row, field, rowDest, true);
|
- |
|
819 |
if (res == null) {
|
- |
|
820 |
res = super.getValueFrom(row, field, rowDest);
|
- |
|
821 |
}
|
- |
|
822 |
if (field.equals("POURCENT_REMISE")) {
|
- |
|
823 |
return getRemiseClient(row);
|
- |
|
824 |
}
|
- |
|
825 |
return res;
|
- |
|
826 |
}
|
- |
|
827 |
};
|
- |
|
828 |
m3.fill("CODE", "CODE");
|
825 |
m3.fill("CODE", "CODE");
|
829 |
m3.fill("NOM", "NOM");
|
826 |
m3.fill("NOM", "NOM");
|
830 |
for (String string : completionField) {
|
827 |
for (String string : completionField) {
|
831 |
m3.fill(string, string);
|
828 |
m3.fill(string, string);
|
832 |
}
|
829 |
}
|
Line 859... |
Line 856... |
859 |
}
|
856 |
}
|
860 |
});
|
857 |
});
|
861 |
}
|
858 |
}
|
862 |
|
859 |
|
863 |
// Calcul automatique du total HT
|
860 |
// Calcul automatique du total HT
|
864 |
tableElement_QuantiteLivree.addModificationListener(tableElement_PrixMetrique1_VenteHT);
|
861 |
this.qte.addModificationListener(tableElement_PrixMetrique1_VenteHT);
|
865 |
tableElement_QuantiteLivree.addModificationListener(totalHT);
|
862 |
tableElement_QuantiteLivree.addModificationListener(totalHT);
|
866 |
tableElement_QuantiteLivree.addModificationListener(totalHA);
|
863 |
tableElement_QuantiteLivree.addModificationListener(totalHA);
|
867 |
qteU.addModificationListener(totalHT);
|
864 |
qteU.addModificationListener(totalHT);
|
868 |
qteU.addModificationListener(totalHA);
|
865 |
qteU.addModificationListener(totalHA);
|
869 |
this.ha.addModificationListener(this.totalHA);
|
866 |
this.ha.addModificationListener(this.totalHA);
|
Line 1100... |
Line 1097... |
1100 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
1097 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
1101 |
|
1098 |
|
1102 |
if (filterFamilleArticle) {
|
1099 |
if (filterFamilleArticle) {
|
1103 |
|
1100 |
|
1104 |
if (row.isForeignEmpty("ID_FAMILLE_ARTICLE")) {
|
1101 |
if (row.isForeignEmpty("ID_FAMILLE_ARTICLE")) {
|
1105 |
m.setWhere(null);
|
1102 |
codeCompletionManager.setWhere(null);
|
1106 |
m2.setWhere(null);
|
1103 |
m2.setWhere(null);
|
1107 |
|
1104 |
|
1108 |
} else {
|
1105 |
} else {
|
1109 |
m.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
1106 |
codeCompletionManager.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
1110 |
m2.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
1107 |
m2.setWhere(new Where(sqlTableArticle.getField("ID_FAMILLE_ARTICLE"), "=", row.getForeignID("ID_FAMILLE_ARTICLE")));
|
1111 |
}
|
1108 |
}
|
1112 |
}
|
1109 |
}
|
1113 |
SQLRowAccessor foreign = row.getForeign("ID_ARTICLE");
|
1110 |
SQLRowAccessor foreign = row.getForeign("ID_ARTICLE");
|
1114 |
if (foreign != null && !foreign.isUndefined() && foreign.getObject("CODE") != null && foreign.getString("CODE").equals(row.getString("CODE"))) {
|
1111 |
if (foreign != null && !foreign.isUndefined() && foreign.getObject("CODE") != null && foreign.getString("CODE").equals(row.getString("CODE"))) {
|
Line 1224... |
Line 1221... |
1224 |
if (l2.size() > 0) {
|
1221 |
if (l2.size() > 0) {
|
1225 |
System.err.println("ARTICLE " + l2.get(0).getString("NOM"));
|
1222 |
System.err.println("ARTICLE " + l2.get(0).getString("NOM"));
|
1226 |
Tuple3<Double, String, String> art = Tuple3.create(1.0D, l2.get(0).getString("CODE"), l2.get(0).getString("NOM"));
|
1223 |
Tuple3<Double, String, String> art = Tuple3.create(1.0D, l2.get(0).getString("CODE"), l2.get(0).getString("NOM"));
|
1227 |
List<Tuple3<Double, String, String>> l = new ArrayList<Tuple3<Double, String, String>>();
|
1224 |
List<Tuple3<Double, String, String>> l = new ArrayList<Tuple3<Double, String, String>>();
|
1228 |
l.add(art);
|
1225 |
l.add(art);
|
1229 |
insertFromDrop(l, m);
|
1226 |
insertFromDrop(l, codeCompletionManager);
|
1230 |
} else {
|
1227 |
} else {
|
1231 |
System.err.println("ARTICLE NOT FOUND !");
|
1228 |
System.err.println("ARTICLE NOT FOUND !");
|
1232 |
}
|
1229 |
}
|
1233 |
}
|
1230 |
}
|
1234 |
|
1231 |
|
Line 1253... |
Line 1250... |
1253 |
}
|
1250 |
}
|
1254 |
|
1251 |
|
1255 |
JButton buttonStock = new JButton("Consulter le stock");
|
1252 |
JButton buttonStock = new JButton("Consulter le stock");
|
1256 |
buttonStock.addActionListener(new ActionListener() {
|
1253 |
buttonStock.addActionListener(new ActionListener() {
|
1257 |
public void actionPerformed(ActionEvent event) {
|
1254 |
public void actionPerformed(ActionEvent event) {
|
- |
|
1255 |
try {
|
1258 |
SQLRowValues rowValsSel = table.getSelectedRowValues();
|
1256 |
SQLRowValues rowValsSel = table.getSelectedRowValues();
|
1259 |
if (rowValsSel != null) {
|
1257 |
if (rowValsSel != null) {
|
1260 |
SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
|
1258 |
SQLRowAccessor foreignArt = rowValsSel.getForeign("ID_ARTICLE");
|
1261 |
if (foreignArt != null && !foreignArt.isUndefined()) {
|
1259 |
if (foreignArt != null && !foreignArt.isUndefined()) {
|
1262 |
SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
|
1260 |
SQLRowAccessor rowValsStock = StockSQLElement.getStock(rowValsSel);
|
Line 1265... |
Line 1263... |
1265 |
frame.selectionId(rowValsStock.getID());
|
1263 |
frame.selectionId(rowValsStock.getID());
|
1266 |
frame.setVisible(true);
|
1264 |
frame.setVisible(true);
|
1267 |
}
|
1265 |
}
|
1268 |
}
|
1266 |
}
|
1269 |
}
|
1267 |
}
|
1270 |
|
- |
|
- |
|
1268 |
} catch (Exception e) {
|
- |
|
1269 |
ExceptionHandler.handle("Erreur d'accès au stock", e);
|
- |
|
1270 |
}
|
1271 |
}
|
1271 |
}
|
1272 |
});
|
1272 |
});
|
1273 |
|
1273 |
|
1274 |
this.buttons.add(buttonStock);
|
1274 |
this.buttons.add(buttonStock);
|
1275 |
|
1275 |
|