Line 39... |
Line 39... |
39 |
public enum TypeStockMouvement {
|
39 |
public enum TypeStockMouvement {
|
40 |
REEL, THEORIQUE, REEL_THEORIQUE, RETOUR
|
40 |
REEL, THEORIQUE, REEL_THEORIQUE, RETOUR
|
41 |
};
|
41 |
};
|
42 |
|
42 |
|
43 |
private double realQty, virtualQty, receiptQty, deliverQty;
|
43 |
private double realQty, virtualQty, receiptQty, deliverQty;
|
44 |
public SQLRowAccessor article;
|
44 |
public SQLRowAccessor article, stock;
|
45 |
|
45 |
|
46 |
List<StockItemComponent> components = new ArrayList<StockItemComponent>();
|
46 |
List<StockItemComponent> components = new ArrayList<StockItemComponent>();
|
47 |
|
47 |
|
48 |
public StockItem(SQLRowAccessor article) {
|
48 |
public StockItem(SQLRowAccessor article, SQLRowAccessor stock) {
|
49 |
this.article = article;
|
49 |
this.article = article;
|
50 |
if (this.article.isForeignEmpty("ID_STOCK")) {
|
- |
|
51 |
this.realQty = 0;
|
50 |
this.stock = stock;
|
52 |
this.virtualQty = 0;
|
- |
|
53 |
this.receiptQty = 0;
|
- |
|
54 |
this.deliverQty = 0;
|
- |
|
55 |
} else {
|
- |
|
56 |
SQLRowAccessor row = this.article.getForeign("ID_STOCK");
|
- |
|
57 |
this.realQty = row.getFloat("QTE_REEL");
|
51 |
this.realQty = stock.getFloat("QTE_REEL");
|
58 |
this.virtualQty = row.getFloat("QTE_TH");
|
52 |
this.virtualQty = stock.getFloat("QTE_TH");
|
59 |
this.receiptQty = row.getFloat("QTE_RECEPT_ATTENTE");
|
53 |
this.receiptQty = stock.getFloat("QTE_RECEPT_ATTENTE");
|
60 |
this.deliverQty = row.getFloat("QTE_LIV_ATTENTE");
|
54 |
this.deliverQty = stock.getFloat("QTE_LIV_ATTENTE");
|
61 |
}
|
- |
|
62 |
}
|
55 |
}
|
63 |
|
56 |
|
64 |
public void updateQty(double qty, TypeStockMouvement t) {
|
57 |
public void updateQty(double qty, TypeStockMouvement t) {
|
65 |
updateQty(qty, t, false);
|
58 |
updateQty(qty, t, false);
|
66 |
}
|
59 |
}
|
67 |
|
60 |
|
- |
|
61 |
public void setDeliverQty(double deliverQty) {
|
- |
|
62 |
this.deliverQty = deliverQty;
|
- |
|
63 |
}
|
- |
|
64 |
|
- |
|
65 |
public void setRealQty(double realQty) {
|
- |
|
66 |
this.realQty = realQty;
|
- |
|
67 |
}
|
- |
|
68 |
|
- |
|
69 |
public void setReceiptQty(double receiptQty) {
|
- |
|
70 |
this.receiptQty = receiptQty;
|
- |
|
71 |
}
|
- |
|
72 |
|
- |
|
73 |
public void setVirtualQty(double virtualQty) {
|
- |
|
74 |
this.virtualQty = virtualQty;
|
- |
|
75 |
}
|
- |
|
76 |
|
68 |
public SQLRowAccessor getArticle() {
|
77 |
public SQLRowAccessor getArticle() {
|
69 |
return article;
|
78 |
return article;
|
70 |
};
|
79 |
};
|
71 |
|
80 |
|
72 |
public void addItemComponent(StockItemComponent item) {
|
81 |
public void addItemComponent(StockItemComponent item) {
|
73 |
this.components.add(item);
|
82 |
this.components.add(item);
|
74 |
};
|
83 |
};
|
75 |
|
84 |
|
76 |
public void updateQtyFromChildren() throws IllegalArgumentException {
|
85 |
public boolean updateQtyFromChildren() throws IllegalArgumentException {
|
77 |
if (components.size() == 0) {
|
86 |
if (components.size() == 0) {
|
- |
|
87 |
if (this.article.isUndefined()) {
|
- |
|
88 |
return false;
|
- |
|
89 |
}
|
- |
|
90 |
String code = "";
|
- |
|
91 |
if (this.article != null && this.article.getFields().contains("CODE") && this.article.getString("CODE") != null) {
|
- |
|
92 |
code = this.article.getString("CODE");
|
- |
|
93 |
}
|
78 |
throw new IllegalArgumentException("Impossible de calculé les quantités depuis les composants. Cet article n'est pas composé!");
|
94 |
System.err.println("Impossible de mettre à jour le stock, l'articel n'est pas une nomenclature " + code);
|
- |
|
95 |
return false;
|
- |
|
96 |
|
79 |
}
|
97 |
}
|
80 |
StockItemComponent comp = components.get(0);
|
98 |
StockItemComponent comp = components.get(0);
|
81 |
double real = comp.getItem().getRealQty() == 0 ? 0 : Math.ceil(comp.getItem().getRealQty() / (comp.getQty() * comp.getQtyUnit().doubleValue()));
|
99 |
double real = comp.getItem().getRealQty() == 0 ? 0 : Math.ceil(comp.getItem().getRealQty() / (comp.getQty() * comp.getQtyUnit().doubleValue()));
|
82 |
double virtual = comp.getItem().getVirtualQty() == 0 ? 0 : Math.ceil(comp.getItem().getVirtualQty() / (comp.getQty() * comp.getQtyUnit().doubleValue()));
|
100 |
double virtual = comp.getItem().getVirtualQty() == 0 ? 0 : Math.ceil(comp.getItem().getVirtualQty() / (comp.getQty() * comp.getQtyUnit().doubleValue()));
|
83 |
for (StockItemComponent stockItemComponent : components) {
|
101 |
for (StockItemComponent stockItemComponent : components) {
|
Line 88... |
Line 106... |
88 |
|
106 |
|
89 |
}
|
107 |
}
|
90 |
// La quantité du kit ne peut être négative
|
108 |
// La quantité du kit ne peut être négative
|
91 |
this.realQty = Math.max(0, real);
|
109 |
this.realQty = Math.max(0, real);
|
92 |
this.virtualQty = Math.max(0, virtual);
|
110 |
this.virtualQty = Math.max(0, virtual);
|
- |
|
111 |
return true;
|
93 |
}
|
112 |
}
|
94 |
|
113 |
|
95 |
public void fillCommandeFournisseur(ListMap<SQLRow, SQLRowValues> cmd) {
|
114 |
public void fillCommandeFournisseur(ListMap<SQLRow, SQLRowValues> cmd) {
|
96 |
|
- |
|
- |
|
115 |
// TODO Gestion Stock Min par depot
|
97 |
SQLPreferences prefs = new SQLPreferences(article.getTable().getDBRoot());
|
116 |
SQLPreferences prefs = new SQLPreferences(article.getTable().getDBRoot());
|
98 |
boolean gestionStockMin = prefs.getBoolean(GestionArticleGlobalPreferencePanel.WARNING_STOCK_MIN, true);
|
117 |
boolean gestionStockMin = prefs.getBoolean(GestionArticleGlobalPreferencePanel.WARNING_STOCK_MIN, true);
|
99 |
if (article.getTable().getFieldsName().contains("QTE_MIN") && gestionStockMin && article.getObject("QTE_MIN") != null && getRealQty() < article.getInt("QTE_MIN")) {
|
118 |
if (gestionStockMin && stock.getObject("QTE_MIN") != null && getRealQty() < stock.getFloat("QTE_MIN")) {
|
100 |
// final float qteShow = qteNvlle;
|
119 |
// final float qteShow = qteNvlle;
|
101 |
SQLInjector inj = SQLInjector.getInjector(article.getTable(), article.getTable().getTable("COMMANDE_ELEMENT"));
|
120 |
SQLInjector inj = SQLInjector.getInjector(article.getTable(), article.getTable().getTable("COMMANDE_ELEMENT"));
|
102 |
final SQLRow asRow = article.asRow();
|
121 |
final SQLRow asRow = article.asRow();
|
103 |
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(asRow));
|
122 |
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(asRow));
|
104 |
rowValsElt.put("ID_STYLE", 2);
|
123 |
rowValsElt.put("ID_STYLE", 2);
|
105 |
final SQLRowAccessor unite = article.getForeign("ID_UNITE_VENTE");
|
124 |
final SQLRowAccessor unite = article.getForeign("ID_UNITE_VENTE");
|
106 |
final double qteElt = article.getInt("QTE_MIN") - getRealQty();
|
125 |
final double qteElt = stock.getFloat("QTE_MIN") - getRealQty();
|
107 |
if (unite.isUndefined() || unite.getBoolean("A_LA_PIECE")) {
|
126 |
if (unite.isUndefined() || unite.getBoolean("A_LA_PIECE")) {
|
108 |
rowValsElt.put("QTE", Math.round(qteElt));
|
127 |
rowValsElt.put("QTE", Math.round(qteElt));
|
109 |
rowValsElt.put("QTE_UNITAIRE", BigDecimal.ONE);
|
128 |
rowValsElt.put("QTE_UNITAIRE", BigDecimal.ONE);
|
110 |
} else {
|
129 |
} else {
|
111 |
rowValsElt.put("QTE", 1);
|
130 |
rowValsElt.put("QTE", 1);
|
Line 211... |
Line 230... |
211 |
public double getVirtualQty() {
|
230 |
public double getVirtualQty() {
|
212 |
return virtualQty;
|
231 |
return virtualQty;
|
213 |
}
|
232 |
}
|
214 |
|
233 |
|
215 |
public boolean isStockInit() {
|
234 |
public boolean isStockInit() {
|
216 |
return !this.article.isForeignEmpty("ID_STOCK");
|
235 |
return this.stock != null && !this.stock.isUndefined();
|
217 |
}
|
236 |
}
|
218 |
|
237 |
|
219 |
public void clearStockValues() {
|
238 |
public void clearStockValues() {
|
220 |
this.realQty = 0;
|
239 |
this.realQty = 0;
|
221 |
this.deliverQty = 0;
|
240 |
this.deliverQty = 0;
|
222 |
this.receiptQty = 0;
|
241 |
this.receiptQty = 0;
|
223 |
this.virtualQty = 0;
|
242 |
this.virtualQty = 0;
|
224 |
}
|
243 |
}
|
225 |
|
244 |
|
226 |
public String getUpdateRequest() {
|
245 |
public String getUpdateRequest() {
|
227 |
final SQLTable stockTable = this.article.getTable().getForeignTable("ID_STOCK");
|
246 |
final SQLTable stockTable = this.stock.getTable();
|
228 |
UpdateBuilder update = new UpdateBuilder(stockTable);
|
247 |
UpdateBuilder update = new UpdateBuilder(stockTable);
|
229 |
update.setWhere(new Where(stockTable.getKey(), "=", getArticle().getForeign("ID_STOCK").getID()));
|
248 |
update.setWhere(new Where(stockTable.getKey(), "=", this.stock.getID()));
|
230 |
update.setObject("QTE_REEL", getRealQty());
|
249 |
update.setObject("QTE_REEL", getRealQty());
|
231 |
update.setObject("QTE_TH", getVirtualQty());
|
250 |
update.setObject("QTE_TH", getVirtualQty());
|
232 |
update.setObject("QTE_LIV_ATTENTE", getDeliverQty());
|
251 |
update.setObject("QTE_LIV_ATTENTE", getDeliverQty());
|
233 |
update.setObject("QTE_RECEPT_ATTENTE", getReceiptQty());
|
252 |
update.setObject("QTE_RECEPT_ATTENTE", getReceiptQty());
|
234 |
return update.asString();
|
253 |
return update.asString();
|