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 19... |
Line 19... |
19 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
|
19 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
|
20 |
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
|
20 |
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
|
21 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
21 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
22 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
22 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
23 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
23 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
- |
|
24 |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel;
|
24 |
import org.openconcerto.sql.element.SQLComponent;
|
25 |
import org.openconcerto.sql.element.SQLComponent;
|
25 |
import org.openconcerto.sql.element.SQLElement;
|
26 |
import org.openconcerto.sql.element.SQLElement;
|
26 |
import org.openconcerto.sql.element.UISQLComponent;
|
27 |
import org.openconcerto.sql.element.UISQLComponent;
|
27 |
import org.openconcerto.sql.model.SQLInjector;
|
28 |
import org.openconcerto.sql.model.SQLInjector;
|
28 |
import org.openconcerto.sql.model.SQLRow;
|
29 |
import org.openconcerto.sql.model.SQLRow;
|
Line 30... |
Line 31... |
30 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
31 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
31 |
import org.openconcerto.sql.model.SQLRowValues;
|
32 |
import org.openconcerto.sql.model.SQLRowValues;
|
32 |
import org.openconcerto.sql.model.SQLSelect;
|
33 |
import org.openconcerto.sql.model.SQLSelect;
|
33 |
import org.openconcerto.sql.model.SQLTable;
|
34 |
import org.openconcerto.sql.model.SQLTable;
|
34 |
import org.openconcerto.sql.model.Where;
|
35 |
import org.openconcerto.sql.model.Where;
|
- |
|
36 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
35 |
import org.openconcerto.sql.request.ListSQLRequest;
|
37 |
import org.openconcerto.sql.request.ListSQLRequest;
|
36 |
import org.openconcerto.sql.request.UpdateBuilder;
|
38 |
import org.openconcerto.sql.request.UpdateBuilder;
|
37 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
39 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
38 |
import org.openconcerto.sql.users.UserManager;
|
40 |
import org.openconcerto.sql.users.UserManager;
|
39 |
import org.openconcerto.sql.view.EditFrame;
|
41 |
import org.openconcerto.sql.view.EditFrame;
|
Line 211... |
Line 213... |
211 |
return "Commande N°" + rowElt.getForeign("ID_COMMANDE_CLIENT").getString("NUMERO");
|
213 |
return "Commande N°" + rowElt.getForeign("ID_COMMANDE_CLIENT").getString("NUMERO");
|
212 |
}
|
214 |
}
|
213 |
}, res.get(0), res, TypeStockUpdate.VIRTUAL_DELIVER, false);
|
215 |
}, res.get(0), res, TypeStockUpdate.VIRTUAL_DELIVER, false);
|
214 |
try {
|
216 |
try {
|
215 |
updater.update();
|
217 |
updater.update();
|
- |
|
218 |
} catch (
|
- |
|
219 |
|
216 |
} catch (SQLException e1) {
|
220 |
SQLException e1) {
|
217 |
e1.printStackTrace();
|
221 |
e1.printStackTrace();
|
218 |
}
|
222 |
}
|
219 |
}
|
223 |
}
|
220 |
}
|
224 |
}
|
221 |
}
|
225 |
}
|
Line 227... |
Line 231... |
227 |
|
231 |
|
228 |
protected List<String> getListFields() {
|
232 |
protected List<String> getListFields() {
|
229 |
final List<String> l = new ArrayList<String>();
|
233 |
final List<String> l = new ArrayList<String>();
|
230 |
l.add("CODE");
|
234 |
l.add("CODE");
|
231 |
l.add("NOM");
|
235 |
l.add("NOM");
|
- |
|
236 |
SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
|
- |
|
237 |
if (prefs.getBoolean(GestionArticleGlobalPreferencePanel.ACTIVER_DECLINAISON, false)) {
|
- |
|
238 |
|
- |
|
239 |
for (String fieldName : getTable().getFieldsName()) {
|
- |
|
240 |
if (fieldName.startsWith("ID_ARTICLE_DECLINAISON_")) {
|
- |
|
241 |
l.add(fieldName);
|
- |
|
242 |
}
|
- |
|
243 |
}
|
- |
|
244 |
}
|
232 |
l.add("ID_COMMANDE_CLIENT");
|
245 |
l.add("ID_COMMANDE_CLIENT");
|
233 |
l.add("ID_ARTICLE");
|
246 |
l.add("ID_ARTICLE");
|
234 |
l.add("ID_DEPOT_STOCK");
|
247 |
l.add("ID_DEPOT_STOCK");
|
235 |
l.add("PA_HT");
|
248 |
l.add("PA_HT");
|
236 |
l.add("PV_HT");
|
249 |
l.add("PV_HT");
|
Line 248... |
Line 261... |
248 |
/**
|
261 |
/**
|
249 |
* Transfert d'une commande en commande fournisseur
|
262 |
* Transfert d'une commande en commande fournisseur
|
250 |
*
|
263 |
*
|
251 |
* @param commandeID
|
264 |
* @param commandeID
|
252 |
*/
|
265 |
*/
|
253 |
public void transfertCommande(List<SQLRowValues> commandeClientEltsRows) {
|
266 |
public void transfertCommande(List<SQLRowAccessor> commandeClientEltsRows) {
|
254 |
|
267 |
|
255 |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
|
268 |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() {
|
256 |
|
269 |
|
257 |
@Override
|
270 |
@Override
|
258 |
public void run() {
|
271 |
public void run() {
|
Line 262... |
Line 275... |
262 |
|
275 |
|
263 |
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
|
276 |
final ListMap<SQLRow, SQLRowValues> map = new ListMap<SQLRow, SQLRowValues>();
|
264 |
List<String> fields2copy = Arrays.asList("CODE", "NOM", "VALEUR_METRIQUE_1", "VALEUR_METRIQUE_2", "VALEUR_METRIQUE_3");
|
277 |
List<String> fields2copy = Arrays.asList("CODE", "NOM", "VALEUR_METRIQUE_1", "VALEUR_METRIQUE_2", "VALEUR_METRIQUE_3");
|
265 |
|
278 |
|
266 |
Set<Integer> artAdded = new HashSet<Integer>();
|
279 |
Set<Integer> artAdded = new HashSet<Integer>();
|
267 |
for (SQLRowValues sqlRow : commandeClientEltsRows) {
|
280 |
for (SQLRowAccessor sqlRow : commandeClientEltsRows) {
|
268 |
boolean article = false;
|
281 |
boolean article = false;
|
269 |
if (sqlRow.getTable().getName().equalsIgnoreCase("ARTICLE")) {
|
282 |
if (sqlRow.getTable().getName().equalsIgnoreCase("ARTICLE")) {
|
270 |
article = true;
|
283 |
article = true;
|
271 |
}
|
284 |
}
|
272 |
|
285 |
|
273 |
// renderer sur liste des ar
|
- |
|
274 |
|
- |
|
275 |
// if()
|
- |
|
276 |
|
- |
|
277 |
/// rowValsElt.put("QTE", sqlRow.getObject("QTE"));
|
- |
|
278 |
SQLRowAccessor rowArticleFind;
|
286 |
SQLRowAccessor rowArticleFind;
|
279 |
SQLRowValues rowArticle;
|
- |
|
280 |
int qte = 1;
|
287 |
int qte = 1;
|
281 |
BigDecimal qteUV = BigDecimal.ONE;
|
288 |
BigDecimal qteUV = BigDecimal.ONE;
|
282 |
boolean gestionStock = true;
|
289 |
boolean gestionStock = true;
|
283 |
if (!article) {
|
290 |
if (!article) {
|
- |
|
291 |
SQLRowValues rowArticle;
|
- |
|
292 |
if (sqlRow.contains("ID_ARTICLE") && sqlRow.getNonEmptyForeign("ID_ARTICLE") != null) {
|
- |
|
293 |
// on récupére l'article qui lui correspond
|
- |
|
294 |
rowArticleFind = sqlRow.asRow().getForeign("ID_ARTICLE");
|
- |
|
295 |
rowArticle = rowArticleFind.asRowValues();
|
- |
|
296 |
} else {
|
284 |
// on récupére l'article qui lui correspond
|
297 |
// on récupére l'article qui lui correspond
|
285 |
rowArticle = new SQLRowValues(eltArticle.getTable());
|
298 |
rowArticle = new SQLRowValues(eltArticle.getTable());
|
286 |
for (String field : fields2copy) {
|
299 |
for (String field : fields2copy) {
|
287 |
// if (sqlRow.getTable().getFieldsName().contains(field.getName())) {
|
- |
|
288 |
rowArticle.put(field, sqlRow.asRow().getObject(field));
|
300 |
rowArticle.put(field, sqlRow.asRow().getObject(field));
|
289 |
// }
|
- |
|
290 |
}
|
301 |
}
|
291 |
|
- |
|
292 |
int idArticle = ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
|
302 |
int idArticle = ReferenceArticleSQLElement.getIdForCNM(rowArticle, true);
|
293 |
rowArticleFind = eltArticle.getTable().getRow(idArticle);
|
303 |
rowArticleFind = eltArticle.getTable().getRow(idArticle);
|
294 |
|
- |
|
- |
|
304 |
}
|
295 |
gestionStock = rowArticleFind.getBoolean("GESTION_STOCK");
|
305 |
gestionStock = rowArticleFind.getBoolean("GESTION_STOCK");
|
296 |
if (!gestionStock) {
|
306 |
if (!gestionStock) {
|
297 |
qte = sqlRow.getInt("QTE");
|
307 |
qte = sqlRow.getInt("QTE");
|
298 |
qteUV = sqlRow.getBigDecimal("QTE_UNITAIRE");
|
308 |
qteUV = sqlRow.getBigDecimal("QTE_UNITAIRE");
|
299 |
|
309 |
|
Line 307... |
Line 317... |
307 |
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
|
317 |
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
|
308 |
}
|
318 |
}
|
309 |
}
|
319 |
}
|
310 |
} else {
|
320 |
} else {
|
311 |
rowArticleFind = sqlRow;
|
321 |
rowArticleFind = sqlRow;
|
312 |
rowArticle = sqlRow;
|
- |
|
313 |
if (rowArticle.getForeign("ID_STOCK") != null && !rowArticle.isForeignEmpty("ID_STOCK")) {
|
322 |
if (sqlRow.getForeign("ID_STOCK") != null && !sqlRow.isForeignEmpty("ID_STOCK")) {
|
314 |
SQLRowAccessor rowStock = rowArticle.getForeign("ID_STOCK");
|
323 |
SQLRowAccessor rowStock = sqlRow.getForeign("ID_STOCK");
|
315 |
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
|
324 |
qte = -Math.round(rowStock.getFloat("QTE_TH") - rowStock.getFloat("QTE_MIN"));
|
316 |
}
|
325 |
}
|
317 |
}
|
326 |
}
|
318 |
if (rowArticleFind != null && !rowArticleFind.isUndefined() && (!gestionStock || !artAdded.contains(rowArticleFind.getID()))) {
|
327 |
if (rowArticleFind != null && !rowArticleFind.isUndefined() && (!gestionStock || !artAdded.contains(rowArticleFind.getID()))) {
|
319 |
|
328 |
|
320 |
artAdded.add(rowArticleFind.getID());
|
329 |
artAdded.add(rowArticleFind.getID());
|
321 |
|
330 |
|
322 |
SQLInjector inj = SQLInjector.getInjector(rowArticle.getTable(), tableCmdElt);
|
331 |
SQLInjector inj = SQLInjector.getInjector(eltArticle.getTable(), tableCmdElt);
|
323 |
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticleFind.asRow()));
|
332 |
SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(rowArticleFind.asRow()));
|
324 |
|
333 |
|
325 |
rowValsElt.put("ID_STYLE", sqlRow.getObject("ID_STYLE"));
|
- |
|
326 |
|
- |
|
327 |
rowValsElt.put("QTE", qte);
|
334 |
rowValsElt.put("QTE", qte);
|
328 |
rowValsElt.put("QTE_UNITAIRE", qteUV);
|
335 |
rowValsElt.put("QTE_UNITAIRE", qteUV);
|
329 |
|
336 |
|
330 |
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
|
337 |
rowValsElt.put("T_POIDS", rowValsElt.getLong("POIDS") * rowValsElt.getInt("QTE"));
|
331 |
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
|
338 |
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
|
332 |
rowValsElt.put("T_PA_TTC", ((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)),
|
339 |
rowValsElt.put("T_PA_TTC", ((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)),
|
333 |
DecimalUtils.HIGH_PRECISION));
|
340 |
DecimalUtils.HIGH_PRECISION));
|
334 |
// rowValsElt.put("ID_DEVISE",
|
- |
|
335 |
// rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE"));
|
- |
|
336 |
map.add(rowArticleFind.asRow().getForeignRow("ID_FOURNISSEUR"), rowValsElt);
|
341 |
map.add(rowArticleFind.asRow().getForeignRow("ID_FOURNISSEUR"), rowValsElt);
|
337 |
}
|
342 |
}
|
338 |
}
|
343 |
}
|
339 |
|
344 |
|
340 |
MouvementStockSQLElement.createCommandeF(map, null, "");
|
345 |
MouvementStockSQLElement.createCommandeF(map, null, "");
|