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.finance.payment.element.SDDMessageSQLElement;
|
- |
|
18 |
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.sales.invoice.element.SaisieVenteFactureSQLElement;
|
17 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
21 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
18 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
22 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
19 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
20 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
21 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
25 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
Line 30... |
Line 34... |
30 |
import org.openconcerto.sql.request.UpdateBuilder;
|
34 |
import org.openconcerto.sql.request.UpdateBuilder;
|
31 |
import org.openconcerto.sql.utils.AlterTable;
|
35 |
import org.openconcerto.sql.utils.AlterTable;
|
32 |
import org.openconcerto.sql.utils.ChangeTable;
|
36 |
import org.openconcerto.sql.utils.ChangeTable;
|
33 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
37 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
34 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
38 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
- |
|
39 |
import org.openconcerto.utils.CollectionUtils;
|
35 |
|
40 |
|
36 |
import java.math.BigDecimal;
|
41 |
import java.math.BigDecimal;
|
37 |
import java.sql.SQLException;
|
42 |
import java.sql.SQLException;
|
38 |
import java.sql.Types;
|
43 |
import java.sql.Types;
|
39 |
import java.util.Arrays;
|
44 |
import java.util.Arrays;
|
Line 78... |
Line 83... |
78 |
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
|
83 |
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
|
79 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
84 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
80 |
tClient.getSchema().updateVersion();
|
85 |
tClient.getSchema().updateVersion();
|
81 |
tClient.fetchFields();
|
86 |
tClient.fetchFields();
|
82 |
}
|
87 |
}
|
- |
|
88 |
if (!tClient.contains("DATE")) {
|
- |
|
89 |
final AlterTable alterClient = new AlterTable(tClient);
|
- |
|
90 |
alterClient.addColumn("DATE", "date");
|
- |
|
91 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
- |
|
92 |
tClient.getSchema().updateVersion();
|
- |
|
93 |
tClient.fetchFields();
|
- |
|
94 |
}
|
83 |
if (!tClient.contains("COMMENTAIRES")) {
|
95 |
if (!tClient.contains("COMMENTAIRES")) {
|
84 |
final AlterTable alterClient = new AlterTable(tClient);
|
96 |
final AlterTable alterClient = new AlterTable(tClient);
|
85 |
alterClient.addVarCharColumn("COMMENTAIRES", 2048);
|
97 |
alterClient.addVarCharColumn("COMMENTAIRES", 2048);
|
86 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
98 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
87 |
tClient.getSchema().updateVersion();
|
99 |
tClient.getSchema().updateVersion();
|
Line 233... |
Line 245... |
233 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
245 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
234 |
tableAttachment.getSchema().updateVersion();
|
246 |
tableAttachment.getSchema().updateVersion();
|
235 |
tableAttachment.fetchFields();
|
247 |
tableAttachment.fetchFields();
|
236 |
}
|
248 |
}
|
237 |
|
249 |
|
238 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "SALARIE");
|
250 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
239 |
for (String string : gedTable) {
|
251 |
for (String string : gedTable) {
|
240 |
SQLTable tableGED = root.getTable(string);
|
252 |
SQLTable tableGED = root.getTable(string);
|
241 |
if (!tableGED.contains("ATTACHMENTS")) {
|
253 |
if (!tableGED.contains("ATTACHMENTS")) {
|
242 |
final AlterTable alter = new AlterTable(tableGED);
|
254 |
final AlterTable alter = new AlterTable(tableGED);
|
243 |
alter.addIntegerColumn("ATTACHMENTS", 0);
|
255 |
alter.addIntegerColumn("ATTACHMENTS", 0);
|
Line 271... |
Line 283... |
271 |
|
283 |
|
272 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
284 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
273 |
if (!tableCmdElt.contains("LIVRE")) {
|
285 |
if (!tableCmdElt.contains("LIVRE")) {
|
274 |
AlterTable t = new AlterTable(tableCmdElt);
|
286 |
AlterTable t = new AlterTable(tableCmdElt);
|
275 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
287 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
276 |
t.addBooleanColumn("LIVRE", Boolean.TRUE, false);
|
288 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
277 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
289 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
278 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
290 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
279 |
root.refetchTable(tableCmdElt.getName());
|
291 |
root.refetchTable(tableCmdElt.getName());
|
280 |
root.getSchema().updateVersion();
|
292 |
root.getSchema().updateVersion();
|
281 |
|
293 |
|
Line 297... |
Line 309... |
297 |
// tableCmdElt.getName()).quote()
|
309 |
// tableCmdElt.getName()).quote()
|
298 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
310 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
299 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
311 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
300 |
}
|
312 |
}
|
301 |
|
313 |
|
- |
|
314 |
// Fix bad default value
|
- |
|
315 |
if (tableCmdElt.contains("LIVRE")) {
|
- |
|
316 |
AlterTable t = new AlterTable(tableCmdElt);
|
- |
|
317 |
t.alterColumnDefault("LIVRE", "false");
|
- |
|
318 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
- |
|
319 |
root.refetchTable(tableCmdElt.getName());
|
- |
|
320 |
root.getSchema().updateVersion();
|
- |
|
321 |
}
|
- |
|
322 |
|
302 |
// Achat
|
323 |
// Achat
|
303 |
|
324 |
|
304 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
325 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
305 |
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
|
326 |
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
|
306 |
AlterTable t = new AlterTable(tableBRElt);
|
327 |
AlterTable t = new AlterTable(tableBRElt);
|
Line 862... |
Line 883... |
862 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
883 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
863 |
tableArt.getSchema().updateVersion();
|
884 |
tableArt.getSchema().updateVersion();
|
864 |
tableArt.fetchFields();
|
885 |
tableArt.fetchFields();
|
865 |
}
|
886 |
}
|
866 |
|
887 |
|
- |
|
888 |
if (!tableArt.contains("ADDITIONAL_TICKET_COPY")) {
|
- |
|
889 |
final AlterTable alterArt = new AlterTable(tableArt);
|
- |
|
890 |
alterArt.addBooleanColumn("ADDITIONAL_TICKET_COPY", Boolean.FALSE, false);
|
- |
|
891 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
- |
|
892 |
tableArt.getSchema().updateVersion();
|
- |
|
893 |
tableArt.fetchFields();
|
- |
|
894 |
}
|
- |
|
895 |
|
867 |
SQLTable tableDevisAcompte = root.getTable("DEVIS");
|
896 |
SQLTable tableDevisAcompte = root.getTable("DEVIS");
|
868 |
|
897 |
|
869 |
if (!tableDevisAcompte.contains("T_ACOMPTE")) {
|
898 |
if (!tableDevisAcompte.contains("T_ACOMPTE")) {
|
870 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
899 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
871 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
900 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
Line 1015... |
Line 1044... |
1015 |
alterRegisterLog.getTable().fetchFields();
|
1044 |
alterRegisterLog.getTable().fetchFields();
|
1016 |
alterRegister.getTable().fetchFields();
|
1045 |
alterRegister.getTable().fetchFields();
|
1017 |
}
|
1046 |
}
|
1018 |
// Prefs compte AN
|
1047 |
// Prefs compte AN
|
1019 |
SQLTable table = root.findTable("PREFS_COMPTE");
|
1048 |
SQLTable table = root.findTable("PREFS_COMPTE");
|
1020 |
AlterTable t = new AlterTable(table);
|
- |
|
1021 |
|
1049 |
|
1022 |
if (!table.getFieldsName().contains("ID_JOURNAL_AN")) {
|
1050 |
if (!table.getFieldsName().contains("ID_JOURNAL_AN")) {
|
- |
|
1051 |
AlterTable t = new AlterTable(table);
|
1023 |
t.addForeignColumn("ID_JOURNAL_AN", root.getTable("JOURNAL"));
|
1052 |
t.addForeignColumn("ID_JOURNAL_AN", root.getTable("JOURNAL"));
|
1024 |
t.addBooleanColumn("CREATE_NUL_SOLDE_ECR", Boolean.TRUE, false);
|
1053 |
t.addBooleanColumn("CREATE_NUL_SOLDE_ECR", Boolean.TRUE, false);
|
1025 |
table.getBase().getDataSource().execute(t.asString());
|
1054 |
table.getBase().getDataSource().execute(t.asString());
|
1026 |
table.getSchema().updateVersion();
|
1055 |
table.getSchema().updateVersion();
|
1027 |
table.fetchFields();
|
1056 |
table.fetchFields();
|
1028 |
}
|
1057 |
}
|
1029 |
|
1058 |
|
- |
|
1059 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
- |
|
1060 |
AlterTable t = new AlterTable(table);
|
- |
|
1061 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
- |
|
1062 |
table.getBase().getDataSource().execute(t.asString());
|
- |
|
1063 |
table.getSchema().updateVersion();
|
- |
|
1064 |
table.fetchFields();
|
- |
|
1065 |
}
|
- |
|
1066 |
|
1030 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1067 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1031 |
if (!tableEcr.contains("CLOTURE")) {
|
1068 |
if (!tableEcr.contains("CLOTURE")) {
|
1032 |
final AlterTable alter = new AlterTable(tableEcr);
|
1069 |
final AlterTable alter = new AlterTable(tableEcr);
|
1033 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1070 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1034 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
1071 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
Line 1044... |
Line 1081... |
1044 |
alterKmElt.addIntegerColumn("JOUR", 1);
|
1081 |
alterKmElt.addIntegerColumn("JOUR", 1);
|
1045 |
tkmElt.getBase().getDataSource().execute(alterKmElt.asString());
|
1082 |
tkmElt.getBase().getDataSource().execute(alterKmElt.asString());
|
1046 |
tkmElt.getSchema().updateVersion();
|
1083 |
tkmElt.getSchema().updateVersion();
|
1047 |
tkmElt.fetchFields();
|
1084 |
tkmElt.fetchFields();
|
1048 |
}
|
1085 |
}
|
1049 |
// Ref bancaires fournisseurs
|
1086 |
// Ref bancaires fournisseurs et clients
|
- |
|
1087 |
for (final SQLTable bankT : Arrays.asList(tableFournisseur, tClient)) {
|
1050 |
if (!tableFournisseur.contains("IBAN")) {
|
1088 |
if (!bankT.contains("IBAN")) {
|
1051 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
1089 |
final AlterTable alter = new AlterTable(bankT);
|
1052 |
alter.addVarCharColumn("IBAN", 128);
|
1090 |
alter.addVarCharColumn("IBAN", 128);
|
1053 |
alter.addVarCharColumn("BIC", 128);
|
1091 |
alter.addVarCharColumn("BIC", 128);
|
1054 |
tableFournisseur.getBase().getDataSource().execute(alter.asString());
|
1092 |
bankT.getDBSystemRoot().getDataSource().execute(alter.asString());
|
1055 |
tableFournisseur.getSchema().updateVersion();
|
1093 |
bankT.getSchema().updateVersion();
|
1056 |
tableFournisseur.fetchFields();
|
1094 |
bankT.fetchFields();
|
- |
|
1095 |
}
|
1057 |
}
|
1096 |
}
|
- |
|
1097 |
final SQLTable typeReglT = root.getTable("TYPE_REGLEMENT");
|
- |
|
1098 |
if (typeReglT.getRow(TypeReglementSQLElement.PRELEVEMENT) == null) {
|
- |
|
1099 |
final SQLRowValues directDebitVals = new SQLRowValues(typeReglT).put("NOM", "Prélèvement");
|
- |
|
1100 |
directDebitVals.put("COMPTANT", Boolean.FALSE).put("ECHEANCE", Boolean.FALSE);
|
- |
|
1101 |
directDebitVals.setID(TypeReglementSQLElement.PRELEVEMENT).insertVerbatim();
|
1058 |
}
|
1102 |
}
|
- |
|
1103 |
if (!tableClient.contains("ACCEPTE_EMAIL")) {
|
- |
|
1104 |
final AlterTable alter = new AlterTable(tableClient);
|
- |
|
1105 |
alter.addBooleanColumn("ACCEPTE_EMAIL", Boolean.FALSE, false);
|
- |
|
1106 |
alter.addBooleanColumn("ACCEPTE_COURRIER", Boolean.FALSE, false);
|
- |
|
1107 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
- |
|
1108 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
- |
|
1109 |
exec(alter);
|
- |
|
1110 |
}
|
- |
|
1111 |
final SQLTable contactT = root.getTable("CONTACT");
|
- |
|
1112 |
if (!contactT.contains("DATE_NAISSANCE")) {
|
- |
|
1113 |
final AlterTable alter = new AlterTable(contactT);
|
- |
|
1114 |
alter.addColumn("DATE_NAISSANCE", "date");
|
- |
|
1115 |
exec(alter);
|
- |
|
1116 |
}
|
- |
|
1117 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
- |
|
1118 |
if (createSDDMsgTable != null) {
|
- |
|
1119 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
- |
|
1120 |
root.createTables(createSDDMsgTable, createMandate);
|
- |
|
1121 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
- |
|
1122 |
final SQLTable mandateT = root.getTable(createMandate.getName());
|
- |
|
1123 |
|
- |
|
1124 |
final AlterTable alterFact = new AlterTable(root.getTable(SaisieVenteFactureSQLElement.TABLENAME));
|
- |
|
1125 |
alterFact.addForeignColumn(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, msgT);
|
- |
|
1126 |
alterFact.addVarCharColumn(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, 35);
|
- |
|
1127 |
|
- |
|
1128 |
final AlterTable alterModeRegl = new AlterTable(root.getTable("MODE_REGLEMENT"));
|
- |
|
1129 |
alterModeRegl.addForeignColumn(null, mandateT);
|
1059 |
|
1130 |
|
- |
|
1131 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterFact, alterModeRegl))) {
|
- |
|
1132 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
- |
|
1133 |
}
|
- |
|
1134 |
root.getSchema().updateVersion();
|
- |
|
1135 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
- |
|
1136 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
- |
|
1137 |
}
|
- |
|
1138 |
|
- |
|
1139 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
- |
|
1140 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
- |
|
1141 |
final AlterTable alter = new AlterTable(vcT);
|
- |
|
1142 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
- |
|
1143 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
- |
|
1144 |
exec(alter);
|
- |
|
1145 |
}
|
- |
|
1146 |
|
- |
|
1147 |
}
|
- |
|
1148 |
|
- |
|
1149 |
public static void exec(final AlterTable alter) throws SQLException {
|
- |
|
1150 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
- |
|
1151 |
alter.getTable().getSchema().updateVersion();
|
- |
|
1152 |
alter.getTable().fetchFields();
|
- |
|
1153 |
}
|
1060 |
}
|
1154 |
}
|