Line 27... |
Line 27... |
27 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
27 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
28 |
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
|
28 |
import org.openconcerto.erp.core.supplychain.stock.element.ComposedItemStockUpdater;
|
29 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
29 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
30 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
|
30 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
|
31 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
31 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
- |
|
32 |
import org.openconcerto.sql.model.AliasedTable;
|
32 |
import org.openconcerto.sql.model.DBRoot;
|
33 |
import org.openconcerto.sql.model.DBRoot;
|
33 |
import org.openconcerto.sql.model.SQLField;
|
34 |
import org.openconcerto.sql.model.SQLField;
|
34 |
import org.openconcerto.sql.model.SQLField.Properties;
|
35 |
import org.openconcerto.sql.model.SQLField.Properties;
|
35 |
import org.openconcerto.sql.model.SQLName;
|
36 |
import org.openconcerto.sql.model.SQLName;
|
36 |
import org.openconcerto.sql.model.SQLRow;
|
37 |
import org.openconcerto.sql.model.SQLRow;
|
Line 78... |
Line 79... |
78 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
79 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
79 |
tableCompte.getSchema().updateVersion();
|
80 |
tableCompte.getSchema().updateVersion();
|
80 |
tableCompte.fetchFields();
|
81 |
tableCompte.fetchFields();
|
81 |
}
|
82 |
}
|
82 |
|
83 |
|
- |
|
84 |
// Champ obsolete sur compte
|
- |
|
85 |
SQLTable tableTitre = root.getTable("TITRE_PERSONNEL");
|
- |
|
86 |
if (!tableTitre.contains("OBSOLETE")) {
|
- |
|
87 |
final AlterTable alter = new AlterTable(tableTitre);
|
- |
|
88 |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
- |
|
89 |
tableTitre.getBase().getDataSource().execute(alter.asString());
|
- |
|
90 |
tableTitre.getSchema().updateVersion();
|
- |
|
91 |
tableTitre.fetchFields();
|
- |
|
92 |
final UpdateBuilder updBuilder = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("OBSOLETE"), Boolean.TRUE);
|
- |
|
93 |
updBuilder.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mlle"));
|
- |
|
94 |
tableTitre.getBase().getDataSource().execute(updBuilder.asString());
|
- |
|
95 |
final UpdateBuilder updBuilder2 = new UpdateBuilder(tableTitre).setObject(tableTitre.getField("CODE"), "M.");
|
- |
|
96 |
updBuilder2.setWhere(new Where(tableTitre.getField("CODE"), "=", "Mr"));
|
- |
|
97 |
|
- |
|
98 |
tableTitre.getBase().getDataSource().execute(updBuilder2.asString());
|
- |
|
99 |
|
- |
|
100 |
}
|
- |
|
101 |
|
83 |
// Transaction du solde
|
102 |
// Transaction du solde
|
84 |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
|
103 |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
|
85 |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
|
104 |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
|
86 |
createTable.addForeignColumn("CLIENT");
|
105 |
createTable.addForeignColumn("CLIENT");
|
87 |
createTable.addDateAndTimeColumn("DATE");
|
106 |
createTable.addDateAndTimeColumn("DATE");
|
Line 229... |
Line 248... |
229 |
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
|
248 |
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
|
230 |
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
|
249 |
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
|
231 |
createTable.addVarCharColumn("TAG", 128);
|
250 |
createTable.addVarCharColumn("TAG", 128);
|
232 |
createTable.addIntegerColumn("VERSION", 0);
|
251 |
createTable.addIntegerColumn("VERSION", 0);
|
233 |
createTable.addVarCharColumn("HASH", 32);
|
252 |
createTable.addVarCharColumn("HASH", 32);
|
234 |
|
- |
|
- |
|
253 |
createTable.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false);
|
235 |
try {
|
254 |
try {
|
236 |
root.getBase().getDataSource().execute(createTable.asString());
|
255 |
root.getBase().getDataSource().execute(createTable.asString());
|
237 |
InstallationPanel.insertUndef(createTable);
|
256 |
InstallationPanel.insertUndef(createTable);
|
238 |
root.refetchTable("ATTACHMENT");
|
257 |
root.refetchTable("ATTACHMENT");
|
239 |
root.getSchema().updateVersion();
|
258 |
root.getSchema().updateVersion();
|
Line 265... |
Line 284... |
265 |
alter.addVarCharColumn("INFOS", 8000);
|
284 |
alter.addVarCharColumn("INFOS", 8000);
|
266 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
285 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
267 |
tableAttachment.getSchema().updateVersion();
|
286 |
tableAttachment.getSchema().updateVersion();
|
268 |
tableAttachment.fetchFields();
|
287 |
tableAttachment.fetchFields();
|
269 |
}
|
288 |
}
|
- |
|
289 |
if (!tableAttachment.contains("ENCRYPTED")) {
|
- |
|
290 |
final AlterTable alter = new AlterTable(tableAttachment);
|
- |
|
291 |
alter.addBooleanColumn("ENCRYPTED", Boolean.FALSE, false);
|
- |
|
292 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
- |
|
293 |
tableAttachment.getSchema().updateVersion();
|
- |
|
294 |
tableAttachment.fetchFields();
|
270 |
|
295 |
}
|
271 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
296 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
272 |
for (String string : gedTable) {
|
297 |
for (String string : gedTable) {
|
273 |
SQLTable tableGED = root.getTable(string);
|
298 |
SQLTable tableGED = root.getTable(string);
|
274 |
if (!tableGED.contains("ATTACHMENTS")) {
|
299 |
if (!tableGED.contains("ATTACHMENTS")) {
|
275 |
final AlterTable alter = new AlterTable(tableGED);
|
300 |
final AlterTable alter = new AlterTable(tableGED);
|
Line 407... |
Line 432... |
407 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
432 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
408 |
root.refetchTable(tableCmdFElt.getName());
|
433 |
root.refetchTable(tableCmdFElt.getName());
|
409 |
root.getSchema().updateVersion();
|
434 |
root.getSchema().updateVersion();
|
410 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
435 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
411 |
build.setObject("RECU", Boolean.FALSE);
|
436 |
build.setObject("RECU", Boolean.FALSE);
|
412 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
- |
|
413 |
|
437 |
|
414 |
Where w = Where.createRaw(tableCmdFElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdFElt.getField("QTE").getQuotedName() + "*"
|
438 |
Where w = Where.createRaw(tableCmdFElt.getField("QTE_RECUE").getQuotedName() + " < (" + tableCmdFElt.getField("QTE").getQuotedName() + "*"
|
415 |
+ tableCmdFElt.getField("QTE_UNITAIRE").getQuotedName() + ")", tableCmdFElt.getField("QTE_UNITAIRE"), tableCmdFElt.getField("QTE"), tableCmdFElt.getField("QTE_RECUE"));
|
439 |
+ tableCmdFElt.getField("QTE_UNITAIRE").getQuotedName() + ")", tableCmdFElt.getField("QTE_UNITAIRE"), tableCmdFElt.getField("QTE"), tableCmdFElt.getField("QTE_RECUE"));
|
416 |
build.setWhere(w.or(new Where(tableCmdFElt.getKey(), "=", 1)));
|
440 |
build.setWhere(w.or(new Where(tableCmdFElt.getKey(), "=", 1)));
|
417 |
System.err.println(build.asString());
|
441 |
System.err.println(build.asString());
|
Line 2284... |
Line 2308... |
2284 |
alter.addForeignColumn("ID_DEPOT_STOCK", tableDepotStock);
|
2308 |
alter.addForeignColumn("ID_DEPOT_STOCK", tableDepotStock);
|
2285 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
2309 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
2286 |
tableEtatStock.getSchema().updateVersion();
|
2310 |
tableEtatStock.getSchema().updateVersion();
|
2287 |
tableEtatStock.fetchFields();
|
2311 |
tableEtatStock.fetchFields();
|
2288 |
}
|
2312 |
}
|
- |
|
2313 |
|
- |
|
2314 |
// Création de la table Agence
|
- |
|
2315 |
if (!root.contains("AGENCE")) {
|
- |
|
2316 |
SQLCreateTable createAgence = new SQLCreateTable(root, "AGENCE");
|
- |
|
2317 |
createAgence.addVarCharColumn("DESIGNATION", 256);
|
- |
|
2318 |
createAgence.addVarCharColumn("TEL_1", 256);
|
- |
|
2319 |
createAgence.addVarCharColumn("EMAIL", 256);
|
- |
|
2320 |
createAgence.addVarCharColumn("FAX", 256);
|
- |
|
2321 |
createAgence.addForeignColumn("ID_CLIENT", root.findTable("CLIENT"));
|
- |
|
2322 |
createAgence.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE"));
|
- |
|
2323 |
|
- |
|
2324 |
try {
|
- |
|
2325 |
// test
|
- |
|
2326 |
root.getBase().getDataSource().execute(createAgence.asString());
|
- |
|
2327 |
root.refetchTable("AGENCE");
|
- |
|
2328 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("AGENCE"));
|
- |
|
2329 |
SQLRow rowInserted = rowVals.commit();
|
- |
|
2330 |
SQLTable.setUndefID(root.getSchema(), "AGENCE", rowInserted.getID());
|
- |
|
2331 |
tableDevis.getSchema().updateVersion();
|
- |
|
2332 |
} catch (SQLException ex) {
|
- |
|
2333 |
throw new IllegalStateException("Erreur lors de la création de la table AGENCE", ex);
|
- |
|
2334 |
}
|
- |
|
2335 |
}
|
- |
|
2336 |
// Tarification client par famille article
|
- |
|
2337 |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) {
|
- |
|
2338 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT");
|
- |
|
2339 |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
- |
|
2340 |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
- |
|
2341 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
- |
|
2342 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
- |
|
2343 |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
- |
|
2344 |
try {
|
- |
|
2345 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
- |
|
2346 |
InstallationPanel.insertUndef(createTableQtyTarif);
|
- |
|
2347 |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT");
|
- |
|
2348 |
root.getSchema().updateVersion();
|
- |
|
2349 |
} catch (SQLException ex) {
|
- |
|
2350 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex);
|
- |
|
2351 |
}
|
- |
|
2352 |
}
|
- |
|
2353 |
|
- |
|
2354 |
// Tarification client par famille article
|
- |
|
2355 |
if (root.getTable("TARIF_FAMILLE_ARTICLE_CLIENT") == null) {
|
- |
|
2356 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_FAMILLE_ARTICLE_CLIENT");
|
- |
|
2357 |
createTableQtyTarif.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
- |
|
2358 |
createTableQtyTarif.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
- |
|
2359 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
- |
|
2360 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
- |
|
2361 |
// createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
- |
|
2362 |
try {
|
- |
|
2363 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
- |
|
2364 |
InstallationPanel.insertUndef(createTableQtyTarif);
|
- |
|
2365 |
root.refetchTable("TARIF_FAMILLE_ARTICLE_CLIENT");
|
- |
|
2366 |
root.getSchema().updateVersion();
|
- |
|
2367 |
} catch (SQLException ex) {
|
- |
|
2368 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_FAMILLE_ARTICLE_CLIENT", ex);
|
- |
|
2369 |
}
|
- |
|
2370 |
}
|
- |
|
2371 |
|
- |
|
2372 |
SQLTable tableAvoirC = root.getTable("AVOIR_CLIENT");
|
- |
|
2373 |
if (!tableAvoirC.contains("ID_TAXE_PORT")) {
|
- |
|
2374 |
final AlterTable alterB = new AlterTable(tableAvoirC);
|
- |
|
2375 |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
- |
|
2376 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
2377 |
root.refetchTable(tableAvoirC.getName());
|
- |
|
2378 |
root.getSchema().updateVersion();
|
- |
|
2379 |
}
|
- |
|
2380 |
|
- |
|
2381 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
- |
|
2382 |
if (!tableVF.contains("ID_FACTURATION_COMMANDE_CLIENT")) {
|
- |
|
2383 |
final AlterTable alter = new AlterTable(tableVF);
|
- |
|
2384 |
final SQLTable tableFacturationCommandeClient = tableVF.getDBRoot().getTable("FACTURATION_COMMANDE_CLIENT");
|
- |
|
2385 |
alter.addForeignColumn("ID_FACTURATION_COMMANDE_CLIENT", tableFacturationCommandeClient);
|
- |
|
2386 |
tableVF.getBase().getDataSource().execute(alter.asString());
|
- |
|
2387 |
tableVF.getSchema().updateVersion();
|
- |
|
2388 |
tableVF.fetchFields();
|
- |
|
2389 |
|
- |
|
2390 |
// update ID_FACTURATION_COMMANDE
|
- |
|
2391 |
UpdateBuilder builder = new UpdateBuilder(tableVF);
|
- |
|
2392 |
AliasedTable ref = new AliasedTable(tableFacturationCommandeClient, "tf");
|
- |
|
2393 |
builder.addBackwardVirtualJoin(ref, "ID_SAISIE_VENTE_FACTURE");
|
- |
|
2394 |
builder.setFromVirtualJoinField("ID_FACTURATION_COMMANDE_CLIENT", "tf", tableFacturationCommandeClient.getKey().getName());
|
- |
|
2395 |
tableVF.getBase().getDataSource().execute(builder.asString());
|
- |
|
2396 |
}
|
- |
|
2397 |
if (!root.getTable("NUMEROTATION_AUTO").contains("CODE_LETTRAGE_PARTIEL")) {
|
- |
|
2398 |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO"));
|
- |
|
2399 |
alterNumero.addVarCharColumn("CODE_LETTRAGE_PARTIEL", 256);
|
- |
|
2400 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
- |
|
2401 |
root.refetchTable("NUMEROTATION_AUTO");
|
- |
|
2402 |
root.getSchema().updateVersion();
|
- |
|
2403 |
}
|
- |
|
2404 |
|
- |
|
2405 |
if (!root.getTable("ECRITURE").contains("LETTRAGE_PARTIEL")) {
|
- |
|
2406 |
final AlterTable alterEcriture = new AlterTable(root.getTable("ECRITURE"));
|
- |
|
2407 |
alterEcriture.addVarCharColumn("LETTRAGE_PARTIEL", 256);
|
- |
|
2408 |
root.getBase().getDataSource().execute(alterEcriture.asString());
|
- |
|
2409 |
root.refetchTable("ECRITURE");
|
- |
|
2410 |
root.getSchema().updateVersion();
|
- |
|
2411 |
}
|
- |
|
2412 |
|
- |
|
2413 |
SQLTable tableFactureF = root.getTable("FACTURE_FOURNISSEUR");
|
- |
|
2414 |
if (!tableFactureF.contains("ID_AVOIR_FOURNISSEUR_2")) {
|
- |
|
2415 |
final AlterTable alter = new AlterTable(tableFactureF);
|
- |
|
2416 |
final SQLTable tableAvoirF = tableVF.getDBRoot().getTable("AVOIR_FOURNISSEUR");
|
- |
|
2417 |
alter.addForeignColumn("ID_AVOIR_FOURNISSEUR_2", tableAvoirF);
|
- |
|
2418 |
tableFactureF.getBase().getDataSource().execute(alter.asString());
|
- |
|
2419 |
tableFactureF.getSchema().updateVersion();
|
- |
|
2420 |
tableVF.fetchFields();
|
- |
|
2421 |
}
|
- |
|
2422 |
|
2289 |
}
|
2423 |
}
|
2290 |
|
2424 |
|
2291 |
public static void initStock(SQLRow rowArticle, int idDepot) {
|
2425 |
public static void initStock(SQLRow rowArticle, int idDepot) {
|
2292 |
|
2426 |
|
2293 |
SQLSelect selStock = new SQLSelect();
|
2427 |
SQLSelect selStock = new SQLSelect();
|