142 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
142 |
ilm |
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.config.update;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.InstallationPanel;
|
177 |
ilm |
17 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
156 |
ilm |
18 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
174 |
ilm |
19 |
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
|
151 |
ilm |
20 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
|
|
21 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
|
|
22 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
|
|
23 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
144 |
ilm |
24 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
|
|
25 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
|
|
26 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
149 |
ilm |
27 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
174 |
ilm |
28 |
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
|
156 |
ilm |
29 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
|
|
30 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
|
144 |
ilm |
31 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
182 |
ilm |
32 |
import org.openconcerto.sql.changer.convert.SetFKDefault;
|
180 |
ilm |
33 |
import org.openconcerto.sql.model.AliasedTable;
|
142 |
ilm |
34 |
import org.openconcerto.sql.model.DBRoot;
|
156 |
ilm |
35 |
import org.openconcerto.sql.model.SQLField;
|
142 |
ilm |
36 |
import org.openconcerto.sql.model.SQLField.Properties;
|
|
|
37 |
import org.openconcerto.sql.model.SQLName;
|
156 |
ilm |
38 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
39 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
144 |
ilm |
40 |
import org.openconcerto.sql.model.SQLRowValues;
|
156 |
ilm |
41 |
import org.openconcerto.sql.model.SQLSelect;
|
144 |
ilm |
42 |
import org.openconcerto.sql.model.SQLSyntax;
|
|
|
43 |
import org.openconcerto.sql.model.SQLSystem;
|
142 |
ilm |
44 |
import org.openconcerto.sql.model.SQLTable;
|
182 |
ilm |
45 |
import org.openconcerto.sql.model.SQLUpdate;
|
142 |
ilm |
46 |
import org.openconcerto.sql.model.Where;
|
156 |
ilm |
47 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
142 |
ilm |
48 |
import org.openconcerto.sql.request.UpdateBuilder;
|
|
|
49 |
import org.openconcerto.sql.utils.AlterTable;
|
149 |
ilm |
50 |
import org.openconcerto.sql.utils.ChangeTable;
|
142 |
ilm |
51 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
144 |
ilm |
52 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
151 |
ilm |
53 |
import org.openconcerto.utils.CollectionUtils;
|
156 |
ilm |
54 |
import org.openconcerto.utils.ExceptionHandler;
|
142 |
ilm |
55 |
|
|
|
56 |
import java.math.BigDecimal;
|
156 |
ilm |
57 |
import java.sql.Clob;
|
142 |
ilm |
58 |
import java.sql.SQLException;
|
|
|
59 |
import java.sql.Types;
|
156 |
ilm |
60 |
import java.util.ArrayList;
|
142 |
ilm |
61 |
import java.util.Arrays;
|
156 |
ilm |
62 |
import java.util.Collections;
|
142 |
ilm |
63 |
import java.util.EnumSet;
|
156 |
ilm |
64 |
import java.util.HashMap;
|
142 |
ilm |
65 |
import java.util.List;
|
156 |
ilm |
66 |
import java.util.Map;
|
174 |
ilm |
67 |
import java.util.Set;
|
156 |
ilm |
68 |
import java.util.prefs.BackingStoreException;
|
142 |
ilm |
69 |
|
156 |
ilm |
70 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
71 |
|
142 |
ilm |
72 |
public class Updater_1_5 {
|
|
|
73 |
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
|
|
|
74 |
|
|
|
75 |
public static void update(final DBRoot root) throws SQLException {
|
|
|
76 |
// Champ obsolete sur compte
|
|
|
77 |
SQLTable tableCompte = root.getTable("COMPTE_PCE");
|
|
|
78 |
if (!tableCompte.contains("OBSOLETE")) {
|
|
|
79 |
final AlterTable alter = new AlterTable(tableCompte);
|
|
|
80 |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
|
|
81 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
|
|
82 |
tableCompte.getSchema().updateVersion();
|
|
|
83 |
tableCompte.fetchFields();
|
|
|
84 |
}
|
|
|
85 |
|
180 |
ilm |
86 |
// Champ obsolete sur compte
|
|
|
87 |
SQLTable tableTitre = root.getTable("TITRE_PERSONNEL");
|
|
|
88 |
if (!tableTitre.contains("OBSOLETE")) {
|
|
|
89 |
final AlterTable alter = new AlterTable(tableTitre);
|
|
|
90 |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
|
|
91 |
tableTitre.getBase().getDataSource().execute(alter.asString());
|
|
|
92 |
tableTitre.getSchema().updateVersion();
|
|
|
93 |
tableTitre.fetchFields();
|
|
|
94 |
final UpdateBuilder updBuilder = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("OBSOLETE"), Boolean.TRUE);
|
|
|
95 |
updBuilder.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mlle"));
|
|
|
96 |
tableTitre.getBase().getDataSource().execute(updBuilder.asString());
|
|
|
97 |
final UpdateBuilder updBuilder2 = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("CODE"), "M.");
|
|
|
98 |
updBuilder2.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mr"));
|
|
|
99 |
|
|
|
100 |
tableTitre.getBase().getDataSource().execute(updBuilder2.asString());
|
|
|
101 |
|
|
|
102 |
}
|
|
|
103 |
|
142 |
ilm |
104 |
// Transaction du solde
|
|
|
105 |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
|
|
|
106 |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
|
|
|
107 |
createTable.addForeignColumn("CLIENT");
|
|
|
108 |
createTable.addDateAndTimeColumn("DATE");
|
|
|
109 |
createTable.addDecimalColumn("MONTANT", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
110 |
createTable.addForeignColumn("MODE_REGLEMENT");
|
|
|
111 |
createTable.addForeignColumn("MOUVEMENT");
|
|
|
112 |
try {
|
|
|
113 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
114 |
InstallationPanel.insertUndef(createTable);
|
|
|
115 |
root.refetchTable(COMPTE_CLIENT_TRANSACTION);
|
|
|
116 |
root.getSchema().updateVersion();
|
|
|
117 |
} catch (SQLException ex) {
|
|
|
118 |
throw new IllegalStateException("Erreur lors de la création de la table " + COMPTE_CLIENT_TRANSACTION, ex);
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
// Solde
|
|
|
122 |
final SQLTable tClient = root.getTable("CLIENT");
|
|
|
123 |
if (!tClient.contains("SOLDE_COMPTE")) {
|
|
|
124 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
125 |
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
126 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
127 |
tClient.getSchema().updateVersion();
|
|
|
128 |
tClient.fetchFields();
|
|
|
129 |
}
|
151 |
ilm |
130 |
if (!tClient.contains("DATE")) {
|
|
|
131 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
132 |
alterClient.addColumn("DATE", "date");
|
|
|
133 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
134 |
tClient.getSchema().updateVersion();
|
|
|
135 |
tClient.fetchFields();
|
|
|
136 |
}
|
144 |
ilm |
137 |
if (!tClient.contains("COMMENTAIRES")) {
|
|
|
138 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
139 |
alterClient.addVarCharColumn("COMMENTAIRES", 2048);
|
|
|
140 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
141 |
tClient.getSchema().updateVersion();
|
|
|
142 |
tClient.fetchFields();
|
|
|
143 |
}
|
142 |
ilm |
144 |
|
182 |
ilm |
145 |
if (!tClient.contains("ALERTE")) {
|
|
|
146 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
147 |
alterClient.addVarCharColumn("ALERTE", 4096);
|
|
|
148 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
149 |
tClient.getSchema().updateVersion();
|
|
|
150 |
tClient.fetchFields();
|
|
|
151 |
}
|
|
|
152 |
|
142 |
ilm |
153 |
final SQLTable tCompteClient = root.getTable("COMPTE_CLIENT_TRANSACTION");
|
|
|
154 |
if (!tCompteClient.contains("ID_MOUVEMENT")) {
|
|
|
155 |
final AlterTable alterClient = new AlterTable(tCompteClient);
|
|
|
156 |
alterClient.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
|
|
157 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
158 |
tClient.getSchema().updateVersion();
|
|
|
159 |
tClient.fetchFields();
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
final SQLTable tCmdClient = root.getTable("COMMANDE_CLIENT");
|
|
|
163 |
if (!tCmdClient.contains("DATE_LIVRAISON_PREV")) {
|
|
|
164 |
final AlterTable alterCmdClient = new AlterTable(tCmdClient);
|
|
|
165 |
alterCmdClient.addColumn("DATE_LIVRAISON_PREV", "date");
|
|
|
166 |
tCmdClient.getBase().getDataSource().execute(alterCmdClient.asString());
|
|
|
167 |
tCmdClient.getSchema().updateVersion();
|
|
|
168 |
tCmdClient.fetchFields();
|
|
|
169 |
}
|
|
|
170 |
|
149 |
ilm |
171 |
if (!tClient.contains("CONDITIONS_LIVRAISON")) {
|
|
|
172 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
173 |
alterClient.addVarCharColumn("CONDITIONS_LIVRAISON", 512);
|
|
|
174 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
175 |
tClient.getSchema().updateVersion();
|
|
|
176 |
tClient.fetchFields();
|
|
|
177 |
}
|
|
|
178 |
|
142 |
ilm |
179 |
{
|
|
|
180 |
// Ajout du champ SANS_VALEUR_ENCAISSEMENT pour gérer les anciens cheques sans le compte
|
|
|
181 |
// 511
|
|
|
182 |
List<String> tablesCheque = Arrays.asList("CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
|
|
|
183 |
|
|
|
184 |
for (String string : tablesCheque) {
|
|
|
185 |
|
|
|
186 |
final SQLTable table = root.getTable(string);
|
|
|
187 |
if (!table.contains("SANS_VALEUR_ENCAISSEMENT")) {
|
|
|
188 |
AlterTable alterElt = new AlterTable(table);
|
|
|
189 |
alterElt.addBooleanColumn("SANS_VALEUR_ENCAISSEMENT", Boolean.FALSE, false);
|
|
|
190 |
table.getBase().getDataSource().execute(alterElt.asString());
|
|
|
191 |
root.refetchTable(string);
|
|
|
192 |
root.getSchema().updateVersion();
|
|
|
193 |
UpdateBuilder upBuilder = new UpdateBuilder(table);
|
|
|
194 |
upBuilder.setObject("SANS_VALEUR_ENCAISSEMENT", Boolean.TRUE);
|
|
|
195 |
table.getBase().getDataSource().execute(upBuilder.asString());
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
SQLTable tableEncElt = root.getTable("ENCAISSER_MONTANT_ELEMENT");
|
|
|
200 |
if (tableEncElt.getField("DATE").getType().getType() == Types.TIMESTAMP) {
|
|
|
201 |
AlterTable t = new AlterTable(tableEncElt);
|
|
|
202 |
t.alterColumn("DATE", EnumSet.allOf(Properties.class), "date", null, Boolean.TRUE);
|
|
|
203 |
tableEncElt.getBase().getDataSource().execute(t.asString());
|
|
|
204 |
root.refetchTable(tableEncElt.getName());
|
|
|
205 |
root.getSchema().updateVersion();
|
|
|
206 |
}
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
// TVA Intra
|
|
|
210 |
final SQLTable tTva = root.getTable("TAXE");
|
|
|
211 |
if (!tTva.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
|
|
|
212 |
final AlterTable alterTaxe = new AlterTable(tTva);
|
|
|
213 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_COLLECTE_INTRA", root.getTable("COMPTE_PCE"));
|
|
|
214 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_DED_INTRA", root.getTable("COMPTE_PCE"));
|
|
|
215 |
tTva.getBase().getDataSource().execute(alterTaxe.asString());
|
|
|
216 |
tTva.getSchema().updateVersion();
|
|
|
217 |
tTva.fetchFields();
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
if (!root.contains("TAXE_COMPLEMENTAIRE")) {
|
|
|
221 |
final SQLCreateTable createTable = new SQLCreateTable(root, "TAXE_COMPLEMENTAIRE");
|
|
|
222 |
createTable.addForeignColumn("ID_COMPTE_PCE_PRODUITS", root.getTable("COMPTE_PCE"));
|
|
|
223 |
createTable.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
|
|
224 |
createTable.addDecimalColumn("POURCENT", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
225 |
createTable.addVarCharColumn("CODE", 25);
|
|
|
226 |
createTable.addVarCharColumn("NOM", 256);
|
|
|
227 |
|
|
|
228 |
try {
|
|
|
229 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
230 |
InstallationPanel.insertUndef(createTable);
|
|
|
231 |
root.refetchTable("TAXE_COMPLEMENTAIRE");
|
|
|
232 |
root.getSchema().updateVersion();
|
|
|
233 |
} catch (SQLException ex) {
|
|
|
234 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TAXE_COMPLEMENTAIRE", ex);
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
SQLTable tableArt = root.getTable("ARTICLE");
|
|
|
238 |
final AlterTable alterArt = new AlterTable(tableArt);
|
|
|
239 |
alterArt.addForeignColumn("ID_TAXE_COMPLEMENTAIRE", root.getTable("TAXE_COMPLEMENTAIRE"));
|
|
|
240 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
|
|
241 |
tableArt.getSchema().updateVersion();
|
|
|
242 |
tableArt.fetchFields();
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
// GED
|
|
|
246 |
if (!root.contains("ATTACHMENT")) {
|
|
|
247 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ATTACHMENT");
|
|
|
248 |
createTable.addVarCharColumn("SOURCE_TABLE", 128);
|
|
|
249 |
createTable.addIntegerColumn("SOURCE_ID", 0);
|
|
|
250 |
createTable.addVarCharColumn("NAME", 256);
|
|
|
251 |
createTable.addVarCharColumn("MIMETYPE", 256);
|
|
|
252 |
createTable.addVarCharColumn("FILENAME", 256);
|
|
|
253 |
createTable.addLongColumn("FILESIZE", 0L, false);
|
|
|
254 |
createTable.addVarCharColumn("STORAGE_PATH", 256);
|
|
|
255 |
createTable.addVarCharColumn("STORAGE_FILENAME", 256);
|
|
|
256 |
createTable.addVarCharColumn("DIRECTORY", 256);
|
|
|
257 |
createTable.addVarCharColumn("THUMBNAIL", 256);
|
|
|
258 |
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
|
|
|
259 |
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
|
|
|
260 |
createTable.addVarCharColumn("TAG", 128);
|
|
|
261 |
createTable.addIntegerColumn("VERSION", 0);
|
|
|
262 |
createTable.addVarCharColumn("HASH", 32);
|
180 |
ilm |
263 |
createTable.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false);
|
142 |
ilm |
264 |
try {
|
|
|
265 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
266 |
InstallationPanel.insertUndef(createTable);
|
|
|
267 |
root.refetchTable("ATTACHMENT");
|
|
|
268 |
root.getSchema().updateVersion();
|
|
|
269 |
} catch (SQLException ex) {
|
|
|
270 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ATTACHMENT", ex);
|
|
|
271 |
}
|
|
|
272 |
}
|
|
|
273 |
SQLTable tableAttachment = root.getTable("ATTACHMENT");
|
|
|
274 |
if (!tableAttachment.contains("DIRECTORY")) {
|
|
|
275 |
final AlterTable alter = new AlterTable(tableAttachment);
|
|
|
276 |
alter.addVarCharColumn("STORAGE_FILENAME", 256);
|
|
|
277 |
alter.addVarCharColumn("DIRECTORY", 256);
|
|
|
278 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
|
|
279 |
tableAttachment.getSchema().updateVersion();
|
|
|
280 |
tableAttachment.fetchFields();
|
|
|
281 |
}
|
149 |
ilm |
282 |
if (!tableAttachment.contains("ID_PARENT")) {
|
|
|
283 |
final AlterTable alter = new AlterTable(tableAttachment);
|
|
|
284 |
alter.addForeignColumn("ID_PARENT", tableAttachment);
|
|
|
285 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
|
|
286 |
tableAttachment.getSchema().updateVersion();
|
|
|
287 |
tableAttachment.fetchFields();
|
|
|
288 |
}
|
142 |
ilm |
289 |
|
|
|
290 |
if (!tableAttachment.contains("VERSION")) {
|
|
|
291 |
final AlterTable alter = new AlterTable(tableAttachment);
|
|
|
292 |
alter.addIntegerColumn("VERSION", 0);
|
|
|
293 |
alter.addVarCharColumn("HASH", 32);
|
|
|
294 |
alter.addVarCharColumn("INFOS", 8000);
|
|
|
295 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
|
|
296 |
tableAttachment.getSchema().updateVersion();
|
|
|
297 |
tableAttachment.fetchFields();
|
|
|
298 |
}
|
180 |
ilm |
299 |
if (!tableAttachment.contains("ENCRYPTED")) {
|
|
|
300 |
final AlterTable alter = new AlterTable(tableAttachment);
|
|
|
301 |
alter.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false);
|
|
|
302 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
|
|
303 |
tableAttachment.getSchema().updateVersion();
|
|
|
304 |
tableAttachment.fetchFields();
|
|
|
305 |
}
|
151 |
ilm |
306 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
142 |
ilm |
307 |
for (String string : gedTable) {
|
|
|
308 |
SQLTable tableGED = root.getTable(string);
|
|
|
309 |
if (!tableGED.contains("ATTACHMENTS")) {
|
|
|
310 |
final AlterTable alter = new AlterTable(tableGED);
|
|
|
311 |
alter.addIntegerColumn("ATTACHMENTS", 0);
|
|
|
312 |
tableGED.getBase().getDataSource().execute(alter.asString());
|
|
|
313 |
tableGED.getSchema().updateVersion();
|
|
|
314 |
tableGED.fetchFields();
|
|
|
315 |
}
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
// gestion articles en attente
|
|
|
319 |
{
|
|
|
320 |
|
|
|
321 |
// Vente
|
|
|
322 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
|
|
323 |
if (!tableBLElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
324 |
AlterTable t = new AlterTable(tableBLElt);
|
|
|
325 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
|
|
326 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
|
|
327 |
root.refetchTable(tableBLElt.getName());
|
|
|
328 |
root.getSchema().updateVersion();
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
332 |
if (!tableVFElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
|
|
333 |
AlterTable t = new AlterTable(tableVFElt);
|
|
|
334 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
|
|
335 |
tableVFElt.getBase().getDataSource().execute(t.asString());
|
|
|
336 |
root.refetchTable(tableVFElt.getName());
|
|
|
337 |
root.getSchema().updateVersion();
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
|
|
341 |
if (!tableCmdElt.contains("LIVRE")) {
|
|
|
342 |
AlterTable t = new AlterTable(tableCmdElt);
|
156 |
ilm |
343 |
// FIXME mis par défaut à true avant --> à fixer
|
142 |
ilm |
344 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
151 |
ilm |
345 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
142 |
ilm |
346 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
|
|
347 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
|
|
348 |
root.refetchTable(tableCmdElt.getName());
|
|
|
349 |
root.getSchema().updateVersion();
|
|
|
350 |
|
|
|
351 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
|
|
352 |
// tableCmdElt.getName()).quote()
|
|
|
353 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
|
|
354 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
156 |
ilm |
355 |
{
|
|
|
356 |
List<String> tablesWorkFlow = Arrays.asList("SAISIE_VENTE_FACTURE", "BON_DE_LIVRAISON");
|
|
|
357 |
for (String tableWorkFlow : tablesWorkFlow) {
|
|
|
358 |
|
|
|
359 |
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
|
|
|
360 |
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
|
|
|
361 |
SQLTable tableBL = root.getTable(tableWorkFlow);
|
|
|
362 |
// SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
|
|
|
363 |
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ,"
|
|
|
364 |
+ new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ," + new SQLName(root.getName(), tableBL.getName()).quote()
|
|
|
365 |
+ " b WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\"" + " AND b.\"ID\"=t.\"ID_" + tableWorkFlow
|
|
|
366 |
+ "\" 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.\""
|
|
|
367 |
+ (tableWorkFlow.startsWith("BON") ? "TOTAL_HT" : "T_HT") + "\")>=SUM(c.\"T_HT\") ) ";
|
|
|
368 |
List<Integer> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
|
|
369 |
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
|
|
|
370 |
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
|
|
371 |
build.setObject("LIVRE_FORCED", Boolean.TRUE);
|
|
|
372 |
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
|
|
|
373 |
build.setWhere(where);
|
|
|
374 |
|
|
|
375 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
|
|
376 |
}
|
|
|
377 |
}
|
142 |
ilm |
378 |
}
|
151 |
ilm |
379 |
// Fix bad default value
|
|
|
380 |
if (tableCmdElt.contains("LIVRE")) {
|
|
|
381 |
AlterTable t = new AlterTable(tableCmdElt);
|
|
|
382 |
t.alterColumnDefault("LIVRE", "false");
|
|
|
383 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
|
|
384 |
root.refetchTable(tableCmdElt.getName());
|
|
|
385 |
root.getSchema().updateVersion();
|
156 |
ilm |
386 |
UpdateBuilder upLivre = new UpdateBuilder(tableCmdElt);
|
|
|
387 |
upLivre.setObject("LIVRE", Boolean.FALSE);
|
|
|
388 |
upLivre.setWhere(new Where(tableCmdElt.getKey(), "=", 1));
|
|
|
389 |
|
|
|
390 |
tableCmdElt.getBase().getDataSource().execute(upLivre.asString());
|
151 |
ilm |
391 |
}
|
|
|
392 |
|
142 |
ilm |
393 |
// Achat
|
|
|
394 |
|
|
|
395 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
|
|
396 |
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
|
|
|
397 |
AlterTable t = new AlterTable(tableBRElt);
|
|
|
398 |
t.addForeignColumn("ID_COMMANDE_ELEMENT", root.getTable("COMMANDE_ELEMENT"));
|
|
|
399 |
tableBRElt.getBase().getDataSource().execute(t.asString());
|
|
|
400 |
root.refetchTable(tableBRElt.getName());
|
|
|
401 |
root.getSchema().updateVersion();
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
|
|
|
405 |
if (!tableCmdFElt.contains("RECU")) {
|
|
|
406 |
AlterTable t = new AlterTable(tableCmdFElt);
|
|
|
407 |
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
|
177 |
ilm |
408 |
t.addBooleanColumn("RECU", Boolean.FALSE, false);
|
142 |
ilm |
409 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
|
|
410 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
|
|
411 |
root.refetchTable(tableCmdFElt.getName());
|
|
|
412 |
root.getSchema().updateVersion();
|
|
|
413 |
|
|
|
414 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
|
|
415 |
// tableCmdElt.getName()).quote()
|
|
|
416 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
|
|
417 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
156 |
ilm |
418 |
{
|
|
|
419 |
SQLTable tableCmdCli = root.getTable("COMMANDE");
|
|
|
420 |
SQLTable tableTR = root.getTable("TR_COMMANDE");
|
|
|
421 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
|
|
422 |
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
|
|
|
423 |
+ " c ," + new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
|
|
|
424 |
+ " 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\")) ";
|
|
|
425 |
|
|
|
426 |
System.err.println(sel);
|
|
|
427 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
|
|
428 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
|
|
429 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
|
|
430 |
build.setObject("RECU_FORCED", Boolean.TRUE);
|
|
|
431 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
|
|
432 |
build.setWhere(where);
|
|
|
433 |
System.err.println(build.asString());
|
|
|
434 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
|
|
435 |
}
|
177 |
ilm |
436 |
} else {
|
|
|
437 |
// Fix bad default value
|
|
|
438 |
String defaultValue = tableCmdFElt.getField("RECU").getDefaultValue();
|
|
|
439 |
if (defaultValue != null && defaultValue.equals("true")) {
|
|
|
440 |
AlterTable t = new AlterTable(tableCmdFElt);
|
|
|
441 |
t.alterColumn("RECU", EnumSet.allOf(Properties.class), "boolean", "false", false);
|
|
|
442 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
|
|
443 |
root.refetchTable(tableCmdFElt.getName());
|
|
|
444 |
root.getSchema().updateVersion();
|
|
|
445 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
|
|
446 |
build.setObject("RECU", Boolean.FALSE);
|
|
|
447 |
|
|
|
448 |
Where w = Where.createRaw(tableCmdFElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdFElt.getField("QTE").getQuotedName() + "*"
|
|
|
449 |
+ tableCmdFElt.getField("QTE_UNITAIRE").getQuotedName() + ")", tableCmdFElt.getField("QTE_UNITAIRE"), tableCmdFElt.getField("QTE"), tableCmdFElt.getField("QTE_RECUE"));
|
|
|
450 |
build.setWhere(w.or(new Where(tableCmdFElt.getKey(), "=", 1)));
|
|
|
451 |
System.err.println(build.asString());
|
|
|
452 |
tableCmdFElt.getDBSystemRoot().getDataSource().execute(build.asString());
|
|
|
453 |
}
|
|
|
454 |
|
142 |
ilm |
455 |
}
|
|
|
456 |
|
156 |
ilm |
457 |
// Champ matière
|
|
|
458 |
SQLTable tableArt = root.getTable("ARTICLE");
|
|
|
459 |
if (!tableArt.contains("MATIERE")) {
|
|
|
460 |
final AlterTable alter = new AlterTable(tableArt);
|
|
|
461 |
alter.addVarCharColumn("MATIERE", 128);
|
|
|
462 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
|
|
463 |
tableArt.getSchema().updateVersion();
|
|
|
464 |
tableArt.fetchFields();
|
|
|
465 |
}
|
|
|
466 |
|
142 |
ilm |
467 |
}
|
144 |
ilm |
468 |
// ----------------------- 1.5.1
|
142 |
ilm |
469 |
|
144 |
ilm |
470 |
if (!root.contains("FABRICANT")) {
|
|
|
471 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FABRICANT");
|
|
|
472 |
createTableEtat.addVarCharColumn("NOM", 256);
|
|
|
473 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
474 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
475 |
root.refetchTable("FABRICANT");
|
|
|
476 |
root.getSchema().updateVersion();
|
|
|
477 |
|
|
|
478 |
final AlterTable alterA = new AlterTable(root.getTable("ARTICLE"));
|
|
|
479 |
alterA.addForeignColumn("ID_FABRICANT", root.findTable("FABRICANT"));
|
|
|
480 |
root.getBase().getDataSource().execute(alterA.asString());
|
|
|
481 |
root.refetchTable("ARTICLE");
|
|
|
482 |
root.getSchema().updateVersion();
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
// CIM
|
|
|
486 |
{
|
|
|
487 |
if (!root.contains("ETAT_DEMANDE_ACHAT_ELEMENT")) {
|
|
|
488 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
489 |
createTableEtat.addVarCharColumn("NOM", 256);
|
|
|
490 |
createTableEtat.addIntegerColumn("COLOR", null, true);
|
|
|
491 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
492 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
493 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
494 |
root.getSchema().updateVersion();
|
|
|
495 |
|
|
|
496 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_ACHAT_ELEMENT"));
|
|
|
497 |
rowVals.put("NOM", "En attente");
|
|
|
498 |
rowVals.insert();
|
|
|
499 |
rowVals.put("NOM", "Demande de prix");
|
|
|
500 |
rowVals.insert();
|
|
|
501 |
rowVals.put("NOM", "En commande");
|
|
|
502 |
rowVals.insert();
|
|
|
503 |
rowVals.put("NOM", "Réceptionnée");
|
|
|
504 |
rowVals.insert();
|
|
|
505 |
rowVals.put("NOM", "Réception partielle");
|
|
|
506 |
rowVals.insert();
|
|
|
507 |
rowVals.put("NOM", "A relancer");
|
|
|
508 |
rowVals.insert();
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
if (!root.contains("DEMANDE_ACHAT_ELEMENT")) {
|
|
|
512 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_ACHAT_ELEMENT");
|
|
|
513 |
createTableDmd.addVarCharColumn("CODE", 256);
|
|
|
514 |
createTableDmd.addVarCharColumn("NOM", 256);
|
|
|
515 |
createTableDmd.addIntegerColumn("QTE", 1);
|
|
|
516 |
createTableDmd.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
|
|
517 |
|
|
|
518 |
createTableDmd.addVarCharColumn("REPERE", 256);
|
|
|
519 |
createTableDmd.addVarCharColumn("REFERENCE", 256);
|
|
|
520 |
createTableDmd.addForeignColumn("FABRICANT");
|
|
|
521 |
createTableDmd.addColumn("DATE", "date");
|
|
|
522 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
523 |
createTableDmd.addForeignColumn("UNITE_VENTE");
|
|
|
524 |
createTableDmd.addForeignColumn("ARTICLE");
|
|
|
525 |
createTableDmd.addForeignColumn("FAMILLE_ARTICLE");
|
|
|
526 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
|
|
527 |
createTableDmd.addBooleanColumn("EN_STOCK", Boolean.FALSE, false);
|
|
|
528 |
|
|
|
529 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
|
|
530 |
InstallationPanel.insertUndef(createTableDmd);
|
|
|
531 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
532 |
root.getSchema().updateVersion();
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
if (!root.contains("ETAT_DEMANDE_PRIX")) {
|
|
|
536 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_PRIX");
|
|
|
537 |
createTableEtat.addVarCharColumn("NOM", 256);
|
|
|
538 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
539 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
540 |
root.refetchTable("ETAT_DEMANDE_PRIX");
|
|
|
541 |
root.getSchema().updateVersion();
|
|
|
542 |
|
|
|
543 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_PRIX"));
|
|
|
544 |
rowVals.put("NOM", "En attente");
|
|
|
545 |
rowVals.insert();
|
|
|
546 |
rowVals.put("NOM", "Refusée");
|
|
|
547 |
rowVals.insert();
|
|
|
548 |
rowVals.put("NOM", "Acceptée");
|
|
|
549 |
rowVals.insert();
|
|
|
550 |
rowVals.put("NOM", "En cours");
|
|
|
551 |
rowVals.insert();
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
if (!root.contains("DEMANDE_PRIX")) {
|
|
|
555 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_PRIX");
|
|
|
556 |
createTableDmd.addVarCharColumn("NUMERO", 256);
|
|
|
557 |
createTableDmd.addVarCharColumn("OBJET", 1024);
|
|
|
558 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
|
|
559 |
// createTableDemande.addForeignColumn("ID_AFFAIRE",
|
|
|
560 |
// ctxt.getRoot().findTable("AFFAIRE"));
|
|
|
561 |
createTableDmd.addColumn("DATE", "date");
|
|
|
562 |
// createTableDemandeM.addColumn("DATE_DISPOSITION", "date");
|
|
|
563 |
createTableDmd.addColumn("DATE_BUTOIRE", "date");
|
|
|
564 |
createTableDmd.addColumn("T_HT", "bigint DEFAULT 0");
|
|
|
565 |
createTableDmd.addColumn("T_TVA", "bigint DEFAULT 0");
|
|
|
566 |
createTableDmd.addColumn("T_TTC", "bigint DEFAULT 0");
|
|
|
567 |
// createTableDemandeM.addForeignColumn("ID_TAXE", findTableTaxe);
|
|
|
568 |
|
|
|
569 |
createTableDmd.addForeignColumn("COMMERCIAL");
|
|
|
570 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_PRIX");
|
|
|
571 |
// createTableDemandeM.addForeignColumn("ID_ADRESSE",
|
|
|
572 |
// ctxt.getRoot().findTable("ADRESSE"));
|
|
|
573 |
createTableDmd.addVarCharColumn("INFOS", 1024);
|
|
|
574 |
|
|
|
575 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
|
|
576 |
InstallationPanel.insertUndef(createTableDmd);
|
|
|
577 |
root.refetchTable("DEMANDE_PRIX");
|
|
|
578 |
root.getSchema().updateVersion();
|
|
|
579 |
|
|
|
580 |
final SQLCreateTable createTableDemandeMElt = new SQLCreateTable(root, "DEMANDE_PRIX_ELEMENT");
|
|
|
581 |
createTableDemandeMElt.addVarCharColumn("NOM", 512);
|
|
|
582 |
createTableDemandeMElt.addForeignColumn("DEMANDE_PRIX");
|
|
|
583 |
createTableDemandeMElt.addForeignColumn("ID_TAXE", root.getTable("TAXE").getSQLName(), root.getTable("TAXE").getKey().getName(), "2");
|
|
|
584 |
|
|
|
585 |
createTableDemandeMElt.addIntegerColumn("QTE", 0);
|
|
|
586 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
|
|
587 |
createTableDemandeMElt.addColumn("PRIX_METRIQUE_VT_3", "bigint DEFAULT 0");
|
|
|
588 |
|
|
|
589 |
createTableDemandeMElt.addDecimalColumn("PA_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
590 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_2", 16, 6, BigDecimal.ZERO, false);
|
|
|
591 |
|
|
|
592 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_1", 16, 6, BigDecimal.ZERO, false);
|
|
|
593 |
createTableDemandeMElt.addDecimalColumn("T_PA_TTC", 16, 2, BigDecimal.ZERO, false);
|
|
|
594 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
|
|
595 |
createTableDemandeMElt.addDecimalColumn("T_PA_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
596 |
createTableDemandeMElt.addColumn("T_POIDS", "real DEFAULT 0");
|
|
|
597 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
|
|
598 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_3", 16, 6, BigDecimal.ZERO, false);
|
|
|
599 |
|
|
|
600 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
|
|
601 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
|
|
602 |
createTableDemandeMElt.addDecimalColumn("T_PV_TTC", 16, 2, BigDecimal.ZERO, false);
|
|
|
603 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_1", root.findTable("METRIQUE"));
|
|
|
604 |
SQLTable findTable = root.findTable("MODE_VENTE_ARTICLE");
|
|
|
605 |
createTableDemandeMElt.addForeignColumn("ID_MODE_VENTE_ARTICLE", findTable.getSQLName(), findTable.getKey().getName(), String.valueOf(ReferenceArticleSQLElement.A_LA_PIECE));
|
|
|
606 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_3", root.findTable("METRIQUE"));
|
|
|
607 |
createTableDemandeMElt.addForeignColumn("ID_STYLE", root.findTable("STYLE"));
|
|
|
608 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_2", root.findTable("METRIQUE"));
|
|
|
609 |
createTableDemandeMElt.addIntegerColumn("QTE_ACHAT", 1);
|
|
|
610 |
createTableDemandeMElt.addForeignColumn("ID_DEVISE", root.findTable("DEVISE"));
|
|
|
611 |
createTableDemandeMElt.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
|
|
612 |
|
|
|
613 |
createTableDemandeMElt.addVarCharColumn("CODE", 256);
|
|
|
614 |
createTableDemandeMElt.addColumn("SERVICE", "boolean DEFAULT false");
|
|
|
615 |
|
|
|
616 |
createTableDemandeMElt.addDecimalColumn("T_PV_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
617 |
createTableDemandeMElt.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
618 |
createTableDemandeMElt.addColumn("POIDS", "real DEFAULT 0");
|
|
|
619 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE", 16, 6, BigDecimal.ZERO, false);
|
|
|
620 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE_T", 16, 6, BigDecimal.ZERO, false);
|
|
|
621 |
|
|
|
622 |
createTableDemandeMElt.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE"));
|
|
|
623 |
createTableDemandeMElt.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
|
|
624 |
createTableDemandeMElt.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE"));
|
|
|
625 |
createTableDemandeMElt.addVarCharColumn("DESCRIPTIF", 2048);
|
|
|
626 |
createTableDemandeMElt.addIntegerColumn("NIVEAU", 1);
|
156 |
ilm |
627 |
if (root.contains("DEPOT_STOCK")) {
|
|
|
628 |
createTableDemandeMElt.addForeignColumn("DEPOT_STOCK");
|
|
|
629 |
}
|
144 |
ilm |
630 |
createTableDemandeMElt.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
|
|
|
631 |
createTableDemandeMElt.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
|
|
632 |
createTableDemandeMElt.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
|
|
633 |
createTableDemandeMElt.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
|
|
634 |
|
|
|
635 |
root.getBase().getDataSource().execute(createTableDemandeMElt.asString());
|
|
|
636 |
InstallationPanel.insertUndef(createTableDemandeMElt);
|
|
|
637 |
root.refetchTable("DEMANDE_PRIX_ELEMENT");
|
|
|
638 |
root.getSchema().updateVersion();
|
|
|
639 |
|
|
|
640 |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO"));
|
|
|
641 |
alterNumero.addVarCharColumn("DMD_PRIX_FORMAT", 128);
|
|
|
642 |
alterNumero.addIntegerColumn("DMD_PRIX_START", 1);
|
|
|
643 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
|
|
644 |
root.refetchTable("NUMEROTATION_AUTO");
|
|
|
645 |
root.getSchema().updateVersion();
|
|
|
646 |
|
|
|
647 |
final AlterTable alterCmd = new AlterTable(root.getTable("COMMANDE_ELEMENT"));
|
|
|
648 |
alterCmd.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
|
|
649 |
root.getBase().getDataSource().execute(alterCmd.asString());
|
|
|
650 |
root.refetchTable("COMMANDE_ELEMENT");
|
|
|
651 |
root.getSchema().updateVersion();
|
|
|
652 |
|
|
|
653 |
final AlterTable alterF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"));
|
|
|
654 |
alterF.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
|
|
655 |
root.getBase().getDataSource().execute(alterF.asString());
|
|
|
656 |
root.refetchTable("FACTURE_FOURNISSEUR_ELEMENT");
|
|
|
657 |
root.getSchema().updateVersion();
|
|
|
658 |
|
|
|
659 |
final AlterTable alterB = new AlterTable(root.getTable("BON_RECEPTION_ELEMENT"));
|
|
|
660 |
alterB.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
|
|
661 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
662 |
root.refetchTable("BON_RECEPTION_ELEMENT");
|
|
|
663 |
root.getSchema().updateVersion();
|
|
|
664 |
}
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
SQLTable tableDmdAChat = root.findTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
668 |
if (!tableDmdAChat.contains("ID_FAMILLE_ARTICLE")) {
|
|
|
669 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
670 |
alterB.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
|
|
671 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
672 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
673 |
root.getSchema().updateVersion();
|
|
|
674 |
}
|
|
|
675 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
|
|
676 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
677 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
|
|
678 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
679 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
680 |
root.getSchema().updateVersion();
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
|
|
684 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
685 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
|
|
686 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
687 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
688 |
root.getSchema().updateVersion();
|
|
|
689 |
}
|
149 |
ilm |
690 |
if (!tableDmdAChat.contains("REPRISE")) {
|
|
|
691 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
692 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
|
|
693 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
694 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
695 |
root.getSchema().updateVersion();
|
|
|
696 |
}
|
|
|
697 |
|
156 |
ilm |
698 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
|
|
699 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
700 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
|
|
701 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
702 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
703 |
root.getSchema().updateVersion();
|
|
|
704 |
}
|
|
|
705 |
|
|
|
706 |
if (!tableDmdAChat.contains("REPRISE")) {
|
|
|
707 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
708 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
|
|
709 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
710 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
711 |
root.getSchema().updateVersion();
|
|
|
712 |
}
|
|
|
713 |
|
149 |
ilm |
714 |
if (!tableDmdAChat.contains("IMPORT")) {
|
|
|
715 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
716 |
alterB.addBooleanColumn("IMPORT", Boolean.FALSE, false);
|
|
|
717 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
718 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
719 |
root.getSchema().updateVersion();
|
|
|
720 |
}
|
|
|
721 |
|
156 |
ilm |
722 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
|
|
723 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
724 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
|
|
725 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
726 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
727 |
root.getSchema().updateVersion();
|
|
|
728 |
}
|
144 |
ilm |
729 |
if (!tableDmdAChat.contains("QTE_RECUE")) {
|
|
|
730 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
731 |
alterB.addIntegerColumn("QTE_RECUE", 0);
|
|
|
732 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
733 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
734 |
root.getSchema().updateVersion();
|
|
|
735 |
}
|
156 |
ilm |
736 |
|
144 |
ilm |
737 |
if (!tableDmdAChat.contains("REPERE_SOURCE")) {
|
|
|
738 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
739 |
alterB.addVarCharColumn("REPERE_SOURCE", 128);
|
|
|
740 |
alterB.addVarCharColumn("CODE_SOURCE", 128);
|
|
|
741 |
alterB.addVarCharColumn("NOM_SOURCE", 128);
|
|
|
742 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
743 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
744 |
root.getSchema().updateVersion();
|
|
|
745 |
}
|
|
|
746 |
SQLTable tableEtatDmdAChat = root.findTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
747 |
if (!tableEtatDmdAChat.contains("COLOR")) {
|
|
|
748 |
final AlterTable alterB = new AlterTable(tableEtatDmdAChat);
|
|
|
749 |
alterB.addIntegerColumn("COLOR", null, true);
|
|
|
750 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
751 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
|
|
752 |
root.getSchema().updateVersion();
|
|
|
753 |
}
|
|
|
754 |
|
|
|
755 |
if (!tableDmdAChat.contains("T_HT")) {
|
|
|
756 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
|
|
757 |
alterB.addVarCharColumn("NUMERO_SE", 128);
|
|
|
758 |
alterB.addVarCharColumn("DESCRIPTIF_SE", 512);
|
|
|
759 |
alterB.addVarCharColumn("REVISION", 48);
|
|
|
760 |
alterB.addDecimalColumn("P_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
761 |
alterB.addDecimalColumn("T_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
762 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
763 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
|
|
764 |
root.getSchema().updateVersion();
|
|
|
765 |
}
|
|
|
766 |
|
|
|
767 |
if (!root.contains("FACTURATION_COMMANDE_CLIENT")) {
|
|
|
768 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FACTURATION_COMMANDE_CLIENT");
|
|
|
769 |
createTableEtat.addVarCharColumn("NOM", 256);
|
|
|
770 |
createTableEtat.addIntegerColumn("TYPE_FACTURE", TypeFactureCommandeClient.GLOBALE.getId());
|
|
|
771 |
createTableEtat.addBooleanColumn("CHOICE", Boolean.FALSE, false);
|
|
|
772 |
createTableEtat.addForeignColumn("TYPE_REGLEMENT");
|
|
|
773 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
|
|
774 |
createTableEtat.addForeignColumn("SAISIE_VENTE_FACTURE");
|
|
|
775 |
createTableEtat.addForeignColumn("MODELE");
|
|
|
776 |
createTableEtat.addIntegerColumn("AJOURS", 0);
|
|
|
777 |
createTableEtat.addDecimalColumn("MONTANT", 16, 8, BigDecimal.ZERO, false);
|
|
|
778 |
createTableEtat.addDecimalColumn("POURCENT", 16, 8, BigDecimal.ZERO, false);
|
|
|
779 |
createTableEtat.addBooleanColumn("COMPTANT", Boolean.FALSE, false);
|
|
|
780 |
createTableEtat.addColumn("DATE_PREVISIONNELLE", "date");
|
|
|
781 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
782 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
783 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
|
|
784 |
root.getSchema().updateVersion();
|
|
|
785 |
}
|
|
|
786 |
SQLTable tableFacturationCmd = root.getTable("FACTURATION_COMMANDE_CLIENT");
|
|
|
787 |
if (!tableFacturationCmd.contains("FIN_MOIS")) {
|
|
|
788 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
|
|
789 |
alt.addBooleanColumn("FIN_MOIS", Boolean.FALSE, false);
|
|
|
790 |
root.getBase().getDataSource().execute(alt.asString());
|
|
|
791 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
|
|
792 |
root.getSchema().updateVersion();
|
|
|
793 |
}
|
|
|
794 |
if (!tableFacturationCmd.contains("LENJOUR")) {
|
|
|
795 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
|
|
796 |
alt.addIntegerColumn("LENJOUR", 0);
|
|
|
797 |
root.getBase().getDataSource().execute(alt.asString());
|
|
|
798 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
|
|
799 |
root.getSchema().updateVersion();
|
|
|
800 |
}
|
156 |
ilm |
801 |
|
144 |
ilm |
802 |
if (!root.contains("CHIFFRAGE_COMMANDE_CLIENT")) {
|
|
|
803 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "CHIFFRAGE_COMMANDE_CLIENT");
|
|
|
804 |
createTableEtat.addVarCharColumn("NOM", 256);
|
|
|
805 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
|
|
806 |
createTableEtat.addForeignColumn("UNITE_VENTE");
|
|
|
807 |
createTableEtat.addForeignColumn("FAMILLE_ARTICLE");
|
|
|
808 |
createTableEtat.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, false);
|
|
|
809 |
createTableEtat.addDecimalColumn("PA_HT", 16, 8, BigDecimal.ZERO, false);
|
|
|
810 |
createTableEtat.addDecimalColumn("PV_HT", 16, 8, BigDecimal.ZERO, false);
|
|
|
811 |
createTableEtat.addDecimalColumn("T_PV_HT", 16, 8, BigDecimal.ZERO, false);
|
|
|
812 |
createTableEtat.addDecimalColumn("T_PA_HT", 16, 8, BigDecimal.ZERO, false);
|
|
|
813 |
createTableEtat.addDecimalColumn("MARGE", 16, 8, BigDecimal.ZERO, false);
|
|
|
814 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
815 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
816 |
root.refetchTable("CHIFFRAGE_COMMANDE_CLIENT");
|
|
|
817 |
root.getSchema().updateVersion();
|
|
|
818 |
}
|
|
|
819 |
|
|
|
820 |
// VARIABLE_SALARIE
|
|
|
821 |
SQLTable tableVarSal = root.findTable("VARIABLE_SALARIE");
|
|
|
822 |
if (!tableVarSal.contains("HEURE_ABS_DEFAULT_VAL")) {
|
|
|
823 |
|
|
|
824 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
|
|
825 |
|
|
|
826 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
|
|
827 |
|
|
|
828 |
String field = sqlField.getName();
|
|
|
829 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
182 |
ilm |
830 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.equalsIgnoreCase("HEURE_TRAV") && !tableVarSal.contains(field + "_DEFAULT_VAL")) {
|
144 |
ilm |
831 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
|
|
832 |
}
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
836 |
root.refetchTable("VARIABLE_SALARIE");
|
|
|
837 |
root.getSchema().updateVersion();
|
|
|
838 |
}
|
|
|
839 |
|
|
|
840 |
SQLTable tableFpaye = root.findTable("FICHE_PAYE");
|
|
|
841 |
if (!tableFpaye.contains("TAXE_CM_SAL")) {
|
|
|
842 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
|
|
843 |
alterB.addDecimalColumn("SAL_BASE_BRUT", 16, 2, BigDecimal.ZERO, false);
|
|
|
844 |
alterB.addDecimalColumn("TAXE_CM_SAL", 16, 2, BigDecimal.ZERO, false);
|
|
|
845 |
alterB.addDecimalColumn("TAXE_CM_PAT", 16, 2, BigDecimal.ZERO, false);
|
|
|
846 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE", 16, 2, BigDecimal.ZERO, false);
|
|
|
847 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE", 16, 2, BigDecimal.ZERO, false);
|
|
|
848 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
849 |
root.refetchTable("FICHE_PAYE");
|
|
|
850 |
root.getSchema().updateVersion();
|
|
|
851 |
|
|
|
852 |
SQLTable tableElementPaye = root.getTable("FICHE_PAYE_ELEMENT");
|
|
|
853 |
|
|
|
854 |
AlterTable tEltPaye = new AlterTable(tableElementPaye);
|
|
|
855 |
tEltPaye.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
|
|
|
856 |
tableElementPaye.getBase().getDataSource().execute(tEltPaye.asString());
|
|
|
857 |
tableElementPaye.getSchema().updateVersion();
|
|
|
858 |
tableElementPaye.fetchFields();
|
|
|
859 |
|
|
|
860 |
}
|
|
|
861 |
|
177 |
ilm |
862 |
if (!tableFpaye.contains("CSG_REDUITE")) {
|
|
|
863 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
|
|
864 |
alterB.addDecimalColumn("CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
|
|
|
865 |
alterB.addDecimalColumn("SAL_BRUT_CSG", 16, 2, BigDecimal.ZERO, false);
|
|
|
866 |
alterB.addDecimalColumn("SAL_BRUT_CSG_REDUITE", 16, 2, BigDecimal.ZERO, false);
|
|
|
867 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
868 |
root.refetchTable("FICHE_PAYE");
|
|
|
869 |
root.getSchema().updateVersion();
|
|
|
870 |
}
|
|
|
871 |
|
182 |
ilm |
872 |
if (!tableFpaye.contains("PERTE_TPT")) {
|
|
|
873 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
|
|
874 |
alterB.addDecimalColumn("PERTE_TPT", 16, 2, BigDecimal.ZERO, false);
|
|
|
875 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
876 |
root.refetchTable("FICHE_PAYE");
|
|
|
877 |
root.getSchema().updateVersion();
|
|
|
878 |
}
|
|
|
879 |
|
144 |
ilm |
880 |
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
|
|
|
881 |
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
|
|
|
882 |
final AlterTable alterB = new AlterTable(tableCpaye);
|
|
|
883 |
alterB.addDecimalColumn("TAXE_CM_SAL_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
884 |
alterB.addDecimalColumn("TAXE_CM_PAT_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
885 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
886 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
887 |
alterB.addDecimalColumn("SAL_BASE_BRUT_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
888 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
889 |
root.refetchTable("CUMULS_PAYE");
|
|
|
890 |
root.getSchema().updateVersion();
|
|
|
891 |
}
|
|
|
892 |
|
|
|
893 |
SQLTable tableEtatCivil = root.findTable("ETAT_CIVIL");
|
|
|
894 |
if (!tableEtatCivil.contains("NATIONNALITE")) {
|
|
|
895 |
final AlterTable alterB = new AlterTable(tableEtatCivil);
|
|
|
896 |
alterB.addVarCharColumn("NATIONNALITE", 256);
|
|
|
897 |
alterB.addVarCharColumn("CNPS", 256);
|
|
|
898 |
alterB.addVarCharColumn("TYPE_PIECE_IDENTITE", 256);
|
|
|
899 |
alterB.addVarCharColumn("NUMERO_PIECE", 256);
|
|
|
900 |
alterB.addVarCharColumn("NOM_PERE", 256);
|
|
|
901 |
alterB.addVarCharColumn("NOM_MERE", 256);
|
|
|
902 |
alterB.addVarCharColumn("CONJOINT_NOM", 256);
|
|
|
903 |
alterB.addColumn("CONJOINT_DATE_NAISSANCE", "date");
|
|
|
904 |
alterB.addVarCharColumn("CONJOINT_LIEU_NAISSANCE", 256);
|
|
|
905 |
alterB.addVarCharColumn("CONJOINT_PROFESSION", 256);
|
|
|
906 |
alterB.addColumn("DATE_DEBUT_PIECE", "date");
|
|
|
907 |
alterB.addColumn("DATE_FIN_PIECE", "date");
|
|
|
908 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
909 |
root.refetchTable("ETAT_CIVIL");
|
|
|
910 |
root.getSchema().updateVersion();
|
|
|
911 |
}
|
|
|
912 |
|
|
|
913 |
// ARTICLE CLIENT
|
|
|
914 |
if (!root.contains("ARTICLE_CODE_CLIENT")) {
|
|
|
915 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ARTICLE_CODE_CLIENT");
|
|
|
916 |
createTableEtat.addVarCharColumn("NOM", 512);
|
|
|
917 |
createTableEtat.addVarCharColumn("CODE", 512);
|
|
|
918 |
createTableEtat.addForeignColumn("CLIENT");
|
|
|
919 |
createTableEtat.addForeignColumn("ARTICLE");
|
|
|
920 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
|
|
921 |
InstallationPanel.insertUndef(createTableEtat);
|
|
|
922 |
root.refetchTable("ARTICLE_CODE_CLIENT");
|
|
|
923 |
root.getSchema().updateVersion();
|
|
|
924 |
}
|
|
|
925 |
SQLTable tableClient = root.getTable("CLIENT");
|
|
|
926 |
if (!tableClient.contains("CODE_FOURNISSEUR")) {
|
|
|
927 |
final AlterTable alter = new AlterTable(tableClient);
|
|
|
928 |
alter.addVarCharColumn("CODE_FOURNISSEUR", 256);
|
|
|
929 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
|
|
930 |
tableCompte.getSchema().updateVersion();
|
|
|
931 |
tableCompte.fetchFields();
|
|
|
932 |
}
|
|
|
933 |
SQLTable tableArticle = root.getTable("ARTICLE");
|
|
|
934 |
if (!tableArticle.contains("TARE")) {
|
|
|
935 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
|
|
936 |
alterArticle.addDecimalColumn("TARE", 16, 8, BigDecimal.ZERO, true);
|
|
|
937 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
|
|
938 |
tableArticle.getSchema().updateVersion();
|
|
|
939 |
tableArticle.fetchFields();
|
|
|
940 |
}
|
|
|
941 |
if (!tableArticle.contains("IFCO")) {
|
|
|
942 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
|
|
943 |
alterArticle.addIntegerColumn("IFCO", 0);
|
|
|
944 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
|
|
945 |
tableArticle.getSchema().updateVersion();
|
|
|
946 |
tableArticle.fetchFields();
|
|
|
947 |
}
|
177 |
ilm |
948 |
if (!tableArticle.contains("DLC")) {
|
|
|
949 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
|
|
950 |
alterArticle.addColumn("DLC", "date");
|
|
|
951 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
|
|
952 |
tableArticle.getSchema().updateVersion();
|
|
|
953 |
tableArticle.fetchFields();
|
|
|
954 |
}
|
182 |
ilm |
955 |
if (!tableArticle.contains("OPTION")) {
|
|
|
956 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
|
|
957 |
alterArticle.addBooleanColumn("OPTION", Boolean.FALSE, false);
|
|
|
958 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
|
|
959 |
tableArticle.getSchema().updateVersion();
|
|
|
960 |
tableArticle.fetchFields();
|
|
|
961 |
}
|
|
|
962 |
|
144 |
ilm |
963 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
|
|
964 |
if (!tableFournisseur.contains("NUMERO_TVA")) {
|
|
|
965 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
|
|
966 |
alter.addVarCharColumn("NUMERO_TVA", 128);
|
|
|
967 |
alter.addVarCharColumn("SIRET", 128);
|
|
|
968 |
tableFournisseur.getBase().getDataSource().execute(alter.asString());
|
|
|
969 |
tableFournisseur.getSchema().updateVersion();
|
|
|
970 |
tableFournisseur.fetchFields();
|
|
|
971 |
}
|
182 |
ilm |
972 |
if (!tableFournisseur.contains("CONDITIONS_PORT")) {
|
|
|
973 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
|
|
974 |
alter.addVarCharColumn("CONDITIONS_PORT", 128);
|
|
|
975 |
tableFournisseur.getBase().getDataSource().execute(alter.asString());
|
|
|
976 |
tableFournisseur.getSchema().updateVersion();
|
|
|
977 |
tableFournisseur.fetchFields();
|
|
|
978 |
}
|
144 |
ilm |
979 |
|
|
|
980 |
// POS
|
149 |
ilm |
981 |
final SQLTable caisseT = root.getTable("CAISSE");
|
|
|
982 |
final String registerLogTableName = "CAISSE_JOURNAL";
|
|
|
983 |
if (!root.contains(registerLogTableName)) {
|
144 |
ilm |
984 |
final SQLTable receiptT = root.getTable("TICKET_CAISSE");
|
|
|
985 |
final SQLTable userT = root.findTable("USER_COMMON", true);
|
|
|
986 |
|
149 |
ilm |
987 |
final SQLCreateTable createLogT = new SQLCreateTable(caisseT.getDBRoot(), registerLogTableName);
|
144 |
ilm |
988 |
createLogT.setCreateOrder(false);
|
|
|
989 |
AddMDFields.addFields(createLogT, userT);
|
|
|
990 |
createLogT.addForeignColumn("ID_CAISSE", caisseT);
|
|
|
991 |
createLogT.addDateAndTimeColumn("DATE");
|
|
|
992 |
createLogT.addForeignColumn("ID_USER", userT);
|
|
|
993 |
createLogT.addVarCharColumn("EVT", 128);
|
|
|
994 |
createLogT.addVarCharColumn("CREATOR", 128);
|
|
|
995 |
createLogT.addVarCharColumn("CREATOR_VERSION", 128);
|
|
|
996 |
createLogT.addUniqueConstraint("logSequence", Arrays.asList("ID_CAISSE", "DATE"));
|
|
|
997 |
|
|
|
998 |
final SQLCreateTable createClotureT = new SQLCreateTable(caisseT.getDBRoot(), "CAISSE_CLOTURE");
|
|
|
999 |
createClotureT.setCreateOrder(false);
|
|
|
1000 |
AddMDFields.addFields(createClotureT, userT);
|
|
|
1001 |
createClotureT.addForeignColumn("ID_ENTREE_JOURNAL", createLogT);
|
|
|
1002 |
createClotureT.addVarCharColumn("PERIODE", 32);
|
|
|
1003 |
final String dateType = createClotureT.getSyntax().getTypeNames(java.sql.Date.class).iterator().next();
|
|
|
1004 |
createClotureT.addColumn("DEBUT", dateType, null, false);
|
|
|
1005 |
createClotureT.addColumn("FIN", dateType, null, false);
|
149 |
ilm |
1006 |
createClotureT.addDecimalColumn("TOTAL_TTC", 16, 6, BigDecimal.ZERO, false);
|
144 |
ilm |
1007 |
// don't use foreign keys, we actually want redundant info so that we can check
|
|
|
1008 |
// coherence
|
|
|
1009 |
// nullable to allow for days without any sales
|
|
|
1010 |
createClotureT.addVarCharColumn("PREMIER_TICKET", 64, false, "null", true);
|
|
|
1011 |
createClotureT.addVarCharColumn("PREMIER_TICKET_HASH", 128, false, "null", true);
|
|
|
1012 |
createClotureT.addVarCharColumn("DERNIER_TICKET", 64, false, "null", true);
|
|
|
1013 |
createClotureT.addVarCharColumn("DERNIER_TICKET_HASH", 128, false, "null", true);
|
|
|
1014 |
createClotureT.addUniqueConstraint("uniqueness", Arrays.asList("ID_ENTREE_JOURNAL"));
|
|
|
1015 |
|
|
|
1016 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
|
|
1017 |
alterRegister.addForeignColumn("ID_DERNIERE_ENTREE_JOURNAL", createLogT);
|
|
|
1018 |
alterRegister.addForeignColumn("ID_DERNIERE_CLOTURE", createClotureT);
|
|
|
1019 |
|
|
|
1020 |
final AlterTable alterReceipt = new AlterTable(receiptT);
|
|
|
1021 |
alterReceipt.addVarCharColumn("FILE_HASH", 128, false, "null", true);
|
|
|
1022 |
alterReceipt.addVarCharColumn("FILE_HASH_PREVIOUS", 128, false, "null", true);
|
|
|
1023 |
alterReceipt.addUniqueConstraint("uniqueNumber", new UniqueConstraintCreatorHelper(Arrays.asList("NUMERO"), TicketCaisseSQLElement.UNARCHIVED_WHERE) {
|
|
|
1024 |
@Override
|
|
|
1025 |
public Object getObject(SQLSyntax s) {
|
|
|
1026 |
if (s.getSystem() == SQLSystem.H2) {
|
|
|
1027 |
return TicketCaisseSQLElement.UniqueNumber_PartialUniqueTrigger.class;
|
|
|
1028 |
} else {
|
|
|
1029 |
return super.getObject(s);
|
|
|
1030 |
}
|
|
|
1031 |
}
|
|
|
1032 |
});
|
|
|
1033 |
alterReceipt.addUniqueConstraint("uniqueDate", new UniqueConstraintCreatorHelper(Arrays.asList("ID_CAISSE", "DATE"), TicketCaisseSQLElement.DATE_WHERE) {
|
|
|
1034 |
@Override
|
|
|
1035 |
public Object getObject(SQLSyntax s) {
|
|
|
1036 |
if (s.getSystem() == SQLSystem.H2) {
|
|
|
1037 |
return TicketCaisseSQLElement.UniqueDate_PartialUniqueTrigger.class;
|
|
|
1038 |
} else {
|
|
|
1039 |
return super.getObject(s);
|
|
|
1040 |
}
|
|
|
1041 |
}
|
|
|
1042 |
});
|
|
|
1043 |
|
|
|
1044 |
root.createTables(createLogT, createClotureT);
|
|
|
1045 |
root.getDBSystemRoot().getDataSource().execute(alterRegister.asString());
|
|
|
1046 |
root.getDBSystemRoot().getDataSource().execute(alterReceipt.asString());
|
|
|
1047 |
caisseT.getSchema().updateVersion();
|
|
|
1048 |
alterRegister.getTable().fetchFields();
|
|
|
1049 |
alterReceipt.getTable().fetchFields();
|
|
|
1050 |
}
|
|
|
1051 |
|
149 |
ilm |
1052 |
SQLTable tableArt = root.getTable("ARTICLE");
|
|
|
1053 |
if (!tableArt.contains("MASQUE_CAISSE")) {
|
|
|
1054 |
final AlterTable alterArt = new AlterTable(tableArt);
|
|
|
1055 |
alterArt.addBooleanColumn("MASQUE_CAISSE", Boolean.FALSE, false);
|
|
|
1056 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
|
|
1057 |
tableArt.getSchema().updateVersion();
|
|
|
1058 |
tableArt.fetchFields();
|
|
|
1059 |
}
|
|
|
1060 |
|
151 |
ilm |
1061 |
if (!tableArt.contains("ADDITIONAL_TICKET_COPY")) {
|
|
|
1062 |
final AlterTable alterArt = new AlterTable(tableArt);
|
|
|
1063 |
alterArt.addBooleanColumn("ADDITIONAL_TICKET_COPY", Boolean.FALSE, false);
|
|
|
1064 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
|
|
1065 |
tableArt.getSchema().updateVersion();
|
|
|
1066 |
tableArt.fetchFields();
|
|
|
1067 |
}
|
|
|
1068 |
|
149 |
ilm |
1069 |
SQLTable tableDevisAcompte = root.getTable("DEVIS");
|
|
|
1070 |
|
|
|
1071 |
if (!tableDevisAcompte.contains("T_ACOMPTE")) {
|
|
|
1072 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
|
|
1073 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
|
|
1074 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1075 |
root.refetchTable("DEVIS");
|
|
|
1076 |
root.getSchema().updateVersion();
|
|
|
1077 |
|
|
|
1078 |
SQLTable tableEncaisse = root.getTable("ENCAISSER_MONTANT");
|
|
|
1079 |
final AlterTable alterC = new AlterTable(tableEncaisse);
|
|
|
1080 |
alterC.addBooleanColumn("ACOMPTE", Boolean.FALSE, false);
|
|
|
1081 |
alterC.addForeignColumn("ID_DEVIS", tableDevisAcompte);
|
|
|
1082 |
root.getBase().getDataSource().execute(alterC.asString());
|
|
|
1083 |
root.refetchTable("ENCAISSER_MONTANT");
|
|
|
1084 |
root.getSchema().updateVersion();
|
|
|
1085 |
|
|
|
1086 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
|
|
1087 |
final AlterTable alterF = new AlterTable(tableVF);
|
|
|
1088 |
alterF.addLongColumn("T_ACOMPTE", 0L, false);
|
|
|
1089 |
root.getBase().getDataSource().execute(alterF.asString());
|
|
|
1090 |
root.refetchTable("SAISIE_VENTE_FACTURE");
|
|
|
1091 |
root.getSchema().updateVersion();
|
|
|
1092 |
}
|
|
|
1093 |
|
182 |
ilm |
1094 |
SQLTable tableCommandeAcompte = root.getTable("COMMANDE_CLIENT");
|
|
|
1095 |
if (!tableCommandeAcompte.contains("T_ACOMPTE")) {
|
|
|
1096 |
final AlterTable alterB = new AlterTable(tableCommandeAcompte);
|
|
|
1097 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
|
|
1098 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1099 |
root.refetchTable("COMMANDE_CLIENT");
|
|
|
1100 |
root.getSchema().updateVersion();
|
|
|
1101 |
|
|
|
1102 |
SQLTable tableEncaisse = root.getTable("ENCAISSER_MONTANT");
|
|
|
1103 |
final AlterTable alterC = new AlterTable(tableEncaisse);
|
|
|
1104 |
alterC.addForeignColumn("ID_COMMANDE_CLIENT", tableDevisAcompte);
|
|
|
1105 |
root.getBase().getDataSource().execute(alterC.asString());
|
|
|
1106 |
root.refetchTable("ENCAISSER_MONTANT");
|
|
|
1107 |
root.getSchema().updateVersion();
|
|
|
1108 |
}
|
|
|
1109 |
|
|
|
1110 |
if (!tableDevisAcompte.contains("DATE_LIVRAISON")) {
|
|
|
1111 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
|
|
1112 |
alterB.addColumn("DATE_LIVRAISON", "date");
|
|
|
1113 |
alterB.addVarCharColumn("TRANSFORMATION", 200);
|
|
|
1114 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1115 |
root.refetchTable("DEVIS");
|
|
|
1116 |
root.getSchema().updateVersion();
|
|
|
1117 |
}
|
|
|
1118 |
|
144 |
ilm |
1119 |
// Paye Simplifiée
|
|
|
1120 |
if (!tableFpaye.contains("ALLEGEMENT_COTISATION")) {
|
|
|
1121 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
|
|
1122 |
alterB.addDecimalColumn("ALLEGEMENT_COTISATION", 16, 2, BigDecimal.ZERO, false);
|
|
|
1123 |
alterB.addDecimalColumn("CICE", 16, 2, BigDecimal.ZERO, false);
|
|
|
1124 |
alterB.addDecimalColumn("AVANTAGE_NATURE", 16, 2, BigDecimal.ZERO, false);
|
|
|
1125 |
alterB.addDecimalColumn("HEURE_TRAV", 16, 2, BigDecimal.ZERO, false);
|
|
|
1126 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1127 |
root.refetchTable("FICHE_PAYE");
|
|
|
1128 |
root.getSchema().updateVersion();
|
|
|
1129 |
|
|
|
1130 |
final AlterTable alterC = new AlterTable(tableCpaye);
|
|
|
1131 |
alterC.addDecimalColumn("ALLEGEMENT_COTISATION_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
1132 |
alterC.addDecimalColumn("CICE_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
1133 |
alterC.addDecimalColumn("AVANTAGE_NATURE_C", 16, 2, BigDecimal.ZERO, false);
|
|
|
1134 |
root.getBase().getDataSource().execute(alterC.asString());
|
|
|
1135 |
root.refetchTable("CUMULS_PAYE");
|
|
|
1136 |
root.getSchema().updateVersion();
|
|
|
1137 |
|
|
|
1138 |
}
|
156 |
ilm |
1139 |
|
144 |
ilm |
1140 |
if (!tableFpaye.contains("DETAILS_CONGES")) {
|
|
|
1141 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
|
|
1142 |
alterB.addVarCharColumn("DETAILS_CONGES", 512);
|
|
|
1143 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1144 |
root.refetchTable("FICHE_PAYE");
|
|
|
1145 |
root.getSchema().updateVersion();
|
|
|
1146 |
}
|
|
|
1147 |
|
|
|
1148 |
SQLTable tableFPayeElt = root.getTable("FICHE_PAYE_ELEMENT");
|
|
|
1149 |
if (!tableFPayeElt.contains("ID_STYLE")) {
|
|
|
1150 |
final AlterTable alterB = new AlterTable(tableFPayeElt);
|
|
|
1151 |
alterB.addForeignColumn("ID_STYLE", root.getTable("STYLE"));
|
|
|
1152 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1153 |
root.refetchTable("FICHE_PAYE_ELEMENT");
|
|
|
1154 |
root.getSchema().updateVersion();
|
|
|
1155 |
}
|
|
|
1156 |
|
177 |
ilm |
1157 |
boolean upVar = false;
|
|
|
1158 |
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");
|
|
|
1159 |
final AlterTable alterVarSal = new AlterTable(tableVarSal);
|
|
|
1160 |
for (String field : f) {
|
|
|
1161 |
if (!tableVarSal.contains(field)) {
|
|
|
1162 |
upVar = true;
|
|
|
1163 |
alterVarSal.addColumn(field, "real DEFAULT 0");
|
|
|
1164 |
alterVarSal.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
|
|
1165 |
alterVarSal.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
|
144 |
ilm |
1166 |
}
|
177 |
ilm |
1167 |
}
|
|
|
1168 |
if (upVar) {
|
|
|
1169 |
root.getBase().getDataSource().execute(alterVarSal.asString());
|
144 |
ilm |
1170 |
root.refetchTable(tableVarSal.getName());
|
|
|
1171 |
root.getSchema().updateVersion();
|
|
|
1172 |
}
|
|
|
1173 |
|
|
|
1174 |
SQLTable tableDevis = root.getTable("DEVIS");
|
|
|
1175 |
if (!tableDevis.contains("ID_TAXE_PORT")) {
|
|
|
1176 |
final AlterTable alterB = new AlterTable(tableDevis);
|
|
|
1177 |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
|
|
1178 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1179 |
root.refetchTable(tableDevis.getName());
|
|
|
1180 |
root.getSchema().updateVersion();
|
|
|
1181 |
}
|
149 |
ilm |
1182 |
|
|
|
1183 |
// 1.5.3
|
|
|
1184 |
List<String> tableRemiseF = Arrays.asList("COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
|
|
|
1185 |
for (String t : tableRemiseF) {
|
|
|
1186 |
|
|
|
1187 |
final SQLTable tableCommande = root.getTable(t);
|
|
|
1188 |
AlterTable tCommande = new AlterTable(tableCommande);
|
|
|
1189 |
boolean updateCmd = false;
|
|
|
1190 |
if (!tableCommande.contains("ID_TAXE_PORT")) {
|
|
|
1191 |
updateCmd = true;
|
|
|
1192 |
tCommande.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
|
|
1193 |
}
|
|
|
1194 |
|
|
|
1195 |
if (!tableCommande.contains("PORT_HT")) {
|
|
|
1196 |
updateCmd = true;
|
|
|
1197 |
tCommande.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
|
|
1198 |
}
|
|
|
1199 |
|
|
|
1200 |
if (!tableCommande.contains("REMISE_HT")) {
|
|
|
1201 |
updateCmd = true;
|
|
|
1202 |
tCommande.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
|
|
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
if (updateCmd) {
|
|
|
1206 |
tableCommande.getBase().getDataSource().execute(tCommande.asString());
|
|
|
1207 |
tableCommande.getSchema().updateVersion();
|
|
|
1208 |
tableCommande.fetchFields();
|
|
|
1209 |
}
|
|
|
1210 |
}
|
|
|
1211 |
|
|
|
1212 |
List<String> tableElement = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
|
|
1213 |
for (String tableName : tableElement) {
|
|
|
1214 |
final SQLTable table = root.getTable(tableName);
|
|
|
1215 |
if (!table.contains("ID_FAMILLE_ARTICLE")) {
|
|
|
1216 |
AlterTable t = new AlterTable(table);
|
|
|
1217 |
t.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
|
|
1218 |
table.getBase().getDataSource().execute(t.asString());
|
|
|
1219 |
root.refetchTable(table.getName());
|
|
|
1220 |
root.getSchema().updateVersion();
|
|
|
1221 |
}
|
|
|
1222 |
}
|
|
|
1223 |
|
|
|
1224 |
final SQLTable tableBlElt = root.getTable("BON_RECEPTION_ELEMENT");
|
|
|
1225 |
if (!tableBlElt.contains("QTE_ORIGINE")) {
|
|
|
1226 |
AlterTable t = new AlterTable(tableBlElt);
|
|
|
1227 |
t.addIntegerColumn("QTE_ORIGINE", null, true);
|
|
|
1228 |
tableBlElt.getBase().getDataSource().execute(t.asString());
|
|
|
1229 |
root.refetchTable(tableBlElt.getName());
|
|
|
1230 |
root.getSchema().updateVersion();
|
|
|
1231 |
}
|
|
|
1232 |
// Caisse 1.5.3
|
|
|
1233 |
if (!root.getTable(registerLogTableName).contains("HOST_NAME")) {
|
|
|
1234 |
final AlterTable alterRegisterLog = new AlterTable(root.getTable(registerLogTableName));
|
|
|
1235 |
// to check for shared register installations
|
|
|
1236 |
alterRegisterLog.addVarCharColumn("HOST_NAME", 128, true, null, true);
|
|
|
1237 |
alterRegisterLog.addVarCharColumn("HOST_USER", 128, true, null, true);
|
|
|
1238 |
|
|
|
1239 |
// no longer needed since we need more than the last entry, just remove the duplicate
|
|
|
1240 |
// data and select from CAISSE_JOURNAL
|
|
|
1241 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
|
|
1242 |
alterRegister.dropColumn("ID_DERNIERE_ENTREE_JOURNAL");
|
|
|
1243 |
|
|
|
1244 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterRegisterLog, alterRegister))) {
|
|
|
1245 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
|
|
1246 |
}
|
|
|
1247 |
caisseT.getSchema().updateVersion();
|
|
|
1248 |
alterRegisterLog.getTable().fetchFields();
|
|
|
1249 |
alterRegister.getTable().fetchFields();
|
|
|
1250 |
}
|
|
|
1251 |
// Prefs compte AN
|
|
|
1252 |
SQLTable table = root.findTable("PREFS_COMPTE");
|
|
|
1253 |
|
|
|
1254 |
if (!table.getFieldsName().contains("ID_JOURNAL_AN")) {
|
151 |
ilm |
1255 |
AlterTable t = new AlterTable(table);
|
149 |
ilm |
1256 |
t.addForeignColumn("ID_JOURNAL_AN", root.getTable("JOURNAL"));
|
|
|
1257 |
t.addBooleanColumn("CREATE_NUL_SOLDE_ECR", Boolean.TRUE, false);
|
|
|
1258 |
table.getBase().getDataSource().execute(t.asString());
|
|
|
1259 |
table.getSchema().updateVersion();
|
|
|
1260 |
table.fetchFields();
|
|
|
1261 |
}
|
|
|
1262 |
|
177 |
ilm |
1263 |
if (!table.getFieldsName().contains("ID_JOURNAL_CB_ATTENTE")) {
|
|
|
1264 |
AlterTable t = new AlterTable(table);
|
|
|
1265 |
t.addForeignColumn("ID_JOURNAL_CB_ATTENTE", root.getTable("JOURNAL"));
|
|
|
1266 |
table.getBase().getDataSource().execute(t.asString());
|
|
|
1267 |
table.getSchema().updateVersion();
|
|
|
1268 |
table.fetchFields();
|
|
|
1269 |
}
|
|
|
1270 |
|
|
|
1271 |
if (!table.getFieldsName().contains("ID_COMPTE_PCE_CB_ATTENTE")) {
|
|
|
1272 |
AlterTable t = new AlterTable(table);
|
|
|
1273 |
t.addForeignColumn("ID_COMPTE_PCE_CB_ATTENTE", root.getTable("COMPTE_PCE"));
|
|
|
1274 |
table.getBase().getDataSource().execute(t.asString());
|
|
|
1275 |
table.getSchema().updateVersion();
|
|
|
1276 |
table.fetchFields();
|
|
|
1277 |
}
|
|
|
1278 |
|
151 |
ilm |
1279 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
|
|
1280 |
AlterTable t = new AlterTable(table);
|
|
|
1281 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
|
|
1282 |
table.getBase().getDataSource().execute(t.asString());
|
|
|
1283 |
table.getSchema().updateVersion();
|
|
|
1284 |
table.fetchFields();
|
|
|
1285 |
}
|
156 |
ilm |
1286 |
// Etat stock
|
|
|
1287 |
if (!root.contains("ETAT_STOCK")) {
|
151 |
ilm |
1288 |
|
156 |
ilm |
1289 |
try {
|
|
|
1290 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ETAT_STOCK");
|
|
|
1291 |
createTable.addColumn("DATE", "date");
|
|
|
1292 |
createTable.addDecimalColumn("MONTANT_HA", 16, 8, BigDecimal.ZERO, true);
|
|
|
1293 |
createTable.addDecimalColumn("MONTANT_VT", 16, 8, BigDecimal.ZERO, true);
|
|
|
1294 |
createTable.addBooleanColumn("INVENTAIRE", Boolean.FALSE, false);
|
|
|
1295 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
1296 |
InstallationPanel.insertUndef(createTable);
|
|
|
1297 |
root.refetchTable("ETAT_STOCK");
|
|
|
1298 |
root.getSchema().updateVersion();
|
|
|
1299 |
|
|
|
1300 |
final SQLCreateTable createTableElt = new SQLCreateTable(root, "ETAT_STOCK_ELEMENT");
|
|
|
1301 |
createTableElt.addForeignColumn("ARTICLE");
|
|
|
1302 |
createTableElt.addForeignColumn("ETAT_STOCK");
|
|
|
1303 |
createTableElt.addDecimalColumn("PA", 16, 8, BigDecimal.ZERO, true);
|
|
|
1304 |
createTableElt.addDecimalColumn("PV", 16, 8, BigDecimal.ZERO, true);
|
|
|
1305 |
createTableElt.addDecimalColumn("T_PA", 16, 8, BigDecimal.ZERO, true);
|
|
|
1306 |
createTableElt.addDecimalColumn("T_PV", 16, 8, BigDecimal.ZERO, true);
|
|
|
1307 |
createTableElt.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, true);
|
|
|
1308 |
createTableElt.addDecimalColumn("ECART", 16, 8, BigDecimal.ZERO, true);
|
|
|
1309 |
createTableElt.addVarCharColumn("CODE", 256);
|
|
|
1310 |
createTableElt.addVarCharColumn("NOM", 2048);
|
|
|
1311 |
|
|
|
1312 |
root.getBase().getDataSource().execute(createTableElt.asString());
|
|
|
1313 |
InstallationPanel.insertUndef(createTableElt);
|
|
|
1314 |
root.refetchTable("ETAT_STOCK_ELEMENT");
|
|
|
1315 |
root.getSchema().updateVersion();
|
|
|
1316 |
|
|
|
1317 |
} catch (SQLException ex) {
|
|
|
1318 |
throw new IllegalStateException("Erreur lors de la création de la table ETAT_STOCK_ELEMENT", ex);
|
|
|
1319 |
}
|
|
|
1320 |
} else {
|
|
|
1321 |
final SQLTable tableEtatStock = root.getTable("ETAT_STOCK_ELEMENT");
|
|
|
1322 |
SQLField fieldNom = tableEtatStock.getField("NOM");
|
|
|
1323 |
int size = fieldNom.getType().getSize();
|
|
|
1324 |
if (size == 512) {
|
|
|
1325 |
AlterTable alter = new AlterTable(tableEtatStock);
|
|
|
1326 |
alter.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(" + 2048 + ")", "''", false);
|
|
|
1327 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
|
|
1328 |
tableEtatStock.getSchema().updateVersion();
|
|
|
1329 |
tableEtatStock.fetchFields();
|
|
|
1330 |
}
|
|
|
1331 |
|
|
|
1332 |
}
|
|
|
1333 |
SQLTable tableMvtStock = root.getTable("MOUVEMENT_STOCK");
|
|
|
1334 |
if (!tableMvtStock.contains("ID_ETAT_STOCK")) {
|
|
|
1335 |
final AlterTable alter = new AlterTable(tableMvtStock);
|
|
|
1336 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
|
|
1337 |
alter.addBooleanColumn("OUVERTURE", Boolean.FALSE, false);
|
|
|
1338 |
alter.addForeignColumn("ID_ETAT_STOCK", root.getTable("ETAT_STOCK"));
|
|
|
1339 |
tableMvtStock.getBase().getDataSource().execute(alter.asString());
|
|
|
1340 |
tableMvtStock.getSchema().updateVersion();
|
|
|
1341 |
tableMvtStock.fetchFields();
|
|
|
1342 |
}
|
149 |
ilm |
1343 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
|
|
1344 |
if (!tableEcr.contains("CLOTURE")) {
|
|
|
1345 |
final AlterTable alter = new AlterTable(tableEcr);
|
|
|
1346 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
|
|
1347 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
|
|
1348 |
tableEcr.getBase().getDataSource().execute(alter.asString());
|
|
|
1349 |
tableEcr.getSchema().updateVersion();
|
|
|
1350 |
tableEcr.fetchFields();
|
|
|
1351 |
}
|
|
|
1352 |
|
|
|
1353 |
// Jour Km Element
|
|
|
1354 |
final SQLTable tkmElt = root.getTable("SAISIE_KM_ELEMENT");
|
|
|
1355 |
if (!tkmElt.contains("JOUR")) {
|
|
|
1356 |
final AlterTable alterKmElt = new AlterTable(tkmElt);
|
|
|
1357 |
alterKmElt.addIntegerColumn("JOUR", 1);
|
|
|
1358 |
tkmElt.getBase().getDataSource().execute(alterKmElt.asString());
|
|
|
1359 |
tkmElt.getSchema().updateVersion();
|
|
|
1360 |
tkmElt.fetchFields();
|
|
|
1361 |
}
|
151 |
ilm |
1362 |
// Ref bancaires fournisseurs et clients
|
|
|
1363 |
for (final SQLTable bankT : Arrays.asList(tableFournisseur, tClient)) {
|
|
|
1364 |
if (!bankT.contains("IBAN")) {
|
|
|
1365 |
final AlterTable alter = new AlterTable(bankT);
|
|
|
1366 |
alter.addVarCharColumn("IBAN", 128);
|
|
|
1367 |
alter.addVarCharColumn("BIC", 128);
|
|
|
1368 |
bankT.getDBSystemRoot().getDataSource().execute(alter.asString());
|
|
|
1369 |
bankT.getSchema().updateVersion();
|
|
|
1370 |
bankT.fetchFields();
|
|
|
1371 |
}
|
149 |
ilm |
1372 |
}
|
151 |
ilm |
1373 |
final SQLTable typeReglT = root.getTable("TYPE_REGLEMENT");
|
|
|
1374 |
if (typeReglT.getRow(TypeReglementSQLElement.PRELEVEMENT) == null) {
|
|
|
1375 |
final SQLRowValues directDebitVals = new SQLRowValues(typeReglT).put("NOM", "Prélèvement");
|
|
|
1376 |
directDebitVals.put("COMPTANT", Boolean.FALSE).put("ECHEANCE", Boolean.FALSE);
|
|
|
1377 |
directDebitVals.setID(TypeReglementSQLElement.PRELEVEMENT).insertVerbatim();
|
|
|
1378 |
}
|
|
|
1379 |
if (!tableClient.contains("ACCEPTE_EMAIL")) {
|
|
|
1380 |
final AlterTable alter = new AlterTable(tableClient);
|
|
|
1381 |
alter.addBooleanColumn("ACCEPTE_EMAIL", Boolean.FALSE, false);
|
|
|
1382 |
alter.addBooleanColumn("ACCEPTE_COURRIER", Boolean.FALSE, false);
|
|
|
1383 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
|
|
1384 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
|
|
1385 |
exec(alter);
|
|
|
1386 |
}
|
|
|
1387 |
final SQLTable contactT = root.getTable("CONTACT");
|
156 |
ilm |
1388 |
if (contactT != null && !contactT.contains("DATE_NAISSANCE")) {
|
151 |
ilm |
1389 |
final AlterTable alter = new AlterTable(contactT);
|
|
|
1390 |
alter.addColumn("DATE_NAISSANCE", "date");
|
|
|
1391 |
exec(alter);
|
|
|
1392 |
}
|
156 |
ilm |
1393 |
|
151 |
ilm |
1394 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
|
|
1395 |
if (createSDDMsgTable != null) {
|
|
|
1396 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
|
|
1397 |
root.createTables(createSDDMsgTable, createMandate);
|
|
|
1398 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
|
|
1399 |
final SQLTable mandateT = root.getTable(createMandate.getName());
|
|
|
1400 |
|
|
|
1401 |
final AlterTable alterFact = new AlterTable(root.getTable(SaisieVenteFactureSQLElement.TABLENAME));
|
|
|
1402 |
alterFact.addForeignColumn(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, msgT);
|
|
|
1403 |
alterFact.addVarCharColumn(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, 35);
|
|
|
1404 |
|
|
|
1405 |
final AlterTable alterModeRegl = new AlterTable(root.getTable("MODE_REGLEMENT"));
|
|
|
1406 |
alterModeRegl.addForeignColumn(null, mandateT);
|
|
|
1407 |
|
|
|
1408 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterFact, alterModeRegl))) {
|
|
|
1409 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
|
|
1410 |
}
|
|
|
1411 |
root.getSchema().updateVersion();
|
|
|
1412 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
|
|
1413 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
156 |
ilm |
1414 |
} else {
|
|
|
1415 |
// Before r24495 InstallationPanel.fixUnboundedVarchar() would change this field to
|
|
|
1416 |
// varchar
|
|
|
1417 |
final SQLField xmlField = root.getTable(SDDMessageSQLElement.TABLE_NAME).getField("XML");
|
|
|
1418 |
if (xmlField.getTypeDecl().contains("char")) {
|
|
|
1419 |
final AlterTable alterTable = new AlterTable(xmlField.getTable());
|
|
|
1420 |
alterTable.alterColumn(xmlField.getName(), EnumSet.of(Properties.TYPE), alterTable.getSyntax().getTypeNames(Clob.class).iterator().next(), null, null);
|
|
|
1421 |
root.getDBSystemRoot().getDataSource().execute(alterTable.asString());
|
|
|
1422 |
root.getSchema().updateVersion();
|
|
|
1423 |
xmlField.getTable().fetchFields();
|
|
|
1424 |
}
|
151 |
ilm |
1425 |
}
|
|
|
1426 |
|
|
|
1427 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
|
|
1428 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
|
|
1429 |
final AlterTable alter = new AlterTable(vcT);
|
|
|
1430 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
|
|
1431 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
|
|
1432 |
exec(alter);
|
|
|
1433 |
}
|
|
|
1434 |
|
156 |
ilm |
1435 |
// 1.6
|
|
|
1436 |
// gestion depots des cheques
|
|
|
1437 |
String chequeDepotTable = "DEPOT_CHEQUE";
|
|
|
1438 |
if (!root.contains(chequeDepotTable)) {
|
|
|
1439 |
|
|
|
1440 |
// Table depot cheque
|
|
|
1441 |
final SQLCreateTable createTableDepotCheque = new SQLCreateTable(root, chequeDepotTable);
|
|
|
1442 |
createTableDepotCheque.addVarCharColumn("NOM", 512);
|
|
|
1443 |
createTableDepotCheque.addLongColumn("MONTANT", 0L, false);
|
|
|
1444 |
createTableDepotCheque.addColumn("DATE", "date");
|
|
|
1445 |
if (root.contains("BANQUE")) {
|
|
|
1446 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE"));
|
|
|
1447 |
} else if (root.contains("BANQUE_POLE_PRODUIT")) {
|
|
|
1448 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE_POLE_PRODUIT"));
|
|
|
1449 |
}
|
|
|
1450 |
createTableDepotCheque.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
|
|
1451 |
createTableDepotCheque.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
|
|
1452 |
root.getBase().getDataSource().execute(createTableDepotCheque.asString());
|
|
|
1453 |
InstallationPanel.insertUndef(createTableDepotCheque);
|
|
|
1454 |
root.refetchTable(chequeDepotTable);
|
|
|
1455 |
root.getSchema().updateVersion();
|
|
|
1456 |
|
|
|
1457 |
// Table depot cheque element
|
|
|
1458 |
final SQLCreateTable createTableDepotElt = new SQLCreateTable(root, chequeDepotTable + "_ELEMENT");
|
|
|
1459 |
createTableDepotElt.addVarCharColumn("NUMERO", 128);
|
|
|
1460 |
createTableDepotElt.addVarCharColumn("BANQUE", 128);
|
|
|
1461 |
createTableDepotElt.addVarCharColumn("PIECE", 512);
|
|
|
1462 |
createTableDepotElt.addLongColumn("MONTANT", 0L, false);
|
|
|
1463 |
createTableDepotElt.addColumn("DATE", "date");
|
|
|
1464 |
createTableDepotElt.addForeignColumn("ID_CHEQUE_A_ENCAISSER", root.getTable("CHEQUE_A_ENCAISSER"));
|
|
|
1465 |
createTableDepotElt.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
|
|
1466 |
createTableDepotElt.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
|
|
1467 |
createTableDepotElt.addForeignColumn("ID_DEPOT_CHEQUE", root.getTable(chequeDepotTable));
|
|
|
1468 |
root.getBase().getDataSource().execute(createTableDepotElt.asString());
|
|
|
1469 |
InstallationPanel.insertUndef(createTableDepotElt);
|
|
|
1470 |
root.refetchTable(chequeDepotTable + "_ELEMENT");
|
|
|
1471 |
root.getSchema().updateVersion();
|
|
|
1472 |
}
|
|
|
1473 |
|
|
|
1474 |
final SQLTable articleT = root.getTable("ARTICLE");
|
|
|
1475 |
if (!articleT.contains("QTE_UNITAIRE")) {
|
|
|
1476 |
final AlterTable alter = new AlterTable(articleT);
|
|
|
1477 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
|
|
1478 |
exec(alter);
|
|
|
1479 |
}
|
|
|
1480 |
|
|
|
1481 |
final SQLTable articleFT = root.getTable("ARTICLE_FOURNISSEUR");
|
|
|
1482 |
if (!articleFT.contains("QTE_UNITAIRE")) {
|
|
|
1483 |
final AlterTable alter = new AlterTable(articleFT);
|
|
|
1484 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
|
|
1485 |
exec(alter);
|
|
|
1486 |
}
|
|
|
1487 |
|
|
|
1488 |
// Cout de revient
|
|
|
1489 |
if (!root.contains("COUT_REVIENT")) {
|
|
|
1490 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "COUT_REVIENT");
|
|
|
1491 |
createTableCR.addVarCharColumn("CODE", 48);
|
|
|
1492 |
createTableCR.addVarCharColumn("NOM", 256);
|
|
|
1493 |
createTableCR.addDecimalColumn("POURCENT", 16, 6, BigDecimal.ZERO, false);
|
|
|
1494 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
|
|
1495 |
InstallationPanel.insertUndef(createTableCR);
|
|
|
1496 |
root.refetchTable("COUT_REVIENT");
|
|
|
1497 |
root.getSchema().updateVersion();
|
|
|
1498 |
|
|
|
1499 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
|
|
1500 |
alterArticle.addForeignColumn("ID_COUT_REVIENT", root.findTable("COUT_REVIENT"));
|
|
|
1501 |
exec(alterArticle);
|
|
|
1502 |
root.refetchTable("ARTICLE");
|
|
|
1503 |
root.getSchema().updateVersion();
|
|
|
1504 |
}
|
|
|
1505 |
|
|
|
1506 |
if (!root.getTable("ARTICLE").contains("MARGE_WITH_COUT_REVIENT")) {
|
|
|
1507 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
|
|
1508 |
alterArticle.addBooleanColumn("MARGE_WITH_COUT_REVIENT", Boolean.FALSE, false);
|
|
|
1509 |
exec(alterArticle);
|
|
|
1510 |
root.refetchTable("ARTICLE");
|
|
|
1511 |
root.getSchema().updateVersion();
|
|
|
1512 |
}
|
|
|
1513 |
|
|
|
1514 |
if (!root.getTable("FACTURE_FOURNISSEUR").contains("NET_A_PAYER")) {
|
|
|
1515 |
final AlterTable alterFactF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR"));
|
|
|
1516 |
alterFactF.addLongColumn("NET_A_PAYER", 0L, false);
|
|
|
1517 |
alterFactF.addLongColumn("AVOIR_TTC", 0L, false);
|
|
|
1518 |
exec(alterFactF);
|
|
|
1519 |
root.refetchTable("FACTURE_FOURNISSEUR");
|
|
|
1520 |
root.getSchema().updateVersion();
|
|
|
1521 |
}
|
|
|
1522 |
|
|
|
1523 |
// Frais Document
|
|
|
1524 |
if (!root.contains("FRAIS_DOCUMENT")) {
|
|
|
1525 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "FRAIS_DOCUMENT");
|
|
|
1526 |
createTableCR.addVarCharColumn("CODE", 48);
|
|
|
1527 |
createTableCR.addVarCharColumn("NOM", 256);
|
|
|
1528 |
createTableCR.addLongColumn("MONTANT_HT", 0L, false);
|
|
|
1529 |
createTableCR.addForeignColumn("ID_TAXE", root.getTable("TAXE"));
|
|
|
1530 |
createTableCR.addLongColumn("MONTANT_TTC", 0L, false);
|
|
|
1531 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
|
|
1532 |
InstallationPanel.insertUndef(createTableCR);
|
|
|
1533 |
root.refetchTable("FRAIS_DOCUMENT");
|
|
|
1534 |
|
|
|
1535 |
final AlterTable alterClient = new AlterTable(root.getTable("CLIENT"));
|
|
|
1536 |
alterClient.addForeignColumn("ID_FRAIS_DOCUMENT", root.findTable("FRAIS_DOCUMENT"));
|
|
|
1537 |
exec(alterClient);
|
|
|
1538 |
root.refetchTable("CLIENT");
|
|
|
1539 |
|
|
|
1540 |
List<String> tables = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE");
|
|
|
1541 |
for (String tableToUp : tables) {
|
|
|
1542 |
final AlterTable alter = new AlterTable(root.getTable(tableToUp));
|
|
|
1543 |
alter.addLongColumn("FRAIS_DOCUMENT_HT", 0L, false);
|
|
|
1544 |
alter.addForeignColumn("ID_TAXE_FRAIS_DOCUMENT", root.getTable("TAXE"));
|
|
|
1545 |
exec(alter);
|
|
|
1546 |
root.refetchTable(tableToUp);
|
|
|
1547 |
}
|
|
|
1548 |
root.getSchema().updateVersion();
|
|
|
1549 |
}
|
|
|
1550 |
|
|
|
1551 |
final SQLTable chequeAvoirT = root.getTable("CHEQUE_AVOIR_CLIENT");
|
|
|
1552 |
|
|
|
1553 |
String tBanque = root.contains("BANQUE") ? "BANQUE" : "BANQUE_POLE_PRODUIT";
|
|
|
1554 |
if (!chequeAvoirT.contains("ID_" + tBanque)) {
|
|
|
1555 |
|
|
|
1556 |
final AlterTable alterChqAvoir = new AlterTable(chequeAvoirT);
|
|
|
1557 |
alterChqAvoir.addForeignColumn("ID_" + tBanque, root.findTable(tBanque));
|
|
|
1558 |
exec(alterChqAvoir);
|
|
|
1559 |
}
|
|
|
1560 |
|
|
|
1561 |
// Prelevement à la source
|
|
|
1562 |
final SQLTable fichePayeT = root.getTable("FICHE_PAYE");
|
|
|
1563 |
if (!fichePayeT.contains("ID_PAS")) {
|
|
|
1564 |
final SQLCreateTable createTablePas = new SQLCreateTable(root, "PAS");
|
|
|
1565 |
createTablePas.addForeignColumn("ID_TYPE_TAUX_PAS", root.findTable("TYPE_TAUX_PAS"));
|
|
|
1566 |
createTablePas.addVarCharColumn("CODE_PAS", 256);
|
|
|
1567 |
createTablePas.addDecimalColumn("TAUX_PAS", 16, 2, BigDecimal.ZERO, false);
|
|
|
1568 |
root.getBase().getDataSource().execute(createTablePas.asString());
|
|
|
1569 |
InstallationPanel.insertUndef(createTablePas);
|
|
|
1570 |
root.refetchTable("PAS");
|
|
|
1571 |
root.getSchema().updateVersion();
|
|
|
1572 |
|
|
|
1573 |
final AlterTable alterFichePaye = new AlterTable(fichePayeT);
|
|
|
1574 |
alterFichePaye.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
|
|
1575 |
alterFichePaye.addDecimalColumn("TOTAL_PAS", 16, 2, BigDecimal.ZERO, false);
|
|
|
1576 |
alterFichePaye.addDecimalColumn("NET_AVANT_PAS", 16, 2, BigDecimal.ZERO, false);
|
|
|
1577 |
exec(alterFichePaye);
|
|
|
1578 |
|
|
|
1579 |
final SQLTable tableSal = root.getTable("SALARIE");
|
|
|
1580 |
final AlterTable alterSalarie = new AlterTable(tableSal);
|
|
|
1581 |
alterSalarie.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
|
|
1582 |
exec(alterSalarie);
|
|
|
1583 |
|
|
|
1584 |
final AlterTable alterEtatCivil = new AlterTable(tableEtatCivil);
|
|
|
1585 |
alterEtatCivil.addVarCharColumn("NTT", 50);
|
|
|
1586 |
exec(alterEtatCivil);
|
|
|
1587 |
|
|
|
1588 |
Map<String, SQLRow> typeTauxPasMap = new HashMap<>();
|
|
|
1589 |
SQLSelect selTypeTaux = new SQLSelect();
|
|
|
1590 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getKey());
|
|
|
1591 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getField("CODE"));
|
|
|
1592 |
List<SQLRow> resultTypeTaux = SQLRowListRSH.execute(selTypeTaux);
|
|
|
1593 |
for (SQLRow sqlRow : resultTypeTaux) {
|
|
|
1594 |
typeTauxPasMap.put(sqlRow.getString("CODE"), sqlRow);
|
|
|
1595 |
}
|
|
|
1596 |
|
|
|
1597 |
SQLSelect selSal = new SQLSelect();
|
|
|
1598 |
selSal.addSelect(tableSal.getKey());
|
|
|
1599 |
List<SQLRow> rowSal = SQLRowListRSH.execute(selSal);
|
|
|
1600 |
for (SQLRow sqlRow : rowSal) {
|
|
|
1601 |
SQLRowValues rowValsSal = sqlRow.createEmptyUpdateRow();
|
|
|
1602 |
final SQLRowValues putRowValues = rowValsSal.putRowValues("ID_PAS");
|
|
|
1603 |
putRowValues.put("ID_TYPE_TAUX_PAS", typeTauxPasMap.get("13").getID());
|
|
|
1604 |
putRowValues.put("TAUX_PAS", BigDecimal.ZERO);
|
|
|
1605 |
putRowValues.commit();
|
|
|
1606 |
}
|
|
|
1607 |
}
|
|
|
1608 |
|
|
|
1609 |
if (!root.contains("ARTICLE_TARIF_FOURNISSEUR")) {
|
|
|
1610 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_TARIF_FOURNISSEUR");
|
|
|
1611 |
|
|
|
1612 |
createTable.addForeignColumn("ARTICLE");
|
|
|
1613 |
createTable.addForeignColumn("FOURNISSEUR");
|
|
|
1614 |
createTable.addVarCharColumn("REF_FOURNISSEUR", 500);
|
|
|
1615 |
createTable.addVarCharColumn("TYPE_REAPPRO", 256);
|
|
|
1616 |
createTable.addVarCharColumn("CONDITIONS", 1024);
|
|
|
1617 |
createTable.addVarCharColumn("ACHETEUR", 256);
|
|
|
1618 |
createTable.addVarCharColumn("CODE_PAYS_ORIGINE", 256);
|
|
|
1619 |
createTable.addDecimalColumn("PRIX_ACHAT_DEVISE_F", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
1620 |
createTable.addDecimalColumn("PRIX_ACHAT", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
1621 |
createTable.addIntegerColumn("QTE", 1);
|
|
|
1622 |
createTable.addDateAndTimeColumn("DATE_PRIX");
|
|
|
1623 |
// createTable.addDecimalColumn("COEF_TRANSPORT_PORT", 16, 6, BigDecimal.valueOf(0),
|
|
|
1624 |
// false);
|
|
|
1625 |
// createTable.addDecimalColumn("COEF_TAXE_D", 16, 6, BigDecimal.valueOf(0), false);
|
|
|
1626 |
// createTable.addDecimalColumn("COEF_TRANSPORT_SIEGE", 16, 6, BigDecimal.valueOf(0),
|
|
|
1627 |
// false);
|
|
|
1628 |
// createTable.addDecimalColumn("COEF_FRAIS_MOULE", 16, 6, BigDecimal.valueOf(0),
|
|
|
1629 |
// false);
|
|
|
1630 |
// createTable.addDecimalColumn("COEF_FRAIS_INDIRECTS", 16, 6, BigDecimal.valueOf(0),
|
|
|
1631 |
// false);
|
|
|
1632 |
createTable.addIntegerColumn("DELAI_REAPPRO", 0);
|
|
|
1633 |
createTable.addIntegerColumn("DELAI_TRANSPORT", 0);
|
|
|
1634 |
createTable.addIntegerColumn("PRIORITE", 0);
|
|
|
1635 |
createTable.addDecimalColumn("COEF_PRIX_MINI", 16, 2, BigDecimal.valueOf(0), false);
|
|
|
1636 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
1637 |
InstallationPanel.insertUndef(createTable);
|
|
|
1638 |
root.refetchTable("ARTICLE_TARIF_FOURNISSEUR");
|
|
|
1639 |
root.getSchema().updateVersion();
|
|
|
1640 |
}
|
|
|
1641 |
|
|
|
1642 |
// Gestion des catègories comptables
|
|
|
1643 |
if (!root.contains("CATEGORIE_COMPTABLE")) {
|
|
|
1644 |
final SQLCreateTable createTable = new SQLCreateTable(root, "CATEGORIE_COMPTABLE");
|
|
|
1645 |
createTable.addVarCharColumn("NOM", 128);
|
|
|
1646 |
createTable.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
|
|
1647 |
createTable.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
|
|
1648 |
createTable.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
|
|
1649 |
createTable.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
|
|
1650 |
|
|
|
1651 |
try {
|
|
|
1652 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
1653 |
InstallationPanel.insertUndef(createTable);
|
|
|
1654 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
|
|
1655 |
root.getSchema().updateVersion();
|
|
|
1656 |
} catch (SQLException ex) {
|
|
|
1657 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CATEGORIE_COMPTABLE", ex);
|
|
|
1658 |
}
|
|
|
1659 |
|
|
|
1660 |
AlterTable tableClientCat = new AlterTable(root.getTable("CLIENT"));
|
|
|
1661 |
tableClientCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
|
|
1662 |
root.getBase().getDataSource().execute(tableClientCat.asString());
|
|
|
1663 |
root.refetchTable("CLIENT");
|
|
|
1664 |
root.getSchema().updateVersion();
|
|
|
1665 |
|
|
|
1666 |
AlterTable tableF = new AlterTable(root.getTable("FOURNISSEUR"));
|
|
|
1667 |
tableF.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
|
|
1668 |
root.getBase().getDataSource().execute(tableF.asString());
|
|
|
1669 |
root.refetchTable("FOURNISSEUR");
|
|
|
1670 |
root.getSchema().updateVersion();
|
|
|
1671 |
|
|
|
1672 |
final SQLCreateTable createTableArtCat = new SQLCreateTable(root, "ARTICLE_CATEGORIE_COMPTABLE");
|
|
|
1673 |
createTableArtCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
|
|
1674 |
createTableArtCat.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
|
|
1675 |
createTableArtCat.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
|
|
1676 |
createTableArtCat.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
|
|
1677 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
|
|
1678 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
|
|
1679 |
|
|
|
1680 |
try {
|
|
|
1681 |
root.getBase().getDataSource().execute(createTableArtCat.asString());
|
|
|
1682 |
InstallationPanel.insertUndef(createTableArtCat);
|
|
|
1683 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
|
|
1684 |
root.getSchema().updateVersion();
|
|
|
1685 |
} catch (SQLException ex) {
|
|
|
1686 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_CATEGORIE_COMPTABLE", ex);
|
|
|
1687 |
}
|
|
|
1688 |
|
|
|
1689 |
}
|
|
|
1690 |
|
|
|
1691 |
// Article fournisseur secondaire
|
|
|
1692 |
if (!root.contains("ARTICLE_FOURNISSEUR_SECONDAIRE")) {
|
|
|
1693 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_FOURNISSEUR_SECONDAIRE");
|
|
|
1694 |
createTable.addForeignColumn("ARTICLE");
|
|
|
1695 |
createTable.addForeignColumn("FOURNISSEUR");
|
|
|
1696 |
try {
|
|
|
1697 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
1698 |
InstallationPanel.insertUndef(createTable);
|
|
|
1699 |
root.refetchTable("ARTICLE_FOURNISSEUR_SECONDAIRE");
|
|
|
1700 |
root.getSchema().updateVersion();
|
|
|
1701 |
} catch (SQLException ex) {
|
|
|
1702 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_FOURNISSEUR_SECONDAIRE", ex);
|
|
|
1703 |
}
|
|
|
1704 |
}
|
|
|
1705 |
|
|
|
1706 |
if (!root.getTable("ARTICLE").contains("AUTO_PRIX_ACHAT_NOMENCLATURE")) {
|
|
|
1707 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
|
|
1708 |
t.addBooleanColumn("AUTO_PRIX_ACHAT_NOMENCLATURE", false, false);
|
|
|
1709 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
|
|
1710 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
|
|
1711 |
root.getSchema().updateVersion();
|
|
|
1712 |
}
|
|
|
1713 |
|
|
|
1714 |
// Gestion multidepot
|
182 |
ilm |
1715 |
final SQLTable userT = root.findTable("USER_COMMON");
|
156 |
ilm |
1716 |
{
|
|
|
1717 |
// Ajout table depot
|
|
|
1718 |
if (!root.contains("DEPOT_STOCK")) {
|
|
|
1719 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DEPOT_STOCK");
|
|
|
1720 |
createTable.addVarCharColumn("CODE", 25);
|
|
|
1721 |
createTable.addVarCharColumn("NOM", 256);
|
|
|
1722 |
createTable.addVarCharColumn("UI_LOCK", 256);
|
182 |
ilm |
1723 |
createTable.addForeignColumn("ID_USER_UI_LOCK", userT);
|
156 |
ilm |
1724 |
// sqlRowValues.put("UI_LOCK", "ro");
|
|
|
1725 |
// sqlRowValues.put("ID_USER_UI_LOCK", 2);
|
|
|
1726 |
|
|
|
1727 |
try {
|
|
|
1728 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
1729 |
InstallationPanel.insertUndef(createTable);
|
|
|
1730 |
|
|
|
1731 |
root.refetchTable("DEPOT_STOCK");
|
|
|
1732 |
root.getSchema().updateVersion();
|
|
|
1733 |
|
|
|
1734 |
SQLRowValues rowValsDefStock = new SQLRowValues(root.getTable("DEPOT_STOCK"));
|
|
|
1735 |
rowValsDefStock.put("NOM", "Principal");
|
|
|
1736 |
rowValsDefStock.put("UI_LOCK", "ro");
|
|
|
1737 |
rowValsDefStock.commit();
|
|
|
1738 |
} catch (SQLException ex) {
|
|
|
1739 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DEPOT_STOCK", ex);
|
|
|
1740 |
}
|
|
|
1741 |
}
|
|
|
1742 |
|
|
|
1743 |
List<String> tableElementDepot = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
|
|
|
1744 |
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
|
|
1745 |
for (String tableName : tableElementDepot) {
|
|
|
1746 |
final SQLTable tableToAddDepot = root.getTable(tableName);
|
|
|
1747 |
if (!tableToAddDepot.contains("ID_DEPOT_STOCK")) {
|
|
|
1748 |
AlterTable t = new AlterTable(tableToAddDepot);
|
|
|
1749 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
|
|
1750 |
tableToAddDepot.getBase().getDataSource().execute(t.asString());
|
|
|
1751 |
root.refetchTable(tableToAddDepot.getName());
|
|
|
1752 |
root.getSchema().updateVersion();
|
|
|
1753 |
}
|
|
|
1754 |
}
|
|
|
1755 |
|
|
|
1756 |
// Depot defaut
|
|
|
1757 |
if (!root.getTable("ARTICLE").contains("ID_DEPOT_STOCK")) {
|
|
|
1758 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
|
|
1759 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
|
|
1760 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
|
|
1761 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
|
|
1762 |
root.getSchema().updateVersion();
|
|
|
1763 |
}
|
|
|
1764 |
|
|
|
1765 |
// Liason depot stock
|
|
|
1766 |
if (!root.getTable("STOCK").contains("ID_DEPOT_STOCK")) {
|
|
|
1767 |
AlterTable t = new AlterTable(root.getTable("STOCK"));
|
|
|
1768 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
|
|
1769 |
t.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
|
|
1770 |
t.addColumn("QTE_MIN", "real DEFAULT 0");
|
|
|
1771 |
root.getTable("STOCK").getBase().getDataSource().execute(t.asString());
|
|
|
1772 |
root.refetchTable(root.getTable("STOCK").getName());
|
|
|
1773 |
root.getSchema().updateVersion();
|
|
|
1774 |
}
|
|
|
1775 |
|
|
|
1776 |
// Ajout depot sur mvt
|
|
|
1777 |
if (!root.getTable("MOUVEMENT_STOCK").contains("ID_STOCK")) {
|
|
|
1778 |
AlterTable t = new AlterTable(root.getTable("MOUVEMENT_STOCK"));
|
|
|
1779 |
t.addForeignColumn("ID_STOCK", root.getTable("STOCK"));
|
|
|
1780 |
t.addIntegerColumn("SOURCE_ELEMENTID", 1);
|
|
|
1781 |
root.getTable("MOUVEMENT_STOCK").getBase().getDataSource().execute(t.asString());
|
|
|
1782 |
root.refetchTable(root.getTable("MOUVEMENT_STOCK").getName());
|
|
|
1783 |
root.getSchema().updateVersion();
|
|
|
1784 |
|
|
|
1785 |
// REQUETE update STOCK.ID_ARTICLE et QTE_MIN
|
|
|
1786 |
SQLTable tableStock = root.getTable("STOCK");
|
|
|
1787 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
|
|
1788 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
|
|
1789 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
|
|
1790 |
buildStockArt.setFromVirtualJoinField("QTE_MIN", tableArticle.getAlias(), "QTE_MIN");
|
|
|
1791 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
|
|
1792 |
|
|
|
1793 |
// REQUETE UPDATE MVT ID_STOCK
|
|
|
1794 |
UpdateBuilder buildMvtStock = new UpdateBuilder(tableMvtStock);
|
|
|
1795 |
buildMvtStock.addForwardVirtualJoin(tableArticle, "ID_ARTICLE");
|
|
|
1796 |
buildMvtStock.setFromVirtualJoinField("ID_STOCK", tableArticle.getAlias(), "ID_STOCK");
|
|
|
1797 |
|
|
|
1798 |
// REQUETE UPDATE STOCK ID_DEPOT_STOCK
|
|
|
1799 |
UpdateBuilder buildStock = new UpdateBuilder(tableStock);
|
|
|
1800 |
buildStock.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
|
|
1801 |
|
|
|
1802 |
UpdateBuilder buildArticleDepot = new UpdateBuilder(tableArticle);
|
|
|
1803 |
buildArticleDepot.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
|
|
1804 |
|
|
|
1805 |
// REQUETE UPDATE ARTICLE_DEPOT_STOCK
|
|
|
1806 |
// String req = "INSERT INTO " + root.getTable("ARTICLE_STOCK").getSQLName().quote()
|
|
|
1807 |
// + " (" + root.getTable("ARTICLE_STOCK").getField("ID_ARTICLE").getQuotedName() +
|
|
|
1808 |
// ",";
|
|
|
1809 |
// req += root.getTable("ARTICLE_STOCK").getField("ID_STOCK").getQuotedName() + ", "
|
|
|
1810 |
// + root.getTable("ARTICLE_STOCK").getField("QTE_MIN").getQuotedName() + ") SELECT
|
|
|
1811 |
// "
|
|
|
1812 |
// + root.getTable("ARTICLE").getKey().getQuotedName() + "," +
|
|
|
1813 |
// root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + ", "
|
|
|
1814 |
// + root.getTable("ARTICLE").getField("QTE_MIN").getQuotedName();
|
|
|
1815 |
// req += " FROM " + root.getTable("ARTICLE").getSQLName().quote();
|
|
|
1816 |
// req += " WHERE " + root.getTable("ARTICLE").getKey().getQuotedName() + " > 1 AND
|
|
|
1817 |
// " + root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + " >1 ";
|
|
|
1818 |
// req += " AND " + root.getTable("ARTICLE").getArchiveField().getQuotedName() + " =
|
|
|
1819 |
// 0";
|
|
|
1820 |
|
|
|
1821 |
tableStock.getDBSystemRoot().getDataSource().execute(buildArticleDepot.asString());
|
|
|
1822 |
tableStock.getDBSystemRoot().getDataSource().execute(buildMvtStock.asString());
|
|
|
1823 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStock.asString());
|
|
|
1824 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
|
|
1825 |
}
|
|
|
1826 |
|
|
|
1827 |
}
|
|
|
1828 |
|
|
|
1829 |
// Gestion Livraison depuis devis
|
|
|
1830 |
SQLTable tableTrDevis = root.getTable("TR_DEVIS");
|
|
|
1831 |
if (!tableTrDevis.contains("ID_BON_DE_LIVRAISON")) {
|
|
|
1832 |
AlterTable t = new AlterTable(tableTrDevis);
|
|
|
1833 |
t.addForeignColumn("ID_BON_DE_LIVRAISON", root.getTable("BON_DE_LIVRAISON"));
|
|
|
1834 |
tableTrDevis.getBase().getDataSource().execute(t.asString());
|
|
|
1835 |
root.refetchTable(tableTrDevis.getName());
|
|
|
1836 |
root.getSchema().updateVersion();
|
|
|
1837 |
}
|
|
|
1838 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
|
|
1839 |
if (!tableBLElt.contains("ID_DEVIS_ELEMENT")) {
|
|
|
1840 |
AlterTable t = new AlterTable(tableBLElt);
|
|
|
1841 |
t.addForeignColumn("ID_DEVIS_ELEMENT", root.getTable("DEVIS_ELEMENT"));
|
|
|
1842 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
|
|
1843 |
root.refetchTable(tableBLElt.getName());
|
|
|
1844 |
root.getSchema().updateVersion();
|
|
|
1845 |
}
|
|
|
1846 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
|
|
1847 |
if (!tableDevisElt.contains("QTE_LIVREE")) {
|
|
|
1848 |
AlterTable t = new AlterTable(tableDevisElt);
|
|
|
1849 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
|
|
1850 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
|
|
1851 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
|
|
1852 |
tableDevisElt.getBase().getDataSource().execute(t.asString());
|
|
|
1853 |
root.refetchTable(tableDevisElt.getName());
|
|
|
1854 |
root.getSchema().updateVersion();
|
|
|
1855 |
|
|
|
1856 |
// Move show devise pref in global
|
|
|
1857 |
SQLSelect sel = new SQLSelect();
|
|
|
1858 |
sel.addSelect(root.getTable("DEVISE_HISTORIQUE").getKey(), "COUNT");
|
|
|
1859 |
Number n = (Number) root.getDBSystemRoot().getDataSource().executeScalar(sel.asString());
|
|
|
1860 |
if (n.intValue() > 0) {
|
|
|
1861 |
SQLPreferences prefs = new SQLPreferences(root);
|
|
|
1862 |
prefs.putBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, true);
|
|
|
1863 |
try {
|
|
|
1864 |
prefs.sync();
|
|
|
1865 |
} catch (BackingStoreException e) {
|
|
|
1866 |
// TODO Auto-generated catch block
|
|
|
1867 |
e.printStackTrace();
|
|
|
1868 |
}
|
|
|
1869 |
}
|
|
|
1870 |
}
|
|
|
1871 |
|
|
|
1872 |
SQLTable tablePosteAn = root.getTable("POSTE_ANALYTIQUE");
|
|
|
1873 |
if (!tablePosteAn.contains("OBSOLETE")) {
|
|
|
1874 |
AlterTable t = new AlterTable(tablePosteAn);
|
|
|
1875 |
t.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
|
|
1876 |
tablePosteAn.getBase().getDataSource().execute(t.asString());
|
|
|
1877 |
root.refetchTable(tablePosteAn.getName());
|
|
|
1878 |
root.getSchema().updateVersion();
|
|
|
1879 |
}
|
|
|
1880 |
|
|
|
1881 |
SQLTable tableCheque = root.getTable("CHEQUE_A_ENCAISSER");
|
|
|
1882 |
if (!tableCheque.contains("ID_COMPTE_PCE_TIERS")) {
|
|
|
1883 |
AlterTable t = new AlterTable(tableCheque);
|
|
|
1884 |
t.addVarCharColumn("TIERS", 256);
|
|
|
1885 |
t.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
|
|
1886 |
tableCheque.getBase().getDataSource().execute(t.asString());
|
|
|
1887 |
root.refetchTable(tableCheque.getName());
|
|
|
1888 |
|
|
|
1889 |
SQLTable tableEnc = root.getTable("ENCAISSER_MONTANT");
|
|
|
1890 |
AlterTable tEnc = new AlterTable(tableEnc);
|
|
|
1891 |
tEnc.addVarCharColumn("TIERS", 256);
|
|
|
1892 |
tEnc.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
|
|
1893 |
tableEnc.getBase().getDataSource().execute(tEnc.asString());
|
|
|
1894 |
root.refetchTable(tableEnc.getName());
|
|
|
1895 |
root.getSchema().updateVersion();
|
|
|
1896 |
|
|
|
1897 |
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
|
|
1898 |
AlterTable tEch = new AlterTable(tableEch);
|
|
|
1899 |
tEch.addVarCharColumn("TIERS", 256);
|
|
|
1900 |
tEch.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
|
|
1901 |
tableEch.getBase().getDataSource().execute(tEch.asString());
|
|
|
1902 |
root.refetchTable(tableEch.getName());
|
|
|
1903 |
root.getSchema().updateVersion();
|
|
|
1904 |
|
|
|
1905 |
SQLTable tableChq = root.getTable("DEPOT_CHEQUE_ELEMENT");
|
|
|
1906 |
AlterTable tChq = new AlterTable(tableChq);
|
|
|
1907 |
tChq.addVarCharColumn("TIERS", 256);
|
|
|
1908 |
tableChq.getBase().getDataSource().execute(tChq.asString());
|
|
|
1909 |
root.refetchTable(tableChq.getName());
|
|
|
1910 |
root.getSchema().updateVersion();
|
|
|
1911 |
}
|
|
|
1912 |
|
|
|
1913 |
if (!tableEcr.contains("DATE_ECHEANCE")) {
|
|
|
1914 |
AlterTable t = new AlterTable(tableEcr);
|
|
|
1915 |
t.addColumn("DATE_ECHEANCE", "date");
|
|
|
1916 |
tableEcr.getBase().getDataSource().execute(t.asString());
|
|
|
1917 |
root.refetchTable(tableEcr.getName());
|
|
|
1918 |
root.getSchema().updateVersion();
|
|
|
1919 |
}
|
|
|
1920 |
|
|
|
1921 |
if (!tableVarSal.contains("HEURE_ABS_CUMUL_VAL")) {
|
|
|
1922 |
|
|
|
1923 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
|
|
1924 |
|
|
|
1925 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
|
|
1926 |
|
|
|
1927 |
String field = sqlField.getName();
|
|
|
1928 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
182 |
ilm |
1929 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL") && !tableVarSal.contains(field + "_CUMUL_VAL")) {
|
156 |
ilm |
1930 |
alterB.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
|
|
|
1931 |
}
|
|
|
1932 |
}
|
|
|
1933 |
|
|
|
1934 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1935 |
root.refetchTable("VARIABLE_SALARIE");
|
|
|
1936 |
root.getSchema().updateVersion();
|
|
|
1937 |
}
|
174 |
ilm |
1938 |
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
|
|
|
1939 |
if (!tableBL.contains("ID_COMMERCIAL")) {
|
|
|
1940 |
final AlterTable alterB = new AlterTable(tableBL);
|
|
|
1941 |
alterB.addForeignColumn("ID_COMMERCIAL", root.getTable("COMMERCIAL"));
|
|
|
1942 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1943 |
root.refetchTable("BON_DE_LIVRAISON");
|
|
|
1944 |
root.getSchema().updateVersion();
|
|
|
1945 |
}
|
156 |
ilm |
1946 |
|
182 |
ilm |
1947 |
if (!tableBL.contains("VERROU_FACTURATION")) {
|
|
|
1948 |
final AlterTable alterB = new AlterTable(tableBL);
|
|
|
1949 |
alterB.addBooleanColumn("VERROU_FACTURATION", Boolean.FALSE, false);
|
|
|
1950 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
1951 |
root.refetchTable("BON_DE_LIVRAISON");
|
|
|
1952 |
root.getSchema().updateVersion();
|
|
|
1953 |
}
|
|
|
1954 |
|
156 |
ilm |
1955 |
// fix stock
|
|
|
1956 |
{
|
|
|
1957 |
SQLTable tableStock = root.getTable("STOCK");
|
|
|
1958 |
|
|
|
1959 |
// Doublon depot stock
|
|
|
1960 |
SQLSelect sel = new SQLSelect();
|
|
|
1961 |
sel.addSelectFunctionStar("COUNT");
|
|
|
1962 |
sel.addSelect(tableStock.getField("ID_DEPOT_STOCK"));
|
|
|
1963 |
sel.addSelect(tableStock.getField("ID_ARTICLE"));
|
|
|
1964 |
sel.addGroupBy(tableStock.getField("ID_DEPOT_STOCK"));
|
|
|
1965 |
sel.addGroupBy(tableStock.getField("ID_ARTICLE"));
|
|
|
1966 |
sel.setHaving(Where.createRaw("COUNT(*)>1", Collections.emptyList()));
|
|
|
1967 |
System.err.println(sel.asString());
|
|
|
1968 |
|
|
|
1969 |
List<Object[]> resultStockDoublon = (List<Object[]>) tableStock.getDBSystemRoot().getDataSource().execute(sel.asString(), new ArrayListHandler());
|
|
|
1970 |
for (Object[] objects : resultStockDoublon) {
|
|
|
1971 |
|
|
|
1972 |
if (((Number) objects[2]).intValue() == 1) {
|
|
|
1973 |
|
|
|
1974 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
|
|
1975 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
|
|
1976 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
|
|
1977 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
|
|
1978 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
|
|
1979 |
} else {
|
|
|
1980 |
SQLSelect selD = new SQLSelect();
|
|
|
1981 |
selD.addSelectStar(tableStock);
|
|
|
1982 |
Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", objects[2]);
|
|
|
1983 |
w = w.and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", objects[1]));
|
|
|
1984 |
selD.setWhere(w);
|
|
|
1985 |
List<SQLRow> badStock = SQLRowListRSH.execute(selD);
|
|
|
1986 |
if (badStock.size() > 1) {
|
|
|
1987 |
SQLRowValues stock = badStock.get(0).createUpdateRow();
|
|
|
1988 |
List<String> fieldsToMerge = Arrays.asList("QTE_REEL", "QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_LIV_ATTENTE");
|
|
|
1989 |
List<Integer> listBadIds = new ArrayList<>();
|
|
|
1990 |
for (int i = 1; i < badStock.size(); i++) {
|
|
|
1991 |
SQLRow rowBad = badStock.get(i);
|
|
|
1992 |
listBadIds.add(rowBad.getID());
|
|
|
1993 |
for (String field : fieldsToMerge) {
|
|
|
1994 |
stock.put(field, stock.getFloat(field) + rowBad.getFloat(field));
|
|
|
1995 |
}
|
|
|
1996 |
rowBad.createEmptyUpdateRow().put("ARCHIVE", 1).commit();
|
|
|
1997 |
}
|
|
|
1998 |
List<SQLTable> tablesToMErge = Arrays.asList(root.getTable("MOUVEMENT_STOCK"), root.getTable("ARTICLE"));
|
|
|
1999 |
for (SQLTable mergeTable : tablesToMErge) {
|
|
|
2000 |
UpdateBuilder up = new UpdateBuilder(mergeTable);
|
|
|
2001 |
up.setObject("ID_STOCK", stock.getID());
|
|
|
2002 |
up.setWhere(new Where(mergeTable.getField("ID_STOCK"), listBadIds));
|
|
|
2003 |
mergeTable.getDBSystemRoot().getDataSource().execute(up.asString());
|
|
|
2004 |
}
|
|
|
2005 |
stock.commit();
|
|
|
2006 |
|
|
|
2007 |
}
|
|
|
2008 |
}
|
|
|
2009 |
}
|
|
|
2010 |
|
182 |
ilm |
2011 |
// Remove useless since 1.7.1
|
|
|
2012 |
// SQLSelect selArt = new SQLSelect();
|
|
|
2013 |
// selArt.addSelectStar(tableArt);
|
|
|
2014 |
// Where w = new Where(tableArt.getField("ID_STOCK"), "=", 1);
|
|
|
2015 |
// selArt.setWhere(w);
|
|
|
2016 |
// List<SQLRow> badStock = SQLRowListRSH.execute(selArt);
|
|
|
2017 |
// for (SQLRow sqlRow : badStock) {
|
|
|
2018 |
// initStock(sqlRow);
|
|
|
2019 |
// }
|
|
|
2020 |
|
156 |
ilm |
2021 |
}
|
|
|
2022 |
|
174 |
ilm |
2023 |
// Tarification client par quantite
|
|
|
2024 |
if (root.getTable("TARIF_ARTICLE_CLIENT") == null) {
|
|
|
2025 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_ARTICLE_CLIENT");
|
|
|
2026 |
createTableQtyTarif.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
|
|
2027 |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
|
|
2028 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
|
|
2029 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
|
|
2030 |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
|
|
2031 |
try {
|
|
|
2032 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
|
|
2033 |
InstallationPanel.insertUndef(createTableQtyTarif);
|
|
|
2034 |
root.refetchTable("TARIF_ARTICLE_CLIENT");
|
|
|
2035 |
root.getSchema().updateVersion();
|
|
|
2036 |
} catch (SQLException ex) {
|
|
|
2037 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_QUANTITE", ex);
|
|
|
2038 |
}
|
|
|
2039 |
}
|
156 |
ilm |
2040 |
|
174 |
ilm |
2041 |
SQLTable tableTrCmd = root.getTable("TR_COMMANDE");
|
|
|
2042 |
if (!tableTrCmd.contains("ID_FACTURE_FOURNISSEUR")) {
|
|
|
2043 |
AlterTable t = new AlterTable(tableTrCmd);
|
|
|
2044 |
t.addForeignColumn("ID_FACTURE_FOURNISSEUR", root.getTable("FACTURE_FOURNISSEUR"));
|
|
|
2045 |
tableTrCmd.getBase().getDataSource().execute(t.asString());
|
|
|
2046 |
root.refetchTable(tableTrCmd.getName());
|
|
|
2047 |
root.getSchema().updateVersion();
|
|
|
2048 |
}
|
|
|
2049 |
|
|
|
2050 |
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
|
|
|
2051 |
if (!tableContrat.contains("COMPLEMENT_PCS")) {
|
|
|
2052 |
AlterTable t = new AlterTable(tableContrat);
|
|
|
2053 |
t.addVarCharColumn("COMPLEMENT_PCS", 54);
|
|
|
2054 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
|
|
2055 |
root.refetchTable(tableContrat.getName());
|
|
|
2056 |
root.getSchema().updateVersion();
|
|
|
2057 |
}
|
177 |
ilm |
2058 |
if (!tableContrat.contains("SPECTACLE_OBJET")) {
|
|
|
2059 |
AlterTable t = new AlterTable(tableContrat);
|
|
|
2060 |
t.addVarCharColumn("SPECTACLE_OBJET", 54);
|
|
|
2061 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
|
|
2062 |
root.refetchTable(tableContrat.getName());
|
|
|
2063 |
root.getSchema().updateVersion();
|
|
|
2064 |
}
|
174 |
ilm |
2065 |
|
177 |
ilm |
2066 |
if (!tableContrat.contains("SPECTACLE_OBJET")) {
|
|
|
2067 |
AlterTable t = new AlterTable(tableContrat);
|
|
|
2068 |
t.addVarCharColumn("SPECTACLE_OBJET", 54);
|
|
|
2069 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
|
|
2070 |
root.refetchTable(tableContrat.getName());
|
|
|
2071 |
root.getSchema().updateVersion();
|
|
|
2072 |
}
|
|
|
2073 |
if (!tableContrat.contains("SPECTACLE_JOUR_CONTRAT")) {
|
|
|
2074 |
AlterTable t = new AlterTable(tableContrat);
|
|
|
2075 |
t.addDecimalColumn("SPECTACLE_JOUR_CONTRAT", 16, 2, null, true);
|
|
|
2076 |
tableContrat.getBase().getDataSource().execute(t.asString());
|
|
|
2077 |
root.refetchTable(tableContrat.getName());
|
|
|
2078 |
root.getSchema().updateVersion();
|
|
|
2079 |
}
|
|
|
2080 |
|
174 |
ilm |
2081 |
List<String> tablesCatComptable = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT");
|
|
|
2082 |
for (String tableToUp : tablesCatComptable) {
|
|
|
2083 |
final SQLTable tableCatComptToAdd = root.getTable(tableToUp);
|
|
|
2084 |
if (!tableCatComptToAdd.contains("ID_CATEGORIE_COMPTABLE")) {
|
|
|
2085 |
final AlterTable alter = new AlterTable(tableCatComptToAdd);
|
|
|
2086 |
alter.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
|
|
2087 |
exec(alter);
|
|
|
2088 |
root.refetchTable(tableToUp);
|
|
|
2089 |
root.getSchema().updateVersion();
|
|
|
2090 |
}
|
|
|
2091 |
}
|
|
|
2092 |
|
|
|
2093 |
|
|
|
2094 |
// Modèles pour les emails
|
|
|
2095 |
if (!root.contains(EmailTemplateSQLElement.TABLE_NAME)) {
|
|
|
2096 |
final SQLCreateTable createTable = new SQLCreateTable(root, EmailTemplateSQLElement.TABLE_NAME);
|
|
|
2097 |
createTable.addVarCharColumn("NOM", 80);
|
|
|
2098 |
createTable.addVarCharColumn("TITRE", 80);
|
|
|
2099 |
createTable.addVarCharColumn("TEXTE", 4096);
|
|
|
2100 |
createTable.addVarCharColumn("FORMAT_DATE", 20);
|
|
|
2101 |
createTable.addBooleanColumn("PAR_DEFAUT", Boolean.FALSE, false);
|
|
|
2102 |
try {
|
|
|
2103 |
root.getBase().getDataSource().execute(createTable.asString());
|
|
|
2104 |
InstallationPanel.insertUndef(createTable);
|
|
|
2105 |
root.refetchTable(EmailTemplateSQLElement.TABLE_NAME);
|
|
|
2106 |
root.getSchema().updateVersion();
|
|
|
2107 |
} catch (SQLException ex) {
|
|
|
2108 |
throw new IllegalStateException("Erreur lors de la création de la table " + EmailTemplateSQLElement.TABLE_NAME, ex);
|
|
|
2109 |
}
|
|
|
2110 |
}
|
|
|
2111 |
// Force undefined policy to inDb
|
|
|
2112 |
root.setMetadata(SQLTable.UNDEFINED_ID_POLICY, "inDB");
|
177 |
ilm |
2113 |
final Map<String, Number> mapTableNameUndefined = SQLTable.getUndefinedIDs(root.getSchema());
|
174 |
ilm |
2114 |
final Set<String> tables = root.getSchema().getTableNames();
|
|
|
2115 |
for (String tName : tables) {
|
|
|
2116 |
if (!mapTableNameUndefined.containsKey(tName)) {
|
|
|
2117 |
System.err.println("Updater_1_5.update() adding undefined in db for " + tName);
|
|
|
2118 |
SQLTable.setUndefID(root.getSchema(), tName, null);
|
|
|
2119 |
}
|
|
|
2120 |
}
|
|
|
2121 |
|
|
|
2122 |
// Création de la table Modéle
|
|
|
2123 |
if (!root.contains("CONTACT_SALARIE")) {
|
|
|
2124 |
|
|
|
2125 |
SQLCreateTable createModele = new SQLCreateTable(root, "CONTACT_SALARIE");
|
|
|
2126 |
createModele.addVarCharColumn("NOM", 256);
|
|
|
2127 |
createModele.addVarCharColumn("PRENOM", 256);
|
|
|
2128 |
createModele.addVarCharColumn("TEL_DIRECT", 256);
|
|
|
2129 |
createModele.addVarCharColumn("TEL_MOBILE", 256);
|
|
|
2130 |
createModele.addVarCharColumn("EMAIL", 256);
|
|
|
2131 |
createModele.addVarCharColumn("FAX", 256);
|
|
|
2132 |
createModele.addVarCharColumn("FONCTION", 256);
|
|
|
2133 |
createModele.addVarCharColumn("TEL_PERSONEL", 256);
|
|
|
2134 |
createModele.addVarCharColumn("TEL_STANDARD", 256);
|
|
|
2135 |
createModele.addForeignColumn("ID_TITRE_PERSONNEL", root.findTable("TITRE_PERSONNEL"));
|
|
|
2136 |
createModele.addForeignColumn("ID_SALARIE", root.findTable("SALARIE"));
|
|
|
2137 |
|
|
|
2138 |
try {
|
|
|
2139 |
root.getBase().getDataSource().execute(createModele.asString());
|
|
|
2140 |
root.refetchTable("CONTACT_SALARIE");
|
|
|
2141 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("CONTACT_SALARIE"));
|
|
|
2142 |
SQLRow rowInserted = rowVals.commit();
|
|
|
2143 |
SQLTable.setUndefID(root.getSchema(), "CONTACT_SALARIE", rowInserted.getID());
|
|
|
2144 |
tableDevis.getSchema().updateVersion();
|
|
|
2145 |
} catch (SQLException ex) {
|
|
|
2146 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
|
|
2147 |
}
|
|
|
2148 |
}
|
|
|
2149 |
|
|
|
2150 |
final SQLTable tableRgltPaye = root.getTable("REGLEMENT_PAYE");
|
|
|
2151 |
if (!tableRgltPaye.contains("IBAN")) {
|
|
|
2152 |
final AlterTable alter = new AlterTable(tableRgltPaye);
|
|
|
2153 |
alter.addVarCharColumn("IBAN", 128);
|
|
|
2154 |
exec(alter);
|
|
|
2155 |
root.refetchTable(tableRgltPaye.getName());
|
|
|
2156 |
root.getSchema().updateVersion();
|
|
|
2157 |
}
|
|
|
2158 |
if (!tableRgltPaye.contains("BIC")) {
|
|
|
2159 |
final AlterTable alter = new AlterTable(tableRgltPaye);
|
|
|
2160 |
alter.addVarCharColumn("BIC", 40);
|
|
|
2161 |
exec(alter);
|
|
|
2162 |
root.refetchTable(tableRgltPaye.getName());
|
|
|
2163 |
root.getSchema().updateVersion();
|
|
|
2164 |
}
|
|
|
2165 |
final SQLTable tableSalarie = root.getTable("SALARIE");
|
|
|
2166 |
if (!tableSalarie.contains("ID_USER_COMMON")) {
|
|
|
2167 |
final AlterTable alter = new AlterTable(tableSalarie);
|
182 |
ilm |
2168 |
alter.addForeignColumn("ID_USER_COMMON", userT);
|
174 |
ilm |
2169 |
exec(alter);
|
|
|
2170 |
root.refetchTable(tableSalarie.getName());
|
|
|
2171 |
root.getSchema().updateVersion();
|
|
|
2172 |
}
|
|
|
2173 |
|
|
|
2174 |
final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
|
|
|
2175 |
if (!tableInfosSalarie.contains("DUREE_FORFAIT")) {
|
|
|
2176 |
final AlterTable alter = new AlterTable(tableInfosSalarie);
|
|
|
2177 |
alter.addColumn("DUREE_FORFAIT", "real");
|
|
|
2178 |
exec(alter);
|
|
|
2179 |
root.refetchTable(tableSalarie.getName());
|
|
|
2180 |
root.getSchema().updateVersion();
|
|
|
2181 |
}
|
177 |
ilm |
2182 |
boolean upDimensionArt = false;
|
174 |
ilm |
2183 |
|
177 |
ilm |
2184 |
final AlterTable alterDimensionArt = new AlterTable(tableArt);
|
|
|
2185 |
if (!tableArt.contains("LONGUEUR")) {
|
|
|
2186 |
alterDimensionArt.addDecimalColumn("LONGUEUR", 16, 8, null, true);
|
|
|
2187 |
upDimensionArt = true;
|
|
|
2188 |
}
|
|
|
2189 |
if (!tableArt.contains("LARGEUR")) {
|
|
|
2190 |
alterDimensionArt.addDecimalColumn("LARGEUR", 16, 8, null, true);
|
|
|
2191 |
upDimensionArt = true;
|
|
|
2192 |
}
|
|
|
2193 |
if (!tableArt.contains("HAUTEUR")) {
|
|
|
2194 |
alterDimensionArt.addDecimalColumn("HAUTEUR", 16, 8, null, true);
|
|
|
2195 |
upDimensionArt = true;
|
|
|
2196 |
}
|
|
|
2197 |
if (upDimensionArt) {
|
|
|
2198 |
tableArt.getBase().getDataSource().execute(alterDimensionArt.asString());
|
|
|
2199 |
tableArt.getSchema().updateVersion();
|
|
|
2200 |
tableArt.fetchFields();
|
|
|
2201 |
}
|
|
|
2202 |
|
|
|
2203 |
List<String> tableElementWithTable = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
|
|
|
2204 |
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
|
|
2205 |
for (String tableName : tableElementWithTable) {
|
|
|
2206 |
final SQLTable tableToAddDimension = root.getTable(tableName);
|
|
|
2207 |
boolean upDimensionArtItem = false;
|
|
|
2208 |
|
|
|
2209 |
final AlterTable alterDimensionArtItem = new AlterTable(tableToAddDimension);
|
|
|
2210 |
if (!tableToAddDimension.contains("LONGUEUR")) {
|
|
|
2211 |
alterDimensionArtItem.addDecimalColumn("LONGUEUR", 16, 8, null, true);
|
|
|
2212 |
upDimensionArtItem = true;
|
|
|
2213 |
}
|
|
|
2214 |
if (!tableToAddDimension.contains("LARGEUR")) {
|
|
|
2215 |
alterDimensionArtItem.addDecimalColumn("LARGEUR", 16, 8, null, true);
|
|
|
2216 |
upDimensionArtItem = true;
|
|
|
2217 |
}
|
|
|
2218 |
if (!tableToAddDimension.contains("HAUTEUR")) {
|
|
|
2219 |
alterDimensionArtItem.addDecimalColumn("HAUTEUR", 16, 8, null, true);
|
|
|
2220 |
upDimensionArtItem = true;
|
|
|
2221 |
}
|
|
|
2222 |
if (upDimensionArtItem) {
|
|
|
2223 |
tableToAddDimension.getBase().getDataSource().execute(alterDimensionArtItem.asString());
|
|
|
2224 |
tableToAddDimension.getSchema().updateVersion();
|
|
|
2225 |
tableToAddDimension.fetchFields();
|
|
|
2226 |
}
|
|
|
2227 |
}
|
|
|
2228 |
|
|
|
2229 |
if (!tTva.contains("DEFAULT_ACHAT")) {
|
|
|
2230 |
final AlterTable alterTaxe = new AlterTable(tTva);
|
|
|
2231 |
alterTaxe.addBooleanColumn("DEFAULT_ACHAT", Boolean.FALSE, false);
|
|
|
2232 |
tTva.getBase().getDataSource().execute(alterTaxe.asString());
|
|
|
2233 |
tTva.getSchema().updateVersion();
|
|
|
2234 |
tTva.fetchFields();
|
|
|
2235 |
}
|
|
|
2236 |
SQLTable tableTypeRglt = root.getTable("TYPE_REGLEMENT");
|
|
|
2237 |
if (!tableTypeRglt.contains("SEPA")) {
|
|
|
2238 |
final AlterTable alterTaxe = new AlterTable(tableTypeRglt);
|
|
|
2239 |
alterTaxe.addBooleanColumn("SEPA", Boolean.FALSE, false);
|
|
|
2240 |
tableTypeRglt.getBase().getDataSource().execute(alterTaxe.asString());
|
|
|
2241 |
tableTypeRglt.getSchema().updateVersion();
|
|
|
2242 |
tableTypeRglt.fetchFields();
|
|
|
2243 |
UpdateBuilder upSEPA = new UpdateBuilder(tableTypeRglt);
|
|
|
2244 |
upSEPA.setObject("SEPA", Boolean.TRUE);
|
|
|
2245 |
upSEPA.setObject("ECHEANCE", Boolean.TRUE);
|
|
|
2246 |
upSEPA.setWhere(new Where(tableTypeRglt.getField("NOM"), "=", "Prélèvement"));
|
|
|
2247 |
tTva.getBase().getDataSource().execute(upSEPA.asString());
|
|
|
2248 |
}
|
|
|
2249 |
|
|
|
2250 |
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
|
|
2251 |
if (!tableEch.contains("ID_SEPA_MANDATE")) {
|
|
|
2252 |
|
|
|
2253 |
final AlterTable alterEch = new AlterTable(tableEch);
|
|
|
2254 |
alterEch.addForeignColumn("ID_SEPA_MANDATE", root.getTable("SEPA_MANDATE"));
|
|
|
2255 |
alterEch.addForeignColumn("ID_SDD_MESSAGE", root.getTable(SDDMessageSQLElement.TABLE_NAME));
|
|
|
2256 |
alterEch.addVarCharColumn("SDD_EndToEndId", 35);
|
|
|
2257 |
alterEch.addBooleanColumn("FICHIER_CREE", Boolean.FALSE, false);
|
|
|
2258 |
alterEch.addBooleanColumn("REJETER", Boolean.FALSE, false);
|
|
|
2259 |
alterEch.addVarCharColumn("ETS", 256);
|
|
|
2260 |
alterEch.addForeignColumn("ID_" + BanqueSQLElement.TABLENAME, root.getTable(BanqueSQLElement.TABLENAME));
|
|
|
2261 |
tableEch.getBase().getDataSource().execute(alterEch.asString());
|
|
|
2262 |
tableEch.getSchema().updateVersion();
|
|
|
2263 |
tableEch.fetchFields();
|
|
|
2264 |
|
|
|
2265 |
}
|
|
|
2266 |
if (!tClient.contains("ID_SEPA_MANDATE_DEFAULT")) {
|
|
|
2267 |
final AlterTable alterClient = new AlterTable(tClient);
|
|
|
2268 |
alterClient.addForeignColumn("ID_SEPA_MANDATE_DEFAULT", root.getTable("SEPA_MANDATE"));
|
|
|
2269 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
|
|
2270 |
tClient.getSchema().updateVersion();
|
|
|
2271 |
tClient.fetchFields();
|
|
|
2272 |
}
|
|
|
2273 |
|
|
|
2274 |
if (!tableArt.contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
|
|
|
2275 |
final AlterTable alter = new AlterTable(tableArt);
|
|
|
2276 |
alter.addBooleanColumn("AUTO_PRIX_MIN_VENTE_NOMENCLATURE", Boolean.FALSE, false);
|
|
|
2277 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
|
|
2278 |
tableArt.getSchema().updateVersion();
|
|
|
2279 |
tableArt.fetchFields();
|
|
|
2280 |
}
|
|
|
2281 |
if (!tableArt.contains("DERNIER_DATE_ACHAT")) {
|
|
|
2282 |
final AlterTable alter = new AlterTable(tableArt);
|
|
|
2283 |
alter.addColumn("DERNIER_DATE_ACHAT", "date");
|
|
|
2284 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
|
|
2285 |
tableArt.getSchema().updateVersion();
|
|
|
2286 |
tableArt.fetchFields();
|
|
|
2287 |
ReferenceArticleSQLElement.updateDateAchat(tableArt, null);
|
|
|
2288 |
}
|
|
|
2289 |
|
|
|
2290 |
SQLTable tableFactF = root.getTable("FACTURE_FOURNISSEUR");
|
|
|
2291 |
if (!tableFactF.contains("DATE_REGLEMENT")) {
|
|
|
2292 |
final AlterTable alter = new AlterTable(tableFactF);
|
|
|
2293 |
alter.addColumn("DATE_REGLEMENT", "date");
|
|
|
2294 |
tableFactF.getBase().getDataSource().execute(alter.asString());
|
|
|
2295 |
tableFactF.getSchema().updateVersion();
|
|
|
2296 |
tableFactF.fetchFields();
|
|
|
2297 |
}
|
|
|
2298 |
|
|
|
2299 |
SQLTable tableEchF = root.getTable("ECHEANCE_FOURNISSEUR");
|
|
|
2300 |
if (!tableEchF.contains("ID_FACTURE_FOURNISSEUR")) {
|
|
|
2301 |
final AlterTable alter = new AlterTable(tableEchF);
|
|
|
2302 |
alter.addForeignColumn("ID_FACTURE_FOURNISSEUR", tableFactF);
|
|
|
2303 |
tableEchF.getBase().getDataSource().execute(alter.asString());
|
|
|
2304 |
tableEchF.getSchema().updateVersion();
|
|
|
2305 |
tableEchF.fetchFields();
|
|
|
2306 |
}
|
|
|
2307 |
|
|
|
2308 |
List<String> achatItems = Arrays.asList("DEMANDE_PRIX_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "FACTURE_FOURNISSEUR_ELEMENT");
|
|
|
2309 |
for (String string : achatItems) {
|
|
|
2310 |
boolean alter = false;
|
|
|
2311 |
SQLTable tableItems = root.getTable(string);
|
|
|
2312 |
final AlterTable t = new AlterTable(tableItems);
|
|
|
2313 |
|
|
|
2314 |
if (!tableItems.getFieldsName().contains("POIDS_COLIS_NET")) {
|
|
|
2315 |
t.addColumn("POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
|
|
|
2316 |
alter = true;
|
|
|
2317 |
}
|
|
|
2318 |
|
|
|
2319 |
if (!tableItems.getFieldsName().contains("T_POIDS_COLIS_NET")) {
|
|
|
2320 |
t.addColumn("T_POIDS_COLIS_NET", "numeric (16,8) DEFAULT 1");
|
|
|
2321 |
alter = true;
|
|
|
2322 |
}
|
|
|
2323 |
|
|
|
2324 |
if (!tableItems.getFieldsName().contains("NB_COLIS")) {
|
|
|
2325 |
t.addColumn("NB_COLIS", "integer DEFAULT 0");
|
|
|
2326 |
alter = true;
|
|
|
2327 |
}
|
|
|
2328 |
if (alter) {
|
|
|
2329 |
tableItems.getBase().getDataSource().execute(t.asString());
|
|
|
2330 |
tableItems.getSchema().updateVersion();
|
|
|
2331 |
tableItems.fetchFields();
|
|
|
2332 |
}
|
|
|
2333 |
}
|
|
|
2334 |
|
|
|
2335 |
for (String tableName : tableElementWithTable) {
|
|
|
2336 |
final SQLTable tableToAddTare = root.getTable(tableName);
|
|
|
2337 |
boolean upTareArtItem = false;
|
|
|
2338 |
|
|
|
2339 |
final AlterTable alterTareArtItem = new AlterTable(tableToAddTare);
|
|
|
2340 |
if (!tableToAddTare.contains("TARE")) {
|
|
|
2341 |
alterTareArtItem.addDecimalColumn("TARE", 16, 8, null, true);
|
|
|
2342 |
alterTareArtItem.alterColumn("POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
|
|
|
2343 |
alterTareArtItem.alterColumn("T_POIDS_COLIS_NET", EnumSet.allOf(Properties.class), "numeric(16,8)", "0", true);
|
|
|
2344 |
|
|
|
2345 |
alterTareArtItem.addDecimalColumn("T_POIDS_BRUT", 16, 8, BigDecimal.ZERO, true);
|
|
|
2346 |
|
|
|
2347 |
upTareArtItem = true;
|
|
|
2348 |
}
|
|
|
2349 |
|
|
|
2350 |
if (upTareArtItem) {
|
|
|
2351 |
tableToAddTare.getBase().getDataSource().execute(alterTareArtItem.asString());
|
|
|
2352 |
tableToAddTare.getSchema().updateVersion();
|
|
|
2353 |
tableToAddTare.fetchFields();
|
|
|
2354 |
|
|
|
2355 |
int id = tableToAddTare.getUndefinedID();
|
|
|
2356 |
if (id != SQLRow.NONEXISTANT_ID) {
|
|
|
2357 |
UpdateBuilder build = new UpdateBuilder(tableToAddTare);
|
|
|
2358 |
build.setObject("POIDS_COLIS_NET", BigDecimal.ZERO);
|
|
|
2359 |
build.setWhere(new Where(tableToAddTare.getKey(), "=", id));
|
|
|
2360 |
tableToAddTare.getDBSystemRoot().getDataSource().execute(build.asString());
|
|
|
2361 |
}
|
|
|
2362 |
}
|
|
|
2363 |
}
|
|
|
2364 |
|
|
|
2365 |
// Fix nb char MOUVEMENT_STOCK.NOM
|
|
|
2366 |
if (tableMvtStock.getField("NOM").getType().getSize() == 45) {
|
|
|
2367 |
AlterTable alterMvt = new AlterTable(tableMvtStock);
|
|
|
2368 |
alterMvt.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
|
|
|
2369 |
tableMvtStock.getDBSystemRoot().getDataSource().execute(alterMvt.asString());
|
|
|
2370 |
tableMvtStock.getSchema().updateVersion();
|
|
|
2371 |
}
|
|
|
2372 |
|
|
|
2373 |
SQLTable tableEtatStock = root.getTable("ETAT_STOCK");
|
|
|
2374 |
SQLTable tableDepotStock = root.getTable("DEPOT_STOCK");
|
|
|
2375 |
if (!tableEtatStock.contains("ID_DEPOT_STOCK")) {
|
|
|
2376 |
final AlterTable alter = new AlterTable(tableEtatStock);
|
|
|
2377 |
alter.addForeignColumn("ID_DEPOT_STOCK", tableDepotStock);
|
|
|
2378 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
|
|
2379 |
tableEtatStock.getSchema().updateVersion();
|
|
|
2380 |
tableEtatStock.fetchFields();
|
|
|
2381 |
}
|
180 |
ilm |
2382 |
|
|
|
2383 |
// Création de la table Agence
|
|
|
2384 |
if (!root.contains("AGENCE")) {
|
|
|
2385 |
SQLCreateTable createAgence = new SQLCreateTable(root, "AGENCE");
|
|
|
2386 |
createAgence.addVarCharColumn("DESIGNATION", 256);
|
|
|
2387 |
createAgence.addVarCharColumn("TEL_1", 256);
|
|
|
2388 |
createAgence.addVarCharColumn("EMAIL", 256);
|
|
|
2389 |
createAgence.addVarCharColumn("FAX", 256);
|
|
|
2390 |
createAgence.addForeignColumn("ID_CLIENT", root.findTable("CLIENT"));
|
|
|
2391 |
createAgence.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE"));
|
|
|
2392 |
|
|
|
2393 |
try {
|
|
|
2394 |
// test
|
|
|
2395 |
root.getBase().getDataSource().execute(createAgence.asString());
|
|
|
2396 |
root.refetchTable("AGENCE");
|
|
|
2397 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("AGENCE"));
|
|
|
2398 |
SQLRow rowInserted = rowVals.commit();
|
|
|
2399 |
SQLTable.setUndefID(root.getSchema(), "AGENCE", rowInserted.getID());
|
|
|
2400 |
tableDevis.getSchema().updateVersion();
|
|
|
2401 |
} catch (SQLException ex) {
|
|
|
2402 |
throw new IllegalStateException("Erreur lors de la création de la table AGENCE", ex);
|
|
|
2403 |
}
|
|
|
2404 |
}
|
|
|
2405 |
// Tarification client par famille article
|
|
|
2406 |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) {
|
|
|
2407 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT");
|
|
|
2408 |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
|
|
2409 |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
|
|
2410 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
|
|
2411 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
|
|
2412 |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
|
|
2413 |
try {
|
|
|
2414 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
|
|
2415 |
InstallationPanel.insertUndef(createTableQtyTarif);
|
|
|
2416 |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT");
|
|
|
2417 |
root.getSchema().updateVersion();
|
|
|
2418 |
} catch (SQLException ex) {
|
|
|
2419 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex);
|
|
|
2420 |
}
|
|
|
2421 |
}
|
|
|
2422 |
|
|
|
2423 |
// Tarification client par famille article
|
|
|
2424 |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) {
|
|
|
2425 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT");
|
|
|
2426 |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
|
|
2427 |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
|
|
2428 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
|
|
2429 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
|
|
2430 |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
|
|
2431 |
try {
|
|
|
2432 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
|
|
2433 |
InstallationPanel.insertUndef(createTableQtyTarif);
|
|
|
2434 |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT");
|
|
|
2435 |
root.getSchema().updateVersion();
|
|
|
2436 |
} catch (SQLException ex) {
|
|
|
2437 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex);
|
|
|
2438 |
}
|
|
|
2439 |
}
|
|
|
2440 |
|
|
|
2441 |
SQLTable tableAvoirC = root.getTable("AVOIR_CLIENT");
|
|
|
2442 |
if (!tableAvoirC.contains("ID_TAXE_PORT")) {
|
|
|
2443 |
final AlterTable alterB = new AlterTable(tableAvoirC);
|
|
|
2444 |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
|
|
2445 |
root.getBase().getDataSource().execute(alterB.asString());
|
|
|
2446 |
root.refetchTable(tableAvoirC.getName());
|
|
|
2447 |
root.getSchema().updateVersion();
|
|
|
2448 |
}
|
|
|
2449 |
|
|
|
2450 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
|
|
2451 |
if (!tableVF.contains("ID_FACTURATION_COMMANDE_CLIENT")) {
|
|
|
2452 |
final AlterTable alter = new AlterTable(tableVF);
|
|
|
2453 |
final SQLTable tableFacturationCommandeClient = tableVF.getDBRoot().getTable("FACTURATION_COMMANDE_CLIENT");
|
|
|
2454 |
alter.addForeignColumn("ID_FACTURATION_COMMANDE_CLIENT", tableFacturationCommandeClient);
|
|
|
2455 |
tableVF.getBase().getDataSource().execute(alter.asString());
|
|
|
2456 |
tableVF.getSchema().updateVersion();
|
|
|
2457 |
tableVF.fetchFields();
|
|
|
2458 |
|
|
|
2459 |
// update ID_FACTURATION_COMMANDE
|
|
|
2460 |
UpdateBuilder builder = new UpdateBuilder(tableVF);
|
|
|
2461 |
AliasedTable ref = new AliasedTable(tableFacturationCommandeClient, "tf");
|
|
|
2462 |
builder.addBackwardVirtualJoin(ref, "ID_SAISIE_VENTE_FACTURE");
|
|
|
2463 |
builder.setFromVirtualJoinField("ID_FACTURATION_COMMANDE_CLIENT", "tf", tableFacturationCommandeClient.getKey().getName());
|
|
|
2464 |
tableVF.getBase().getDataSource().execute(builder.asString());
|
|
|
2465 |
}
|
|
|
2466 |
if (!root.getTable("NUMEROTATION_AUTO").contains("CODE_LETTRAGE_PARTIEL")) {
|
|
|
2467 |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO"));
|
|
|
2468 |
alterNumero.addVarCharColumn("CODE_LETTRAGE_PARTIEL", 256);
|
|
|
2469 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
|
|
2470 |
root.refetchTable("NUMEROTATION_AUTO");
|
|
|
2471 |
root.getSchema().updateVersion();
|
|
|
2472 |
}
|
|
|
2473 |
|
|
|
2474 |
if (!root.getTable("ECRITURE").contains("LETTRAGE_PARTIEL")) {
|
|
|
2475 |
final AlterTable alterEcriture = new AlterTable(root.getTable("ECRITURE"));
|
|
|
2476 |
alterEcriture.addVarCharColumn("LETTRAGE_PARTIEL", 256);
|
|
|
2477 |
root.getBase().getDataSource().execute(alterEcriture.asString());
|
|
|
2478 |
root.refetchTable("ECRITURE");
|
|
|
2479 |
root.getSchema().updateVersion();
|
|
|
2480 |
}
|
|
|
2481 |
|
|
|
2482 |
SQLTable tableFactureF = root.getTable("FACTURE_FOURNISSEUR");
|
|
|
2483 |
if (!tableFactureF.contains("ID_AVOIR_FOURNISSEUR_2")) {
|
|
|
2484 |
final AlterTable alter = new AlterTable(tableFactureF);
|
|
|
2485 |
final SQLTable tableAvoirF = tableVF.getDBRoot().getTable("AVOIR_FOURNISSEUR");
|
|
|
2486 |
alter.addForeignColumn("ID_AVOIR_FOURNISSEUR_2", tableAvoirF);
|
|
|
2487 |
tableFactureF.getBase().getDataSource().execute(alter.asString());
|
|
|
2488 |
tableFactureF.getSchema().updateVersion();
|
|
|
2489 |
tableVF.fetchFields();
|
|
|
2490 |
}
|
|
|
2491 |
|
182 |
ilm |
2492 |
SQLTable tableNumAuto = root.getTable("NUMEROTATION_AUTO");
|
|
|
2493 |
if (!tableNumAuto.contains("ARTICLE_FORMAT")) {
|
|
|
2494 |
|
|
|
2495 |
final AlterTable alterNumero = new AlterTable(tableNumAuto);
|
|
|
2496 |
alterNumero.addVarCharColumn("ARTICLE_FORMAT", 128);
|
|
|
2497 |
alterNumero.addIntegerColumn("ARTICLE_START", 1);
|
|
|
2498 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
|
|
2499 |
root.refetchTable("NUMEROTATION_AUTO");
|
|
|
2500 |
root.getSchema().updateVersion();
|
|
|
2501 |
}
|
|
|
2502 |
|
|
|
2503 |
if (!tableArticle.contains("VIRTUEL")) {
|
|
|
2504 |
|
|
|
2505 |
final SQLCreateTable createTableDeclinaisonCouleur = new SQLCreateTable(root, "ARTICLE_DECLINAISON_COULEUR");
|
|
|
2506 |
createTableDeclinaisonCouleur.addVarCharColumn("NOM", 256);
|
|
|
2507 |
root.getBase().getDataSource().execute(createTableDeclinaisonCouleur.asString());
|
|
|
2508 |
InstallationPanel.insertUndef(createTableDeclinaisonCouleur);
|
|
|
2509 |
root.refetchTable("ARTICLE_DECLINAISON_COULEUR");
|
|
|
2510 |
root.getSchema().updateVersion();
|
|
|
2511 |
|
|
|
2512 |
final SQLCreateTable createTableDeclinaisonTaille = new SQLCreateTable(root, "ARTICLE_DECLINAISON_TAILLE");
|
|
|
2513 |
createTableDeclinaisonTaille.addVarCharColumn("NOM", 256);
|
|
|
2514 |
root.getBase().getDataSource().execute(createTableDeclinaisonTaille.asString());
|
|
|
2515 |
InstallationPanel.insertUndef(createTableDeclinaisonTaille);
|
|
|
2516 |
root.refetchTable("ARTICLE_DECLINAISON_TAILLE");
|
|
|
2517 |
root.getSchema().updateVersion();
|
|
|
2518 |
|
|
|
2519 |
final AlterTable alter = new AlterTable(tableArticle);
|
|
|
2520 |
alter.addBooleanColumn("VIRTUEL", false, false);
|
|
|
2521 |
alter.addForeignColumn("ID_ARTICLE_VIRTUEL_PERE", tableArticle);
|
|
|
2522 |
alter.addForeignColumn("ID_ARTICLE_DECLINAISON_TAILLE", root.getTable("ARTICLE_DECLINAISON_TAILLE"));
|
|
|
2523 |
alter.addForeignColumn("ID_ARTICLE_DECLINAISON_COULEUR", root.getTable("ARTICLE_DECLINAISON_COULEUR"));
|
|
|
2524 |
tableArticle.getBase().getDataSource().execute(alter.asString());
|
|
|
2525 |
tableArticle.getSchema().updateVersion();
|
|
|
2526 |
tableArticle.fetchFields();
|
|
|
2527 |
}
|
|
|
2528 |
|
|
|
2529 |
for (String string : achatItems) {
|
|
|
2530 |
boolean alter = false;
|
|
|
2531 |
SQLTable tableItems = root.getTable(string);
|
|
|
2532 |
final AlterTable t = new AlterTable(tableItems);
|
|
|
2533 |
|
|
|
2534 |
if (!tableItems.getFieldsName().contains("ID_ARTICLE_DECLINAISON_TAILLE")) {
|
|
|
2535 |
t.addForeignColumn("ID_ARTICLE_DECLINAISON_TAILLE", root.getTable("ARTICLE_DECLINAISON_TAILLE"));
|
|
|
2536 |
alter = true;
|
|
|
2537 |
}
|
|
|
2538 |
if (!tableItems.getFieldsName().contains("ID_ARTICLE_DECLINAISON_COULEUR")) {
|
|
|
2539 |
t.addForeignColumn("ID_ARTICLE_DECLINAISON_COULEUR", root.getTable("ARTICLE_DECLINAISON_COULEUR"));
|
|
|
2540 |
alter = true;
|
|
|
2541 |
}
|
|
|
2542 |
|
|
|
2543 |
if (alter) {
|
|
|
2544 |
tableItems.getBase().getDataSource().execute(t.asString());
|
|
|
2545 |
tableItems.getSchema().updateVersion();
|
|
|
2546 |
tableItems.fetchFields();
|
|
|
2547 |
}
|
|
|
2548 |
}
|
|
|
2549 |
|
|
|
2550 |
for (String tableName : tableElementWithTable) {
|
|
|
2551 |
final SQLTable tableToDecl = root.getTable(tableName);
|
|
|
2552 |
boolean alter = false;
|
|
|
2553 |
|
|
|
2554 |
final AlterTable alterDecl = new AlterTable(tableToDecl);
|
|
|
2555 |
if (!tableToDecl.getFieldsName().contains("ID_ARTICLE_DECLINAISON_TAILLE")) {
|
|
|
2556 |
alterDecl.addForeignColumn("ID_ARTICLE_DECLINAISON_TAILLE", root.getTable("ARTICLE_DECLINAISON_TAILLE"));
|
|
|
2557 |
alter = true;
|
|
|
2558 |
}
|
|
|
2559 |
if (!tableToDecl.getFieldsName().contains("ID_ARTICLE_DECLINAISON_COULEUR")) {
|
|
|
2560 |
alterDecl.addForeignColumn("ID_ARTICLE_DECLINAISON_COULEUR", root.getTable("ARTICLE_DECLINAISON_COULEUR"));
|
|
|
2561 |
alter = true;
|
|
|
2562 |
}
|
|
|
2563 |
|
|
|
2564 |
if (alter) {
|
|
|
2565 |
tableToDecl.getBase().getDataSource().execute(alterDecl.asString());
|
|
|
2566 |
tableToDecl.getSchema().updateVersion();
|
|
|
2567 |
tableToDecl.fetchFields();
|
|
|
2568 |
}
|
|
|
2569 |
}
|
|
|
2570 |
|
|
|
2571 |
// Création de la table Tarif promotion
|
|
|
2572 |
if (!root.contains("TARIF_PROMOTION")) {
|
|
|
2573 |
|
|
|
2574 |
SQLCreateTable createTarif = new SQLCreateTable(root, "TARIF_PROMOTION");
|
|
|
2575 |
createTarif.addVarCharColumn("NOM", 256);
|
|
|
2576 |
createTarif.addColumn("START", "date");
|
|
|
2577 |
createTarif.addColumn("END", "date");
|
|
|
2578 |
root.getBase().getDataSource().execute(createTarif.asString());
|
|
|
2579 |
InstallationPanel.insertUndef(createTarif);
|
|
|
2580 |
tableDevis.getSchema().updateVersion();
|
|
|
2581 |
root.refetchTable(createTarif.getName());
|
|
|
2582 |
}
|
|
|
2583 |
|
|
|
2584 |
// Création de la table article Tarif promotion
|
|
|
2585 |
if (!root.contains("ARTICLE_TARIF_PROMOTION")) {
|
|
|
2586 |
|
|
|
2587 |
SQLCreateTable createTarif = new SQLCreateTable(root, "ARTICLE_TARIF_PROMOTION");
|
|
|
2588 |
createTarif.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
|
|
2589 |
createTarif.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
|
|
2590 |
createTarif.addForeignColumn("ID_TARIF_PROMOTION", root.findTable("TARIF_PROMOTION", true));
|
|
|
2591 |
createTarif.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
|
|
2592 |
createTarif.addIntegerColumn("QTE", 1);
|
|
|
2593 |
createTarif.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
|
|
2594 |
createTarif.addDecimalColumn("PV_TTC", 16, 6, BigDecimal.ZERO, false);
|
|
|
2595 |
createTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
|
|
2596 |
createTarif.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
|
|
2597 |
createTarif.addDecimalColumn("PRIX_METRIQUE_VT_3", 16, 6, BigDecimal.ZERO, false);
|
|
|
2598 |
root.getBase().getDataSource().execute(createTarif.asString());
|
|
|
2599 |
InstallationPanel.insertUndef(createTarif);
|
|
|
2600 |
tableDevis.getSchema().updateVersion();
|
|
|
2601 |
root.refetchTable(createTarif.getName());
|
|
|
2602 |
}
|
|
|
2603 |
|
|
|
2604 |
if (!root.contains("TAXE_CATEGORIE_COMPTABLE")) {
|
|
|
2605 |
|
|
|
2606 |
final SQLCreateTable createTableTaxeCat = new SQLCreateTable(root, "TAXE_CATEGORIE_COMPTABLE");
|
|
|
2607 |
createTableTaxeCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
|
|
2608 |
createTableTaxeCat.addForeignColumn("ID_TAXE", root.getTable("TAXE"));
|
|
|
2609 |
createTableTaxeCat.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
|
|
2610 |
createTableTaxeCat.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
|
|
2611 |
|
|
|
2612 |
try {
|
|
|
2613 |
root.getBase().getDataSource().execute(createTableTaxeCat.asString());
|
|
|
2614 |
InstallationPanel.insertUndef(createTableTaxeCat);
|
|
|
2615 |
root.refetchTable("TAXE_CATEGORIE_COMPTABLE");
|
|
|
2616 |
root.getSchema().updateVersion();
|
|
|
2617 |
} catch (SQLException ex) {
|
|
|
2618 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TAXE_CATEGORIE_COMPTABLE", ex);
|
|
|
2619 |
}
|
|
|
2620 |
|
|
|
2621 |
}
|
|
|
2622 |
|
|
|
2623 |
|
|
|
2624 |
if (!root.contains("LOT_RECEPTION")) {
|
|
|
2625 |
SQLCreateTable createLotReception = new SQLCreateTable(root, "LOT_RECEPTION");
|
|
|
2626 |
createLotReception.addDateAndTimeColumn("DATE_RECEPTION");
|
|
|
2627 |
createLotReception.addVarCharColumn("FOURNISSEUR", 256);
|
|
|
2628 |
createLotReception.addVarCharColumn("ARTICLE", 256);
|
|
|
2629 |
createLotReception.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
|
|
2630 |
createLotReception.addForeignColumn("ID_DEPOT_STOCK", root.findTable("DEPOT_STOCK", true));
|
|
|
2631 |
createLotReception.addDecimalColumn("QUANTITE", 16, 6, BigDecimal.ONE, false);
|
|
|
2632 |
createLotReception.addVarCharColumn("NUMERO_LOT", 256);
|
|
|
2633 |
createLotReception.addVarCharColumn("NUMERO_SERIE", 256);
|
|
|
2634 |
createLotReception.addDateAndTimeColumn("DLC");
|
|
|
2635 |
createLotReception.addDateAndTimeColumn("DLUO");
|
|
|
2636 |
createLotReception.addForeignColumn("ID_BON_RECEPTION_ELEMENT", root.findTable("BON_RECEPTION_ELEMENT", true));
|
|
|
2637 |
root.getBase().getDataSource().execute(createLotReception.asString());
|
|
|
2638 |
InstallationPanel.insertUndef(createLotReception);
|
|
|
2639 |
|
|
|
2640 |
|
|
|
2641 |
SQLCreateTable createLotLivraison = new SQLCreateTable(root, "LOT_LIVRAISON");
|
|
|
2642 |
createLotLivraison.addDateAndTimeColumn("DATE_LIVRAISON");
|
|
|
2643 |
createLotLivraison.addVarCharColumn("CLIENT", 256);
|
|
|
2644 |
createLotLivraison.addVarCharColumn("ARTICLE", 256);
|
|
|
2645 |
createLotLivraison.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
|
|
2646 |
createLotLivraison.addForeignColumn("ID_DEPOT_STOCK", root.findTable("DEPOT_STOCK", true));
|
|
|
2647 |
createLotLivraison.addDecimalColumn("QUANTITE", 16, 6, BigDecimal.ONE, false);
|
|
|
2648 |
createLotLivraison.addVarCharColumn("NUMERO_LOT", 256);
|
|
|
2649 |
createLotLivraison.addVarCharColumn("NUMERO_SERIE", 256);
|
|
|
2650 |
createLotLivraison.addDateAndTimeColumn("DLC");
|
|
|
2651 |
createLotLivraison.addDateAndTimeColumn("DLUO");
|
|
|
2652 |
createLotLivraison.addForeignColumn("ID_BON_DE_LIVRAISON_ELEMENT", root.findTable("BON_DE_LIVRAISON_ELEMENT", true));
|
|
|
2653 |
root.getBase().getDataSource().execute(createLotLivraison.asString());
|
|
|
2654 |
InstallationPanel.insertUndef(createLotLivraison);
|
|
|
2655 |
|
|
|
2656 |
}
|
|
|
2657 |
|
|
|
2658 |
if (!root.contains("LOT")) {
|
|
|
2659 |
SQLCreateTable createLot = new SQLCreateTable(root, "LOT");
|
|
|
2660 |
createLot.addForeignColumn("ID_STOCK", root.findTable("STOCK", true));
|
|
|
2661 |
createLot.addDecimalColumn("QUANTITE", 16, 6, BigDecimal.ONE, false);
|
|
|
2662 |
createLot.addVarCharColumn("NUMERO_LOT", 256);
|
|
|
2663 |
createLot.addVarCharColumn("NUMERO_SERIE", 256);
|
|
|
2664 |
createLot.addDateAndTimeColumn("DLC");
|
|
|
2665 |
createLot.addDateAndTimeColumn("DLUO");
|
|
|
2666 |
root.getBase().getDataSource().execute(createLot.asString());
|
|
|
2667 |
InstallationPanel.insertUndef(createLot);
|
|
|
2668 |
|
|
|
2669 |
SQLCreateTable createTransfertStock = new SQLCreateTable(root, "TRANSFERT_STOCK");
|
|
|
2670 |
createTransfertStock.addDateAndTimeColumn("DATE");
|
|
|
2671 |
createTransfertStock.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
|
|
2672 |
createTransfertStock.addForeignColumn("ID_DEPOT_STOCK_SOURCE", root.findTable("DEPOT_STOCK", true));
|
|
|
2673 |
createTransfertStock.addForeignColumn("ID_DEPOT_STOCK_DEST", root.findTable("DEPOT_STOCK", true));
|
|
|
2674 |
createTransfertStock.addDecimalColumn("QUANTITE", 16, 6, BigDecimal.ONE, false);
|
|
|
2675 |
createTransfertStock.addVarCharColumn("NUMEROS_SERIE", 50000);
|
|
|
2676 |
createTransfertStock.addVarCharColumn("NUMEROS_LOT", 50000);
|
|
|
2677 |
createTransfertStock.addVarCharColumn("CONTEXTE", 256);
|
|
|
2678 |
|
|
|
2679 |
root.getBase().getDataSource().execute(createTransfertStock.asString());
|
|
|
2680 |
InstallationPanel.insertUndef(createTransfertStock);
|
|
|
2681 |
|
|
|
2682 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
|
|
2683 |
alterArticle.addBooleanColumn("NUMERO_LOT_REQUIS", false, false);
|
|
|
2684 |
alterArticle.addBooleanColumn("NUMERO_SERIE_REQUIS", false, false);
|
|
|
2685 |
alterArticle.addBooleanColumn("DLC_REQUIS", false, false);
|
|
|
2686 |
alterArticle.addBooleanColumn("DLUO_REQUIS", false, false);
|
|
|
2687 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
|
|
2688 |
tableArticle.getSchema().updateVersion();
|
|
|
2689 |
tableArticle.fetchFields();
|
|
|
2690 |
|
|
|
2691 |
final AlterTable alterBonReceptionElement = new AlterTable(root.getTable("BON_RECEPTION_ELEMENT"));
|
|
|
2692 |
alterBonReceptionElement.addForeignColumn("ID_LOT", createLot);
|
|
|
2693 |
tableArticle.getBase().getDataSource().execute(alterBonReceptionElement.asString());
|
|
|
2694 |
|
|
|
2695 |
final AlterTable alterBonLivraisonElement = new AlterTable(root.getTable("BON_DE_LIVRAISON"));
|
|
|
2696 |
alterBonLivraisonElement.addForeignColumn("ID_LOT", createLot);
|
|
|
2697 |
tableArticle.getBase().getDataSource().execute(alterBonLivraisonElement.asString());
|
|
|
2698 |
tableArticle.getSchema().updateVersion();
|
|
|
2699 |
root.refetch();
|
|
|
2700 |
}
|
|
|
2701 |
|
|
|
2702 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
|
|
2703 |
SQLTable tableModele = root.getTable("MODELE");
|
|
|
2704 |
if (!tableBR.contains("ID_MODELE")) {
|
|
|
2705 |
AlterTable a = new AlterTable(tableBR);
|
|
|
2706 |
a.addForeignColumn("ID_MODELE", tableModele);
|
|
|
2707 |
root.getBase().getDataSource().execute(a.asString());
|
|
|
2708 |
tableBR.getSchema().updateVersion();
|
|
|
2709 |
root.refetchTable(tableBR.getName());
|
|
|
2710 |
}
|
|
|
2711 |
|
|
|
2712 |
SQLTable typeModele = tableModele.getForeignTable("ID_TYPE_MODELE");
|
|
|
2713 |
SQLSelect sel = new SQLSelect();
|
|
|
2714 |
sel.addSelect(typeModele.getKey());
|
|
|
2715 |
sel.setWhere(new Where(typeModele.getField("TABLE"), "=", "BON_RECEPTION"));
|
|
|
2716 |
List<SQLRow> l = SQLRowListRSH.execute(sel);
|
|
|
2717 |
if (l.isEmpty()) {
|
|
|
2718 |
SQLRowValues rowVals = new SQLRowValues(typeModele);
|
|
|
2719 |
rowVals.put("TABLE", "BON_RECEPTION");
|
|
|
2720 |
rowVals.put("NOM", "Bon de réception");
|
|
|
2721 |
rowVals.put("DEFAULT_MODELE", "BonReception");
|
|
|
2722 |
rowVals.commit();
|
|
|
2723 |
}
|
|
|
2724 |
// Fix undefined
|
|
|
2725 |
new SetFKDefault(root.getDBSystemRoot()).changeAll(root);
|
|
|
2726 |
List<SQLUpdate> ups = new ArrayList<>();
|
|
|
2727 |
if (userT.getUndefinedIDNumber() != null) {
|
|
|
2728 |
for (SQLField userF : root.getDBSystemRoot().getGraph().getReferentKeys(userT)) {
|
|
|
2729 |
if (userF.getTable().getDBRoot() == root) {
|
|
|
2730 |
SQLUpdate up = new SQLUpdate(Where.isNull(userF));
|
|
|
2731 |
up.add(userF, userT.getUndefinedIDNumber());
|
|
|
2732 |
ups.add(up);
|
|
|
2733 |
}
|
|
|
2734 |
}
|
|
|
2735 |
}
|
|
|
2736 |
if (!ups.isEmpty()) {
|
|
|
2737 |
SQLUpdate.executeMultipleWithBatch(root.getDBSystemRoot(), ups);
|
|
|
2738 |
System.err.println("Updater_1_5.update() fixed " + ups.size() + " error(s) on FK to USER_COMMON");
|
|
|
2739 |
} else {
|
|
|
2740 |
System.err.println("Updater_1_5.update() no error on FK to USER_COMMON");
|
|
|
2741 |
}
|
142 |
ilm |
2742 |
}
|
|
|
2743 |
|
174 |
ilm |
2744 |
public static void initStock(SQLRow rowArticle, int idDepot) {
|
156 |
ilm |
2745 |
|
|
|
2746 |
SQLSelect selStock = new SQLSelect();
|
174 |
ilm |
2747 |
selStock.addSelectStar(rowArticle.getTable().getTable("STOCK"));
|
|
|
2748 |
selStock.setWhere(new Where(rowArticle.getTable().getTable("STOCK").getField("ID_ARTICLE"), "=", rowArticle.getID()));
|
156 |
ilm |
2749 |
List<SQLRow> rowsStock = SQLRowListRSH.execute(selStock);
|
|
|
2750 |
Map<Integer, SQLRow> initedDepot = new HashMap<>();
|
|
|
2751 |
for (SQLRow sqlRow : rowsStock) {
|
|
|
2752 |
initedDepot.put(sqlRow.getForeignID("ID_DEPOT_STOCK"), sqlRow);
|
|
|
2753 |
}
|
|
|
2754 |
|
|
|
2755 |
List<StockItem> stockItems = new ArrayList<StockItem>();
|
174 |
ilm |
2756 |
try {
|
|
|
2757 |
if (!initedDepot.keySet().contains(idDepot)) {
|
|
|
2758 |
SQLRowValues rowVals = new SQLRowValues(rowArticle.getTable().getTable("STOCK"));
|
|
|
2759 |
rowVals.put("ID_ARTICLE", rowArticle.getID());
|
|
|
2760 |
rowVals.put("ID_DEPOT_STOCK", idDepot);
|
156 |
ilm |
2761 |
|
174 |
ilm |
2762 |
SQLRow rowStock = rowVals.commit();
|
|
|
2763 |
if ((rowArticle.getObject("ID_DEPOT_STOCK") == null || rowArticle.isForeignEmpty("ID_DEPOT_STOCK")) && idDepot == DepotStockSQLElement.DEFAULT_ID) {
|
|
|
2764 |
rowArticle.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
|
|
2765 |
} else if (idDepot == rowArticle.getForeignID("ID_DEPOT_STOCK")) {
|
|
|
2766 |
rowArticle.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).commit();
|
|
|
2767 |
}
|
|
|
2768 |
stockItems.add(new StockItem(rowArticle, rowStock));
|
156 |
ilm |
2769 |
|
174 |
ilm |
2770 |
} else {
|
|
|
2771 |
SQLRow rowExisting = initedDepot.get(idDepot);
|
|
|
2772 |
if ((rowArticle.getObject("ID_DEPOT_STOCK") == null || rowArticle.isForeignEmpty("ID_DEPOT_STOCK")) && idDepot == DepotStockSQLElement.DEFAULT_ID) {
|
|
|
2773 |
rowArticle.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
|
|
2774 |
} else if (idDepot == rowArticle.getForeignID("ID_DEPOT_STOCK")) {
|
|
|
2775 |
rowArticle.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).commit();
|
156 |
ilm |
2776 |
}
|
174 |
ilm |
2777 |
stockItems.add(new StockItem(rowArticle, rowExisting));
|
|
|
2778 |
}
|
|
|
2779 |
} catch (SQLException e) {
|
|
|
2780 |
ExceptionHandler.handle("Erreur lors de l'initialisation du stock de l'article", e);
|
|
|
2781 |
}
|
|
|
2782 |
|
|
|
2783 |
if (rowArticle.getReferentRows(rowArticle.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")).size() > 0) {
|
|
|
2784 |
ComposedItemStockUpdater up = new ComposedItemStockUpdater(rowArticle.getTable().getDBRoot(), stockItems);
|
|
|
2785 |
try {
|
|
|
2786 |
up.updateNomenclature(stockItems);
|
156 |
ilm |
2787 |
} catch (SQLException e) {
|
174 |
ilm |
2788 |
ExceptionHandler.handle("Erreur lors de l'actualisation du stock!", e);
|
156 |
ilm |
2789 |
}
|
|
|
2790 |
}
|
|
|
2791 |
}
|
|
|
2792 |
|
174 |
ilm |
2793 |
public static void initStock(SQLRow row) {
|
|
|
2794 |
int foreignID = DepotStockSQLElement.DEFAULT_ID;
|
|
|
2795 |
if (row.getObject("ID_DEPOT_STOCK") != null && !row.isForeignEmpty("ID_DEPOT_STOCK")) {
|
|
|
2796 |
foreignID = row.getForeignID("ID_DEPOT_STOCK");
|
|
|
2797 |
}
|
|
|
2798 |
initStock(row, foreignID);
|
|
|
2799 |
}
|
|
|
2800 |
|
151 |
ilm |
2801 |
public static void exec(final AlterTable alter) throws SQLException {
|
|
|
2802 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
|
|
2803 |
alter.getTable().getSchema().updateVersion();
|
|
|
2804 |
alter.getTable().fetchFields();
|
|
|
2805 |
}
|
142 |
ilm |
2806 |
}
|