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.element.BanqueSQLElement;
|
17 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
18 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
18 |
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
|
19 |
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
21 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
21 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
22 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
Line 37... |
Line 38... |
37 |
import org.openconcerto.sql.model.SQLRowValues;
|
38 |
import org.openconcerto.sql.model.SQLRowValues;
|
38 |
import org.openconcerto.sql.model.SQLSelect;
|
39 |
import org.openconcerto.sql.model.SQLSelect;
|
39 |
import org.openconcerto.sql.model.SQLSyntax;
|
40 |
import org.openconcerto.sql.model.SQLSyntax;
|
40 |
import org.openconcerto.sql.model.SQLSystem;
|
41 |
import org.openconcerto.sql.model.SQLSystem;
|
41 |
import org.openconcerto.sql.model.SQLTable;
|
42 |
import org.openconcerto.sql.model.SQLTable;
|
42 |
import org.openconcerto.sql.model.SQLTable.Index;
|
- |
|
43 |
import org.openconcerto.sql.model.Where;
|
43 |
import org.openconcerto.sql.model.Where;
|
44 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
44 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
45 |
import org.openconcerto.sql.request.UpdateBuilder;
|
45 |
import org.openconcerto.sql.request.UpdateBuilder;
|
46 |
import org.openconcerto.sql.utils.AlterTable;
|
46 |
import org.openconcerto.sql.utils.AlterTable;
|
47 |
import org.openconcerto.sql.utils.ChangeTable;
|
47 |
import org.openconcerto.sql.utils.ChangeTable;
|
Line 368... |
Line 368... |
368 |
|
368 |
|
369 |
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
|
369 |
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
|
370 |
if (!tableCmdFElt.contains("RECU")) {
|
370 |
if (!tableCmdFElt.contains("RECU")) {
|
371 |
AlterTable t = new AlterTable(tableCmdFElt);
|
371 |
AlterTable t = new AlterTable(tableCmdFElt);
|
372 |
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
|
372 |
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
|
373 |
t.addBooleanColumn("RECU", Boolean.TRUE, false);
|
373 |
t.addBooleanColumn("RECU", Boolean.FALSE, false);
|
374 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
374 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
375 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
375 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
376 |
root.refetchTable(tableCmdFElt.getName());
|
376 |
root.refetchTable(tableCmdFElt.getName());
|
377 |
root.getSchema().updateVersion();
|
377 |
root.getSchema().updateVersion();
|
378 |
|
378 |
|
Line 396... |
Line 396... |
396 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
396 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
397 |
build.setWhere(where);
|
397 |
build.setWhere(where);
|
398 |
System.err.println(build.asString());
|
398 |
System.err.println(build.asString());
|
399 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
399 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
400 |
}
|
400 |
}
|
- |
|
401 |
} else {
|
- |
|
402 |
// Fix bad default value
|
- |
|
403 |
String defaultValue = tableCmdFElt.getField("RECU").getDefaultValue();
|
- |
|
404 |
if (defaultValue != null && defaultValue.equals("true")) {
|
- |
|
405 |
AlterTable t = new AlterTable(tableCmdFElt);
|
- |
|
406 |
t.alterColumn("RECU", EnumSet.allOf(Properties.class), "boolean", "false", false);
|
- |
|
407 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
- |
|
408 |
root.refetchTable(tableCmdFElt.getName());
|
- |
|
409 |
root.getSchema().updateVersion();
|
- |
|
410 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
- |
|
411 |
build.setObject("RECU", Boolean.FALSE);
|
- |
|
412 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
413 |
|
- |
|
414 |
Where w = Where.createRaw(tableCmdFElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdFElt.getField("QTE").getQuotedName() + "*"
|
- |
|
415 |
+ tableCmdFElt.getField("QTE_UNITAIRE").getQuotedName() + ")", tableCmdFElt.getField("QTE_UNITAIRE"), tableCmdFElt.getField("QTE"), tableCmdFElt.getField("QTE_RECUE"));
|
- |
|
416 |
build.setWhere(w.or(new Where(tableCmdFElt.getKey(), "=", 1)));
|
- |
|
417 |
System.err.println(build.asString());
|
- |
|
418 |
tableCmdFElt.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
419 |
}
|
- |
|
420 |
|
401 |
}
|
421 |
}
|
402 |
|
422 |
|
403 |
// Champ matière
|
423 |
// Champ matière
|
404 |
SQLTable tableArt = root.getTable("ARTICLE");
|
424 |
SQLTable tableArt = root.getTable("ARTICLE");
|
405 |
if (!tableArt.contains("MATIERE")) {
|
425 |
if (!tableArt.contains("MATIERE")) {
|
Line 803... |
Line 823... |
803 |
tableElementPaye.getSchema().updateVersion();
|
823 |
tableElementPaye.getSchema().updateVersion();
|
804 |
tableElementPaye.fetchFields();
|
824 |
tableElementPaye.fetchFields();
|
805 |
|
825 |
|
806 |
}
|
826 |
}
|
807 |
|
827 |
|
- |
|
828 |
if (!tableFpaye.contains("CSG_REDUITE")) {
|
- |
|
829 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
- |
|
830 |
alterB.addDecimalColumn("CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
|
- |
|
831 |
alterB.addDecimalColumn("SAL_BRUT_CSG", 16, 2, BigDecimal.ZERO, false);
|
- |
|
832 |
alterB.addDecimalColumn("SAL_BRUT_CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
|
- |
|
833 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
834 |
root.refetchTable("FICHE_PAYE");
|
- |
|
835 |
root.getSchema().updateVersion();
|
- |
|
836 |
}
|
- |
|
837 |
|
808 |
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
|
838 |
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
|
809 |
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
|
839 |
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
|
810 |
final AlterTable alterB = new AlterTable(tableCpaye);
|
840 |
final AlterTable alterB = new AlterTable(tableCpaye);
|
811 |
alterB.addDecimalColumn("TAXE_CM_SAL_C", 16, 2, BigDecimal.ZERO, false);
|
841 |
alterB.addDecimalColumn("TAXE_CM_SAL_C", 16, 2, BigDecimal.ZERO, false);
|
812 |
alterB.addDecimalColumn("TAXE_CM_PAT_C", 16, 2, BigDecimal.ZERO, false);
|
842 |
alterB.addDecimalColumn("TAXE_CM_PAT_C", 16, 2, BigDecimal.ZERO, false);
|
Line 871... |
Line 901... |
871 |
alterArticle.addIntegerColumn("IFCO", 0);
|
901 |
alterArticle.addIntegerColumn("IFCO", 0);
|
872 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
902 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
873 |
tableArticle.getSchema().updateVersion();
|
903 |
tableArticle.getSchema().updateVersion();
|
874 |
tableArticle.fetchFields();
|
904 |
tableArticle.fetchFields();
|
875 |
}
|
905 |
}
|
- |
|
906 |
if (!tableArticle.contains("DLC")) {
|
- |
|
907 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
- |
|
908 |
alterArticle.addColumn("DLC", "date");
|
- |
|
909 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
- |
|
910 |
tableArticle.getSchema().updateVersion();
|
- |
|
911 |
tableArticle.fetchFields();
|
- |
|
912 |
}
|
876 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
913 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
877 |
if (!tableFournisseur.contains("NUMERO_TVA")) {
|
914 |
if (!tableFournisseur.contains("NUMERO_TVA")) {
|
878 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
915 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
879 |
alter.addVarCharColumn("NUMERO_TVA", 128);
|
916 |
alter.addVarCharColumn("NUMERO_TVA", 128);
|
880 |
alter.addVarCharColumn("SIRET", 128);
|
917 |
alter.addVarCharColumn("SIRET", 128);
|
Line 1033... |
Line 1070... |
1033 |
root.getBase().getDataSource().execute(alterB.asString());
|
1070 |
root.getBase().getDataSource().execute(alterB.asString());
|
1034 |
root.refetchTable("FICHE_PAYE_ELEMENT");
|
1071 |
root.refetchTable("FICHE_PAYE_ELEMENT");
|
1035 |
root.getSchema().updateVersion();
|
1072 |
root.getSchema().updateVersion();
|
1036 |
}
|
1073 |
}
|
1037 |
|
1074 |
|
1038 |
if (!tableVarSal.contains("IJSS_BRUT")) {
|
1075 |
boolean upVar = false;
|
- |
|
1076 |
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT", "HEURE_CHOM", "TAUX_CHOM", "HEURE_INDEM", "ECRETEMENT_CSG", "IJSS_BRUT_SECU_PAS");
|
1039 |
final AlterTable alterB = new AlterTable(tableVarSal);
|
1077 |
final AlterTable alterVarSal = new AlterTable(tableVarSal);
|
1040 |
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT");
|
- |
|
1041 |
for (String field : f) {
|
1078 |
for (String field : f) {
|
- |
|
1079 |
if (!tableVarSal.contains(field)) {
|
- |
|
1080 |
upVar = true;
|
1042 |
alterB.addColumn(field, "real DEFAULT 0");
|
1081 |
alterVarSal.addColumn(field, "real DEFAULT 0");
|
1043 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
1082 |
alterVarSal.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
- |
|
1083 |
alterVarSal.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
|
1044 |
}
|
1084 |
}
|
- |
|
1085 |
}
|
- |
|
1086 |
if (upVar) {
|
1045 |
root.getBase().getDataSource().execute(alterB.asString());
|
1087 |
root.getBase().getDataSource().execute(alterVarSal.asString());
|
1046 |
root.refetchTable(tableVarSal.getName());
|
1088 |
root.refetchTable(tableVarSal.getName());
|
1047 |
root.getSchema().updateVersion();
|
1089 |
root.getSchema().updateVersion();
|
1048 |
}
|
1090 |
}
|
1049 |
|
1091 |
|
1050 |
SQLTable tableDevis = root.getTable("DEVIS");
|
1092 |
SQLTable tableDevis = root.getTable("DEVIS");
|
Line 1134... |
Line 1176... |
1134 |
table.getBase().getDataSource().execute(t.asString());
|
1176 |
table.getBase().getDataSource().execute(t.asString());
|
1135 |
table.getSchema().updateVersion();
|
1177 |
table.getSchema().updateVersion();
|
1136 |
table.fetchFields();
|
1178 |
table.fetchFields();
|
1137 |
}
|
1179 |
}
|
1138 |
|
1180 |
|
- |
|
1181 |
if (!table.getFieldsName().contains("ID_JOURNAL_CB_ATTENTE")) {
|
- |
|
1182 |
AlterTable t = new AlterTable(table);
|
- |
|
1183 |
t.addForeignColumn("ID_JOURNAL_CB_ATTENTE", root.getTable("JOURNAL"));
|
- |
|
1184 |
table.getBase().getDataSource().execute(t.asString());
|
- |
|
1185 |
table.getSchema().updateVersion();
|
- |
|
1186 |
table.fetchFields();
|
- |
|
1187 |
}
|
- |
|
1188 |
|
- |
|
1189 |
if (!table.getFieldsName().contains("ID_COMPTE_PCE_CB_ATTENTE")) {
|
- |
|
1190 |
AlterTable t = new AlterTable(table);
|
- |
|
1191 |
t.addForeignColumn("ID_COMPTE_PCE_CB_ATTENTE", root.getTable("COMPTE_PCE"));
|
- |
|
1192 |
table.getBase().getDataSource().execute(t.asString());
|
- |
|
1193 |
table.getSchema().updateVersion();
|
- |
|
1194 |
table.fetchFields();
|
- |
|
1195 |
}
|
- |
|
1196 |
|
1139 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
1197 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
1140 |
AlterTable t = new AlterTable(table);
|
1198 |
AlterTable t = new AlterTable(table);
|
1141 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1199 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1142 |
table.getBase().getDataSource().execute(t.asString());
|
1200 |
table.getBase().getDataSource().execute(t.asString());
|
1143 |
table.getSchema().updateVersion();
|
1201 |
table.getSchema().updateVersion();
|
Line 1902... |
Line 1960... |
1902 |
t.addVarCharColumn("COMPLEMENT_PCS", 54);
|
1960 |
t.addVarCharColumn("COMPLEMENT_PCS", 54);
|
1903 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
1961 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
1904 |
root.refetchTable(tableContrat.getName());
|
1962 |
root.refetchTable(tableContrat.getName());
|
1905 |
root.getSchema().updateVersion();
|
1963 |
root.getSchema().updateVersion();
|
1906 |
}
|
1964 |
}
|
- |
|
1965 |
if (!tableContrat.contains("SPECTACLE_OBJET")) {
|
- |
|
1966 |
AlterTable t = new AlterTable(tableContrat);
|
- |
|
1967 |
t.addVarCharColumn("SPECTACLE_OBJET", 54);
|
- |
|
1968 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
- |
|
1969 |
root.refetchTable(tableContrat.getName());
|
- |
|
1970 |
root.getSchema().updateVersion();
|
- |
|
1971 |
}
|
- |
|
1972 |
|
- |
|
1973 |
if (!tableContrat.contains("SPECTACLE_OBJET")) {
|
- |
|
1974 |
AlterTable t = new AlterTable(tableContrat);
|
- |
|
1975 |
t.addVarCharColumn("SPECTACLE_OBJET", 54);
|
- |
|
1976 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
- |
|
1977 |
root.refetchTable(tableContrat.getName());
|
- |
|
1978 |
root.getSchema().updateVersion();
|
- |
|
1979 |
}
|
- |
|
1980 |
if (!tableContrat.contains("SPECTACLE_JOUR_CONTRAT")) {
|
- |
|
1981 |
AlterTable t = new AlterTable(tableContrat);
|
- |
|
1982 |
t.addDecimalColumn("SPECTACLE_JOUR_CONTRAT", 16, 2, null, true);
|
- |
|
1983 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
- |
|
1984 |
root.refetchTable(tableContrat.getName());
|
- |
|
1985 |
root.getSchema().updateVersion();
|
- |
|
1986 |
}
|
1907 |
|
1987 |
|
1908 |
List<String> tablesCatComptable = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT");
|
1988 |
List<String> tablesCatComptable = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT");
|
1909 |
for (String tableToUp : tablesCatComptable) {
|
1989 |
for (String tableToUp : tablesCatComptable) {
|
1910 |
final SQLTable tableCatComptToAdd = root.getTable(tableToUp);
|
1990 |
final SQLTable tableCatComptToAdd = root.getTable(tableToUp);
|
1911 |
if (!tableCatComptToAdd.contains("ID_CATEGORIE_COMPTABLE")) {
|
1991 |
if (!tableCatComptToAdd.contains("ID_CATEGORIE_COMPTABLE")) {
|
Line 1935... |
Line 2015... |
1935 |
throw new IllegalStateException("Erreur lors de la création de la table " + EmailTemplateSQLElement.TABLE_NAME, ex);
|
2015 |
throw new IllegalStateException("Erreur lors de la création de la table " + EmailTemplateSQLElement.TABLE_NAME, ex);
|
1936 |
}
|
2016 |
}
|
1937 |
}
|
2017 |
}
|
1938 |
// Force undefined policy to inDb
|
2018 |
// Force undefined policy to inDb
|
1939 |
root.setMetadata(SQLTable.UNDEFINED_ID_POLICY, "inDB");
|
2019 |
root.setMetadata(SQLTable.UNDEFINED_ID_POLICY, "inDB");
|
1940 |
final Map<String, Number> mapTableNameUndefined = SQLTable.getUndefIDs(root.getSchema());
|
2020 |
final Map<String, Number> mapTableNameUndefined = SQLTable.getUndefinedIDs(root.getSchema());
|
1941 |
final Set<String> tables = root.getSchema().getTableNames();
|
2021 |
final Set<String> tables = root.getSchema().getTableNames();
|
1942 |
for (String tName : tables) {
|
2022 |
for (String tName : tables) {
|
1943 |
if (!mapTableNameUndefined.containsKey(tName)) {
|
2023 |
if (!mapTableNameUndefined.containsKey(tName)) {
|
1944 |
System.err.println("Updater_1_5.update() adding undefined in db for " + tName);
|
2024 |
System.err.println("Updater_1_5.update() adding undefined in db for " + tName);
|
1945 |
SQLTable.setUndefID(root.getSchema(), tName, null);
|
2025 |
SQLTable.setUndefID(root.getSchema(), tName, null);
|
Line 2004... |
Line 2084... |
2004 |
alter.addColumn("DUREE_FORFAIT", "real");
|
2084 |
alter.addColumn("DUREE_FORFAIT", "real");
|
2005 |
exec(alter);
|
2085 |
exec(alter);
|
2006 |
root.refetchTable(tableSalarie.getName());
|
2086 |
root.refetchTable(tableSalarie.getName());
|
2007 |
root.getSchema().updateVersion();
|
2087 |
root.getSchema().updateVersion();
|
2008 |
}
|
2088 |
}
|
- |
|
2089 |
boolean upDimensionArt = false;
|
2009 |
|
2090 |
|
- |
|
2091 |
final AlterTable alterDimensionArt = new AlterTable(tableArt);
|
- |
|
2092 |
if (!tableArt.contains("LONGUEUR")) {
|
- |
|
2093 |
alterDimensionArt.addDecimalColumn("LONGUEUR", 16, 8, null, true);
|
- |
|
2094 |
upDimensionArt = true;
|
- |
|
2095 |
}
|
- |
|
2096 |
if (!tableArt.contains("LARGEUR")) {
|
- |
|
2097 |
alterDimensionArt.addDecimalColumn("LARGEUR", 16, 8, null, true);
|
- |
|
2098 |
upDimensionArt = true;
|
- |
|
2099 |
}
|
- |
|
2100 |
if (!tableArt.contains("HAUTEUR")) {
|
- |
|
2101 |
alterDimensionArt.addDecimalColumn("HAUTEUR", 16, 8, null, true);
|
- |
|
2102 |
upDimensionArt = true;
|
- |
|
2103 |
}
|
- |
|
2104 |
if (upDimensionArt) {
|
- |
|
2105 |
tableArt.getBase().getDataSource().execute(alterDimensionArt.asString());
|
- |
|
2106 |
tableArt.getSchema().updateVersion();
|
- |
|
2107 |
tableArt.fetchFields();
|
- |
|
2108 |
}
|
- |
|
2109 |
|
- |
|
2110 |
List<String> tableElementWithTable = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
|
- |
|
2111 |
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
- |
|
2112 |
for (String tableName : tableElementWithTable) {
|
- |
|
2113 |
final SQLTable tableToAddDimension = root.getTable(tableName);
|
- |
|
2114 |
boolean upDimensionArtItem = false;
|
- |
|
2115 |
|
- |
|
2116 |
final AlterTable alterDimensionArtItem = new AlterTable(tableToAddDimension);
|
- |
|
2117 |
if (!tableToAddDimension.contains("LONGUEUR")) {
|
- |
|
2118 |
alterDimensionArtItem.addDecimalColumn("LONGUEUR", 16, 8, null, true);
|
- |
|
2119 |
upDimensionArtItem = true;
|
- |
|
2120 |
}
|
- |
|
2121 |
if (!tableToAddDimension.contains("LARGEUR")) {
|
- |
|
2122 |
alterDimensionArtItem.addDecimalColumn("LARGEUR", 16, 8, null, true);
|
- |
|
2123 |
upDimensionArtItem = true;
|
- |
|
2124 |
}
|
- |
|
2125 |
if (!tableToAddDimension.contains("HAUTEUR")) {
|
- |
|
2126 |
alterDimensionArtItem.addDecimalColumn("HAUTEUR", 16, 8, null, true);
|
- |
|
2127 |
upDimensionArtItem = true;
|
- |
|
2128 |
}
|
- |
|
2129 |
if (upDimensionArtItem) {
|
- |
|
2130 |
tableToAddDimension.getBase().getDataSource().execute(alterDimensionArtItem.asString());
|
- |
|
2131 |
tableToAddDimension.getSchema().updateVersion();
|
- |
|
2132 |
tableToAddDimension.fetchFields();
|
- |
|
2133 |
}
|
- |
|
2134 |
}
|
- |
|
2135 |
|
- |
|
2136 |
if (!tTva.contains("DEFAULT_ACHAT")) {
|
- |
|
2137 |
final AlterTable alterTaxe = new AlterTable(tTva);
|
- |
|
2138 |
alterTaxe.addBooleanColumn("DEFAULT_ACHAT", Boolean.FALSE, false);
|
- |
|
2139 |
tTva.getBase().getDataSource().execute(alterTaxe.asString());
|
- |
|
2140 |
tTva.getSchema().updateVersion();
|
- |
|
2141 |
tTva.fetchFields();
|
- |
|
2142 |
}
|
- |
|
2143 |
SQLTable tableTypeRglt = root.getTable("TYPE_REGLEMENT");
|
- |
|
2144 |
if (!tableTypeRglt.contains("SEPA")) {
|
- |
|
2145 |
final AlterTable alterTaxe = new AlterTable(tableTypeRglt);
|
- |
|
2146 |
alterTaxe.addBooleanColumn("SEPA", Boolean.FALSE, false);
|
- |
|
2147 |
tableTypeRglt.getBase().getDataSource().execute(alterTaxe.asString());
|
- |
|
2148 |
tableTypeRglt.getSchema().updateVersion();
|
- |
|
2149 |
tableTypeRglt.fetchFields();
|
- |
|
2150 |
UpdateBuilder upSEPA = new UpdateBuilder(tableTypeRglt);
|
- |
|
2151 |
upSEPA.setObject("SEPA", Boolean.TRUE);
|
- |
|
2152 |
upSEPA.setObject("ECHEANCE", Boolean.TRUE);
|
- |
|
2153 |
upSEPA.setWhere(new Where(tableTypeRglt.getField("NOM"), "=", "Prélèvement"));
|
- |
|
2154 |
tTva.getBase().getDataSource().execute(upSEPA.asString());
|
- |
|
2155 |
}
|
- |
|
2156 |
|
- |
|
2157 |
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
- |
|
2158 |
if (!tableEch.contains("ID_SEPA_MANDATE")) {
|
- |
|
2159 |
|
- |
|
2160 |
final AlterTable alterEch = new AlterTable(tableEch);
|
- |
|
2161 |
alterEch.addForeignColumn("ID_SEPA_MANDATE", root.getTable("SEPA_MANDATE"));
|
- |
|
2162 |
alterEch.addForeignColumn("ID_SDD_MESSAGE", root.getTable(SDDMessageSQLElement.TABLE_NAME));
|
- |
|
2163 |
alterEch.addVarCharColumn("SDD_EndToEndId", 35);
|
- |
|
2164 |
alterEch.addBooleanColumn("FICHIER_CREE", Boolean.FALSE, false);
|
- |
|
2165 |
alterEch.addBooleanColumn("REJETER", Boolean.FALSE, false);
|
- |
|
2166 |
alterEch.addVarCharColumn("ETS", 256);
|
- |
|
2167 |
alterEch.addForeignColumn("ID_" + BanqueSQLElement.TABLENAME, root.getTable(BanqueSQLElement.TABLENAME));
|
- |
|
2168 |
tableEch.getBase().getDataSource().execute(alterEch.asString());
|
- |
|
2169 |
tableEch.getSchema().updateVersion();
|
- |
|
2170 |
tableEch.fetchFields();
|
- |
|
2171 |
|
- |
|
2172 |
}
|
- |
|
2173 |
if (!tClient.contains("ID_SEPA_MANDATE_DEFAULT")) {
|
- |
|
2174 |
final AlterTable alterClient = new AlterTable(tClient);
|
- |
|
2175 |
alterClient.addForeignColumn("ID_SEPA_MANDATE_DEFAULT", root.getTable("SEPA_MANDATE"));
|
- |
|
2176 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
- |
|
2177 |
tClient.getSchema().updateVersion();
|
- |
|
2178 |
tClient.fetchFields();
|
- |
|
2179 |
}
|
- |
|
2180 |
|
- |
|
2181 |
if (!tableArt.contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
|
- |
|
2182 |
final AlterTable alter = new AlterTable(tableArt);
|
- |
|
2183 |
alter.addBooleanColumn("AUTO_PRIX_MIN_VENTE_NOMENCLATURE", Boolean.FALSE, false);
|
- |
|
2184 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
- |
|
2185 |
tableArt.getSchema().updateVersion();
|
- |
|
2186 |
tableArt.fetchFields();
|
- |
|
2187 |
}
|
- |
|
2188 |
if (!tableArt.contains("DERNIER_DATE_ACHAT")) {
|
- |
|
2189 |
final AlterTable alter = new AlterTable(tableArt);
|
- |
|
2190 |
alter.addColumn("DERNIER_DATE_ACHAT", "date");
|
- |
|
2191 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
- |
|
2192 |
tableArt.getSchema().updateVersion();
|
- |
|
2193 |
tableArt.fetchFields();
|
- |
|
2194 |
ReferenceArticleSQLElement.updateDateAchat(tableArt, null);
|
- |
|
2195 |
}
|
- |
|
2196 |
|
- |
|
2197 |
SQLTable tableFactF = root.getTable("FACTURE_FOURNISSEUR");
|
- |
|
2198 |
if (!tableFactF.contains("DATE_REGLEMENT")) {
|
- |
|
2199 |
final AlterTable alter = new AlterTable(tableFactF);
|
- |
|
2200 |
alter.addColumn("DATE_REGLEMENT", "date");
|
- |
|
2201 |
tableFactF.getBase().getDataSource().execute(alter.asString());
|
- |
|
2202 |
tableFactF.getSchema().updateVersion();
|
- |
|
2203 |
tableFactF.fetchFields();
|
- |
|
2204 |
}
|
- |
|
2205 |
|
- |
|
2206 |
SQLTable tableEchF = root.getTable("ECHEANCE_FOURNISSEUR");
|
- |
|
2207 |
if (!tableEchF.contains("ID_FACTURE_FOURNISSEUR")) {
|
- |
|
2208 |
final AlterTable alter = new AlterTable(tableEchF);
|
- |
|
2209 |
alter.addForeignColumn("ID_FACTURE_FOURNISSEUR", tableFactF);
|
- |
|
2210 |
tableEchF.getBase().getDataSource().execute(alter.asString());
|
- |
|
2211 |
tableEchF.getSchema().updateVersion();
|
- |
|
2212 |
tableEchF.fetchFields();
|
- |
|
2213 |
}
|
- |
|
2214 |
|
- |
|
2215 |
List<String> achatItems = Arrays.asList("DEMANDE_PRIX_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "FACTURE_FOURNISSEUR_ELEMENT");
|
- |
|
2216 |
for (String string : achatItems) {
|
- |
|
2217 |
boolean alter = false;
|
- |
|
2218 |
SQLTable tableItems = root.getTable(string);
|
- |
|
2219 |
final AlterTable t = new AlterTable(tableItems);
|
- |
|
2220 |
|
- |
|
2221 |
if (!tableItems.getFieldsName().contains("POIDS_COLIS_NET")) {
|
- |
|
2222 |
t.addColumn("POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
|
- |
|
2223 |
alter = true;
|
- |
|
2224 |
}
|
- |
|
2225 |
|
- |
|
2226 |
if (!tableItems.getFieldsName().contains("T_POIDS_COLIS_NET")) {
|
- |
|
2227 |
t.addColumn("T_POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
|
- |
|
2228 |
alter = true;
|
- |
|
2229 |
}
|
- |
|
2230 |
|
- |
|
2231 |
if (!tableItems.getFieldsName().contains("NB_COLIS")) {
|
- |
|
2232 |
t.addColumn("NB_COLIS", "integer DEFAULT 0");
|
- |
|
2233 |
alter = true;
|
- |
|
2234 |
}
|
- |
|
2235 |
if (alter) {
|
- |
|
2236 |
tableItems.getBase().getDataSource().execute(t.asString());
|
- |
|
2237 |
tableItems.getSchema().updateVersion();
|
- |
|
2238 |
tableItems.fetchFields();
|
- |
|
2239 |
}
|
- |
|
2240 |
}
|
- |
|
2241 |
|
- |
|
2242 |
for (String tableName : tableElementWithTable) {
|
- |
|
2243 |
final SQLTable tableToAddTare = root.getTable(tableName);
|
- |
|
2244 |
boolean upTareArtItem = false;
|
- |
|
2245 |
|
- |
|
2246 |
final AlterTable alterTareArtItem = new AlterTable(tableToAddTare);
|
- |
|
2247 |
if (!tableToAddTare.contains("TARE")) {
|
- |
|
2248 |
alterTareArtItem.addDecimalColumn("TARE", 16, 8, null, true);
|
- |
|
2249 |
alterTareArtItem.alterColumn("POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
|
- |
|
2250 |
alterTareArtItem.alterColumn("T_POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
|
- |
|
2251 |
|
- |
|
2252 |
alterTareArtItem.addDecimalColumn("T_POIDS_BRUT", 16, 8, BigDecimal.ZERO, true);
|
- |
|
2253 |
|
- |
|
2254 |
upTareArtItem = true;
|
- |
|
2255 |
}
|
- |
|
2256 |
|
- |
|
2257 |
if (upTareArtItem) {
|
- |
|
2258 |
tableToAddTare.getBase().getDataSource().execute(alterTareArtItem.asString());
|
- |
|
2259 |
tableToAddTare.getSchema().updateVersion();
|
- |
|
2260 |
tableToAddTare.fetchFields();
|
- |
|
2261 |
|
- |
|
2262 |
int id = tableToAddTare.getUndefinedID();
|
- |
|
2263 |
if (id != SQLRow.NONEXISTANT_ID) {
|
- |
|
2264 |
UpdateBuilder build = new UpdateBuilder(tableToAddTare);
|
- |
|
2265 |
build.setObject("POIDS_COLIS_NET", BigDecimal.ZERO);
|
- |
|
2266 |
build.setWhere(new Where(tableToAddTare.getKey(), "=", id));
|
- |
|
2267 |
tableToAddTare.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
2268 |
}
|
- |
|
2269 |
}
|
- |
|
2270 |
}
|
- |
|
2271 |
|
- |
|
2272 |
// Fix nb char MOUVEMENT_STOCK.NOM
|
- |
|
2273 |
if (tableMvtStock.getField("NOM").getType().getSize() == 45) {
|
- |
|
2274 |
AlterTable alterMvt = new AlterTable(tableMvtStock);
|
- |
|
2275 |
alterMvt.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
|
- |
|
2276 |
tableMvtStock.getDBSystemRoot().getDataSource().execute(alterMvt.asString());
|
- |
|
2277 |
tableMvtStock.getSchema().updateVersion();
|
- |
|
2278 |
}
|
- |
|
2279 |
|
- |
|
2280 |
SQLTable tableEtatStock = root.getTable("ETAT_STOCK");
|
- |
|
2281 |
SQLTable tableDepotStock = root.getTable("DEPOT_STOCK");
|
- |
|
2282 |
if (!tableEtatStock.contains("ID_DEPOT_STOCK")) {
|
- |
|
2283 |
final AlterTable alter = new AlterTable(tableEtatStock);
|
- |
|
2284 |
alter.addForeignColumn("ID_DEPOT_STOCK", tableDepotStock);
|
- |
|
2285 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
- |
|
2286 |
tableEtatStock.getSchema().updateVersion();
|
- |
|
2287 |
tableEtatStock.fetchFields();
|
- |
|
2288 |
}
|
2010 |
}
|
2289 |
}
|
2011 |
|
2290 |
|
2012 |
public static void initStock(SQLRow rowArticle, int idDepot) {
|
2291 |
public static void initStock(SQLRow rowArticle, int idDepot) {
|
2013 |
|
2292 |
|
2014 |
SQLSelect selStock = new SQLSelect();
|
2293 |
SQLSelect selStock = new SQLSelect();
|