Line 12... |
Line 12... |
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.config.update;
|
14 |
package org.openconcerto.erp.config.update;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.InstallationPanel;
|
16 |
import org.openconcerto.erp.config.InstallationPanel;
|
- |
|
17 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
17 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
22 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
22 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
25 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
- |
|
26 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
- |
|
27 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
|
25 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
28 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
26 |
import org.openconcerto.sql.model.DBRoot;
|
29 |
import org.openconcerto.sql.model.DBRoot;
|
- |
|
30 |
import org.openconcerto.sql.model.SQLField;
|
27 |
import org.openconcerto.sql.model.SQLField.Properties;
|
31 |
import org.openconcerto.sql.model.SQLField.Properties;
|
28 |
import org.openconcerto.sql.model.SQLName;
|
32 |
import org.openconcerto.sql.model.SQLName;
|
- |
|
33 |
import org.openconcerto.sql.model.SQLRow;
|
- |
|
34 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
35 |
import org.openconcerto.sql.model.SQLRowValues;
|
- |
|
36 |
import org.openconcerto.sql.model.SQLSelect;
|
30 |
import org.openconcerto.sql.model.SQLSyntax;
|
37 |
import org.openconcerto.sql.model.SQLSyntax;
|
31 |
import org.openconcerto.sql.model.SQLSystem;
|
38 |
import org.openconcerto.sql.model.SQLSystem;
|
32 |
import org.openconcerto.sql.model.SQLTable;
|
39 |
import org.openconcerto.sql.model.SQLTable;
|
33 |
import org.openconcerto.sql.model.Where;
|
40 |
import org.openconcerto.sql.model.Where;
|
- |
|
41 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
34 |
import org.openconcerto.sql.request.UpdateBuilder;
|
42 |
import org.openconcerto.sql.request.UpdateBuilder;
|
35 |
import org.openconcerto.sql.utils.AlterTable;
|
43 |
import org.openconcerto.sql.utils.AlterTable;
|
36 |
import org.openconcerto.sql.utils.ChangeTable;
|
44 |
import org.openconcerto.sql.utils.ChangeTable;
|
37 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
45 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
38 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
46 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
39 |
import org.openconcerto.utils.CollectionUtils;
|
47 |
import org.openconcerto.utils.CollectionUtils;
|
- |
|
48 |
import org.openconcerto.utils.ExceptionHandler;
|
40 |
|
49 |
|
41 |
import java.math.BigDecimal;
|
50 |
import java.math.BigDecimal;
|
- |
|
51 |
import java.sql.Clob;
|
42 |
import java.sql.SQLException;
|
52 |
import java.sql.SQLException;
|
43 |
import java.sql.Types;
|
53 |
import java.sql.Types;
|
- |
|
54 |
import java.util.ArrayList;
|
44 |
import java.util.Arrays;
|
55 |
import java.util.Arrays;
|
- |
|
56 |
import java.util.Collections;
|
45 |
import java.util.EnumSet;
|
57 |
import java.util.EnumSet;
|
- |
|
58 |
import java.util.HashMap;
|
46 |
import java.util.List;
|
59 |
import java.util.List;
|
- |
|
60 |
import java.util.Map;
|
- |
|
61 |
import java.util.prefs.BackingStoreException;
|
- |
|
62 |
|
- |
|
63 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
47 |
|
64 |
|
48 |
public class Updater_1_5 {
|
65 |
public class Updater_1_5 {
|
49 |
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
|
66 |
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
|
50 |
|
67 |
|
51 |
public static void update(final DBRoot root) throws SQLException {
|
68 |
public static void update(final DBRoot root) throws SQLException {
|
Line 282... |
Line 299... |
282 |
}
|
299 |
}
|
283 |
|
300 |
|
284 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
301 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
285 |
if (!tableCmdElt.contains("LIVRE")) {
|
302 |
if (!tableCmdElt.contains("LIVRE")) {
|
286 |
AlterTable t = new AlterTable(tableCmdElt);
|
303 |
AlterTable t = new AlterTable(tableCmdElt);
|
- |
|
304 |
// FIXME mis par défaut à true avant --> à fixer
|
287 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
305 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
288 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
306 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
289 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
307 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
290 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
308 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
291 |
root.refetchTable(tableCmdElt.getName());
|
309 |
root.refetchTable(tableCmdElt.getName());
|
292 |
root.getSchema().updateVersion();
|
310 |
root.getSchema().updateVersion();
|
293 |
|
311 |
|
294 |
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
|
- |
|
295 |
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
|
- |
|
296 |
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
|
- |
|
297 |
SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
|
- |
|
298 |
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
|
- |
|
299 |
+ " c ," + new SQLName(root.getName(), tableBL.getName()).quote() + " b ," + new SQLName(root.getName(), tableFactC.getName()).quote()
|
- |
|
300 |
+ " f WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\" AND f.\"ID\"=t.\"ID_SAISIE_VENTE_FACTURE\""
|
- |
|
301 |
+ " AND b.\"ID\"=t.\"ID_BON_DE_LIVRAISON\" AND b.\"ARCHIVE\" = 0 AND f.\"ID\" > 1 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND f.\"ARCHIVE\" = 0 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE_CLIENT\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\") OR SUM(f.\"T_HT\")>=SUM(c.\"T_HT\")) ";
|
- |
|
302 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
- |
|
303 |
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
|
- |
|
304 |
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
305 |
build.setObject("LIVRE_FORCED", Boolean.TRUE);
|
- |
|
306 |
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
|
- |
|
307 |
build.setWhere(where);
|
- |
|
308 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
312 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
309 |
// tableCmdElt.getName()).quote()
|
313 |
// tableCmdElt.getName()).quote()
|
310 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
314 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
311 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
315 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
312 |
}
|
316 |
{
|
- |
|
317 |
List<String> tablesWorkFlow = Arrays.asList("SAISIE_VENTE_FACTURE", "BON_DE_LIVRAISON");
|
- |
|
318 |
for (String tableWorkFlow : tablesWorkFlow) {
|
- |
|
319 |
|
- |
|
320 |
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
|
- |
|
321 |
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
|
- |
|
322 |
SQLTable tableBL = root.getTable(tableWorkFlow);
|
- |
|
323 |
// SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
|
- |
|
324 |
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ,"
|
- |
|
325 |
+ new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ," + new SQLName(root.getName(), tableBL.getName()).quote()
|
- |
|
326 |
+ " b WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\"" + " AND b.\"ID\"=t.\"ID_" + tableWorkFlow
|
- |
|
327 |
+ "\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE_CLIENT\" HAVING (SUM(b.\""
|
- |
|
328 |
+ (tableWorkFlow.startsWith("BON") ? "TOTAL_HT" : "T_HT") + "\")>=SUM(c.\"T_HT\") ) ";
|
- |
|
329 |
List<Integer> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
- |
|
330 |
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
|
- |
|
331 |
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
332 |
build.setObject("LIVRE_FORCED", Boolean.TRUE);
|
- |
|
333 |
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
|
- |
|
334 |
build.setWhere(where);
|
313 |
|
335 |
|
- |
|
336 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
337 |
}
|
- |
|
338 |
}
|
- |
|
339 |
}
|
314 |
// Fix bad default value
|
340 |
// Fix bad default value
|
315 |
if (tableCmdElt.contains("LIVRE")) {
|
341 |
if (tableCmdElt.contains("LIVRE")) {
|
316 |
AlterTable t = new AlterTable(tableCmdElt);
|
342 |
AlterTable t = new AlterTable(tableCmdElt);
|
317 |
t.alterColumnDefault("LIVRE", "false");
|
343 |
t.alterColumnDefault("LIVRE", "false");
|
318 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
344 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
319 |
root.refetchTable(tableCmdElt.getName());
|
345 |
root.refetchTable(tableCmdElt.getName());
|
320 |
root.getSchema().updateVersion();
|
346 |
root.getSchema().updateVersion();
|
- |
|
347 |
UpdateBuilder upLivre = new UpdateBuilder(tableCmdElt);
|
- |
|
348 |
upLivre.setObject("LIVRE", Boolean.FALSE);
|
- |
|
349 |
upLivre.setWhere(new Where(tableCmdElt.getKey(), "=", 1));
|
- |
|
350 |
|
- |
|
351 |
tableCmdElt.getBase().getDataSource().execute(upLivre.asString());
|
321 |
}
|
352 |
}
|
322 |
|
353 |
|
323 |
// Achat
|
354 |
// Achat
|
324 |
|
355 |
|
325 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
356 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
Line 339... |
Line 370... |
339 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
370 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
340 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
371 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
341 |
root.refetchTable(tableCmdFElt.getName());
|
372 |
root.refetchTable(tableCmdFElt.getName());
|
342 |
root.getSchema().updateVersion();
|
373 |
root.getSchema().updateVersion();
|
343 |
|
374 |
|
344 |
SQLTable tableCmdCli = root.getTable("COMMANDE");
|
- |
|
345 |
SQLTable tableTR = root.getTable("TR_COMMANDE");
|
- |
|
346 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
- |
|
347 |
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ,"
|
- |
|
348 |
+ new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
|
- |
|
349 |
+ " AND b.\"ID\"=t.\"ID_BON_RECEPTION\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\")) ";
|
- |
|
350 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
- |
|
351 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
- |
|
352 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
353 |
build.setObject("RECU_FORCED", Boolean.TRUE);
|
- |
|
354 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
- |
|
355 |
build.setWhere(where);
|
- |
|
356 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
375 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
357 |
// tableCmdElt.getName()).quote()
|
376 |
// tableCmdElt.getName()).quote()
|
358 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
377 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
359 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
378 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
- |
|
379 |
{
|
- |
|
380 |
SQLTable tableCmdCli = root.getTable("COMMANDE");
|
- |
|
381 |
SQLTable tableTR = root.getTable("TR_COMMANDE");
|
- |
|
382 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
- |
|
383 |
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
|
- |
|
384 |
+ " c ," + new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
|
- |
|
385 |
+ " AND b.\"ID\"=t.\"ID_BON_RECEPTION\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\")) ";
|
- |
|
386 |
|
- |
|
387 |
System.err.println(sel);
|
- |
|
388 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
- |
|
389 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
- |
|
390 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
391 |
build.setObject("RECU_FORCED", Boolean.TRUE);
|
- |
|
392 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
- |
|
393 |
build.setWhere(where);
|
- |
|
394 |
System.err.println(build.asString());
|
- |
|
395 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
396 |
}
|
- |
|
397 |
}
|
- |
|
398 |
|
- |
|
399 |
// Champ matière
|
- |
|
400 |
SQLTable tableArt = root.getTable("ARTICLE");
|
- |
|
401 |
if (!tableArt.contains("MATIERE")) {
|
- |
|
402 |
final AlterTable alter = new AlterTable(tableArt);
|
- |
|
403 |
alter.addVarCharColumn("MATIERE", 128);
|
- |
|
404 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
- |
|
405 |
tableArt.getSchema().updateVersion();
|
- |
|
406 |
tableArt.fetchFields();
|
360 |
}
|
407 |
}
|
361 |
|
408 |
|
362 |
}
|
409 |
}
|
363 |
// ----------------------- 1.5.1
|
410 |
// ----------------------- 1.5.1
|
364 |
|
411 |
|
Line 517... |
Line 564... |
517 |
createTableDemandeMElt.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE"));
|
564 |
createTableDemandeMElt.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE"));
|
518 |
createTableDemandeMElt.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
565 |
createTableDemandeMElt.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
519 |
createTableDemandeMElt.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE"));
|
566 |
createTableDemandeMElt.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE"));
|
520 |
createTableDemandeMElt.addVarCharColumn("DESCRIPTIF", 2048);
|
567 |
createTableDemandeMElt.addVarCharColumn("DESCRIPTIF", 2048);
|
521 |
createTableDemandeMElt.addIntegerColumn("NIVEAU", 1);
|
568 |
createTableDemandeMElt.addIntegerColumn("NIVEAU", 1);
|
- |
|
569 |
if (root.contains("DEPOT_STOCK")) {
|
- |
|
570 |
createTableDemandeMElt.addForeignColumn("DEPOT_STOCK");
|
- |
|
571 |
}
|
522 |
createTableDemandeMElt.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
|
572 |
createTableDemandeMElt.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
|
523 |
createTableDemandeMElt.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
573 |
createTableDemandeMElt.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
524 |
createTableDemandeMElt.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
574 |
createTableDemandeMElt.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
525 |
createTableDemandeMElt.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
575 |
createTableDemandeMElt.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
526 |
|
576 |
|
Line 585... |
Line 635... |
585 |
root.getBase().getDataSource().execute(alterB.asString());
|
635 |
root.getBase().getDataSource().execute(alterB.asString());
|
586 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
636 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
587 |
root.getSchema().updateVersion();
|
637 |
root.getSchema().updateVersion();
|
588 |
}
|
638 |
}
|
589 |
|
639 |
|
- |
|
640 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
- |
|
641 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
642 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
- |
|
643 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
644 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
645 |
root.getSchema().updateVersion();
|
- |
|
646 |
}
|
- |
|
647 |
|
- |
|
648 |
if (!tableDmdAChat.contains("REPRISE")) {
|
- |
|
649 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
650 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
- |
|
651 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
652 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
653 |
root.getSchema().updateVersion();
|
- |
|
654 |
}
|
- |
|
655 |
|
590 |
if (!tableDmdAChat.contains("IMPORT")) {
|
656 |
if (!tableDmdAChat.contains("IMPORT")) {
|
591 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
657 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
592 |
alterB.addBooleanColumn("IMPORT", Boolean.FALSE, false);
|
658 |
alterB.addBooleanColumn("IMPORT", Boolean.FALSE, false);
|
593 |
root.getBase().getDataSource().execute(alterB.asString());
|
659 |
root.getBase().getDataSource().execute(alterB.asString());
|
594 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
660 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
595 |
root.getSchema().updateVersion();
|
661 |
root.getSchema().updateVersion();
|
596 |
}
|
662 |
}
|
597 |
|
663 |
|
- |
|
664 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
- |
|
665 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
666 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
- |
|
667 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
668 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
669 |
root.getSchema().updateVersion();
|
- |
|
670 |
}
|
598 |
if (!tableDmdAChat.contains("QTE_RECUE")) {
|
671 |
if (!tableDmdAChat.contains("QTE_RECUE")) {
|
599 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
672 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
600 |
alterB.addIntegerColumn("QTE_RECUE", 0);
|
673 |
alterB.addIntegerColumn("QTE_RECUE", 0);
|
601 |
root.getBase().getDataSource().execute(alterB.asString());
|
674 |
root.getBase().getDataSource().execute(alterB.asString());
|
602 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
675 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
603 |
root.getSchema().updateVersion();
|
676 |
root.getSchema().updateVersion();
|
604 |
}
|
677 |
}
|
- |
|
678 |
|
605 |
if (!tableDmdAChat.contains("REPERE_SOURCE")) {
|
679 |
if (!tableDmdAChat.contains("REPERE_SOURCE")) {
|
606 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
680 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
607 |
alterB.addVarCharColumn("REPERE_SOURCE", 128);
|
681 |
alterB.addVarCharColumn("REPERE_SOURCE", 128);
|
608 |
alterB.addVarCharColumn("CODE_SOURCE", 128);
|
682 |
alterB.addVarCharColumn("CODE_SOURCE", 128);
|
609 |
alterB.addVarCharColumn("NOM_SOURCE", 128);
|
683 |
alterB.addVarCharColumn("NOM_SOURCE", 128);
|
Line 664... |
Line 738... |
664 |
alt.addIntegerColumn("LENJOUR", 0);
|
738 |
alt.addIntegerColumn("LENJOUR", 0);
|
665 |
root.getBase().getDataSource().execute(alt.asString());
|
739 |
root.getBase().getDataSource().execute(alt.asString());
|
666 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
740 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
667 |
root.getSchema().updateVersion();
|
741 |
root.getSchema().updateVersion();
|
668 |
}
|
742 |
}
|
- |
|
743 |
|
669 |
if (!root.contains("CHIFFRAGE_COMMANDE_CLIENT")) {
|
744 |
if (!root.contains("CHIFFRAGE_COMMANDE_CLIENT")) {
|
670 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "CHIFFRAGE_COMMANDE_CLIENT");
|
745 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "CHIFFRAGE_COMMANDE_CLIENT");
|
671 |
createTableEtat.addVarCharColumn("NOM", 256);
|
746 |
createTableEtat.addVarCharColumn("NOM", 256);
|
672 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
747 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
673 |
createTableEtat.addForeignColumn("UNITE_VENTE");
|
748 |
createTableEtat.addForeignColumn("UNITE_VENTE");
|
Line 936... |
Line 1011... |
936 |
root.getBase().getDataSource().execute(alterC.asString());
|
1011 |
root.getBase().getDataSource().execute(alterC.asString());
|
937 |
root.refetchTable("CUMULS_PAYE");
|
1012 |
root.refetchTable("CUMULS_PAYE");
|
938 |
root.getSchema().updateVersion();
|
1013 |
root.getSchema().updateVersion();
|
939 |
|
1014 |
|
940 |
}
|
1015 |
}
|
- |
|
1016 |
|
941 |
if (!tableFpaye.contains("DETAILS_CONGES")) {
|
1017 |
if (!tableFpaye.contains("DETAILS_CONGES")) {
|
942 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
1018 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
943 |
alterB.addVarCharColumn("DETAILS_CONGES", 512);
|
1019 |
alterB.addVarCharColumn("DETAILS_CONGES", 512);
|
944 |
root.getBase().getDataSource().execute(alterB.asString());
|
1020 |
root.getBase().getDataSource().execute(alterB.asString());
|
945 |
root.refetchTable("FICHE_PAYE");
|
1021 |
root.refetchTable("FICHE_PAYE");
|
Line 1061... |
Line 1137... |
1061 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1137 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1062 |
table.getBase().getDataSource().execute(t.asString());
|
1138 |
table.getBase().getDataSource().execute(t.asString());
|
1063 |
table.getSchema().updateVersion();
|
1139 |
table.getSchema().updateVersion();
|
1064 |
table.fetchFields();
|
1140 |
table.fetchFields();
|
1065 |
}
|
1141 |
}
|
- |
|
1142 |
// Etat stock
|
- |
|
1143 |
if (!root.contains("ETAT_STOCK")) {
|
1066 |
|
1144 |
|
- |
|
1145 |
try {
|
- |
|
1146 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ETAT_STOCK");
|
- |
|
1147 |
createTable.addColumn("DATE", "date");
|
- |
|
1148 |
createTable.addDecimalColumn("MONTANT_HA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1149 |
createTable.addDecimalColumn("MONTANT_VT", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1150 |
createTable.addBooleanColumn("INVENTAIRE", Boolean.FALSE, false);
|
- |
|
1151 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1152 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1153 |
root.refetchTable("ETAT_STOCK");
|
- |
|
1154 |
root.getSchema().updateVersion();
|
- |
|
1155 |
|
- |
|
1156 |
final SQLCreateTable createTableElt = new SQLCreateTable(root, "ETAT_STOCK_ELEMENT");
|
- |
|
1157 |
createTableElt.addForeignColumn("ARTICLE");
|
- |
|
1158 |
createTableElt.addForeignColumn("ETAT_STOCK");
|
- |
|
1159 |
createTableElt.addDecimalColumn("PA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1160 |
createTableElt.addDecimalColumn("PV", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1161 |
createTableElt.addDecimalColumn("T_PA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1162 |
createTableElt.addDecimalColumn("T_PV", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1163 |
createTableElt.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1164 |
createTableElt.addDecimalColumn("ECART", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1165 |
createTableElt.addVarCharColumn("CODE", 256);
|
- |
|
1166 |
createTableElt.addVarCharColumn("NOM", 2048);
|
- |
|
1167 |
|
- |
|
1168 |
root.getBase().getDataSource().execute(createTableElt.asString());
|
- |
|
1169 |
InstallationPanel.insertUndef(createTableElt);
|
- |
|
1170 |
root.refetchTable("ETAT_STOCK_ELEMENT");
|
- |
|
1171 |
root.getSchema().updateVersion();
|
- |
|
1172 |
|
- |
|
1173 |
} catch (SQLException ex) {
|
- |
|
1174 |
throw new IllegalStateException("Erreur lors de la création de la table ETAT_STOCK_ELEMENT", ex);
|
- |
|
1175 |
}
|
- |
|
1176 |
} else {
|
- |
|
1177 |
final SQLTable tableEtatStock = root.getTable("ETAT_STOCK_ELEMENT");
|
- |
|
1178 |
SQLField fieldNom = tableEtatStock.getField("NOM");
|
- |
|
1179 |
int size = fieldNom.getType().getSize();
|
- |
|
1180 |
if (size == 512) {
|
- |
|
1181 |
AlterTable alter = new AlterTable(tableEtatStock);
|
- |
|
1182 |
alter.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(" + 2048 + ")", "''", false);
|
- |
|
1183 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
- |
|
1184 |
tableEtatStock.getSchema().updateVersion();
|
- |
|
1185 |
tableEtatStock.fetchFields();
|
- |
|
1186 |
}
|
- |
|
1187 |
|
- |
|
1188 |
}
|
- |
|
1189 |
SQLTable tableMvtStock = root.getTable("MOUVEMENT_STOCK");
|
- |
|
1190 |
if (!tableMvtStock.contains("ID_ETAT_STOCK")) {
|
- |
|
1191 |
final AlterTable alter = new AlterTable(tableMvtStock);
|
- |
|
1192 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
- |
|
1193 |
alter.addBooleanColumn("OUVERTURE", Boolean.FALSE, false);
|
- |
|
1194 |
alter.addForeignColumn("ID_ETAT_STOCK", root.getTable("ETAT_STOCK"));
|
- |
|
1195 |
tableMvtStock.getBase().getDataSource().execute(alter.asString());
|
- |
|
1196 |
tableMvtStock.getSchema().updateVersion();
|
- |
|
1197 |
tableMvtStock.fetchFields();
|
- |
|
1198 |
}
|
1067 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1199 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1068 |
if (!tableEcr.contains("CLOTURE")) {
|
1200 |
if (!tableEcr.contains("CLOTURE")) {
|
1069 |
final AlterTable alter = new AlterTable(tableEcr);
|
1201 |
final AlterTable alter = new AlterTable(tableEcr);
|
1070 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1202 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1071 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
1203 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
Line 1107... |
Line 1239... |
1107 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
1239 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
1108 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
1240 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
1109 |
exec(alter);
|
1241 |
exec(alter);
|
1110 |
}
|
1242 |
}
|
1111 |
final SQLTable contactT = root.getTable("CONTACT");
|
1243 |
final SQLTable contactT = root.getTable("CONTACT");
|
1112 |
if (!contactT.contains("DATE_NAISSANCE")) {
|
1244 |
if (contactT != null && !contactT.contains("DATE_NAISSANCE")) {
|
1113 |
final AlterTable alter = new AlterTable(contactT);
|
1245 |
final AlterTable alter = new AlterTable(contactT);
|
1114 |
alter.addColumn("DATE_NAISSANCE", "date");
|
1246 |
alter.addColumn("DATE_NAISSANCE", "date");
|
1115 |
exec(alter);
|
1247 |
exec(alter);
|
1116 |
}
|
1248 |
}
|
- |
|
1249 |
|
1117 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
1250 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
1118 |
if (createSDDMsgTable != null) {
|
1251 |
if (createSDDMsgTable != null) {
|
1119 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
1252 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
1120 |
root.createTables(createSDDMsgTable, createMandate);
|
1253 |
root.createTables(createSDDMsgTable, createMandate);
|
1121 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
1254 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
Line 1132... |
Line 1265... |
1132 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1265 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1133 |
}
|
1266 |
}
|
1134 |
root.getSchema().updateVersion();
|
1267 |
root.getSchema().updateVersion();
|
1135 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
1268 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
1136 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
1269 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
- |
|
1270 |
} else {
|
- |
|
1271 |
// Before r24495 InstallationPanel.fixUnboundedVarchar() would change this field to
|
- |
|
1272 |
// varchar
|
- |
|
1273 |
final SQLField xmlField = root.getTable(SDDMessageSQLElement.TABLE_NAME).getField("XML");
|
- |
|
1274 |
if (xmlField.getTypeDecl().contains("char")) {
|
- |
|
1275 |
final AlterTable alterTable = new AlterTable(xmlField.getTable());
|
- |
|
1276 |
alterTable.alterColumn(xmlField.getName(), EnumSet.of(Properties.TYPE), alterTable.getSyntax().getTypeNames(Clob.class).iterator().next(), null, null);
|
- |
|
1277 |
root.getDBSystemRoot().getDataSource().execute(alterTable.asString());
|
- |
|
1278 |
root.getSchema().updateVersion();
|
- |
|
1279 |
xmlField.getTable().fetchFields();
|
- |
|
1280 |
}
|
1137 |
}
|
1281 |
}
|
1138 |
|
1282 |
|
1139 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
1283 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
1140 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
1284 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
1141 |
final AlterTable alter = new AlterTable(vcT);
|
1285 |
final AlterTable alter = new AlterTable(vcT);
|
1142 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
1286 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
1143 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
1287 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
1144 |
exec(alter);
|
1288 |
exec(alter);
|
1145 |
}
|
1289 |
}
|
1146 |
|
1290 |
|
- |
|
1291 |
// 1.6
|
- |
|
1292 |
// gestion depots des cheques
|
- |
|
1293 |
String chequeDepotTable = "DEPOT_CHEQUE";
|
- |
|
1294 |
if (!root.contains(chequeDepotTable)) {
|
- |
|
1295 |
|
- |
|
1296 |
// Table depot cheque
|
- |
|
1297 |
final SQLCreateTable createTableDepotCheque = new SQLCreateTable(root, chequeDepotTable);
|
- |
|
1298 |
createTableDepotCheque.addVarCharColumn("NOM", 512);
|
- |
|
1299 |
createTableDepotCheque.addLongColumn("MONTANT", 0L, false);
|
- |
|
1300 |
createTableDepotCheque.addColumn("DATE", "date");
|
- |
|
1301 |
if (root.contains("BANQUE")) {
|
- |
|
1302 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE"));
|
- |
|
1303 |
} else if (root.contains("BANQUE_POLE_PRODUIT")) {
|
- |
|
1304 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE_POLE_PRODUIT"));
|
- |
|
1305 |
}
|
- |
|
1306 |
createTableDepotCheque.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
- |
|
1307 |
createTableDepotCheque.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
- |
|
1308 |
root.getBase().getDataSource().execute(createTableDepotCheque.asString());
|
- |
|
1309 |
InstallationPanel.insertUndef(createTableDepotCheque);
|
- |
|
1310 |
root.refetchTable(chequeDepotTable);
|
- |
|
1311 |
root.getSchema().updateVersion();
|
- |
|
1312 |
|
- |
|
1313 |
// Table depot cheque element
|
- |
|
1314 |
final SQLCreateTable createTableDepotElt = new SQLCreateTable(root, chequeDepotTable + "_ELEMENT");
|
- |
|
1315 |
createTableDepotElt.addVarCharColumn("NUMERO", 128);
|
- |
|
1316 |
createTableDepotElt.addVarCharColumn("BANQUE", 128);
|
- |
|
1317 |
createTableDepotElt.addVarCharColumn("PIECE", 512);
|
- |
|
1318 |
createTableDepotElt.addLongColumn("MONTANT", 0L, false);
|
- |
|
1319 |
createTableDepotElt.addColumn("DATE", "date");
|
- |
|
1320 |
createTableDepotElt.addForeignColumn("ID_CHEQUE_A_ENCAISSER", root.getTable("CHEQUE_A_ENCAISSER"));
|
- |
|
1321 |
createTableDepotElt.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
- |
|
1322 |
createTableDepotElt.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
- |
|
1323 |
createTableDepotElt.addForeignColumn("ID_DEPOT_CHEQUE", root.getTable(chequeDepotTable));
|
- |
|
1324 |
root.getBase().getDataSource().execute(createTableDepotElt.asString());
|
- |
|
1325 |
InstallationPanel.insertUndef(createTableDepotElt);
|
- |
|
1326 |
root.refetchTable(chequeDepotTable + "_ELEMENT");
|
- |
|
1327 |
root.getSchema().updateVersion();
|
- |
|
1328 |
}
|
- |
|
1329 |
|
- |
|
1330 |
final SQLTable articleT = root.getTable("ARTICLE");
|
- |
|
1331 |
if (!articleT.contains("QTE_UNITAIRE")) {
|
- |
|
1332 |
final AlterTable alter = new AlterTable(articleT);
|
- |
|
1333 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
- |
|
1334 |
exec(alter);
|
- |
|
1335 |
}
|
- |
|
1336 |
|
- |
|
1337 |
final SQLTable articleFT = root.getTable("ARTICLE_FOURNISSEUR");
|
- |
|
1338 |
if (!articleFT.contains("QTE_UNITAIRE")) {
|
- |
|
1339 |
final AlterTable alter = new AlterTable(articleFT);
|
- |
|
1340 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
- |
|
1341 |
exec(alter);
|
- |
|
1342 |
}
|
- |
|
1343 |
|
- |
|
1344 |
// Cout de revient
|
- |
|
1345 |
if (!root.contains("COUT_REVIENT")) {
|
- |
|
1346 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "COUT_REVIENT");
|
- |
|
1347 |
createTableCR.addVarCharColumn("CODE", 48);
|
- |
|
1348 |
createTableCR.addVarCharColumn("NOM", 256);
|
- |
|
1349 |
createTableCR.addDecimalColumn("POURCENT", 16, 6, BigDecimal.ZERO, false);
|
- |
|
1350 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
- |
|
1351 |
InstallationPanel.insertUndef(createTableCR);
|
- |
|
1352 |
root.refetchTable("COUT_REVIENT");
|
- |
|
1353 |
root.getSchema().updateVersion();
|
- |
|
1354 |
|
- |
|
1355 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1356 |
alterArticle.addForeignColumn("ID_COUT_REVIENT", root.findTable("COUT_REVIENT"));
|
- |
|
1357 |
exec(alterArticle);
|
- |
|
1358 |
root.refetchTable("ARTICLE");
|
- |
|
1359 |
root.getSchema().updateVersion();
|
- |
|
1360 |
}
|
- |
|
1361 |
|
- |
|
1362 |
if (!root.getTable("ARTICLE").contains("MARGE_WITH_COUT_REVIENT")) {
|
- |
|
1363 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1364 |
alterArticle.addBooleanColumn("MARGE_WITH_COUT_REVIENT", Boolean.FALSE, false);
|
- |
|
1365 |
exec(alterArticle);
|
- |
|
1366 |
root.refetchTable("ARTICLE");
|
- |
|
1367 |
root.getSchema().updateVersion();
|
- |
|
1368 |
}
|
- |
|
1369 |
|
- |
|
1370 |
if (!root.getTable("FACTURE_FOURNISSEUR").contains("NET_A_PAYER")) {
|
- |
|
1371 |
final AlterTable alterFactF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR"));
|
- |
|
1372 |
alterFactF.addLongColumn("NET_A_PAYER", 0L, false);
|
- |
|
1373 |
alterFactF.addLongColumn("AVOIR_TTC", 0L, false);
|
- |
|
1374 |
exec(alterFactF);
|
- |
|
1375 |
root.refetchTable("FACTURE_FOURNISSEUR");
|
- |
|
1376 |
root.getSchema().updateVersion();
|
- |
|
1377 |
}
|
- |
|
1378 |
|
- |
|
1379 |
// Frais Document
|
- |
|
1380 |
if (!root.contains("FRAIS_DOCUMENT")) {
|
- |
|
1381 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "FRAIS_DOCUMENT");
|
- |
|
1382 |
createTableCR.addVarCharColumn("CODE", 48);
|
- |
|
1383 |
createTableCR.addVarCharColumn("NOM", 256);
|
- |
|
1384 |
createTableCR.addLongColumn("MONTANT_HT", 0L, false);
|
- |
|
1385 |
createTableCR.addForeignColumn("ID_TAXE", root.getTable("TAXE"));
|
- |
|
1386 |
createTableCR.addLongColumn("MONTANT_TTC", 0L, false);
|
- |
|
1387 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
- |
|
1388 |
InstallationPanel.insertUndef(createTableCR);
|
- |
|
1389 |
root.refetchTable("FRAIS_DOCUMENT");
|
- |
|
1390 |
|
- |
|
1391 |
final AlterTable alterClient = new AlterTable(root.getTable("CLIENT"));
|
- |
|
1392 |
alterClient.addForeignColumn("ID_FRAIS_DOCUMENT", root.findTable("FRAIS_DOCUMENT"));
|
- |
|
1393 |
exec(alterClient);
|
- |
|
1394 |
root.refetchTable("CLIENT");
|
- |
|
1395 |
|
- |
|
1396 |
List<String> tables = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE");
|
- |
|
1397 |
for (String tableToUp : tables) {
|
- |
|
1398 |
final AlterTable alter = new AlterTable(root.getTable(tableToUp));
|
- |
|
1399 |
alter.addLongColumn("FRAIS_DOCUMENT_HT", 0L, false);
|
- |
|
1400 |
alter.addForeignColumn("ID_TAXE_FRAIS_DOCUMENT", root.getTable("TAXE"));
|
- |
|
1401 |
exec(alter);
|
- |
|
1402 |
root.refetchTable(tableToUp);
|
- |
|
1403 |
}
|
- |
|
1404 |
root.getSchema().updateVersion();
|
- |
|
1405 |
}
|
- |
|
1406 |
|
- |
|
1407 |
final SQLTable chequeAvoirT = root.getTable("CHEQUE_AVOIR_CLIENT");
|
- |
|
1408 |
|
- |
|
1409 |
String tBanque = root.contains("BANQUE") ? "BANQUE" : "BANQUE_POLE_PRODUIT";
|
- |
|
1410 |
if (!chequeAvoirT.contains("ID_" + tBanque)) {
|
- |
|
1411 |
|
- |
|
1412 |
final AlterTable alterChqAvoir = new AlterTable(chequeAvoirT);
|
- |
|
1413 |
alterChqAvoir.addForeignColumn("ID_" + tBanque, root.findTable(tBanque));
|
- |
|
1414 |
exec(alterChqAvoir);
|
- |
|
1415 |
}
|
- |
|
1416 |
|
- |
|
1417 |
// Prelevement à la source
|
- |
|
1418 |
final SQLTable fichePayeT = root.getTable("FICHE_PAYE");
|
- |
|
1419 |
if (!fichePayeT.contains("ID_PAS")) {
|
- |
|
1420 |
final SQLCreateTable createTablePas = new SQLCreateTable(root, "PAS");
|
- |
|
1421 |
createTablePas.addForeignColumn("ID_TYPE_TAUX_PAS", root.findTable("TYPE_TAUX_PAS"));
|
- |
|
1422 |
createTablePas.addVarCharColumn("CODE_PAS", 256);
|
- |
|
1423 |
createTablePas.addDecimalColumn("TAUX_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1424 |
root.getBase().getDataSource().execute(createTablePas.asString());
|
- |
|
1425 |
InstallationPanel.insertUndef(createTablePas);
|
- |
|
1426 |
root.refetchTable("PAS");
|
- |
|
1427 |
root.getSchema().updateVersion();
|
- |
|
1428 |
|
- |
|
1429 |
final AlterTable alterFichePaye = new AlterTable(fichePayeT);
|
- |
|
1430 |
alterFichePaye.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
- |
|
1431 |
alterFichePaye.addDecimalColumn("TOTAL_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1432 |
alterFichePaye.addDecimalColumn("NET_AVANT_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1433 |
exec(alterFichePaye);
|
- |
|
1434 |
|
- |
|
1435 |
final SQLTable tableSal = root.getTable("SALARIE");
|
- |
|
1436 |
final AlterTable alterSalarie = new AlterTable(tableSal);
|
- |
|
1437 |
alterSalarie.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
- |
|
1438 |
exec(alterSalarie);
|
- |
|
1439 |
|
- |
|
1440 |
final AlterTable alterEtatCivil = new AlterTable(tableEtatCivil);
|
- |
|
1441 |
alterEtatCivil.addVarCharColumn("NTT", 50);
|
- |
|
1442 |
exec(alterEtatCivil);
|
- |
|
1443 |
|
- |
|
1444 |
Map<String, SQLRow> typeTauxPasMap = new HashMap<>();
|
- |
|
1445 |
SQLSelect selTypeTaux = new SQLSelect();
|
- |
|
1446 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getKey());
|
- |
|
1447 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getField("CODE"));
|
- |
|
1448 |
List<SQLRow> resultTypeTaux = SQLRowListRSH.execute(selTypeTaux);
|
- |
|
1449 |
for (SQLRow sqlRow : resultTypeTaux) {
|
- |
|
1450 |
typeTauxPasMap.put(sqlRow.getString("CODE"), sqlRow);
|
- |
|
1451 |
}
|
- |
|
1452 |
|
- |
|
1453 |
SQLSelect selSal = new SQLSelect();
|
- |
|
1454 |
selSal.addSelect(tableSal.getKey());
|
- |
|
1455 |
List<SQLRow> rowSal = SQLRowListRSH.execute(selSal);
|
- |
|
1456 |
for (SQLRow sqlRow : rowSal) {
|
- |
|
1457 |
SQLRowValues rowValsSal = sqlRow.createEmptyUpdateRow();
|
- |
|
1458 |
final SQLRowValues putRowValues = rowValsSal.putRowValues("ID_PAS");
|
- |
|
1459 |
putRowValues.put("ID_TYPE_TAUX_PAS", typeTauxPasMap.get("13").getID());
|
- |
|
1460 |
putRowValues.put("TAUX_PAS", BigDecimal.ZERO);
|
- |
|
1461 |
putRowValues.commit();
|
- |
|
1462 |
}
|
- |
|
1463 |
}
|
- |
|
1464 |
|
- |
|
1465 |
if (!root.contains("ARTICLE_TARIF_FOURNISSEUR")) {
|
- |
|
1466 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_TARIF_FOURNISSEUR");
|
- |
|
1467 |
|
- |
|
1468 |
createTable.addForeignColumn("ARTICLE");
|
- |
|
1469 |
createTable.addForeignColumn("FOURNISSEUR");
|
- |
|
1470 |
createTable.addVarCharColumn("REF_FOURNISSEUR", 500);
|
- |
|
1471 |
createTable.addVarCharColumn("TYPE_REAPPRO", 256);
|
- |
|
1472 |
createTable.addVarCharColumn("CONDITIONS", 1024);
|
- |
|
1473 |
createTable.addVarCharColumn("ACHETEUR", 256);
|
- |
|
1474 |
createTable.addVarCharColumn("CODE_PAYS_ORIGINE", 256);
|
- |
|
1475 |
createTable.addDecimalColumn("PRIX_ACHAT_DEVISE_F", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1476 |
createTable.addDecimalColumn("PRIX_ACHAT", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1477 |
createTable.addIntegerColumn("QTE", 1);
|
- |
|
1478 |
createTable.addDateAndTimeColumn("DATE_PRIX");
|
- |
|
1479 |
// createTable.addDecimalColumn("COEF_TRANSPORT_PORT", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1480 |
// false);
|
- |
|
1481 |
// createTable.addDecimalColumn("COEF_TAXE_D", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1482 |
// createTable.addDecimalColumn("COEF_TRANSPORT_SIEGE", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1483 |
// false);
|
- |
|
1484 |
// createTable.addDecimalColumn("COEF_FRAIS_MOULE", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1485 |
// false);
|
- |
|
1486 |
// createTable.addDecimalColumn("COEF_FRAIS_INDIRECTS", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1487 |
// false);
|
- |
|
1488 |
createTable.addIntegerColumn("DELAI_REAPPRO", 0);
|
- |
|
1489 |
createTable.addIntegerColumn("DELAI_TRANSPORT", 0);
|
- |
|
1490 |
createTable.addIntegerColumn("PRIORITE", 0);
|
- |
|
1491 |
createTable.addDecimalColumn("COEF_PRIX_MINI", 16, 2, BigDecimal.valueOf(0), false);
|
- |
|
1492 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1493 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1494 |
root.refetchTable("ARTICLE_TARIF_FOURNISSEUR");
|
- |
|
1495 |
root.getSchema().updateVersion();
|
- |
|
1496 |
}
|
- |
|
1497 |
|
- |
|
1498 |
// Gestion des catègories comptables
|
- |
|
1499 |
if (!root.contains("CATEGORIE_COMPTABLE")) {
|
- |
|
1500 |
final SQLCreateTable createTable = new SQLCreateTable(root, "CATEGORIE_COMPTABLE");
|
- |
|
1501 |
createTable.addVarCharColumn("NOM", 128);
|
- |
|
1502 |
createTable.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
- |
|
1503 |
createTable.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
- |
|
1504 |
createTable.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
- |
|
1505 |
createTable.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
- |
|
1506 |
|
- |
|
1507 |
try {
|
- |
|
1508 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1509 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1510 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
- |
|
1511 |
root.getSchema().updateVersion();
|
- |
|
1512 |
} catch (SQLException ex) {
|
- |
|
1513 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CATEGORIE_COMPTABLE", ex);
|
- |
|
1514 |
}
|
- |
|
1515 |
|
- |
|
1516 |
AlterTable tableClientCat = new AlterTable(root.getTable("CLIENT"));
|
- |
|
1517 |
tableClientCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1518 |
root.getBase().getDataSource().execute(tableClientCat.asString());
|
- |
|
1519 |
root.refetchTable("CLIENT");
|
- |
|
1520 |
root.getSchema().updateVersion();
|
- |
|
1521 |
|
- |
|
1522 |
AlterTable tableF = new AlterTable(root.getTable("FOURNISSEUR"));
|
- |
|
1523 |
tableF.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1524 |
root.getBase().getDataSource().execute(tableF.asString());
|
- |
|
1525 |
root.refetchTable("FOURNISSEUR");
|
- |
|
1526 |
root.getSchema().updateVersion();
|
- |
|
1527 |
|
- |
|
1528 |
final SQLCreateTable createTableArtCat = new SQLCreateTable(root, "ARTICLE_CATEGORIE_COMPTABLE");
|
- |
|
1529 |
createTableArtCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1530 |
createTableArtCat.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
- |
|
1531 |
createTableArtCat.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
- |
|
1532 |
createTableArtCat.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
- |
|
1533 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
- |
|
1534 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
- |
|
1535 |
|
- |
|
1536 |
try {
|
- |
|
1537 |
root.getBase().getDataSource().execute(createTableArtCat.asString());
|
- |
|
1538 |
InstallationPanel.insertUndef(createTableArtCat);
|
- |
|
1539 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
- |
|
1540 |
root.getSchema().updateVersion();
|
- |
|
1541 |
} catch (SQLException ex) {
|
- |
|
1542 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_CATEGORIE_COMPTABLE", ex);
|
- |
|
1543 |
}
|
- |
|
1544 |
|
- |
|
1545 |
}
|
- |
|
1546 |
|
- |
|
1547 |
// Article fournisseur secondaire
|
- |
|
1548 |
if (!root.contains("ARTICLE_FOURNISSEUR_SECONDAIRE")) {
|
- |
|
1549 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_FOURNISSEUR_SECONDAIRE");
|
- |
|
1550 |
createTable.addForeignColumn("ARTICLE");
|
- |
|
1551 |
createTable.addForeignColumn("FOURNISSEUR");
|
- |
|
1552 |
try {
|
- |
|
1553 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1554 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1555 |
root.refetchTable("ARTICLE_FOURNISSEUR_SECONDAIRE");
|
- |
|
1556 |
root.getSchema().updateVersion();
|
- |
|
1557 |
} catch (SQLException ex) {
|
- |
|
1558 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_FOURNISSEUR_SECONDAIRE", ex);
|
- |
|
1559 |
}
|
- |
|
1560 |
}
|
- |
|
1561 |
|
- |
|
1562 |
if (!root.getTable("ARTICLE").contains("AUTO_PRIX_ACHAT_NOMENCLATURE")) {
|
- |
|
1563 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1564 |
t.addBooleanColumn("AUTO_PRIX_ACHAT_NOMENCLATURE", false, false);
|
- |
|
1565 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
- |
|
1566 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
- |
|
1567 |
root.getSchema().updateVersion();
|
- |
|
1568 |
}
|
- |
|
1569 |
|
- |
|
1570 |
// Gestion multidepot
|
- |
|
1571 |
{
|
- |
|
1572 |
// Ajout table depot
|
- |
|
1573 |
if (!root.contains("DEPOT_STOCK")) {
|
- |
|
1574 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DEPOT_STOCK");
|
- |
|
1575 |
createTable.addVarCharColumn("CODE", 25);
|
- |
|
1576 |
createTable.addVarCharColumn("NOM", 256);
|
- |
|
1577 |
createTable.addVarCharColumn("UI_LOCK", 256);
|
- |
|
1578 |
createTable.addForeignColumn("ID_USER_UI_LOCK", root.findTable("USER_COMMON"));
|
- |
|
1579 |
// sqlRowValues.put("UI_LOCK", "ro");
|
- |
|
1580 |
// sqlRowValues.put("ID_USER_UI_LOCK", 2);
|
- |
|
1581 |
|
- |
|
1582 |
try {
|
- |
|
1583 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1584 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1585 |
|
- |
|
1586 |
root.refetchTable("DEPOT_STOCK");
|
- |
|
1587 |
root.getSchema().updateVersion();
|
- |
|
1588 |
|
- |
|
1589 |
SQLRowValues rowValsDefStock = new SQLRowValues(root.getTable("DEPOT_STOCK"));
|
- |
|
1590 |
rowValsDefStock.put("NOM", "Principal");
|
- |
|
1591 |
rowValsDefStock.put("UI_LOCK", "ro");
|
- |
|
1592 |
rowValsDefStock.commit();
|
- |
|
1593 |
} catch (SQLException ex) {
|
- |
|
1594 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DEPOT_STOCK", ex);
|
- |
|
1595 |
}
|
- |
|
1596 |
}
|
- |
|
1597 |
|
- |
|
1598 |
List<String> tableElementDepot = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
|
- |
|
1599 |
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
- |
|
1600 |
for (String tableName : tableElementDepot) {
|
- |
|
1601 |
final SQLTable tableToAddDepot = root.getTable(tableName);
|
- |
|
1602 |
if (!tableToAddDepot.contains("ID_DEPOT_STOCK")) {
|
- |
|
1603 |
AlterTable t = new AlterTable(tableToAddDepot);
|
- |
|
1604 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1605 |
tableToAddDepot.getBase().getDataSource().execute(t.asString());
|
- |
|
1606 |
root.refetchTable(tableToAddDepot.getName());
|
- |
|
1607 |
root.getSchema().updateVersion();
|
- |
|
1608 |
}
|
- |
|
1609 |
}
|
- |
|
1610 |
|
- |
|
1611 |
// Depot defaut
|
- |
|
1612 |
if (!root.getTable("ARTICLE").contains("ID_DEPOT_STOCK")) {
|
- |
|
1613 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1614 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1615 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
- |
|
1616 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
- |
|
1617 |
root.getSchema().updateVersion();
|
- |
|
1618 |
}
|
- |
|
1619 |
|
- |
|
1620 |
// Liason depot stock
|
- |
|
1621 |
if (!root.getTable("STOCK").contains("ID_DEPOT_STOCK")) {
|
- |
|
1622 |
AlterTable t = new AlterTable(root.getTable("STOCK"));
|
- |
|
1623 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1624 |
t.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
- |
|
1625 |
t.addColumn("QTE_MIN", "real DEFAULT 0");
|
- |
|
1626 |
root.getTable("STOCK").getBase().getDataSource().execute(t.asString());
|
- |
|
1627 |
root.refetchTable(root.getTable("STOCK").getName());
|
- |
|
1628 |
root.getSchema().updateVersion();
|
- |
|
1629 |
}
|
- |
|
1630 |
|
- |
|
1631 |
// Ajout depot sur mvt
|
- |
|
1632 |
if (!root.getTable("MOUVEMENT_STOCK").contains("ID_STOCK")) {
|
- |
|
1633 |
AlterTable t = new AlterTable(root.getTable("MOUVEMENT_STOCK"));
|
- |
|
1634 |
t.addForeignColumn("ID_STOCK", root.getTable("STOCK"));
|
- |
|
1635 |
t.addIntegerColumn("SOURCE_ELEMENTID", 1);
|
- |
|
1636 |
root.getTable("MOUVEMENT_STOCK").getBase().getDataSource().execute(t.asString());
|
- |
|
1637 |
root.refetchTable(root.getTable("MOUVEMENT_STOCK").getName());
|
- |
|
1638 |
root.getSchema().updateVersion();
|
- |
|
1639 |
|
- |
|
1640 |
// REQUETE update STOCK.ID_ARTICLE et QTE_MIN
|
- |
|
1641 |
SQLTable tableStock = root.getTable("STOCK");
|
- |
|
1642 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
- |
|
1643 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
- |
|
1644 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
- |
|
1645 |
buildStockArt.setFromVirtualJoinField("QTE_MIN", tableArticle.getAlias(), "QTE_MIN");
|
- |
|
1646 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
- |
|
1647 |
|
- |
|
1648 |
// REQUETE UPDATE MVT ID_STOCK
|
- |
|
1649 |
UpdateBuilder buildMvtStock = new UpdateBuilder(tableMvtStock);
|
- |
|
1650 |
buildMvtStock.addForwardVirtualJoin(tableArticle, "ID_ARTICLE");
|
- |
|
1651 |
buildMvtStock.setFromVirtualJoinField("ID_STOCK", tableArticle.getAlias(), "ID_STOCK");
|
- |
|
1652 |
|
- |
|
1653 |
// REQUETE UPDATE STOCK ID_DEPOT_STOCK
|
- |
|
1654 |
UpdateBuilder buildStock = new UpdateBuilder(tableStock);
|
- |
|
1655 |
buildStock.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
- |
|
1656 |
|
- |
|
1657 |
UpdateBuilder buildArticleDepot = new UpdateBuilder(tableArticle);
|
- |
|
1658 |
buildArticleDepot.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
- |
|
1659 |
|
- |
|
1660 |
// REQUETE UPDATE ARTICLE_DEPOT_STOCK
|
- |
|
1661 |
// String req = "INSERT INTO " + root.getTable("ARTICLE_STOCK").getSQLName().quote()
|
- |
|
1662 |
// + " (" + root.getTable("ARTICLE_STOCK").getField("ID_ARTICLE").getQuotedName() +
|
- |
|
1663 |
// ",";
|
- |
|
1664 |
// req += root.getTable("ARTICLE_STOCK").getField("ID_STOCK").getQuotedName() + ", "
|
- |
|
1665 |
// + root.getTable("ARTICLE_STOCK").getField("QTE_MIN").getQuotedName() + ") SELECT
|
- |
|
1666 |
// "
|
- |
|
1667 |
// + root.getTable("ARTICLE").getKey().getQuotedName() + "," +
|
- |
|
1668 |
// root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + ", "
|
- |
|
1669 |
// + root.getTable("ARTICLE").getField("QTE_MIN").getQuotedName();
|
- |
|
1670 |
// req += " FROM " + root.getTable("ARTICLE").getSQLName().quote();
|
- |
|
1671 |
// req += " WHERE " + root.getTable("ARTICLE").getKey().getQuotedName() + " > 1 AND
|
- |
|
1672 |
// " + root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + " >1 ";
|
- |
|
1673 |
// req += " AND " + root.getTable("ARTICLE").getArchiveField().getQuotedName() + " =
|
- |
|
1674 |
// 0";
|
- |
|
1675 |
|
- |
|
1676 |
tableStock.getDBSystemRoot().getDataSource().execute(buildArticleDepot.asString());
|
- |
|
1677 |
tableStock.getDBSystemRoot().getDataSource().execute(buildMvtStock.asString());
|
- |
|
1678 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStock.asString());
|
- |
|
1679 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
- |
|
1680 |
}
|
- |
|
1681 |
|
- |
|
1682 |
}
|
- |
|
1683 |
|
- |
|
1684 |
// Gestion Livraison depuis devis
|
- |
|
1685 |
SQLTable tableTrDevis = root.getTable("TR_DEVIS");
|
- |
|
1686 |
if (!tableTrDevis.contains("ID_BON_DE_LIVRAISON")) {
|
- |
|
1687 |
AlterTable t = new AlterTable(tableTrDevis);
|
- |
|
1688 |
t.addForeignColumn("ID_BON_DE_LIVRAISON", root.getTable("BON_DE_LIVRAISON"));
|
- |
|
1689 |
tableTrDevis.getBase().getDataSource().execute(t.asString());
|
- |
|
1690 |
root.refetchTable(tableTrDevis.getName());
|
- |
|
1691 |
root.getSchema().updateVersion();
|
- |
|
1692 |
}
|
- |
|
1693 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
- |
|
1694 |
if (!tableBLElt.contains("ID_DEVIS_ELEMENT")) {
|
- |
|
1695 |
AlterTable t = new AlterTable(tableBLElt);
|
- |
|
1696 |
t.addForeignColumn("ID_DEVIS_ELEMENT", root.getTable("DEVIS_ELEMENT"));
|
- |
|
1697 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
- |
|
1698 |
root.refetchTable(tableBLElt.getName());
|
- |
|
1699 |
root.getSchema().updateVersion();
|
- |
|
1700 |
}
|
- |
|
1701 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
- |
|
1702 |
if (!tableDevisElt.contains("QTE_LIVREE")) {
|
- |
|
1703 |
AlterTable t = new AlterTable(tableDevisElt);
|
- |
|
1704 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
- |
|
1705 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
- |
|
1706 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
- |
|
1707 |
tableDevisElt.getBase().getDataSource().execute(t.asString());
|
- |
|
1708 |
root.refetchTable(tableDevisElt.getName());
|
- |
|
1709 |
root.getSchema().updateVersion();
|
- |
|
1710 |
|
- |
|
1711 |
// Move show devise pref in global
|
- |
|
1712 |
SQLSelect sel = new SQLSelect();
|
- |
|
1713 |
sel.addSelect(root.getTable("DEVISE_HISTORIQUE").getKey(), "COUNT");
|
- |
|
1714 |
Number n = (Number) root.getDBSystemRoot().getDataSource().executeScalar(sel.asString());
|
- |
|
1715 |
if (n.intValue() > 0) {
|
- |
|
1716 |
SQLPreferences prefs = new SQLPreferences(root);
|
- |
|
1717 |
prefs.putBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, true);
|
- |
|
1718 |
try {
|
- |
|
1719 |
prefs.sync();
|
- |
|
1720 |
} catch (BackingStoreException e) {
|
- |
|
1721 |
// TODO Auto-generated catch block
|
- |
|
1722 |
e.printStackTrace();
|
- |
|
1723 |
}
|
- |
|
1724 |
}
|
- |
|
1725 |
}
|
- |
|
1726 |
|
- |
|
1727 |
SQLTable tablePosteAn = root.getTable("POSTE_ANALYTIQUE");
|
- |
|
1728 |
if (!tablePosteAn.contains("OBSOLETE")) {
|
- |
|
1729 |
AlterTable t = new AlterTable(tablePosteAn);
|
- |
|
1730 |
t.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
- |
|
1731 |
tablePosteAn.getBase().getDataSource().execute(t.asString());
|
- |
|
1732 |
root.refetchTable(tablePosteAn.getName());
|
- |
|
1733 |
root.getSchema().updateVersion();
|
- |
|
1734 |
}
|
- |
|
1735 |
|
- |
|
1736 |
SQLTable tableCheque = root.getTable("CHEQUE_A_ENCAISSER");
|
- |
|
1737 |
if (!tableCheque.contains("ID_COMPTE_PCE_TIERS")) {
|
- |
|
1738 |
AlterTable t = new AlterTable(tableCheque);
|
- |
|
1739 |
t.addVarCharColumn("TIERS", 256);
|
- |
|
1740 |
t.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1741 |
tableCheque.getBase().getDataSource().execute(t.asString());
|
- |
|
1742 |
root.refetchTable(tableCheque.getName());
|
- |
|
1743 |
|
- |
|
1744 |
SQLTable tableEnc = root.getTable("ENCAISSER_MONTANT");
|
- |
|
1745 |
AlterTable tEnc = new AlterTable(tableEnc);
|
- |
|
1746 |
tEnc.addVarCharColumn("TIERS", 256);
|
- |
|
1747 |
tEnc.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1748 |
tableEnc.getBase().getDataSource().execute(tEnc.asString());
|
- |
|
1749 |
root.refetchTable(tableEnc.getName());
|
- |
|
1750 |
root.getSchema().updateVersion();
|
- |
|
1751 |
|
- |
|
1752 |
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
- |
|
1753 |
AlterTable tEch = new AlterTable(tableEch);
|
- |
|
1754 |
tEch.addVarCharColumn("TIERS", 256);
|
- |
|
1755 |
tEch.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1756 |
tableEch.getBase().getDataSource().execute(tEch.asString());
|
- |
|
1757 |
root.refetchTable(tableEch.getName());
|
- |
|
1758 |
root.getSchema().updateVersion();
|
- |
|
1759 |
|
- |
|
1760 |
SQLTable tableChq = root.getTable("DEPOT_CHEQUE_ELEMENT");
|
- |
|
1761 |
AlterTable tChq = new AlterTable(tableChq);
|
- |
|
1762 |
tChq.addVarCharColumn("TIERS", 256);
|
- |
|
1763 |
tableChq.getBase().getDataSource().execute(tChq.asString());
|
- |
|
1764 |
root.refetchTable(tableChq.getName());
|
- |
|
1765 |
root.getSchema().updateVersion();
|
- |
|
1766 |
}
|
- |
|
1767 |
|
- |
|
1768 |
if (!tableEcr.contains("DATE_ECHEANCE")) {
|
- |
|
1769 |
AlterTable t = new AlterTable(tableEcr);
|
- |
|
1770 |
t.addColumn("DATE_ECHEANCE", "date");
|
- |
|
1771 |
tableEcr.getBase().getDataSource().execute(t.asString());
|
- |
|
1772 |
root.refetchTable(tableEcr.getName());
|
- |
|
1773 |
root.getSchema().updateVersion();
|
- |
|
1774 |
}
|
- |
|
1775 |
|
- |
|
1776 |
if (!tableVarSal.contains("HEURE_ABS_CUMUL_VAL")) {
|
- |
|
1777 |
|
- |
|
1778 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
- |
|
1779 |
|
- |
|
1780 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
- |
|
1781 |
|
- |
|
1782 |
String field = sqlField.getName();
|
- |
|
1783 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
- |
|
1784 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL")) {
|
- |
|
1785 |
alterB.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
|
- |
|
1786 |
}
|
- |
|
1787 |
}
|
- |
|
1788 |
|
- |
|
1789 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
1790 |
root.refetchTable("VARIABLE_SALARIE");
|
- |
|
1791 |
root.getSchema().updateVersion();
|
- |
|
1792 |
}
|
- |
|
1793 |
|
- |
|
1794 |
// fix stock
|
- |
|
1795 |
{
|
- |
|
1796 |
SQLTable tableStock = root.getTable("STOCK");
|
- |
|
1797 |
|
- |
|
1798 |
// Doublon depot stock
|
- |
|
1799 |
SQLSelect sel = new SQLSelect();
|
- |
|
1800 |
sel.addSelectFunctionStar("COUNT");
|
- |
|
1801 |
sel.addSelect(tableStock.getField("ID_DEPOT_STOCK"));
|
- |
|
1802 |
sel.addSelect(tableStock.getField("ID_ARTICLE"));
|
- |
|
1803 |
sel.addGroupBy(tableStock.getField("ID_DEPOT_STOCK"));
|
- |
|
1804 |
sel.addGroupBy(tableStock.getField("ID_ARTICLE"));
|
- |
|
1805 |
sel.setHaving(Where.createRaw("COUNT(*)>1", Collections.emptyList()));
|
- |
|
1806 |
System.err.println(sel.asString());
|
- |
|
1807 |
|
- |
|
1808 |
List<Object[]> resultStockDoublon = (List<Object[]>) tableStock.getDBSystemRoot().getDataSource().execute(sel.asString(), new ArrayListHandler());
|
- |
|
1809 |
for (Object[] objects : resultStockDoublon) {
|
- |
|
1810 |
|
- |
|
1811 |
if (((Number) objects[2]).intValue() == 1) {
|
- |
|
1812 |
|
- |
|
1813 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
- |
|
1814 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
- |
|
1815 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
- |
|
1816 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
- |
|
1817 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
- |
|
1818 |
} else {
|
- |
|
1819 |
SQLSelect selD = new SQLSelect();
|
- |
|
1820 |
selD.addSelectStar(tableStock);
|
- |
|
1821 |
Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", objects[2]);
|
- |
|
1822 |
w = w.and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", objects[1]));
|
- |
|
1823 |
selD.setWhere(w);
|
- |
|
1824 |
List<SQLRow> badStock = SQLRowListRSH.execute(selD);
|
- |
|
1825 |
if (badStock.size() > 1) {
|
- |
|
1826 |
SQLRowValues stock = badStock.get(0).createUpdateRow();
|
- |
|
1827 |
List<String> fieldsToMerge = Arrays.asList("QTE_REEL", "QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_LIV_ATTENTE");
|
- |
|
1828 |
List<Integer> listBadIds = new ArrayList<>();
|
- |
|
1829 |
for (int i = 1; i < badStock.size(); i++) {
|
- |
|
1830 |
SQLRow rowBad = badStock.get(i);
|
- |
|
1831 |
listBadIds.add(rowBad.getID());
|
- |
|
1832 |
for (String field : fieldsToMerge) {
|
- |
|
1833 |
stock.put(field, stock.getFloat(field) + rowBad.getFloat(field));
|
- |
|
1834 |
}
|
- |
|
1835 |
rowBad.createEmptyUpdateRow().put("ARCHIVE", 1).commit();
|
- |
|
1836 |
}
|
- |
|
1837 |
List<SQLTable> tablesToMErge = Arrays.asList(root.getTable("MOUVEMENT_STOCK"), root.getTable("ARTICLE"));
|
- |
|
1838 |
for (SQLTable mergeTable : tablesToMErge) {
|
- |
|
1839 |
UpdateBuilder up = new UpdateBuilder(mergeTable);
|
- |
|
1840 |
up.setObject("ID_STOCK", stock.getID());
|
- |
|
1841 |
up.setWhere(new Where(mergeTable.getField("ID_STOCK"), listBadIds));
|
- |
|
1842 |
mergeTable.getDBSystemRoot().getDataSource().execute(up.asString());
|
- |
|
1843 |
}
|
- |
|
1844 |
stock.commit();
|
- |
|
1845 |
|
- |
|
1846 |
}
|
- |
|
1847 |
}
|
- |
|
1848 |
}
|
- |
|
1849 |
|
- |
|
1850 |
SQLSelect selArt = new SQLSelect();
|
- |
|
1851 |
selArt.addSelectStar(tableArt);
|
- |
|
1852 |
Where w = new Where(tableArt.getField("ID_STOCK"), "=", 1);
|
- |
|
1853 |
selArt.setWhere(w);
|
- |
|
1854 |
List<SQLRow> badStock = SQLRowListRSH.execute(selArt);
|
- |
|
1855 |
for (SQLRow sqlRow : badStock) {
|
- |
|
1856 |
initStock(sqlRow);
|
- |
|
1857 |
}
|
- |
|
1858 |
}
|
- |
|
1859 |
|
- |
|
1860 |
|
- |
|
1861 |
}
|
- |
|
1862 |
|
- |
|
1863 |
public static void initStock(SQLRow row) {
|
- |
|
1864 |
SQLSelect sel = new SQLSelect();
|
- |
|
1865 |
sel.addSelectStar(row.getTable().getTable("DEPOT_STOCK"));
|
- |
|
1866 |
List<SQLRow> rowsDepot = SQLRowListRSH.execute(sel);
|
- |
|
1867 |
|
- |
|
1868 |
SQLSelect selStock = new SQLSelect();
|
- |
|
1869 |
selStock.addSelectStar(row.getTable().getTable("STOCK"));
|
- |
|
1870 |
selStock.setWhere(new Where(row.getTable().getTable("STOCK").getField("ID_ARTICLE"), "=", row.getID()));
|
- |
|
1871 |
List<SQLRow> rowsStock = SQLRowListRSH.execute(selStock);
|
- |
|
1872 |
Map<Integer, SQLRow> initedDepot = new HashMap<>();
|
- |
|
1873 |
for (SQLRow sqlRow : rowsStock) {
|
- |
|
1874 |
initedDepot.put(sqlRow.getForeignID("ID_DEPOT_STOCK"), sqlRow);
|
- |
|
1875 |
}
|
- |
|
1876 |
|
- |
|
1877 |
List<StockItem> stockItems = new ArrayList<StockItem>();
|
- |
|
1878 |
for (SQLRow sqlRow : rowsDepot) {
|
- |
|
1879 |
try {
|
- |
|
1880 |
if (!initedDepot.keySet().contains(sqlRow.getID())) {
|
- |
|
1881 |
SQLRowValues rowVals = new SQLRowValues(row.getTable().getTable("STOCK"));
|
- |
|
1882 |
rowVals.put("ID_ARTICLE", row.getID());
|
- |
|
1883 |
rowVals.put("ID_DEPOT_STOCK", sqlRow.getID());
|
- |
|
1884 |
|
- |
|
1885 |
SQLRow rowStock = rowVals.commit();
|
- |
|
1886 |
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
|
- |
|
1887 |
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
- |
|
1888 |
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
|
- |
|
1889 |
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).commit();
|
- |
|
1890 |
}
|
- |
|
1891 |
stockItems.add(new StockItem(row, rowStock));
|
- |
|
1892 |
|
- |
|
1893 |
} else {
|
- |
|
1894 |
SQLRow rowExisting = initedDepot.get(sqlRow.getID());
|
- |
|
1895 |
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
|
- |
|
1896 |
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
- |
|
1897 |
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
|
- |
|
1898 |
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).commit();
|
- |
|
1899 |
}
|
- |
|
1900 |
stockItems.add(new StockItem(row, rowExisting));
|
- |
|
1901 |
}
|
- |
|
1902 |
} catch (SQLException e) {
|
- |
|
1903 |
ExceptionHandler.handle("Erreur lors de l'initialisation du stock de l'article", e);
|
- |
|
1904 |
}
|
- |
|
1905 |
}
|
- |
|
1906 |
// if
|
- |
|
1907 |
// (row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")).size()
|
- |
|
1908 |
// > 0) {
|
- |
|
1909 |
// ComposedItemStockUpdater up = new ComposedItemStockUpdater(row.getTable().getDBRoot(),
|
- |
|
1910 |
// stockItems);
|
- |
|
1911 |
// try {
|
- |
|
1912 |
// up.updateNomenclature(stockItems);
|
- |
|
1913 |
// } catch (SQLException e) {
|
- |
|
1914 |
// ExceptionHandler.handle("Erreur lors de l'actualisation du stock!", e);
|
- |
|
1915 |
// }
|
- |
|
1916 |
// }
|
1147 |
}
|
1917 |
}
|
1148 |
|
1918 |
|
1149 |
public static void exec(final AlterTable alter) throws SQLException {
|
1919 |
public static void exec(final AlterTable alter) throws SQLException {
|
1150 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
1920 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
1151 |
alter.getTable().getSchema().updateVersion();
|
1921 |
alter.getTable().getSchema().updateVersion();
|