Line 15... |
Line 15... |
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
|
17 |
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
|
18 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
18 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
19 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
|
19 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
|
- |
|
20 |
import org.openconcerto.erp.core.sales.pos.io.Barcode;
|
20 |
import org.openconcerto.erp.core.sales.pos.ui.BarcodeListener;
|
21 |
import org.openconcerto.erp.core.sales.pos.io.BarcodeListener;
|
- |
|
22 |
import org.openconcerto.erp.core.sales.product.element.LotSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
22 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
|
- |
|
25 |
import org.openconcerto.erp.core.sales.product.element.LotSQLElement.TypeLot;
|
23 |
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
|
26 |
import org.openconcerto.erp.core.sales.product.ui.CurrencyWithSymbolRenderer;
|
24 |
import org.openconcerto.erp.core.sales.product.ui.DeliveredQtyRowValuesRenderer;
|
27 |
import org.openconcerto.erp.core.sales.product.ui.QtyRowValuesRenderer;
|
- |
|
28 |
import org.openconcerto.erp.core.sales.product.ui.QteMultipleRowValuesRenderer;
|
25 |
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
|
29 |
import org.openconcerto.erp.core.sales.product.ui.QteUnitRowValuesRenderer;
|
26 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
30 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
27 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
31 |
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
|
28 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
32 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
29 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
33 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
30 |
import org.openconcerto.sql.Configuration;
|
34 |
import org.openconcerto.sql.Configuration;
|
31 |
import org.openconcerto.sql.element.SQLElement;
|
35 |
import org.openconcerto.sql.element.SQLElement;
|
32 |
import org.openconcerto.sql.model.FieldPath;
|
36 |
import org.openconcerto.sql.model.FieldPath;
|
- |
|
37 |
import org.openconcerto.sql.model.SQLField;
|
33 |
import org.openconcerto.sql.model.SQLRow;
|
38 |
import org.openconcerto.sql.model.SQLRow;
|
34 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
39 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
35 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
40 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
36 |
import org.openconcerto.sql.model.SQLRowValues;
|
41 |
import org.openconcerto.sql.model.SQLRowValues;
|
- |
|
42 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
37 |
import org.openconcerto.sql.model.SQLSelect;
|
43 |
import org.openconcerto.sql.model.SQLSelect;
|
38 |
import org.openconcerto.sql.model.SQLTable;
|
44 |
import org.openconcerto.sql.model.SQLTable;
|
39 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
45 |
import org.openconcerto.sql.model.UndefinedRowValuesCache;
|
40 |
import org.openconcerto.sql.model.Where;
|
46 |
import org.openconcerto.sql.model.Where;
|
41 |
import org.openconcerto.sql.model.graph.Path;
|
47 |
import org.openconcerto.sql.model.graph.Path;
|
42 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
48 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
- |
|
49 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
43 |
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
|
50 |
import org.openconcerto.sql.sqlobject.ITextArticleWithCompletionCellEditor;
|
44 |
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
|
51 |
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
|
45 |
import org.openconcerto.sql.view.EditFrame;
|
52 |
import org.openconcerto.sql.view.EditFrame;
|
46 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
53 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
47 |
import org.openconcerto.sql.view.list.AutoCompletionManager;
|
54 |
import org.openconcerto.sql.view.list.AutoCompletionManager;
|
Line 49... |
Line 56... |
49 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
56 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
50 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
57 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
51 |
import org.openconcerto.sql.view.list.SQLTableElement;
|
58 |
import org.openconcerto.sql.view.list.SQLTableElement;
|
52 |
import org.openconcerto.sql.view.list.ValidStateChecker;
|
59 |
import org.openconcerto.sql.view.list.ValidStateChecker;
|
53 |
import org.openconcerto.ui.preferences.DefaultProps;
|
60 |
import org.openconcerto.ui.preferences.DefaultProps;
|
- |
|
61 |
import org.openconcerto.utils.CompareUtils;
|
54 |
import org.openconcerto.utils.DecimalUtils;
|
62 |
import org.openconcerto.utils.DecimalUtils;
|
55 |
import org.openconcerto.utils.ExceptionHandler;
|
63 |
import org.openconcerto.utils.ExceptionHandler;
|
56 |
import org.openconcerto.utils.Tuple3;
|
64 |
import org.openconcerto.utils.Tuple3;
|
- |
|
65 |
import org.openconcerto.utils.checks.ValidState;
|
57 |
import org.openconcerto.utils.i18n.TranslationManager;
|
66 |
import org.openconcerto.utils.i18n.TranslationManager;
|
58 |
|
67 |
|
59 |
import java.awt.Component;
|
68 |
import java.awt.Component;
|
60 |
import java.awt.event.ActionEvent;
|
69 |
import java.awt.event.ActionEvent;
|
61 |
import java.awt.event.ActionListener;
|
70 |
import java.awt.event.ActionListener;
|
Line 64... |
Line 73... |
64 |
import java.awt.event.KeyEvent;
|
73 |
import java.awt.event.KeyEvent;
|
65 |
import java.awt.event.MouseAdapter;
|
74 |
import java.awt.event.MouseAdapter;
|
66 |
import java.awt.event.MouseEvent;
|
75 |
import java.awt.event.MouseEvent;
|
67 |
import java.math.BigDecimal;
|
76 |
import java.math.BigDecimal;
|
68 |
import java.math.RoundingMode;
|
77 |
import java.math.RoundingMode;
|
- |
|
78 |
import java.sql.SQLException;
|
69 |
import java.util.ArrayList;
|
79 |
import java.util.ArrayList;
|
70 |
import java.util.Arrays;
|
80 |
import java.util.Arrays;
|
71 |
import java.util.Calendar;
|
81 |
import java.util.Calendar;
|
- |
|
82 |
import java.util.Collections;
|
72 |
import java.util.HashMap;
|
83 |
import java.util.HashMap;
|
73 |
import java.util.HashSet;
|
84 |
import java.util.HashSet;
|
74 |
import java.util.List;
|
85 |
import java.util.List;
|
75 |
import java.util.Map;
|
86 |
import java.util.Map;
|
76 |
import java.util.Set;
|
87 |
import java.util.Set;
|
Line 171... |
Line 182... |
171 |
|
182 |
|
172 |
@Override
|
183 |
@Override
|
173 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
184 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
174 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
185 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
175 |
|
186 |
|
176 |
return b && !isFromTranferred(vals);
|
187 |
return b && !isFromTranferred(vals) && !isLotLinked(vals);
|
177 |
|
188 |
|
178 |
}
|
189 |
}
|
179 |
|
190 |
|
180 |
};
|
191 |
};
|
181 |
list.add(tableElementArticle);
|
192 |
list.add(tableElementArticle);
|
Line 211... |
Line 222... |
211 |
final SQLTableElement tableElementCode = new SQLTableElement(e.getTable().getField("CODE"), String.class,
|
222 |
final SQLTableElement tableElementCode = new SQLTableElement(e.getTable().getField("CODE"), String.class,
|
212 |
new ITextArticleWithCompletionCellEditor(e.getTable().getTable("ARTICLE"), e.getTable().getTable("ARTICLE_FOURNISSEUR"), withDeclinaison)) {
|
223 |
new ITextArticleWithCompletionCellEditor(e.getTable().getTable("ARTICLE"), e.getTable().getTable("ARTICLE_FOURNISSEUR"), withDeclinaison)) {
|
213 |
@Override
|
224 |
@Override
|
214 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
225 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
215 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
226 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
216 |
return b && !isFromTranferred(vals);
|
227 |
return b && !isFromTranferred(vals) && !isLotLinked(vals);
|
217 |
|
228 |
|
218 |
}
|
229 |
}
|
219 |
};
|
230 |
};
|
220 |
list.add(tableElementCode);
|
231 |
list.add(tableElementCode);
|
221 |
// Désignation de l'article
|
232 |
// Désignation de l'article
|
222 |
final SQLTableElement tableElementNom = new SQLTableElement(e.getTable().getField("NOM")) {
|
233 |
final SQLTableElement tableElementNom = new SQLTableElement(e.getTable().getField("NOM")) {
|
223 |
@Override
|
234 |
@Override
|
224 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
235 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
225 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
236 |
boolean b = super.isCellEditable(vals, rowIndex, columnIndex);
|
226 |
return b && !isFromTranferred(vals);
|
237 |
return b && !isFromTranferred(vals) && !isLotLinked(vals);
|
227 |
|
238 |
|
228 |
}
|
239 |
}
|
229 |
};
|
240 |
};
|
230 |
list.add(tableElementNom);
|
241 |
list.add(tableElementNom);
|
231 |
|
242 |
|
Line 301... |
Line 312... |
301 |
|
312 |
|
302 |
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
|
313 |
SQLRowAccessor row = vals.getForeign("ID_UNITE_VENTE");
|
303 |
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
|
314 |
if (row != null && !row.isUndefined() && row.getBoolean("A_LA_PIECE")) {
|
304 |
return false;
|
315 |
return false;
|
305 |
} else {
|
316 |
} else {
|
306 |
return super.isCellEditable(vals, rowIndex, columnIndex);
|
317 |
return super.isCellEditable(vals, rowIndex, columnIndex) && !isLotLinked(vals);
|
307 |
}
|
318 |
}
|
308 |
}
|
319 |
}
|
309 |
|
320 |
|
310 |
@Override
|
321 |
@Override
|
311 |
public TableCellRenderer getTableCellRenderer() {
|
322 |
public TableCellRenderer getTableCellRenderer() {
|
Line 363... |
Line 374... |
363 |
tableQteO.setEditable(false);
|
374 |
tableQteO.setEditable(false);
|
364 |
list.add(tableQteO);
|
375 |
list.add(tableQteO);
|
365 |
}
|
376 |
}
|
366 |
|
377 |
|
367 |
// Quantité
|
378 |
// Quantité
|
368 |
final SQLTableElement qteElement = new SQLTableElement(e.getTable().getField("QTE"), Integer.class) {
|
379 |
final SQLTableElement qteElement = new SQLTableElement(e.getTable().getField("QTE"), Integer.class, new QteCellEditor()) {
|
369 |
protected Object getDefaultNullValue() {
|
380 |
protected Object getDefaultNullValue() {
|
370 |
return Integer.valueOf(0);
|
381 |
return Integer.valueOf(0);
|
371 |
}
|
382 |
}
|
- |
|
383 |
|
- |
|
384 |
@Override
|
- |
|
385 |
public boolean isCellEditable(SQLRowValues vals, int rowIndex, int columnIndex) {
|
- |
|
386 |
|
- |
|
387 |
return super.isCellEditable(vals, rowIndex, columnIndex) && !isLotLinked(vals);
|
- |
|
388 |
}
|
- |
|
389 |
|
- |
|
390 |
public TableCellRenderer getTableCellRenderer() {
|
- |
|
391 |
if (getSQLElement().getTable().getFieldsName().contains("QTE_ACHAT")) {
|
- |
|
392 |
return new QteMultipleRowValuesRenderer();
|
- |
|
393 |
} else {
|
- |
|
394 |
return super.getTableCellRenderer();
|
- |
|
395 |
}
|
- |
|
396 |
}
|
372 |
};
|
397 |
};
|
373 |
if (fieldsName.contains("QTE_ORIGINE")) {
|
398 |
if (fieldsName.contains("QTE_ORIGINE")) {
|
374 |
qteElement.setRenderer(new DeliveredQtyRowValuesRenderer(false));
|
399 |
qteElement.setRenderer(new QtyRowValuesRenderer(false));
|
375 |
}
|
400 |
}
|
376 |
list.add(qteElement);
|
401 |
list.add(qteElement);
|
377 |
// TVA
|
402 |
// TVA
|
378 |
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
|
403 |
this.tableElementTVA = new SQLTableElement(e.getTable().getField("ID_TAXE"));
|
379 |
list.add(this.tableElementTVA);
|
404 |
list.add(this.tableElementTVA);
|
Line 533... |
Line 558... |
533 |
this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault);
|
558 |
this.defaultRowVals.put("ID_DEPOT_STOCK", depotDefault);
|
534 |
}
|
559 |
}
|
535 |
|
560 |
|
536 |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("QTE"), false, this.defaultRowVals) {
|
561 |
final RowValuesTableModel model = new RowValuesTableModel(e, list, e.getTable().getField("QTE"), false, this.defaultRowVals) {
|
537 |
@Override
|
562 |
@Override
|
538 |
public void commitData() {
|
563 |
public void commitData() throws SQLException {
|
539 |
super.commitData(true);
|
564 |
commitData(true);
|
540 |
}
|
565 |
}
|
541 |
};
|
- |
|
542 |
|
566 |
|
- |
|
567 |
@Override
|
- |
|
568 |
public void commitData(boolean useMultipleInsertUpdate) throws SQLException {
|
- |
|
569 |
if (getSQLElement().getTable().getName().equalsIgnoreCase("BON_RECEPTION_ELEMENT")) {
|
- |
|
570 |
// Mise à jour de l'ID_ARTICLE et l'ID_DEPOT_STOCK
|
- |
|
571 |
final SQLTable tableLotR = getSQLElement().getTable().getTable("LOT_RECEPTION");
|
- |
|
572 |
for (int i = 0; i < getRowCount(); i++) {
|
- |
|
573 |
final SQLRowValues rowValuesAt = getRowValuesAt(i);
|
- |
|
574 |
final Set<SQLRowValues> referentRows = rowValuesAt.getReferentRows(tableLotR.getField("ID_BON_RECEPTION_ELEMENT"));
|
- |
|
575 |
for (SQLRowValues ref : referentRows) {
|
- |
|
576 |
ref.put("ID_ARTICLE", rowValuesAt.getForeignIDNumber("ID_ARTICLE"));
|
- |
|
577 |
ref.put("ID_DEPOT_STOCK", rowValuesAt.getForeignIDNumber("ID_DEPOT_STOCK"));
|
- |
|
578 |
}
|
- |
|
579 |
}
|
- |
|
580 |
}
|
- |
|
581 |
super.commitData(useMultipleInsertUpdate);
|
- |
|
582 |
if (getSQLElement().getTable().getName().equalsIgnoreCase("BON_RECEPTION_ELEMENT")) {
|
- |
|
583 |
getSQLElement().getDirectory().getElement(LotSQLElement.class).updateLotQuantiteFromBRItems(getCopyOfValues());
|
- |
|
584 |
}
|
- |
|
585 |
}
|
- |
|
586 |
|
- |
|
587 |
@Override
|
- |
|
588 |
public List<SQLRowValues> fetchDataFromDB(SQLRowAccessor rowVals, SQLField referentField, SQLField fieldWhere, Object value) {
|
- |
|
589 |
final SQLTable table = getSQLElement().getTable();
|
- |
|
590 |
List<SQLRowValues> newRows = new ArrayList<>();
|
- |
|
591 |
SQLRowValues rowValsBrItem = new SQLRowValues(table);
|
- |
|
592 |
rowValsBrItem.putNulls(table.getFieldsName());
|
- |
|
593 |
rowValsBrItem.putRowValues("ID_UNITE_VENTE").putNulls("A_LA_PIECE");
|
- |
|
594 |
rowValsBrItem.putRowValues("ID_ARTICLE").putNulls("CODE", "NOM", "DLC_REQUIS", "DLUO_REQUIS", "NUMERO_LOT_REQUIS", "NUMERO_SERIE_REQUIS");
|
- |
|
595 |
if (table.getName().equals("BON_RECEPTION_ELEMENT")) {
|
- |
|
596 |
final SQLTable tableLotR = table.getTable("LOT_RECEPTION");
|
- |
|
597 |
SQLRowValues rowValsLotRecp = new SQLRowValues(tableLotR);
|
- |
|
598 |
rowValsLotRecp.putNulls(rowValsLotRecp.getTable().getFieldsName());
|
- |
|
599 |
rowValsLotRecp.put("ID_BON_RECEPTION_ELEMENT", rowValsBrItem);
|
- |
|
600 |
}
|
- |
|
601 |
if (referentField == null) {
|
- |
|
602 |
referentField = table.getField("ID_" + rowVals.getTable().getName());
|
- |
|
603 |
}
|
- |
|
604 |
final List<SQLRowValues> fetch = SQLRowValuesListFetcher.create(rowValsBrItem).fetch(new Where(referentField, "=", rowVals.getID()));
|
- |
|
605 |
for (SQLRowValues row2 : fetch) {
|
- |
|
606 |
if (fieldWhere == null || CompareUtils.equals(row2.getObject(fieldWhere.getName()), value)) {
|
- |
|
607 |
newRows.add(row2);
|
- |
|
608 |
}
|
- |
|
609 |
}
|
- |
|
610 |
return newRows;
|
- |
|
611 |
}
|
- |
|
612 |
|
- |
|
613 |
};
|
- |
|
614 |
if (getSQLElement().getTable().getName().equalsIgnoreCase("BON_RECEPTION_ELEMENT")) {
|
- |
|
615 |
model.setGestionReferentActive(true);
|
- |
|
616 |
}
|
543 |
setModel(model);
|
617 |
setModel(model);
|
544 |
|
618 |
|
545 |
this.table = new RowValuesTable(model, getConfigurationFile());
|
619 |
this.table = new RowValuesTable(model, getConfigurationFile()) {
|
- |
|
620 |
@Override
|
- |
|
621 |
public synchronized ValidState getValidState() {
|
- |
|
622 |
if (getSQLElement().getTable().getName().equalsIgnoreCase("BON_RECEPTION_ELEMENT")) {
|
- |
|
623 |
final LotSQLElement element = getSQLElement().getDirectory().getElement(LotSQLElement.class);
|
- |
|
624 |
ValidState lotState = element.getValidStateOfRowValuesTable(getRowValuesTable().getRowValuesTableModel(), TypeLot.RECEPTION);
|
- |
|
625 |
if (lotState != ValidState.getTrueInstance()) {
|
- |
|
626 |
return lotState;
|
- |
|
627 |
}
|
- |
|
628 |
}
|
- |
|
629 |
return super.getValidState();
|
- |
|
630 |
}
|
- |
|
631 |
};
|
546 |
ToolTipManager.sharedInstance().unregisterComponent(this.table);
|
632 |
ToolTipManager.sharedInstance().unregisterComponent(this.table);
|
547 |
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
|
633 |
ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
|
548 |
if (getSQLElement().getTable().getName().equals("COMMANDE_ELEMENT")) {
|
634 |
if (getSQLElement().getTable().getName().equals("COMMANDE_ELEMENT")) {
|
549 |
this.table.getClearCloneTableElement().add("QTE_RECUE");
|
635 |
this.table.getClearCloneTableElement().add("QTE_RECUE");
|
550 |
this.table.getClearCloneTableElement().add("RECU");
|
636 |
this.table.getClearCloneTableElement().add("RECU");
|
Line 626... |
Line 712... |
626 |
completionFields.add("QTE_UNITAIRE");
|
712 |
completionFields.add("QTE_UNITAIRE");
|
627 |
completionFields.add("PA_HT");
|
713 |
completionFields.add("PA_HT");
|
628 |
completionFields.add("PV_HT");
|
714 |
completionFields.add("PV_HT");
|
629 |
completionFields.add("POIDS");
|
715 |
completionFields.add("POIDS");
|
630 |
completionFields.add("ID_TAXE");
|
716 |
completionFields.add("ID_TAXE");
|
- |
|
717 |
completionFields.add("ID_MODE_VENTE_ARTICLE");
|
631 |
completionFields.add("PRIX_METRIQUE_HA_1");
|
718 |
completionFields.add("PRIX_METRIQUE_HA_1");
|
632 |
completionFields.add("PRIX_METRIQUE_HA_2");
|
719 |
completionFields.add("PRIX_METRIQUE_HA_2");
|
633 |
completionFields.add("PRIX_METRIQUE_HA_3");
|
720 |
completionFields.add("PRIX_METRIQUE_HA_3");
|
634 |
completionFields.add("VALEUR_METRIQUE_1");
|
721 |
completionFields.add("VALEUR_METRIQUE_1");
|
635 |
completionFields.add("VALEUR_METRIQUE_2");
|
722 |
completionFields.add("VALEUR_METRIQUE_2");
|
636 |
completionFields.add("VALEUR_METRIQUE_3");
|
723 |
completionFields.add("VALEUR_METRIQUE_3");
|
637 |
completionFields.add("ID_MODE_VENTE_ARTICLE");
|
- |
|
638 |
completionFields.add("PRIX_METRIQUE_VT_1");
|
724 |
completionFields.add("PRIX_METRIQUE_VT_1");
|
639 |
completionFields.add("PRIX_METRIQUE_VT_2");
|
725 |
completionFields.add("PRIX_METRIQUE_VT_2");
|
640 |
completionFields.add("PRIX_METRIQUE_VT_3");
|
726 |
completionFields.add("PRIX_METRIQUE_VT_3");
|
641 |
completionFields.add("SERVICE");
|
727 |
completionFields.add("SERVICE");
|
642 |
completionFields.add("ID_DEVISE");
|
728 |
completionFields.add("ID_DEVISE");
|
Line 657... |
Line 743... |
657 |
completionFields.add("POIDS_COLIS_NET");
|
743 |
completionFields.add("POIDS_COLIS_NET");
|
658 |
}
|
744 |
}
|
659 |
if (getSQLElement().getTable().getFieldsName().contains("TARE") && sqlTableArticle.getTable().getFieldsName().contains("TARE")) {
|
745 |
if (getSQLElement().getTable().getFieldsName().contains("TARE") && sqlTableArticle.getTable().getFieldsName().contains("TARE")) {
|
660 |
completionFields.add("TARE");
|
746 |
completionFields.add("TARE");
|
661 |
}
|
747 |
}
|
- |
|
748 |
if (getSQLElement().getTable().getFieldsName().contains("QTE_ACHAT") && sqlTableArticle.getTable().getFieldsName().contains("QTE_ACHAT")) {
|
- |
|
749 |
completionFields.add("QTE_ACHAT");
|
- |
|
750 |
}
|
662 |
this.m = new AutoCompletionManager(tableElementCode, sqlTableArticle.getField("CODE"), this.table, this.table.getRowValuesTableModel()) {
|
751 |
this.m = new AutoCompletionManager(tableElementCode, sqlTableArticle.getField("CODE"), this.table, this.table.getRowValuesTableModel()) {
|
663 |
@Override
|
752 |
@Override
|
664 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
753 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
665 |
Object res = tarifCompletion(row, field);
|
754 |
Object res = tarifCompletion(row, field);
|
666 |
if (res == null) {
|
755 |
if (res == null) {
|
Line 683... |
Line 772... |
683 |
m.fill(string, string);
|
772 |
m.fill(string, string);
|
684 |
}
|
773 |
}
|
685 |
final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
774 |
final Where w = new Where(sqlTableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
686 |
m.setWhere(w);
|
775 |
m.setWhere(w);
|
687 |
|
776 |
|
- |
|
777 |
ComboSQLRequest req = new ComboSQLRequest(sqlTableArticle, Arrays.asList("NOM", "CODE"));
|
- |
|
778 |
req.setWhere(w);
|
688 |
this.m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
|
779 |
this.m2 = new AutoCompletionManager(tableElementNom, ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getField("ARTICLE.NOM"), this.table,
|
689 |
this.table.getRowValuesTableModel()) {
|
780 |
this.table.getRowValuesTableModel(), req) {
|
690 |
@Override
|
781 |
@Override
|
691 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
782 |
protected Object getValueFrom(SQLRow row, String field, SQLRowAccessor rowDest) {
|
692 |
Object res = tarifCompletion(row, field);
|
783 |
Object res = tarifCompletion(row, field);
|
693 |
if (res == null) {
|
784 |
if (res == null) {
|
694 |
return super.getValueFrom(row, field, rowDest);
|
785 |
return super.getValueFrom(row, field, rowDest);
|
695 |
} else {
|
786 |
} else {
|
696 |
return res;
|
787 |
return res;
|
697 |
}
|
788 |
}
|
698 |
}
|
789 |
}
|
699 |
};
|
790 |
};
|
- |
|
791 |
m2.setFillWithField("NOM");
|
700 |
m2.fill("CODE", "CODE");
|
792 |
m2.fill("CODE", "CODE");
|
701 |
m2.fill("ID", "ID_ARTICLE");
|
793 |
m2.fill("ID", "ID_ARTICLE");
|
702 |
for (String string : completionFields) {
|
794 |
for (String string : completionFields) {
|
703 |
m2.fill(string, string);
|
795 |
m2.fill(string, string);
|
704 |
}
|
796 |
}
|
Line 749... |
Line 841... |
749 |
@Override
|
841 |
@Override
|
750 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
842 |
public Object computeValueFrom(SQLRowValues row, SQLTableElement source) {
|
751 |
try {
|
843 |
try {
|
752 |
SQLRowAccessor foreign = row.getForeign("ID_ARTICLE");
|
844 |
SQLRowAccessor foreign = row.getForeign("ID_ARTICLE");
|
753 |
if (foreign != null && !foreign.isUndefined() && foreign.getObject("CODE") != null && foreign.getString("CODE").equals(row.getString("CODE"))) {
|
845 |
if (foreign != null && !foreign.isUndefined() && foreign.getObject("CODE") != null && foreign.getString("CODE").equals(row.getString("CODE"))) {
|
754 |
return foreign.getID();
|
846 |
return foreign/* .getID() */;
|
755 |
} else {
|
847 |
} else {
|
756 |
return tableArticle.getUndefinedID();
|
848 |
return tableArticle.getUndefinedID();
|
757 |
}
|
849 |
}
|
758 |
} catch (Exception e) {
|
850 |
} catch (Exception e) {
|
759 |
return tableArticle.getUndefinedID();
|
851 |
return tableArticle.getUndefinedID();
|
Line 1044... |
Line 1136... |
1044 |
public void keyReceived(KeyEvent ee) {
|
1136 |
public void keyReceived(KeyEvent ee) {
|
1045 |
// TODO Auto-generated method stub
|
1137 |
// TODO Auto-generated method stub
|
1046 |
}
|
1138 |
}
|
1047 |
|
1139 |
|
1048 |
@Override
|
1140 |
@Override
|
1049 |
public void barcodeRead(String code) {
|
1141 |
public void barcodeRead(Barcode barcode) {
|
1050 |
if (((JFrame) SwingUtilities.getRoot(getRowValuesTable())).isActive()) {
|
1142 |
if (((JFrame) SwingUtilities.getRoot(getRowValuesTable())).isActive()) {
|
1051 |
final SQLSelect selArticle = new SQLSelect();
|
1143 |
final SQLSelect selArticle = new SQLSelect();
|
1052 |
final SQLTable tableArticle = getSQLElement().getForeignElement("ID_ARTICLE").getTable();
|
1144 |
final SQLTable tableArticle = getSQLElement().getForeignElement("ID_ARTICLE").getTable();
|
1053 |
selArticle.addSelectStar(tableArticle);
|
1145 |
selArticle.addSelectStar(tableArticle);
|
1054 |
Where w = new Where(tableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
1146 |
Where w = new Where(tableArticle.getField("OBSOLETE"), "=", Boolean.FALSE);
|
1055 |
w = w.and(new Where(tableArticle.getField("CODE_BARRE"), "=", code));
|
1147 |
w = w.and(new Where(tableArticle.getField("CODE_BARRE"), "=", barcode.getData()));
|
1056 |
selArticle.setWhere(w);
|
1148 |
selArticle.setWhere(w);
|
1057 |
List<SQLRow> l2 = SQLRowListRSH.execute(selArticle);
|
1149 |
List<SQLRow> l2 = SQLRowListRSH.execute(selArticle);
|
1058 |
if (l2.size() > 0) {
|
1150 |
if (l2.size() > 0) {
|
1059 |
System.err.println("ARTICLE " + l2.get(0).getString("NOM"));
|
1151 |
System.err.println("ARTICLE " + l2.get(0).getString("NOM"));
|
1060 |
Tuple3<Double, String, String> art = Tuple3.create(1.0D, l2.get(0).getString("CODE"), l2.get(0).getString("NOM"));
|
1152 |
Tuple3<Double, String, String> art = Tuple3.create(1.0D, l2.get(0).getString("CODE"), l2.get(0).getString("NOM"));
|
Line 1185... |
Line 1277... |
1185 |
} else if (this.incoterm != null && this.incoterm.equalsIgnoreCase("DDP")) {
|
1277 |
} else if (this.incoterm != null && this.incoterm.equalsIgnoreCase("DDP")) {
|
1186 |
incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT", "COEF_TAXE_D");
|
1278 |
incoTerms = Arrays.asList("PRIX_ACHAT", "COEF_TRANSPORT_PORT", "COEF_TAXE_D");
|
1187 |
} else {
|
1279 |
} else {
|
1188 |
incoTerms = Arrays.asList("PRIX_ACHAT");
|
1280 |
incoTerms = Arrays.asList("PRIX_ACHAT");
|
1189 |
}
|
1281 |
}
|
- |
|
1282 |
List<SQLRowValues> rows;
|
- |
|
1283 |
|
- |
|
1284 |
if (this.rowFournisseur != null && !this.rowFournisseur.isUndefined()) {
|
- |
|
1285 |
|
1190 |
List<SQLRow> rows = row.getReferentRows(tTarifFournisseur);
|
1286 |
SQLRowValues rowValsTarif = new SQLRowValues(tTarifFournisseur);
|
- |
|
1287 |
rowValsTarif.putNulls(tTarifFournisseur.getFieldsName());
|
- |
|
1288 |
Where where = new Where(tTarifFournisseur.getField("ID_FOURNISSEUR"), "=", this.rowFournisseur.getID()).and(new Where(tTarifFournisseur.getField("ID_ARTICLE"), "=", row.getID()));
|
- |
|
1289 |
rows = SQLRowValuesListFetcher.create(rowValsTarif).fetch(where);
|
- |
|
1290 |
|
- |
|
1291 |
if (rows.isEmpty() && row.getObject("ID_ARTICLE_VIRTUEL_PERE") != null && !row.isForeignEmpty("ID_ARTICLE_VIRTUEL_PERE")) {
|
- |
|
1292 |
Where where2 = new Where(tTarifFournisseur.getField("ID_FOURNISSEUR"), "=", this.rowFournisseur.getID())
|
- |
|
1293 |
.and(new Where(tTarifFournisseur.getField("ID_ARTICLE"), "=", row.getForeignID("ID_ARTICLE_VIRTUEL_PERE")));
|
- |
|
1294 |
rows = SQLRowValuesListFetcher.create(rowValsTarif).fetch(where2);
|
- |
|
1295 |
}
|
- |
|
1296 |
} else {
|
- |
|
1297 |
rows = Collections.emptyList();
|
- |
|
1298 |
}
|
1191 |
if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE") && row.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
|
1299 |
if (row.getBoolean("AUTO_PRIX_ACHAT_NOMENCLATURE") && row.getTable().getDBRoot().contains("ARTICLE_PRIX_REVIENT")) {
|
1192 |
|
1300 |
|
1193 |
List<SQLRow> rowsElt = row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
1301 |
List<SQLRow> rowsElt = row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT"));
|
1194 |
BigDecimal price = BigDecimal.ZERO;
|
1302 |
BigDecimal price = BigDecimal.ZERO;
|
1195 |
final Set<String> tarifNotFound = new HashSet<String>();
|
1303 |
final Set<String> tarifNotFound = new HashSet<String>();
|
Line 1250... |
Line 1358... |
1250 |
} else if (!rows.isEmpty()) {
|
1358 |
} else if (!rows.isEmpty()) {
|
1251 |
|
1359 |
|
1252 |
BigDecimal min = row.getBigDecimal("PRIX_METRIQUE_HA_1");
|
1360 |
BigDecimal min = row.getBigDecimal("PRIX_METRIQUE_HA_1");
|
1253 |
|
1361 |
|
1254 |
Calendar c = null;
|
1362 |
Calendar c = null;
|
1255 |
for (SQLRow sqlRow : rows) {
|
1363 |
for (SQLRowValues sqlRow : rows) {
|
1256 |
if (this.rowFournisseur != null && this.rowFournisseur.getID() == sqlRow.getForeignID("ID_FOURNISSEUR")) {
|
1364 |
if (this.rowFournisseur != null && this.rowFournisseur.getID() == sqlRow.getForeignID("ID_FOURNISSEUR")) {
|
1257 |
BigDecimal price = getPrice(sqlRow, incoTerms);
|
1365 |
BigDecimal price = getPrice(sqlRow, incoTerms);
|
1258 |
final Calendar datePrice = sqlRow.getDate("DATE_PRIX");
|
1366 |
final Calendar datePrice = sqlRow.getDate("DATE_PRIX");
|
1259 |
if (datePrice == null || (this.getDateDevise() != null && !this.getDateDevise().before(datePrice.getTime()))) {
|
1367 |
if (datePrice == null || (this.getDateDevise() != null && !this.getDateDevise().before(datePrice.getTime()))) {
|
1260 |
if (c == null || c.before(datePrice)) {
|
1368 |
if (c == null || c.before(datePrice)) {
|
Line 1478... |
Line 1586... |
1478 |
}
|
1586 |
}
|
1479 |
}
|
1587 |
}
|
1480 |
return false;
|
1588 |
return false;
|
1481 |
}
|
1589 |
}
|
1482 |
|
1590 |
|
- |
|
1591 |
private boolean isLotLinked(SQLRowValues vals) {
|
- |
|
1592 |
if (vals.getTable().getName().equals("BON_RECEPTION_ELEMENT")) {
|
- |
|
1593 |
return !vals.getReferentRows(vals.getTable().getTable("LOT_RECEPTION").getField("ID_BON_RECEPTION_ELEMENT")).isEmpty();
|
- |
|
1594 |
}
|
- |
|
1595 |
return false;
|
- |
|
1596 |
}
|
- |
|
1597 |
|
1483 |
}
|
1598 |
}
|