1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
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
|
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
|
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.
|
9 |
* language governing permissions and limitations under the License.
|
10 |
*
|
10 |
*
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.config.update;
|
14 |
package org.openconcerto.erp.config.update;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.InstallationPanel;
|
16 |
import org.openconcerto.erp.config.InstallationPanel;
|
- |
|
17 |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
|
17 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
|
18 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
20 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
21 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
22 |
import org.openconcerto.erp.core.sales.order.ui.TypeFactureCommandeClient;
|
22 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
|
23 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
24 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
25 |
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
|
- |
|
26 |
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
|
- |
|
27 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem;
|
25 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
28 |
import org.openconcerto.sql.changer.convert.AddMDFields;
|
26 |
import org.openconcerto.sql.model.DBRoot;
|
29 |
import org.openconcerto.sql.model.DBRoot;
|
- |
|
30 |
import org.openconcerto.sql.model.SQLField;
|
27 |
import org.openconcerto.sql.model.SQLField.Properties;
|
31 |
import org.openconcerto.sql.model.SQLField.Properties;
|
28 |
import org.openconcerto.sql.model.SQLName;
|
32 |
import org.openconcerto.sql.model.SQLName;
|
- |
|
33 |
import org.openconcerto.sql.model.SQLRow;
|
- |
|
34 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
29 |
import org.openconcerto.sql.model.SQLRowValues;
|
35 |
import org.openconcerto.sql.model.SQLRowValues;
|
- |
|
36 |
import org.openconcerto.sql.model.SQLSelect;
|
30 |
import org.openconcerto.sql.model.SQLSyntax;
|
37 |
import org.openconcerto.sql.model.SQLSyntax;
|
31 |
import org.openconcerto.sql.model.SQLSystem;
|
38 |
import org.openconcerto.sql.model.SQLSystem;
|
32 |
import org.openconcerto.sql.model.SQLTable;
|
39 |
import org.openconcerto.sql.model.SQLTable;
|
33 |
import org.openconcerto.sql.model.Where;
|
40 |
import org.openconcerto.sql.model.Where;
|
- |
|
41 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
34 |
import org.openconcerto.sql.request.UpdateBuilder;
|
42 |
import org.openconcerto.sql.request.UpdateBuilder;
|
35 |
import org.openconcerto.sql.utils.AlterTable;
|
43 |
import org.openconcerto.sql.utils.AlterTable;
|
36 |
import org.openconcerto.sql.utils.ChangeTable;
|
44 |
import org.openconcerto.sql.utils.ChangeTable;
|
37 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
45 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
38 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
46 |
import org.openconcerto.sql.utils.UniqueConstraintCreatorHelper;
|
39 |
import org.openconcerto.utils.CollectionUtils;
|
47 |
import org.openconcerto.utils.CollectionUtils;
|
- |
|
48 |
import org.openconcerto.utils.ExceptionHandler;
|
40 |
|
49 |
|
41 |
import java.math.BigDecimal;
|
50 |
import java.math.BigDecimal;
|
- |
|
51 |
import java.sql.Clob;
|
42 |
import java.sql.SQLException;
|
52 |
import java.sql.SQLException;
|
43 |
import java.sql.Types;
|
53 |
import java.sql.Types;
|
- |
|
54 |
import java.util.ArrayList;
|
44 |
import java.util.Arrays;
|
55 |
import java.util.Arrays;
|
- |
|
56 |
import java.util.Collections;
|
45 |
import java.util.EnumSet;
|
57 |
import java.util.EnumSet;
|
- |
|
58 |
import java.util.HashMap;
|
46 |
import java.util.List;
|
59 |
import java.util.List;
|
- |
|
60 |
import java.util.Map;
|
- |
|
61 |
import java.util.prefs.BackingStoreException;
|
- |
|
62 |
|
- |
|
63 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
47 |
|
64 |
|
48 |
public class Updater_1_5 {
|
65 |
public class Updater_1_5 {
|
49 |
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
|
66 |
private static final String COMPTE_CLIENT_TRANSACTION = "COMPTE_CLIENT_TRANSACTION";
|
50 |
|
67 |
|
51 |
public static void update(final DBRoot root) throws SQLException {
|
68 |
public static void update(final DBRoot root) throws SQLException {
|
52 |
// Champ obsolete sur compte
|
69 |
// Champ obsolete sur compte
|
53 |
SQLTable tableCompte = root.getTable("COMPTE_PCE");
|
70 |
SQLTable tableCompte = root.getTable("COMPTE_PCE");
|
54 |
if (!tableCompte.contains("OBSOLETE")) {
|
71 |
if (!tableCompte.contains("OBSOLETE")) {
|
55 |
final AlterTable alter = new AlterTable(tableCompte);
|
72 |
final AlterTable alter = new AlterTable(tableCompte);
|
56 |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
73 |
alter.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
57 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
74 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
58 |
tableCompte.getSchema().updateVersion();
|
75 |
tableCompte.getSchema().updateVersion();
|
59 |
tableCompte.fetchFields();
|
76 |
tableCompte.fetchFields();
|
60 |
}
|
77 |
}
|
61 |
|
78 |
|
62 |
// Transaction du solde
|
79 |
// Transaction du solde
|
63 |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
|
80 |
if (!root.contains(COMPTE_CLIENT_TRANSACTION)) {
|
64 |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
|
81 |
final SQLCreateTable createTable = new SQLCreateTable(root, COMPTE_CLIENT_TRANSACTION);
|
65 |
createTable.addForeignColumn("CLIENT");
|
82 |
createTable.addForeignColumn("CLIENT");
|
66 |
createTable.addDateAndTimeColumn("DATE");
|
83 |
createTable.addDateAndTimeColumn("DATE");
|
67 |
createTable.addDecimalColumn("MONTANT", 16, 6, BigDecimal.valueOf(0), false);
|
84 |
createTable.addDecimalColumn("MONTANT", 16, 6, BigDecimal.valueOf(0), false);
|
68 |
createTable.addForeignColumn("MODE_REGLEMENT");
|
85 |
createTable.addForeignColumn("MODE_REGLEMENT");
|
69 |
createTable.addForeignColumn("MOUVEMENT");
|
86 |
createTable.addForeignColumn("MOUVEMENT");
|
70 |
try {
|
87 |
try {
|
71 |
root.getBase().getDataSource().execute(createTable.asString());
|
88 |
root.getBase().getDataSource().execute(createTable.asString());
|
72 |
InstallationPanel.insertUndef(createTable);
|
89 |
InstallationPanel.insertUndef(createTable);
|
73 |
root.refetchTable(COMPTE_CLIENT_TRANSACTION);
|
90 |
root.refetchTable(COMPTE_CLIENT_TRANSACTION);
|
74 |
root.getSchema().updateVersion();
|
91 |
root.getSchema().updateVersion();
|
75 |
} catch (SQLException ex) {
|
92 |
} catch (SQLException ex) {
|
76 |
throw new IllegalStateException("Erreur lors de la création de la table " + COMPTE_CLIENT_TRANSACTION, ex);
|
93 |
throw new IllegalStateException("Erreur lors de la création de la table " + COMPTE_CLIENT_TRANSACTION, ex);
|
77 |
}
|
94 |
}
|
78 |
}
|
95 |
}
|
79 |
// Solde
|
96 |
// Solde
|
80 |
final SQLTable tClient = root.getTable("CLIENT");
|
97 |
final SQLTable tClient = root.getTable("CLIENT");
|
81 |
if (!tClient.contains("SOLDE_COMPTE")) {
|
98 |
if (!tClient.contains("SOLDE_COMPTE")) {
|
82 |
final AlterTable alterClient = new AlterTable(tClient);
|
99 |
final AlterTable alterClient = new AlterTable(tClient);
|
83 |
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
|
100 |
alterClient.addDecimalColumn("SOLDE_COMPTE", 16, 6, BigDecimal.valueOf(0), false);
|
84 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
101 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
85 |
tClient.getSchema().updateVersion();
|
102 |
tClient.getSchema().updateVersion();
|
86 |
tClient.fetchFields();
|
103 |
tClient.fetchFields();
|
87 |
}
|
104 |
}
|
88 |
if (!tClient.contains("DATE")) {
|
105 |
if (!tClient.contains("DATE")) {
|
89 |
final AlterTable alterClient = new AlterTable(tClient);
|
106 |
final AlterTable alterClient = new AlterTable(tClient);
|
90 |
alterClient.addColumn("DATE", "date");
|
107 |
alterClient.addColumn("DATE", "date");
|
91 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
108 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
92 |
tClient.getSchema().updateVersion();
|
109 |
tClient.getSchema().updateVersion();
|
93 |
tClient.fetchFields();
|
110 |
tClient.fetchFields();
|
94 |
}
|
111 |
}
|
95 |
if (!tClient.contains("COMMENTAIRES")) {
|
112 |
if (!tClient.contains("COMMENTAIRES")) {
|
96 |
final AlterTable alterClient = new AlterTable(tClient);
|
113 |
final AlterTable alterClient = new AlterTable(tClient);
|
97 |
alterClient.addVarCharColumn("COMMENTAIRES", 2048);
|
114 |
alterClient.addVarCharColumn("COMMENTAIRES", 2048);
|
98 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
115 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
99 |
tClient.getSchema().updateVersion();
|
116 |
tClient.getSchema().updateVersion();
|
100 |
tClient.fetchFields();
|
117 |
tClient.fetchFields();
|
101 |
}
|
118 |
}
|
102 |
|
119 |
|
103 |
final SQLTable tCompteClient = root.getTable("COMPTE_CLIENT_TRANSACTION");
|
120 |
final SQLTable tCompteClient = root.getTable("COMPTE_CLIENT_TRANSACTION");
|
104 |
if (!tCompteClient.contains("ID_MOUVEMENT")) {
|
121 |
if (!tCompteClient.contains("ID_MOUVEMENT")) {
|
105 |
final AlterTable alterClient = new AlterTable(tCompteClient);
|
122 |
final AlterTable alterClient = new AlterTable(tCompteClient);
|
106 |
alterClient.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
123 |
alterClient.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
107 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
124 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
108 |
tClient.getSchema().updateVersion();
|
125 |
tClient.getSchema().updateVersion();
|
109 |
tClient.fetchFields();
|
126 |
tClient.fetchFields();
|
110 |
}
|
127 |
}
|
111 |
|
128 |
|
112 |
final SQLTable tCmdClient = root.getTable("COMMANDE_CLIENT");
|
129 |
final SQLTable tCmdClient = root.getTable("COMMANDE_CLIENT");
|
113 |
if (!tCmdClient.contains("DATE_LIVRAISON_PREV")) {
|
130 |
if (!tCmdClient.contains("DATE_LIVRAISON_PREV")) {
|
114 |
final AlterTable alterCmdClient = new AlterTable(tCmdClient);
|
131 |
final AlterTable alterCmdClient = new AlterTable(tCmdClient);
|
115 |
alterCmdClient.addColumn("DATE_LIVRAISON_PREV", "date");
|
132 |
alterCmdClient.addColumn("DATE_LIVRAISON_PREV", "date");
|
116 |
tCmdClient.getBase().getDataSource().execute(alterCmdClient.asString());
|
133 |
tCmdClient.getBase().getDataSource().execute(alterCmdClient.asString());
|
117 |
tCmdClient.getSchema().updateVersion();
|
134 |
tCmdClient.getSchema().updateVersion();
|
118 |
tCmdClient.fetchFields();
|
135 |
tCmdClient.fetchFields();
|
119 |
}
|
136 |
}
|
120 |
|
137 |
|
121 |
if (!tClient.contains("CONDITIONS_LIVRAISON")) {
|
138 |
if (!tClient.contains("CONDITIONS_LIVRAISON")) {
|
122 |
final AlterTable alterClient = new AlterTable(tClient);
|
139 |
final AlterTable alterClient = new AlterTable(tClient);
|
123 |
alterClient.addVarCharColumn("CONDITIONS_LIVRAISON", 512);
|
140 |
alterClient.addVarCharColumn("CONDITIONS_LIVRAISON", 512);
|
124 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
141 |
tClient.getBase().getDataSource().execute(alterClient.asString());
|
125 |
tClient.getSchema().updateVersion();
|
142 |
tClient.getSchema().updateVersion();
|
126 |
tClient.fetchFields();
|
143 |
tClient.fetchFields();
|
127 |
}
|
144 |
}
|
128 |
|
145 |
|
129 |
{
|
146 |
{
|
130 |
// Ajout du champ SANS_VALEUR_ENCAISSEMENT pour gérer les anciens cheques sans le compte
|
147 |
// Ajout du champ SANS_VALEUR_ENCAISSEMENT pour gérer les anciens cheques sans le compte
|
131 |
// 511
|
148 |
// 511
|
132 |
List<String> tablesCheque = Arrays.asList("CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
|
149 |
List<String> tablesCheque = Arrays.asList("CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
|
133 |
|
150 |
|
134 |
for (String string : tablesCheque) {
|
151 |
for (String string : tablesCheque) {
|
135 |
|
152 |
|
136 |
final SQLTable table = root.getTable(string);
|
153 |
final SQLTable table = root.getTable(string);
|
137 |
if (!table.contains("SANS_VALEUR_ENCAISSEMENT")) {
|
154 |
if (!table.contains("SANS_VALEUR_ENCAISSEMENT")) {
|
138 |
AlterTable alterElt = new AlterTable(table);
|
155 |
AlterTable alterElt = new AlterTable(table);
|
139 |
alterElt.addBooleanColumn("SANS_VALEUR_ENCAISSEMENT", Boolean.FALSE, false);
|
156 |
alterElt.addBooleanColumn("SANS_VALEUR_ENCAISSEMENT", Boolean.FALSE, false);
|
140 |
table.getBase().getDataSource().execute(alterElt.asString());
|
157 |
table.getBase().getDataSource().execute(alterElt.asString());
|
141 |
root.refetchTable(string);
|
158 |
root.refetchTable(string);
|
142 |
root.getSchema().updateVersion();
|
159 |
root.getSchema().updateVersion();
|
143 |
UpdateBuilder upBuilder = new UpdateBuilder(table);
|
160 |
UpdateBuilder upBuilder = new UpdateBuilder(table);
|
144 |
upBuilder.setObject("SANS_VALEUR_ENCAISSEMENT", Boolean.TRUE);
|
161 |
upBuilder.setObject("SANS_VALEUR_ENCAISSEMENT", Boolean.TRUE);
|
145 |
table.getBase().getDataSource().execute(upBuilder.asString());
|
162 |
table.getBase().getDataSource().execute(upBuilder.asString());
|
146 |
}
|
163 |
}
|
147 |
}
|
164 |
}
|
148 |
|
165 |
|
149 |
SQLTable tableEncElt = root.getTable("ENCAISSER_MONTANT_ELEMENT");
|
166 |
SQLTable tableEncElt = root.getTable("ENCAISSER_MONTANT_ELEMENT");
|
150 |
if (tableEncElt.getField("DATE").getType().getType() == Types.TIMESTAMP) {
|
167 |
if (tableEncElt.getField("DATE").getType().getType() == Types.TIMESTAMP) {
|
151 |
AlterTable t = new AlterTable(tableEncElt);
|
168 |
AlterTable t = new AlterTable(tableEncElt);
|
152 |
t.alterColumn("DATE", EnumSet.allOf(Properties.class), "date", null, Boolean.TRUE);
|
169 |
t.alterColumn("DATE", EnumSet.allOf(Properties.class), "date", null, Boolean.TRUE);
|
153 |
tableEncElt.getBase().getDataSource().execute(t.asString());
|
170 |
tableEncElt.getBase().getDataSource().execute(t.asString());
|
154 |
root.refetchTable(tableEncElt.getName());
|
171 |
root.refetchTable(tableEncElt.getName());
|
155 |
root.getSchema().updateVersion();
|
172 |
root.getSchema().updateVersion();
|
156 |
}
|
173 |
}
|
157 |
}
|
174 |
}
|
158 |
|
175 |
|
159 |
// TVA Intra
|
176 |
// TVA Intra
|
160 |
final SQLTable tTva = root.getTable("TAXE");
|
177 |
final SQLTable tTva = root.getTable("TAXE");
|
161 |
if (!tTva.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
|
178 |
if (!tTva.contains("ID_COMPTE_PCE_COLLECTE_INTRA")) {
|
162 |
final AlterTable alterTaxe = new AlterTable(tTva);
|
179 |
final AlterTable alterTaxe = new AlterTable(tTva);
|
163 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_COLLECTE_INTRA", root.getTable("COMPTE_PCE"));
|
180 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_COLLECTE_INTRA", root.getTable("COMPTE_PCE"));
|
164 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_DED_INTRA", root.getTable("COMPTE_PCE"));
|
181 |
alterTaxe.addForeignColumn("ID_COMPTE_PCE_DED_INTRA", root.getTable("COMPTE_PCE"));
|
165 |
tTva.getBase().getDataSource().execute(alterTaxe.asString());
|
182 |
tTva.getBase().getDataSource().execute(alterTaxe.asString());
|
166 |
tTva.getSchema().updateVersion();
|
183 |
tTva.getSchema().updateVersion();
|
167 |
tTva.fetchFields();
|
184 |
tTva.fetchFields();
|
168 |
}
|
185 |
}
|
169 |
|
186 |
|
170 |
if (!root.contains("TAXE_COMPLEMENTAIRE")) {
|
187 |
if (!root.contains("TAXE_COMPLEMENTAIRE")) {
|
171 |
final SQLCreateTable createTable = new SQLCreateTable(root, "TAXE_COMPLEMENTAIRE");
|
188 |
final SQLCreateTable createTable = new SQLCreateTable(root, "TAXE_COMPLEMENTAIRE");
|
172 |
createTable.addForeignColumn("ID_COMPTE_PCE_PRODUITS", root.getTable("COMPTE_PCE"));
|
189 |
createTable.addForeignColumn("ID_COMPTE_PCE_PRODUITS", root.getTable("COMPTE_PCE"));
|
173 |
createTable.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
190 |
createTable.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
174 |
createTable.addDecimalColumn("POURCENT", 16, 6, BigDecimal.valueOf(0), false);
|
191 |
createTable.addDecimalColumn("POURCENT", 16, 6, BigDecimal.valueOf(0), false);
|
175 |
createTable.addVarCharColumn("CODE", 25);
|
192 |
createTable.addVarCharColumn("CODE", 25);
|
176 |
createTable.addVarCharColumn("NOM", 256);
|
193 |
createTable.addVarCharColumn("NOM", 256);
|
177 |
|
194 |
|
178 |
try {
|
195 |
try {
|
179 |
root.getBase().getDataSource().execute(createTable.asString());
|
196 |
root.getBase().getDataSource().execute(createTable.asString());
|
180 |
InstallationPanel.insertUndef(createTable);
|
197 |
InstallationPanel.insertUndef(createTable);
|
181 |
root.refetchTable("TAXE_COMPLEMENTAIRE");
|
198 |
root.refetchTable("TAXE_COMPLEMENTAIRE");
|
182 |
root.getSchema().updateVersion();
|
199 |
root.getSchema().updateVersion();
|
183 |
} catch (SQLException ex) {
|
200 |
} catch (SQLException ex) {
|
184 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TAXE_COMPLEMENTAIRE", ex);
|
201 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TAXE_COMPLEMENTAIRE", ex);
|
185 |
}
|
202 |
}
|
186 |
|
203 |
|
187 |
SQLTable tableArt = root.getTable("ARTICLE");
|
204 |
SQLTable tableArt = root.getTable("ARTICLE");
|
188 |
final AlterTable alterArt = new AlterTable(tableArt);
|
205 |
final AlterTable alterArt = new AlterTable(tableArt);
|
189 |
alterArt.addForeignColumn("ID_TAXE_COMPLEMENTAIRE", root.getTable("TAXE_COMPLEMENTAIRE"));
|
206 |
alterArt.addForeignColumn("ID_TAXE_COMPLEMENTAIRE", root.getTable("TAXE_COMPLEMENTAIRE"));
|
190 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
207 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
191 |
tableArt.getSchema().updateVersion();
|
208 |
tableArt.getSchema().updateVersion();
|
192 |
tableArt.fetchFields();
|
209 |
tableArt.fetchFields();
|
193 |
}
|
210 |
}
|
194 |
|
211 |
|
195 |
// GED
|
212 |
// GED
|
196 |
if (!root.contains("ATTACHMENT")) {
|
213 |
if (!root.contains("ATTACHMENT")) {
|
197 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ATTACHMENT");
|
214 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ATTACHMENT");
|
198 |
createTable.addVarCharColumn("SOURCE_TABLE", 128);
|
215 |
createTable.addVarCharColumn("SOURCE_TABLE", 128);
|
199 |
createTable.addIntegerColumn("SOURCE_ID", 0);
|
216 |
createTable.addIntegerColumn("SOURCE_ID", 0);
|
200 |
createTable.addVarCharColumn("NAME", 256);
|
217 |
createTable.addVarCharColumn("NAME", 256);
|
201 |
createTable.addVarCharColumn("MIMETYPE", 256);
|
218 |
createTable.addVarCharColumn("MIMETYPE", 256);
|
202 |
createTable.addVarCharColumn("FILENAME", 256);
|
219 |
createTable.addVarCharColumn("FILENAME", 256);
|
203 |
createTable.addLongColumn("FILESIZE", 0L, false);
|
220 |
createTable.addLongColumn("FILESIZE", 0L, false);
|
204 |
createTable.addVarCharColumn("STORAGE_PATH", 256);
|
221 |
createTable.addVarCharColumn("STORAGE_PATH", 256);
|
205 |
createTable.addVarCharColumn("STORAGE_FILENAME", 256);
|
222 |
createTable.addVarCharColumn("STORAGE_FILENAME", 256);
|
206 |
createTable.addVarCharColumn("DIRECTORY", 256);
|
223 |
createTable.addVarCharColumn("DIRECTORY", 256);
|
207 |
createTable.addVarCharColumn("THUMBNAIL", 256);
|
224 |
createTable.addVarCharColumn("THUMBNAIL", 256);
|
208 |
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
|
225 |
createTable.addIntegerColumn("THUMBNAIL_WIDTH", 32);
|
209 |
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
|
226 |
createTable.addIntegerColumn("THUMBNAIL_HEIGHT", 32);
|
210 |
createTable.addVarCharColumn("TAG", 128);
|
227 |
createTable.addVarCharColumn("TAG", 128);
|
211 |
createTable.addIntegerColumn("VERSION", 0);
|
228 |
createTable.addIntegerColumn("VERSION", 0);
|
212 |
createTable.addVarCharColumn("HASH", 32);
|
229 |
createTable.addVarCharColumn("HASH", 32);
|
213 |
|
230 |
|
214 |
try {
|
231 |
try {
|
215 |
root.getBase().getDataSource().execute(createTable.asString());
|
232 |
root.getBase().getDataSource().execute(createTable.asString());
|
216 |
InstallationPanel.insertUndef(createTable);
|
233 |
InstallationPanel.insertUndef(createTable);
|
217 |
root.refetchTable("ATTACHMENT");
|
234 |
root.refetchTable("ATTACHMENT");
|
218 |
root.getSchema().updateVersion();
|
235 |
root.getSchema().updateVersion();
|
219 |
} catch (SQLException ex) {
|
236 |
} catch (SQLException ex) {
|
220 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ATTACHMENT", ex);
|
237 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ATTACHMENT", ex);
|
221 |
}
|
238 |
}
|
222 |
}
|
239 |
}
|
223 |
SQLTable tableAttachment = root.getTable("ATTACHMENT");
|
240 |
SQLTable tableAttachment = root.getTable("ATTACHMENT");
|
224 |
if (!tableAttachment.contains("DIRECTORY")) {
|
241 |
if (!tableAttachment.contains("DIRECTORY")) {
|
225 |
final AlterTable alter = new AlterTable(tableAttachment);
|
242 |
final AlterTable alter = new AlterTable(tableAttachment);
|
226 |
alter.addVarCharColumn("STORAGE_FILENAME", 256);
|
243 |
alter.addVarCharColumn("STORAGE_FILENAME", 256);
|
227 |
alter.addVarCharColumn("DIRECTORY", 256);
|
244 |
alter.addVarCharColumn("DIRECTORY", 256);
|
228 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
245 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
229 |
tableAttachment.getSchema().updateVersion();
|
246 |
tableAttachment.getSchema().updateVersion();
|
230 |
tableAttachment.fetchFields();
|
247 |
tableAttachment.fetchFields();
|
231 |
}
|
248 |
}
|
232 |
if (!tableAttachment.contains("ID_PARENT")) {
|
249 |
if (!tableAttachment.contains("ID_PARENT")) {
|
233 |
final AlterTable alter = new AlterTable(tableAttachment);
|
250 |
final AlterTable alter = new AlterTable(tableAttachment);
|
234 |
alter.addForeignColumn("ID_PARENT", tableAttachment);
|
251 |
alter.addForeignColumn("ID_PARENT", tableAttachment);
|
235 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
252 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
236 |
tableAttachment.getSchema().updateVersion();
|
253 |
tableAttachment.getSchema().updateVersion();
|
237 |
tableAttachment.fetchFields();
|
254 |
tableAttachment.fetchFields();
|
238 |
}
|
255 |
}
|
239 |
|
256 |
|
240 |
if (!tableAttachment.contains("VERSION")) {
|
257 |
if (!tableAttachment.contains("VERSION")) {
|
241 |
final AlterTable alter = new AlterTable(tableAttachment);
|
258 |
final AlterTable alter = new AlterTable(tableAttachment);
|
242 |
alter.addIntegerColumn("VERSION", 0);
|
259 |
alter.addIntegerColumn("VERSION", 0);
|
243 |
alter.addVarCharColumn("HASH", 32);
|
260 |
alter.addVarCharColumn("HASH", 32);
|
244 |
alter.addVarCharColumn("INFOS", 8000);
|
261 |
alter.addVarCharColumn("INFOS", 8000);
|
245 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
262 |
tableAttachment.getBase().getDataSource().execute(alter.asString());
|
246 |
tableAttachment.getSchema().updateVersion();
|
263 |
tableAttachment.getSchema().updateVersion();
|
247 |
tableAttachment.fetchFields();
|
264 |
tableAttachment.fetchFields();
|
248 |
}
|
265 |
}
|
249 |
|
266 |
|
250 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
267 |
List<String> gedTable = Arrays.asList("CLIENT", "MOUVEMENT", "FOURNISSEUR", "ARTICLE", "FACTURE_FOURNISSEUR", "SAISIE_VENTE_FACTURE", "SALARIE");
|
251 |
for (String string : gedTable) {
|
268 |
for (String string : gedTable) {
|
252 |
SQLTable tableGED = root.getTable(string);
|
269 |
SQLTable tableGED = root.getTable(string);
|
253 |
if (!tableGED.contains("ATTACHMENTS")) {
|
270 |
if (!tableGED.contains("ATTACHMENTS")) {
|
254 |
final AlterTable alter = new AlterTable(tableGED);
|
271 |
final AlterTable alter = new AlterTable(tableGED);
|
255 |
alter.addIntegerColumn("ATTACHMENTS", 0);
|
272 |
alter.addIntegerColumn("ATTACHMENTS", 0);
|
256 |
tableGED.getBase().getDataSource().execute(alter.asString());
|
273 |
tableGED.getBase().getDataSource().execute(alter.asString());
|
257 |
tableGED.getSchema().updateVersion();
|
274 |
tableGED.getSchema().updateVersion();
|
258 |
tableGED.fetchFields();
|
275 |
tableGED.fetchFields();
|
259 |
}
|
276 |
}
|
260 |
}
|
277 |
}
|
261 |
|
278 |
|
262 |
// gestion articles en attente
|
279 |
// gestion articles en attente
|
263 |
{
|
280 |
{
|
264 |
|
281 |
|
265 |
// Vente
|
282 |
// Vente
|
266 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
283 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
267 |
if (!tableBLElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
284 |
if (!tableBLElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
268 |
AlterTable t = new AlterTable(tableBLElt);
|
285 |
AlterTable t = new AlterTable(tableBLElt);
|
269 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
286 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
270 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
287 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
271 |
root.refetchTable(tableBLElt.getName());
|
288 |
root.refetchTable(tableBLElt.getName());
|
272 |
root.getSchema().updateVersion();
|
289 |
root.getSchema().updateVersion();
|
273 |
}
|
290 |
}
|
274 |
|
291 |
|
275 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
292 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
276 |
if (!tableVFElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
293 |
if (!tableVFElt.contains("ID_COMMANDE_CLIENT_ELEMENT")) {
|
277 |
AlterTable t = new AlterTable(tableVFElt);
|
294 |
AlterTable t = new AlterTable(tableVFElt);
|
278 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
295 |
t.addForeignColumn("ID_COMMANDE_CLIENT_ELEMENT", root.getTable("COMMANDE_CLIENT_ELEMENT"));
|
279 |
tableVFElt.getBase().getDataSource().execute(t.asString());
|
296 |
tableVFElt.getBase().getDataSource().execute(t.asString());
|
280 |
root.refetchTable(tableVFElt.getName());
|
297 |
root.refetchTable(tableVFElt.getName());
|
281 |
root.getSchema().updateVersion();
|
298 |
root.getSchema().updateVersion();
|
282 |
}
|
299 |
}
|
283 |
|
300 |
|
284 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
301 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
285 |
if (!tableCmdElt.contains("LIVRE")) {
|
302 |
if (!tableCmdElt.contains("LIVRE")) {
|
286 |
AlterTable t = new AlterTable(tableCmdElt);
|
303 |
AlterTable t = new AlterTable(tableCmdElt);
|
- |
|
304 |
// FIXME mis par défaut à true avant --> à fixer
|
287 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
305 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
288 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
306 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
289 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
307 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
290 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
308 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
291 |
root.refetchTable(tableCmdElt.getName());
|
309 |
root.refetchTable(tableCmdElt.getName());
|
292 |
root.getSchema().updateVersion();
|
310 |
root.getSchema().updateVersion();
|
293 |
|
311 |
|
- |
|
312 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
- |
|
313 |
// tableCmdElt.getName()).quote()
|
- |
|
314 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
- |
|
315 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
- |
|
316 |
{
|
- |
|
317 |
List<String> tablesWorkFlow = Arrays.asList("SAISIE_VENTE_FACTURE", "BON_DE_LIVRAISON");
|
- |
|
318 |
for (String tableWorkFlow : tablesWorkFlow) {
|
- |
|
319 |
|
294 |
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
|
320 |
SQLTable tableCmdCli = root.getTable("COMMANDE_CLIENT");
|
295 |
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
|
321 |
SQLTable tableTR = root.getTable("TR_COMMANDE_CLIENT");
|
296 |
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
|
322 |
SQLTable tableBL = root.getTable(tableWorkFlow);
|
297 |
SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
|
323 |
// SQLTable tableFactC = root.getTable("SAISIE_VENTE_FACTURE");
|
298 |
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
|
324 |
String sel = "SELECT t.\"ID_COMMANDE_CLIENT\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ,"
|
299 |
+ " c ," + new SQLName(root.getName(), tableBL.getName()).quote() + " b ," + new SQLName(root.getName(), tableFactC.getName()).quote()
|
325 |
+ new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ," + new SQLName(root.getName(), tableBL.getName()).quote()
|
300 |
+ " f WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\" AND f.\"ID\"=t.\"ID_SAISIE_VENTE_FACTURE\""
|
326 |
+ " b WHERE c.\"ID\"=t.\"ID_COMMANDE_CLIENT\"" + " AND b.\"ID\"=t.\"ID_" + tableWorkFlow
|
- |
|
327 |
+ "\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE_CLIENT\" HAVING (SUM(b.\""
|
301 |
+ " AND b.\"ID\"=t.\"ID_BON_DE_LIVRAISON\" AND b.\"ARCHIVE\" = 0 AND f.\"ID\" > 1 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND f.\"ARCHIVE\" = 0 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE_CLIENT\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\") OR SUM(f.\"T_HT\")>=SUM(c.\"T_HT\")) ";
|
328 |
+ (tableWorkFlow.startsWith("BON") ? "TOTAL_HT" : "T_HT") + "\")>=SUM(c.\"T_HT\") ) ";
|
302 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
329 |
List<Integer> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
303 |
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
|
330 |
UpdateBuilder build = new UpdateBuilder(tableCmdElt);
|
304 |
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
331 |
build.set("QTE_LIVREE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
305 |
build.setObject("LIVRE_FORCED", Boolean.TRUE);
|
332 |
build.setObject("LIVRE_FORCED", Boolean.TRUE);
|
306 |
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
|
333 |
final Where where = new Where(tableCmdElt.getField("ID_COMMANDE_CLIENT"), cmd);
|
307 |
build.setWhere(where);
|
334 |
build.setWhere(where);
|
308 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
- |
|
309 |
// tableCmdElt.getName()).quote()
|
- |
|
310 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
- |
|
311 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
- |
|
312 |
}
|
- |
|
313 |
|
335 |
|
- |
|
336 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
337 |
}
|
- |
|
338 |
}
|
- |
|
339 |
}
|
314 |
// Fix bad default value
|
340 |
// Fix bad default value
|
315 |
if (tableCmdElt.contains("LIVRE")) {
|
341 |
if (tableCmdElt.contains("LIVRE")) {
|
316 |
AlterTable t = new AlterTable(tableCmdElt);
|
342 |
AlterTable t = new AlterTable(tableCmdElt);
|
317 |
t.alterColumnDefault("LIVRE", "false");
|
343 |
t.alterColumnDefault("LIVRE", "false");
|
318 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
344 |
tableCmdElt.getBase().getDataSource().execute(t.asString());
|
319 |
root.refetchTable(tableCmdElt.getName());
|
345 |
root.refetchTable(tableCmdElt.getName());
|
320 |
root.getSchema().updateVersion();
|
346 |
root.getSchema().updateVersion();
|
- |
|
347 |
UpdateBuilder upLivre = new UpdateBuilder(tableCmdElt);
|
- |
|
348 |
upLivre.setObject("LIVRE", Boolean.FALSE);
|
- |
|
349 |
upLivre.setWhere(new Where(tableCmdElt.getKey(), "=", 1));
|
- |
|
350 |
|
- |
|
351 |
tableCmdElt.getBase().getDataSource().execute(upLivre.asString());
|
321 |
}
|
352 |
}
|
322 |
|
353 |
|
323 |
// Achat
|
354 |
// Achat
|
324 |
|
355 |
|
325 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
356 |
SQLTable tableBRElt = root.getTable("BON_RECEPTION_ELEMENT");
|
326 |
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
|
357 |
if (!tableBRElt.contains("ID_COMMANDE_ELEMENT")) {
|
327 |
AlterTable t = new AlterTable(tableBRElt);
|
358 |
AlterTable t = new AlterTable(tableBRElt);
|
328 |
t.addForeignColumn("ID_COMMANDE_ELEMENT", root.getTable("COMMANDE_ELEMENT"));
|
359 |
t.addForeignColumn("ID_COMMANDE_ELEMENT", root.getTable("COMMANDE_ELEMENT"));
|
329 |
tableBRElt.getBase().getDataSource().execute(t.asString());
|
360 |
tableBRElt.getBase().getDataSource().execute(t.asString());
|
330 |
root.refetchTable(tableBRElt.getName());
|
361 |
root.refetchTable(tableBRElt.getName());
|
331 |
root.getSchema().updateVersion();
|
362 |
root.getSchema().updateVersion();
|
332 |
}
|
363 |
}
|
333 |
|
364 |
|
334 |
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
|
365 |
SQLTable tableCmdFElt = root.getTable("COMMANDE_ELEMENT");
|
335 |
if (!tableCmdFElt.contains("RECU")) {
|
366 |
if (!tableCmdFElt.contains("RECU")) {
|
336 |
AlterTable t = new AlterTable(tableCmdFElt);
|
367 |
AlterTable t = new AlterTable(tableCmdFElt);
|
337 |
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
|
368 |
t.addBooleanColumn("RECU_FORCED", Boolean.FALSE, false);
|
338 |
t.addBooleanColumn("RECU", Boolean.TRUE, false);
|
369 |
t.addBooleanColumn("RECU", Boolean.TRUE, false);
|
339 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
370 |
t.addDecimalColumn("QTE_RECUE", 16, 6, BigDecimal.ZERO, true);
|
340 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
371 |
tableCmdFElt.getBase().getDataSource().execute(t.asString());
|
341 |
root.refetchTable(tableCmdFElt.getName());
|
372 |
root.refetchTable(tableCmdFElt.getName());
|
342 |
root.getSchema().updateVersion();
|
373 |
root.getSchema().updateVersion();
|
343 |
|
374 |
|
- |
|
375 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
- |
|
376 |
// tableCmdElt.getName()).quote()
|
- |
|
377 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
- |
|
378 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
- |
|
379 |
{
|
344 |
SQLTable tableCmdCli = root.getTable("COMMANDE");
|
380 |
SQLTable tableCmdCli = root.getTable("COMMANDE");
|
345 |
SQLTable tableTR = root.getTable("TR_COMMANDE");
|
381 |
SQLTable tableTR = root.getTable("TR_COMMANDE");
|
346 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
382 |
SQLTable tableBR = root.getTable("BON_RECEPTION");
|
347 |
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote() + " c ,"
|
383 |
String sel = "SELECT t.\"ID_COMMANDE\" FROM " + new SQLName(root.getName(), tableTR.getName()).quote() + " t ," + new SQLName(root.getName(), tableCmdCli.getName()).quote()
|
348 |
+ new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
|
384 |
+ " c ," + new SQLName(root.getName(), tableBR.getName()).quote() + " b WHERE c.\"ID\"=t.\"ID_COMMANDE\""
|
349 |
+ " AND b.\"ID\"=t.\"ID_BON_RECEPTION\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND t.\"ARCHIVE\" = 0 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\")) ";
|
385 |
+ " AND b.\"ID\"=t.\"ID_BON_RECEPTION\" AND b.\"ARCHIVE\" = 0 AND t.\"ID\" > 1 AND c.\"ID\" > 1 AND c.\"ARCHIVE\" = 0 GROUP BY t.\"ID_COMMANDE\" HAVING (SUM(b.\"TOTAL_HT\")>=SUM(c.\"T_HT\")) ";
|
- |
|
386 |
|
- |
|
387 |
System.err.println(sel);
|
350 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
388 |
List<Object> cmd = tableTR.getDBSystemRoot().getDataSource().executeCol(sel);
|
351 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
389 |
UpdateBuilder build = new UpdateBuilder(tableCmdFElt);
|
352 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
390 |
build.set("QTE_RECUE", "\"QTE\"*\"QTE_UNITAIRE\"");
|
353 |
build.setObject("RECU_FORCED", Boolean.TRUE);
|
391 |
build.setObject("RECU_FORCED", Boolean.TRUE);
|
354 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
392 |
final Where where = new Where(tableCmdFElt.getField("ID_COMMANDE"), cmd);
|
355 |
build.setWhere(where);
|
393 |
build.setWhere(where);
|
356 |
// String up = "UPDATE " + new SQLName(root.getName(),
|
394 |
System.err.println(build.asString());
|
- |
|
395 |
tableTR.getDBSystemRoot().getDataSource().execute(build.asString());
|
- |
|
396 |
}
|
- |
|
397 |
}
|
- |
|
398 |
|
- |
|
399 |
// Champ matière
|
357 |
// tableCmdElt.getName()).quote()
|
400 |
SQLTable tableArt = root.getTable("ARTICLE");
|
- |
|
401 |
if (!tableArt.contains("MATIERE")) {
|
- |
|
402 |
final AlterTable alter = new AlterTable(tableArt);
|
- |
|
403 |
alter.addVarCharColumn("MATIERE", 128);
|
358 |
// + " SET \"QTE_LIVREE\"=\"QTE\"*\"QTE_UNITAIRE\", \"LIVRE_FORCED\"=true WHERE
|
404 |
tableArt.getBase().getDataSource().execute(alter.asString());
|
- |
|
405 |
tableArt.getSchema().updateVersion();
|
359 |
// \"ID_COMMANDE_CLIENT\" IN []";
|
406 |
tableArt.fetchFields();
|
360 |
}
|
407 |
}
|
361 |
|
408 |
|
362 |
}
|
409 |
}
|
363 |
// ----------------------- 1.5.1
|
410 |
// ----------------------- 1.5.1
|
364 |
|
411 |
|
365 |
if (!root.contains("FABRICANT")) {
|
412 |
if (!root.contains("FABRICANT")) {
|
366 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FABRICANT");
|
413 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FABRICANT");
|
367 |
createTableEtat.addVarCharColumn("NOM", 256);
|
414 |
createTableEtat.addVarCharColumn("NOM", 256);
|
368 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
415 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
369 |
InstallationPanel.insertUndef(createTableEtat);
|
416 |
InstallationPanel.insertUndef(createTableEtat);
|
370 |
root.refetchTable("FABRICANT");
|
417 |
root.refetchTable("FABRICANT");
|
371 |
root.getSchema().updateVersion();
|
418 |
root.getSchema().updateVersion();
|
372 |
|
419 |
|
373 |
final AlterTable alterA = new AlterTable(root.getTable("ARTICLE"));
|
420 |
final AlterTable alterA = new AlterTable(root.getTable("ARTICLE"));
|
374 |
alterA.addForeignColumn("ID_FABRICANT", root.findTable("FABRICANT"));
|
421 |
alterA.addForeignColumn("ID_FABRICANT", root.findTable("FABRICANT"));
|
375 |
root.getBase().getDataSource().execute(alterA.asString());
|
422 |
root.getBase().getDataSource().execute(alterA.asString());
|
376 |
root.refetchTable("ARTICLE");
|
423 |
root.refetchTable("ARTICLE");
|
377 |
root.getSchema().updateVersion();
|
424 |
root.getSchema().updateVersion();
|
378 |
}
|
425 |
}
|
379 |
|
426 |
|
380 |
// CIM
|
427 |
// CIM
|
381 |
{
|
428 |
{
|
382 |
if (!root.contains("ETAT_DEMANDE_ACHAT_ELEMENT")) {
|
429 |
if (!root.contains("ETAT_DEMANDE_ACHAT_ELEMENT")) {
|
383 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_ACHAT_ELEMENT");
|
430 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_ACHAT_ELEMENT");
|
384 |
createTableEtat.addVarCharColumn("NOM", 256);
|
431 |
createTableEtat.addVarCharColumn("NOM", 256);
|
385 |
createTableEtat.addIntegerColumn("COLOR", null, true);
|
432 |
createTableEtat.addIntegerColumn("COLOR", null, true);
|
386 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
433 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
387 |
InstallationPanel.insertUndef(createTableEtat);
|
434 |
InstallationPanel.insertUndef(createTableEtat);
|
388 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
435 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
389 |
root.getSchema().updateVersion();
|
436 |
root.getSchema().updateVersion();
|
390 |
|
437 |
|
391 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_ACHAT_ELEMENT"));
|
438 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_ACHAT_ELEMENT"));
|
392 |
rowVals.put("NOM", "En attente");
|
439 |
rowVals.put("NOM", "En attente");
|
393 |
rowVals.insert();
|
440 |
rowVals.insert();
|
394 |
rowVals.put("NOM", "Demande de prix");
|
441 |
rowVals.put("NOM", "Demande de prix");
|
395 |
rowVals.insert();
|
442 |
rowVals.insert();
|
396 |
rowVals.put("NOM", "En commande");
|
443 |
rowVals.put("NOM", "En commande");
|
397 |
rowVals.insert();
|
444 |
rowVals.insert();
|
398 |
rowVals.put("NOM", "Réceptionnée");
|
445 |
rowVals.put("NOM", "Réceptionnée");
|
399 |
rowVals.insert();
|
446 |
rowVals.insert();
|
400 |
rowVals.put("NOM", "Réception partielle");
|
447 |
rowVals.put("NOM", "Réception partielle");
|
401 |
rowVals.insert();
|
448 |
rowVals.insert();
|
402 |
rowVals.put("NOM", "A relancer");
|
449 |
rowVals.put("NOM", "A relancer");
|
403 |
rowVals.insert();
|
450 |
rowVals.insert();
|
404 |
}
|
451 |
}
|
405 |
|
452 |
|
406 |
if (!root.contains("DEMANDE_ACHAT_ELEMENT")) {
|
453 |
if (!root.contains("DEMANDE_ACHAT_ELEMENT")) {
|
407 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_ACHAT_ELEMENT");
|
454 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_ACHAT_ELEMENT");
|
408 |
createTableDmd.addVarCharColumn("CODE", 256);
|
455 |
createTableDmd.addVarCharColumn("CODE", 256);
|
409 |
createTableDmd.addVarCharColumn("NOM", 256);
|
456 |
createTableDmd.addVarCharColumn("NOM", 256);
|
410 |
createTableDmd.addIntegerColumn("QTE", 1);
|
457 |
createTableDmd.addIntegerColumn("QTE", 1);
|
411 |
createTableDmd.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
458 |
createTableDmd.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
412 |
|
459 |
|
413 |
createTableDmd.addVarCharColumn("REPERE", 256);
|
460 |
createTableDmd.addVarCharColumn("REPERE", 256);
|
414 |
createTableDmd.addVarCharColumn("REFERENCE", 256);
|
461 |
createTableDmd.addVarCharColumn("REFERENCE", 256);
|
415 |
createTableDmd.addForeignColumn("FABRICANT");
|
462 |
createTableDmd.addForeignColumn("FABRICANT");
|
416 |
createTableDmd.addColumn("DATE", "date");
|
463 |
createTableDmd.addColumn("DATE", "date");
|
417 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_ACHAT_ELEMENT");
|
464 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_ACHAT_ELEMENT");
|
418 |
createTableDmd.addForeignColumn("UNITE_VENTE");
|
465 |
createTableDmd.addForeignColumn("UNITE_VENTE");
|
419 |
createTableDmd.addForeignColumn("ARTICLE");
|
466 |
createTableDmd.addForeignColumn("ARTICLE");
|
420 |
createTableDmd.addForeignColumn("FAMILLE_ARTICLE");
|
467 |
createTableDmd.addForeignColumn("FAMILLE_ARTICLE");
|
421 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
468 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
422 |
createTableDmd.addBooleanColumn("EN_STOCK", Boolean.FALSE, false);
|
469 |
createTableDmd.addBooleanColumn("EN_STOCK", Boolean.FALSE, false);
|
423 |
|
470 |
|
424 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
471 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
425 |
InstallationPanel.insertUndef(createTableDmd);
|
472 |
InstallationPanel.insertUndef(createTableDmd);
|
426 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
473 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
427 |
root.getSchema().updateVersion();
|
474 |
root.getSchema().updateVersion();
|
428 |
}
|
475 |
}
|
429 |
|
476 |
|
430 |
if (!root.contains("ETAT_DEMANDE_PRIX")) {
|
477 |
if (!root.contains("ETAT_DEMANDE_PRIX")) {
|
431 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_PRIX");
|
478 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ETAT_DEMANDE_PRIX");
|
432 |
createTableEtat.addVarCharColumn("NOM", 256);
|
479 |
createTableEtat.addVarCharColumn("NOM", 256);
|
433 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
480 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
434 |
InstallationPanel.insertUndef(createTableEtat);
|
481 |
InstallationPanel.insertUndef(createTableEtat);
|
435 |
root.refetchTable("ETAT_DEMANDE_PRIX");
|
482 |
root.refetchTable("ETAT_DEMANDE_PRIX");
|
436 |
root.getSchema().updateVersion();
|
483 |
root.getSchema().updateVersion();
|
437 |
|
484 |
|
438 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_PRIX"));
|
485 |
SQLRowValues rowVals = new SQLRowValues(root.getTable("ETAT_DEMANDE_PRIX"));
|
439 |
rowVals.put("NOM", "En attente");
|
486 |
rowVals.put("NOM", "En attente");
|
440 |
rowVals.insert();
|
487 |
rowVals.insert();
|
441 |
rowVals.put("NOM", "Refusée");
|
488 |
rowVals.put("NOM", "Refusée");
|
442 |
rowVals.insert();
|
489 |
rowVals.insert();
|
443 |
rowVals.put("NOM", "Acceptée");
|
490 |
rowVals.put("NOM", "Acceptée");
|
444 |
rowVals.insert();
|
491 |
rowVals.insert();
|
445 |
rowVals.put("NOM", "En cours");
|
492 |
rowVals.put("NOM", "En cours");
|
446 |
rowVals.insert();
|
493 |
rowVals.insert();
|
447 |
}
|
494 |
}
|
448 |
|
495 |
|
449 |
if (!root.contains("DEMANDE_PRIX")) {
|
496 |
if (!root.contains("DEMANDE_PRIX")) {
|
450 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_PRIX");
|
497 |
final SQLCreateTable createTableDmd = new SQLCreateTable(root, "DEMANDE_PRIX");
|
451 |
createTableDmd.addVarCharColumn("NUMERO", 256);
|
498 |
createTableDmd.addVarCharColumn("NUMERO", 256);
|
452 |
createTableDmd.addVarCharColumn("OBJET", 1024);
|
499 |
createTableDmd.addVarCharColumn("OBJET", 1024);
|
453 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
500 |
createTableDmd.addForeignColumn("FOURNISSEUR");
|
454 |
// createTableDemande.addForeignColumn("ID_AFFAIRE",
|
501 |
// createTableDemande.addForeignColumn("ID_AFFAIRE",
|
455 |
// ctxt.getRoot().findTable("AFFAIRE"));
|
502 |
// ctxt.getRoot().findTable("AFFAIRE"));
|
456 |
createTableDmd.addColumn("DATE", "date");
|
503 |
createTableDmd.addColumn("DATE", "date");
|
457 |
// createTableDemandeM.addColumn("DATE_DISPOSITION", "date");
|
504 |
// createTableDemandeM.addColumn("DATE_DISPOSITION", "date");
|
458 |
createTableDmd.addColumn("DATE_BUTOIRE", "date");
|
505 |
createTableDmd.addColumn("DATE_BUTOIRE", "date");
|
459 |
createTableDmd.addColumn("T_HT", "bigint DEFAULT 0");
|
506 |
createTableDmd.addColumn("T_HT", "bigint DEFAULT 0");
|
460 |
createTableDmd.addColumn("T_TVA", "bigint DEFAULT 0");
|
507 |
createTableDmd.addColumn("T_TVA", "bigint DEFAULT 0");
|
461 |
createTableDmd.addColumn("T_TTC", "bigint DEFAULT 0");
|
508 |
createTableDmd.addColumn("T_TTC", "bigint DEFAULT 0");
|
462 |
// createTableDemandeM.addForeignColumn("ID_TAXE", findTableTaxe);
|
509 |
// createTableDemandeM.addForeignColumn("ID_TAXE", findTableTaxe);
|
463 |
|
510 |
|
464 |
createTableDmd.addForeignColumn("COMMERCIAL");
|
511 |
createTableDmd.addForeignColumn("COMMERCIAL");
|
465 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_PRIX");
|
512 |
createTableDmd.addForeignColumn("ETAT_DEMANDE_PRIX");
|
466 |
// createTableDemandeM.addForeignColumn("ID_ADRESSE",
|
513 |
// createTableDemandeM.addForeignColumn("ID_ADRESSE",
|
467 |
// ctxt.getRoot().findTable("ADRESSE"));
|
514 |
// ctxt.getRoot().findTable("ADRESSE"));
|
468 |
createTableDmd.addVarCharColumn("INFOS", 1024);
|
515 |
createTableDmd.addVarCharColumn("INFOS", 1024);
|
469 |
|
516 |
|
470 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
517 |
root.getBase().getDataSource().execute(createTableDmd.asString());
|
471 |
InstallationPanel.insertUndef(createTableDmd);
|
518 |
InstallationPanel.insertUndef(createTableDmd);
|
472 |
root.refetchTable("DEMANDE_PRIX");
|
519 |
root.refetchTable("DEMANDE_PRIX");
|
473 |
root.getSchema().updateVersion();
|
520 |
root.getSchema().updateVersion();
|
474 |
|
521 |
|
475 |
final SQLCreateTable createTableDemandeMElt = new SQLCreateTable(root, "DEMANDE_PRIX_ELEMENT");
|
522 |
final SQLCreateTable createTableDemandeMElt = new SQLCreateTable(root, "DEMANDE_PRIX_ELEMENT");
|
476 |
createTableDemandeMElt.addVarCharColumn("NOM", 512);
|
523 |
createTableDemandeMElt.addVarCharColumn("NOM", 512);
|
477 |
createTableDemandeMElt.addForeignColumn("DEMANDE_PRIX");
|
524 |
createTableDemandeMElt.addForeignColumn("DEMANDE_PRIX");
|
478 |
createTableDemandeMElt.addForeignColumn("ID_TAXE", root.getTable("TAXE").getSQLName(), root.getTable("TAXE").getKey().getName(), "2");
|
525 |
createTableDemandeMElt.addForeignColumn("ID_TAXE", root.getTable("TAXE").getSQLName(), root.getTable("TAXE").getKey().getName(), "2");
|
479 |
|
526 |
|
480 |
createTableDemandeMElt.addIntegerColumn("QTE", 0);
|
527 |
createTableDemandeMElt.addIntegerColumn("QTE", 0);
|
481 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
528 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
482 |
createTableDemandeMElt.addColumn("PRIX_METRIQUE_VT_3", "bigint DEFAULT 0");
|
529 |
createTableDemandeMElt.addColumn("PRIX_METRIQUE_VT_3", "bigint DEFAULT 0");
|
483 |
|
530 |
|
484 |
createTableDemandeMElt.addDecimalColumn("PA_HT", 16, 6, BigDecimal.ZERO, false);
|
531 |
createTableDemandeMElt.addDecimalColumn("PA_HT", 16, 6, BigDecimal.ZERO, false);
|
485 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_2", 16, 6, BigDecimal.ZERO, false);
|
532 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_2", 16, 6, BigDecimal.ZERO, false);
|
486 |
|
533 |
|
487 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_1", 16, 6, BigDecimal.ZERO, false);
|
534 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_1", 16, 6, BigDecimal.ZERO, false);
|
488 |
createTableDemandeMElt.addDecimalColumn("T_PA_TTC", 16, 2, BigDecimal.ZERO, false);
|
535 |
createTableDemandeMElt.addDecimalColumn("T_PA_TTC", 16, 2, BigDecimal.ZERO, false);
|
489 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
536 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
490 |
createTableDemandeMElt.addDecimalColumn("T_PA_HT", 16, 6, BigDecimal.ZERO, false);
|
537 |
createTableDemandeMElt.addDecimalColumn("T_PA_HT", 16, 6, BigDecimal.ZERO, false);
|
491 |
createTableDemandeMElt.addColumn("T_POIDS", "real DEFAULT 0");
|
538 |
createTableDemandeMElt.addColumn("T_POIDS", "real DEFAULT 0");
|
492 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
539 |
createTableDemandeMElt.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
493 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_3", 16, 6, BigDecimal.ZERO, false);
|
540 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_HA_3", 16, 6, BigDecimal.ZERO, false);
|
494 |
|
541 |
|
495 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
542 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
496 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
543 |
createTableDemandeMElt.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
497 |
createTableDemandeMElt.addDecimalColumn("T_PV_TTC", 16, 2, BigDecimal.ZERO, false);
|
544 |
createTableDemandeMElt.addDecimalColumn("T_PV_TTC", 16, 2, BigDecimal.ZERO, false);
|
498 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_1", root.findTable("METRIQUE"));
|
545 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_1", root.findTable("METRIQUE"));
|
499 |
SQLTable findTable = root.findTable("MODE_VENTE_ARTICLE");
|
546 |
SQLTable findTable = root.findTable("MODE_VENTE_ARTICLE");
|
500 |
createTableDemandeMElt.addForeignColumn("ID_MODE_VENTE_ARTICLE", findTable.getSQLName(), findTable.getKey().getName(), String.valueOf(ReferenceArticleSQLElement.A_LA_PIECE));
|
547 |
createTableDemandeMElt.addForeignColumn("ID_MODE_VENTE_ARTICLE", findTable.getSQLName(), findTable.getKey().getName(), String.valueOf(ReferenceArticleSQLElement.A_LA_PIECE));
|
501 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_3", root.findTable("METRIQUE"));
|
548 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_3", root.findTable("METRIQUE"));
|
502 |
createTableDemandeMElt.addForeignColumn("ID_STYLE", root.findTable("STYLE"));
|
549 |
createTableDemandeMElt.addForeignColumn("ID_STYLE", root.findTable("STYLE"));
|
503 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_2", root.findTable("METRIQUE"));
|
550 |
createTableDemandeMElt.addForeignColumn("ID_METRIQUE_2", root.findTable("METRIQUE"));
|
504 |
createTableDemandeMElt.addIntegerColumn("QTE_ACHAT", 1);
|
551 |
createTableDemandeMElt.addIntegerColumn("QTE_ACHAT", 1);
|
505 |
createTableDemandeMElt.addForeignColumn("ID_DEVISE", root.findTable("DEVISE"));
|
552 |
createTableDemandeMElt.addForeignColumn("ID_DEVISE", root.findTable("DEVISE"));
|
506 |
createTableDemandeMElt.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
553 |
createTableDemandeMElt.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
507 |
|
554 |
|
508 |
createTableDemandeMElt.addVarCharColumn("CODE", 256);
|
555 |
createTableDemandeMElt.addVarCharColumn("CODE", 256);
|
509 |
createTableDemandeMElt.addColumn("SERVICE", "boolean DEFAULT false");
|
556 |
createTableDemandeMElt.addColumn("SERVICE", "boolean DEFAULT false");
|
510 |
|
557 |
|
511 |
createTableDemandeMElt.addDecimalColumn("T_PV_HT", 16, 6, BigDecimal.ZERO, false);
|
558 |
createTableDemandeMElt.addDecimalColumn("T_PV_HT", 16, 6, BigDecimal.ZERO, false);
|
512 |
createTableDemandeMElt.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
559 |
createTableDemandeMElt.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
513 |
createTableDemandeMElt.addColumn("POIDS", "real DEFAULT 0");
|
560 |
createTableDemandeMElt.addColumn("POIDS", "real DEFAULT 0");
|
514 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE", 16, 6, BigDecimal.ZERO, false);
|
561 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE", 16, 6, BigDecimal.ZERO, false);
|
515 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE_T", 16, 6, BigDecimal.ZERO, false);
|
562 |
createTableDemandeMElt.addDecimalColumn("PA_DEVISE_T", 16, 6, BigDecimal.ZERO, false);
|
516 |
|
563 |
|
517 |
createTableDemandeMElt.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE"));
|
564 |
createTableDemandeMElt.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE"));
|
518 |
createTableDemandeMElt.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
565 |
createTableDemandeMElt.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
519 |
createTableDemandeMElt.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE"));
|
566 |
createTableDemandeMElt.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE"));
|
520 |
createTableDemandeMElt.addVarCharColumn("DESCRIPTIF", 2048);
|
567 |
createTableDemandeMElt.addVarCharColumn("DESCRIPTIF", 2048);
|
521 |
createTableDemandeMElt.addIntegerColumn("NIVEAU", 1);
|
568 |
createTableDemandeMElt.addIntegerColumn("NIVEAU", 1);
|
- |
|
569 |
if (root.contains("DEPOT_STOCK")) {
|
- |
|
570 |
createTableDemandeMElt.addForeignColumn("DEPOT_STOCK");
|
- |
|
571 |
}
|
522 |
createTableDemandeMElt.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
|
572 |
createTableDemandeMElt.addForeignColumn("ID_ECO_CONTRIBUTION", root.findTable("ECO_CONTRIBUTION"));
|
523 |
createTableDemandeMElt.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
573 |
createTableDemandeMElt.addDecimalColumn("ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
524 |
createTableDemandeMElt.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
574 |
createTableDemandeMElt.addDecimalColumn("T_ECO_CONTRIBUTION", 16, 2, BigDecimal.ZERO, false);
|
525 |
createTableDemandeMElt.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
575 |
createTableDemandeMElt.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
526 |
|
576 |
|
527 |
root.getBase().getDataSource().execute(createTableDemandeMElt.asString());
|
577 |
root.getBase().getDataSource().execute(createTableDemandeMElt.asString());
|
528 |
InstallationPanel.insertUndef(createTableDemandeMElt);
|
578 |
InstallationPanel.insertUndef(createTableDemandeMElt);
|
529 |
root.refetchTable("DEMANDE_PRIX_ELEMENT");
|
579 |
root.refetchTable("DEMANDE_PRIX_ELEMENT");
|
530 |
root.getSchema().updateVersion();
|
580 |
root.getSchema().updateVersion();
|
531 |
|
581 |
|
532 |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO"));
|
582 |
final AlterTable alterNumero = new AlterTable(root.getTable("NUMEROTATION_AUTO"));
|
533 |
alterNumero.addVarCharColumn("DMD_PRIX_FORMAT", 128);
|
583 |
alterNumero.addVarCharColumn("DMD_PRIX_FORMAT", 128);
|
534 |
alterNumero.addIntegerColumn("DMD_PRIX_START", 1);
|
584 |
alterNumero.addIntegerColumn("DMD_PRIX_START", 1);
|
535 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
585 |
root.getBase().getDataSource().execute(alterNumero.asString());
|
536 |
root.refetchTable("NUMEROTATION_AUTO");
|
586 |
root.refetchTable("NUMEROTATION_AUTO");
|
537 |
root.getSchema().updateVersion();
|
587 |
root.getSchema().updateVersion();
|
538 |
|
588 |
|
539 |
final AlterTable alterCmd = new AlterTable(root.getTable("COMMANDE_ELEMENT"));
|
589 |
final AlterTable alterCmd = new AlterTable(root.getTable("COMMANDE_ELEMENT"));
|
540 |
alterCmd.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
590 |
alterCmd.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
541 |
root.getBase().getDataSource().execute(alterCmd.asString());
|
591 |
root.getBase().getDataSource().execute(alterCmd.asString());
|
542 |
root.refetchTable("COMMANDE_ELEMENT");
|
592 |
root.refetchTable("COMMANDE_ELEMENT");
|
543 |
root.getSchema().updateVersion();
|
593 |
root.getSchema().updateVersion();
|
544 |
|
594 |
|
545 |
final AlterTable alterF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"));
|
595 |
final AlterTable alterF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"));
|
546 |
alterF.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
596 |
alterF.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
547 |
root.getBase().getDataSource().execute(alterF.asString());
|
597 |
root.getBase().getDataSource().execute(alterF.asString());
|
548 |
root.refetchTable("FACTURE_FOURNISSEUR_ELEMENT");
|
598 |
root.refetchTable("FACTURE_FOURNISSEUR_ELEMENT");
|
549 |
root.getSchema().updateVersion();
|
599 |
root.getSchema().updateVersion();
|
550 |
|
600 |
|
551 |
final AlterTable alterB = new AlterTable(root.getTable("BON_RECEPTION_ELEMENT"));
|
601 |
final AlterTable alterB = new AlterTable(root.getTable("BON_RECEPTION_ELEMENT"));
|
552 |
alterB.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
602 |
alterB.addForeignColumn("ID_DEMANDE_ACHAT_ELEMENT", root.findTable("DEMANDE_ACHAT_ELEMENT"));
|
553 |
root.getBase().getDataSource().execute(alterB.asString());
|
603 |
root.getBase().getDataSource().execute(alterB.asString());
|
554 |
root.refetchTable("BON_RECEPTION_ELEMENT");
|
604 |
root.refetchTable("BON_RECEPTION_ELEMENT");
|
555 |
root.getSchema().updateVersion();
|
605 |
root.getSchema().updateVersion();
|
556 |
}
|
606 |
}
|
557 |
}
|
607 |
}
|
558 |
|
608 |
|
559 |
SQLTable tableDmdAChat = root.findTable("DEMANDE_ACHAT_ELEMENT");
|
609 |
SQLTable tableDmdAChat = root.findTable("DEMANDE_ACHAT_ELEMENT");
|
560 |
if (!tableDmdAChat.contains("ID_FAMILLE_ARTICLE")) {
|
610 |
if (!tableDmdAChat.contains("ID_FAMILLE_ARTICLE")) {
|
561 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
611 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
562 |
alterB.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
612 |
alterB.addForeignColumn("ID_FAMILLE_ARTICLE", root.findTable("FAMILLE_ARTICLE"));
|
563 |
root.getBase().getDataSource().execute(alterB.asString());
|
613 |
root.getBase().getDataSource().execute(alterB.asString());
|
564 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
614 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
565 |
root.getSchema().updateVersion();
|
615 |
root.getSchema().updateVersion();
|
566 |
}
|
616 |
}
|
567 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
617 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
568 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
618 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
569 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
619 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
570 |
root.getBase().getDataSource().execute(alterB.asString());
|
620 |
root.getBase().getDataSource().execute(alterB.asString());
|
571 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
621 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
572 |
root.getSchema().updateVersion();
|
622 |
root.getSchema().updateVersion();
|
573 |
}
|
623 |
}
|
574 |
|
624 |
|
575 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
625 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
576 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
626 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
577 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
627 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
578 |
root.getBase().getDataSource().execute(alterB.asString());
|
628 |
root.getBase().getDataSource().execute(alterB.asString());
|
579 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
629 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
580 |
root.getSchema().updateVersion();
|
630 |
root.getSchema().updateVersion();
|
581 |
}
|
631 |
}
|
582 |
if (!tableDmdAChat.contains("REPRISE")) {
|
632 |
if (!tableDmdAChat.contains("REPRISE")) {
|
583 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
633 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
584 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
634 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
585 |
root.getBase().getDataSource().execute(alterB.asString());
|
635 |
root.getBase().getDataSource().execute(alterB.asString());
|
586 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
636 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
587 |
root.getSchema().updateVersion();
|
637 |
root.getSchema().updateVersion();
|
588 |
}
|
638 |
}
|
589 |
|
639 |
|
- |
|
640 |
if (!tableDmdAChat.contains("ID_COMMANDE")) {
|
- |
|
641 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
642 |
alterB.addForeignColumn("ID_COMMANDE", root.findTable("COMMANDE"));
|
- |
|
643 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
644 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
645 |
root.getSchema().updateVersion();
|
- |
|
646 |
}
|
- |
|
647 |
|
- |
|
648 |
if (!tableDmdAChat.contains("REPRISE")) {
|
- |
|
649 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
650 |
alterB.addBooleanColumn("REPRISE", Boolean.FALSE, false);
|
- |
|
651 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
652 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
653 |
root.getSchema().updateVersion();
|
- |
|
654 |
}
|
- |
|
655 |
|
590 |
if (!tableDmdAChat.contains("IMPORT")) {
|
656 |
if (!tableDmdAChat.contains("IMPORT")) {
|
591 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
657 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
592 |
alterB.addBooleanColumn("IMPORT", Boolean.FALSE, false);
|
658 |
alterB.addBooleanColumn("IMPORT", Boolean.FALSE, false);
|
593 |
root.getBase().getDataSource().execute(alterB.asString());
|
659 |
root.getBase().getDataSource().execute(alterB.asString());
|
594 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
660 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
595 |
root.getSchema().updateVersion();
|
661 |
root.getSchema().updateVersion();
|
596 |
}
|
662 |
}
|
597 |
|
663 |
|
- |
|
664 |
if (!tableDmdAChat.contains("ID_BON_RECEPTION")) {
|
- |
|
665 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
- |
|
666 |
alterB.addForeignColumn("ID_BON_RECEPTION", root.findTable("BON_RECEPTION"));
|
- |
|
667 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
668 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
- |
|
669 |
root.getSchema().updateVersion();
|
- |
|
670 |
}
|
598 |
if (!tableDmdAChat.contains("QTE_RECUE")) {
|
671 |
if (!tableDmdAChat.contains("QTE_RECUE")) {
|
599 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
672 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
600 |
alterB.addIntegerColumn("QTE_RECUE", 0);
|
673 |
alterB.addIntegerColumn("QTE_RECUE", 0);
|
601 |
root.getBase().getDataSource().execute(alterB.asString());
|
674 |
root.getBase().getDataSource().execute(alterB.asString());
|
602 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
675 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
603 |
root.getSchema().updateVersion();
|
676 |
root.getSchema().updateVersion();
|
604 |
}
|
677 |
}
|
- |
|
678 |
|
605 |
if (!tableDmdAChat.contains("REPERE_SOURCE")) {
|
679 |
if (!tableDmdAChat.contains("REPERE_SOURCE")) {
|
606 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
680 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
607 |
alterB.addVarCharColumn("REPERE_SOURCE", 128);
|
681 |
alterB.addVarCharColumn("REPERE_SOURCE", 128);
|
608 |
alterB.addVarCharColumn("CODE_SOURCE", 128);
|
682 |
alterB.addVarCharColumn("CODE_SOURCE", 128);
|
609 |
alterB.addVarCharColumn("NOM_SOURCE", 128);
|
683 |
alterB.addVarCharColumn("NOM_SOURCE", 128);
|
610 |
root.getBase().getDataSource().execute(alterB.asString());
|
684 |
root.getBase().getDataSource().execute(alterB.asString());
|
611 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
685 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
612 |
root.getSchema().updateVersion();
|
686 |
root.getSchema().updateVersion();
|
613 |
}
|
687 |
}
|
614 |
SQLTable tableEtatDmdAChat = root.findTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
688 |
SQLTable tableEtatDmdAChat = root.findTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
615 |
if (!tableEtatDmdAChat.contains("COLOR")) {
|
689 |
if (!tableEtatDmdAChat.contains("COLOR")) {
|
616 |
final AlterTable alterB = new AlterTable(tableEtatDmdAChat);
|
690 |
final AlterTable alterB = new AlterTable(tableEtatDmdAChat);
|
617 |
alterB.addIntegerColumn("COLOR", null, true);
|
691 |
alterB.addIntegerColumn("COLOR", null, true);
|
618 |
root.getBase().getDataSource().execute(alterB.asString());
|
692 |
root.getBase().getDataSource().execute(alterB.asString());
|
619 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
693 |
root.refetchTable("ETAT_DEMANDE_ACHAT_ELEMENT");
|
620 |
root.getSchema().updateVersion();
|
694 |
root.getSchema().updateVersion();
|
621 |
}
|
695 |
}
|
622 |
|
696 |
|
623 |
if (!tableDmdAChat.contains("T_HT")) {
|
697 |
if (!tableDmdAChat.contains("T_HT")) {
|
624 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
698 |
final AlterTable alterB = new AlterTable(tableDmdAChat);
|
625 |
alterB.addVarCharColumn("NUMERO_SE", 128);
|
699 |
alterB.addVarCharColumn("NUMERO_SE", 128);
|
626 |
alterB.addVarCharColumn("DESCRIPTIF_SE", 512);
|
700 |
alterB.addVarCharColumn("DESCRIPTIF_SE", 512);
|
627 |
alterB.addVarCharColumn("REVISION", 48);
|
701 |
alterB.addVarCharColumn("REVISION", 48);
|
628 |
alterB.addDecimalColumn("P_HT", 16, 6, BigDecimal.ZERO, false);
|
702 |
alterB.addDecimalColumn("P_HT", 16, 6, BigDecimal.ZERO, false);
|
629 |
alterB.addDecimalColumn("T_HT", 16, 6, BigDecimal.ZERO, false);
|
703 |
alterB.addDecimalColumn("T_HT", 16, 6, BigDecimal.ZERO, false);
|
630 |
root.getBase().getDataSource().execute(alterB.asString());
|
704 |
root.getBase().getDataSource().execute(alterB.asString());
|
631 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
705 |
root.refetchTable("DEMANDE_ACHAT_ELEMENT");
|
632 |
root.getSchema().updateVersion();
|
706 |
root.getSchema().updateVersion();
|
633 |
}
|
707 |
}
|
634 |
|
708 |
|
635 |
if (!root.contains("FACTURATION_COMMANDE_CLIENT")) {
|
709 |
if (!root.contains("FACTURATION_COMMANDE_CLIENT")) {
|
636 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FACTURATION_COMMANDE_CLIENT");
|
710 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "FACTURATION_COMMANDE_CLIENT");
|
637 |
createTableEtat.addVarCharColumn("NOM", 256);
|
711 |
createTableEtat.addVarCharColumn("NOM", 256);
|
638 |
createTableEtat.addIntegerColumn("TYPE_FACTURE", TypeFactureCommandeClient.GLOBALE.getId());
|
712 |
createTableEtat.addIntegerColumn("TYPE_FACTURE", TypeFactureCommandeClient.GLOBALE.getId());
|
639 |
createTableEtat.addBooleanColumn("CHOICE", Boolean.FALSE, false);
|
713 |
createTableEtat.addBooleanColumn("CHOICE", Boolean.FALSE, false);
|
640 |
createTableEtat.addForeignColumn("TYPE_REGLEMENT");
|
714 |
createTableEtat.addForeignColumn("TYPE_REGLEMENT");
|
641 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
715 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
642 |
createTableEtat.addForeignColumn("SAISIE_VENTE_FACTURE");
|
716 |
createTableEtat.addForeignColumn("SAISIE_VENTE_FACTURE");
|
643 |
createTableEtat.addForeignColumn("MODELE");
|
717 |
createTableEtat.addForeignColumn("MODELE");
|
644 |
createTableEtat.addIntegerColumn("AJOURS", 0);
|
718 |
createTableEtat.addIntegerColumn("AJOURS", 0);
|
645 |
createTableEtat.addDecimalColumn("MONTANT", 16, 8, BigDecimal.ZERO, false);
|
719 |
createTableEtat.addDecimalColumn("MONTANT", 16, 8, BigDecimal.ZERO, false);
|
646 |
createTableEtat.addDecimalColumn("POURCENT", 16, 8, BigDecimal.ZERO, false);
|
720 |
createTableEtat.addDecimalColumn("POURCENT", 16, 8, BigDecimal.ZERO, false);
|
647 |
createTableEtat.addBooleanColumn("COMPTANT", Boolean.FALSE, false);
|
721 |
createTableEtat.addBooleanColumn("COMPTANT", Boolean.FALSE, false);
|
648 |
createTableEtat.addColumn("DATE_PREVISIONNELLE", "date");
|
722 |
createTableEtat.addColumn("DATE_PREVISIONNELLE", "date");
|
649 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
723 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
650 |
InstallationPanel.insertUndef(createTableEtat);
|
724 |
InstallationPanel.insertUndef(createTableEtat);
|
651 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
725 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
652 |
root.getSchema().updateVersion();
|
726 |
root.getSchema().updateVersion();
|
653 |
}
|
727 |
}
|
654 |
SQLTable tableFacturationCmd = root.getTable("FACTURATION_COMMANDE_CLIENT");
|
728 |
SQLTable tableFacturationCmd = root.getTable("FACTURATION_COMMANDE_CLIENT");
|
655 |
if (!tableFacturationCmd.contains("FIN_MOIS")) {
|
729 |
if (!tableFacturationCmd.contains("FIN_MOIS")) {
|
656 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
730 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
657 |
alt.addBooleanColumn("FIN_MOIS", Boolean.FALSE, false);
|
731 |
alt.addBooleanColumn("FIN_MOIS", Boolean.FALSE, false);
|
658 |
root.getBase().getDataSource().execute(alt.asString());
|
732 |
root.getBase().getDataSource().execute(alt.asString());
|
659 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
733 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
660 |
root.getSchema().updateVersion();
|
734 |
root.getSchema().updateVersion();
|
661 |
}
|
735 |
}
|
662 |
if (!tableFacturationCmd.contains("LENJOUR")) {
|
736 |
if (!tableFacturationCmd.contains("LENJOUR")) {
|
663 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
737 |
AlterTable alt = new AlterTable(tableFacturationCmd);
|
664 |
alt.addIntegerColumn("LENJOUR", 0);
|
738 |
alt.addIntegerColumn("LENJOUR", 0);
|
665 |
root.getBase().getDataSource().execute(alt.asString());
|
739 |
root.getBase().getDataSource().execute(alt.asString());
|
666 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
740 |
root.refetchTable("FACTURATION_COMMANDE_CLIENT");
|
667 |
root.getSchema().updateVersion();
|
741 |
root.getSchema().updateVersion();
|
668 |
}
|
742 |
}
|
- |
|
743 |
|
669 |
if (!root.contains("CHIFFRAGE_COMMANDE_CLIENT")) {
|
744 |
if (!root.contains("CHIFFRAGE_COMMANDE_CLIENT")) {
|
670 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "CHIFFRAGE_COMMANDE_CLIENT");
|
745 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "CHIFFRAGE_COMMANDE_CLIENT");
|
671 |
createTableEtat.addVarCharColumn("NOM", 256);
|
746 |
createTableEtat.addVarCharColumn("NOM", 256);
|
672 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
747 |
createTableEtat.addForeignColumn("COMMANDE_CLIENT");
|
673 |
createTableEtat.addForeignColumn("UNITE_VENTE");
|
748 |
createTableEtat.addForeignColumn("UNITE_VENTE");
|
674 |
createTableEtat.addForeignColumn("FAMILLE_ARTICLE");
|
749 |
createTableEtat.addForeignColumn("FAMILLE_ARTICLE");
|
675 |
createTableEtat.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, false);
|
750 |
createTableEtat.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, false);
|
676 |
createTableEtat.addDecimalColumn("PA_HT", 16, 8, BigDecimal.ZERO, false);
|
751 |
createTableEtat.addDecimalColumn("PA_HT", 16, 8, BigDecimal.ZERO, false);
|
677 |
createTableEtat.addDecimalColumn("PV_HT", 16, 8, BigDecimal.ZERO, false);
|
752 |
createTableEtat.addDecimalColumn("PV_HT", 16, 8, BigDecimal.ZERO, false);
|
678 |
createTableEtat.addDecimalColumn("T_PV_HT", 16, 8, BigDecimal.ZERO, false);
|
753 |
createTableEtat.addDecimalColumn("T_PV_HT", 16, 8, BigDecimal.ZERO, false);
|
679 |
createTableEtat.addDecimalColumn("T_PA_HT", 16, 8, BigDecimal.ZERO, false);
|
754 |
createTableEtat.addDecimalColumn("T_PA_HT", 16, 8, BigDecimal.ZERO, false);
|
680 |
createTableEtat.addDecimalColumn("MARGE", 16, 8, BigDecimal.ZERO, false);
|
755 |
createTableEtat.addDecimalColumn("MARGE", 16, 8, BigDecimal.ZERO, false);
|
681 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
756 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
682 |
InstallationPanel.insertUndef(createTableEtat);
|
757 |
InstallationPanel.insertUndef(createTableEtat);
|
683 |
root.refetchTable("CHIFFRAGE_COMMANDE_CLIENT");
|
758 |
root.refetchTable("CHIFFRAGE_COMMANDE_CLIENT");
|
684 |
root.getSchema().updateVersion();
|
759 |
root.getSchema().updateVersion();
|
685 |
}
|
760 |
}
|
686 |
|
761 |
|
687 |
// VARIABLE_SALARIE
|
762 |
// VARIABLE_SALARIE
|
688 |
SQLTable tableVarSal = root.findTable("VARIABLE_SALARIE");
|
763 |
SQLTable tableVarSal = root.findTable("VARIABLE_SALARIE");
|
689 |
if (!tableVarSal.contains("HEURE_ABS_DEFAULT_VAL")) {
|
764 |
if (!tableVarSal.contains("HEURE_ABS_DEFAULT_VAL")) {
|
690 |
|
765 |
|
691 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
766 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
692 |
|
767 |
|
693 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
768 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
694 |
|
769 |
|
695 |
String field = sqlField.getName();
|
770 |
String field = sqlField.getName();
|
696 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
771 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
697 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.equalsIgnoreCase("HEURE_TRAV")) {
|
772 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.equalsIgnoreCase("HEURE_TRAV")) {
|
698 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
773 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
699 |
}
|
774 |
}
|
700 |
}
|
775 |
}
|
701 |
|
776 |
|
702 |
root.getBase().getDataSource().execute(alterB.asString());
|
777 |
root.getBase().getDataSource().execute(alterB.asString());
|
703 |
root.refetchTable("VARIABLE_SALARIE");
|
778 |
root.refetchTable("VARIABLE_SALARIE");
|
704 |
root.getSchema().updateVersion();
|
779 |
root.getSchema().updateVersion();
|
705 |
}
|
780 |
}
|
706 |
|
781 |
|
707 |
SQLTable tableFpaye = root.findTable("FICHE_PAYE");
|
782 |
SQLTable tableFpaye = root.findTable("FICHE_PAYE");
|
708 |
if (!tableFpaye.contains("TAXE_CM_SAL")) {
|
783 |
if (!tableFpaye.contains("TAXE_CM_SAL")) {
|
709 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
784 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
710 |
alterB.addDecimalColumn("SAL_BASE_BRUT", 16, 2, BigDecimal.ZERO, false);
|
785 |
alterB.addDecimalColumn("SAL_BASE_BRUT", 16, 2, BigDecimal.ZERO, false);
|
711 |
alterB.addDecimalColumn("TAXE_CM_SAL", 16, 2, BigDecimal.ZERO, false);
|
786 |
alterB.addDecimalColumn("TAXE_CM_SAL", 16, 2, BigDecimal.ZERO, false);
|
712 |
alterB.addDecimalColumn("TAXE_CM_PAT", 16, 2, BigDecimal.ZERO, false);
|
787 |
alterB.addDecimalColumn("TAXE_CM_PAT", 16, 2, BigDecimal.ZERO, false);
|
713 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE", 16, 2, BigDecimal.ZERO, false);
|
788 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE", 16, 2, BigDecimal.ZERO, false);
|
714 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE", 16, 2, BigDecimal.ZERO, false);
|
789 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE", 16, 2, BigDecimal.ZERO, false);
|
715 |
root.getBase().getDataSource().execute(alterB.asString());
|
790 |
root.getBase().getDataSource().execute(alterB.asString());
|
716 |
root.refetchTable("FICHE_PAYE");
|
791 |
root.refetchTable("FICHE_PAYE");
|
717 |
root.getSchema().updateVersion();
|
792 |
root.getSchema().updateVersion();
|
718 |
|
793 |
|
719 |
SQLTable tableElementPaye = root.getTable("FICHE_PAYE_ELEMENT");
|
794 |
SQLTable tableElementPaye = root.getTable("FICHE_PAYE_ELEMENT");
|
720 |
|
795 |
|
721 |
AlterTable tEltPaye = new AlterTable(tableElementPaye);
|
796 |
AlterTable tEltPaye = new AlterTable(tableElementPaye);
|
722 |
tEltPaye.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
|
797 |
tEltPaye.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(512)", "''", false);
|
723 |
tableElementPaye.getBase().getDataSource().execute(tEltPaye.asString());
|
798 |
tableElementPaye.getBase().getDataSource().execute(tEltPaye.asString());
|
724 |
tableElementPaye.getSchema().updateVersion();
|
799 |
tableElementPaye.getSchema().updateVersion();
|
725 |
tableElementPaye.fetchFields();
|
800 |
tableElementPaye.fetchFields();
|
726 |
|
801 |
|
727 |
}
|
802 |
}
|
728 |
|
803 |
|
729 |
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
|
804 |
SQLTable tableCpaye = root.findTable("CUMULS_PAYE");
|
730 |
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
|
805 |
if (!tableCpaye.contains("TAXE_CM_SAL_C")) {
|
731 |
final AlterTable alterB = new AlterTable(tableCpaye);
|
806 |
final AlterTable alterB = new AlterTable(tableCpaye);
|
732 |
alterB.addDecimalColumn("TAXE_CM_SAL_C", 16, 2, BigDecimal.ZERO, false);
|
807 |
alterB.addDecimalColumn("TAXE_CM_SAL_C", 16, 2, BigDecimal.ZERO, false);
|
733 |
alterB.addDecimalColumn("TAXE_CM_PAT_C", 16, 2, BigDecimal.ZERO, false);
|
808 |
alterB.addDecimalColumn("TAXE_CM_PAT_C", 16, 2, BigDecimal.ZERO, false);
|
734 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE_C", 16, 2, BigDecimal.ZERO, false);
|
809 |
alterB.addDecimalColumn("SAL_BRUT_COTISABLE_C", 16, 2, BigDecimal.ZERO, false);
|
735 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE_C", 16, 2, BigDecimal.ZERO, false);
|
810 |
alterB.addDecimalColumn("SAL_BRUT_TAXABLE_C", 16, 2, BigDecimal.ZERO, false);
|
736 |
alterB.addDecimalColumn("SAL_BASE_BRUT_C", 16, 2, BigDecimal.ZERO, false);
|
811 |
alterB.addDecimalColumn("SAL_BASE_BRUT_C", 16, 2, BigDecimal.ZERO, false);
|
737 |
root.getBase().getDataSource().execute(alterB.asString());
|
812 |
root.getBase().getDataSource().execute(alterB.asString());
|
738 |
root.refetchTable("CUMULS_PAYE");
|
813 |
root.refetchTable("CUMULS_PAYE");
|
739 |
root.getSchema().updateVersion();
|
814 |
root.getSchema().updateVersion();
|
740 |
}
|
815 |
}
|
741 |
|
816 |
|
742 |
SQLTable tableEtatCivil = root.findTable("ETAT_CIVIL");
|
817 |
SQLTable tableEtatCivil = root.findTable("ETAT_CIVIL");
|
743 |
if (!tableEtatCivil.contains("NATIONNALITE")) {
|
818 |
if (!tableEtatCivil.contains("NATIONNALITE")) {
|
744 |
final AlterTable alterB = new AlterTable(tableEtatCivil);
|
819 |
final AlterTable alterB = new AlterTable(tableEtatCivil);
|
745 |
alterB.addVarCharColumn("NATIONNALITE", 256);
|
820 |
alterB.addVarCharColumn("NATIONNALITE", 256);
|
746 |
alterB.addVarCharColumn("CNPS", 256);
|
821 |
alterB.addVarCharColumn("CNPS", 256);
|
747 |
alterB.addVarCharColumn("TYPE_PIECE_IDENTITE", 256);
|
822 |
alterB.addVarCharColumn("TYPE_PIECE_IDENTITE", 256);
|
748 |
alterB.addVarCharColumn("NUMERO_PIECE", 256);
|
823 |
alterB.addVarCharColumn("NUMERO_PIECE", 256);
|
749 |
alterB.addVarCharColumn("NOM_PERE", 256);
|
824 |
alterB.addVarCharColumn("NOM_PERE", 256);
|
750 |
alterB.addVarCharColumn("NOM_MERE", 256);
|
825 |
alterB.addVarCharColumn("NOM_MERE", 256);
|
751 |
alterB.addVarCharColumn("CONJOINT_NOM", 256);
|
826 |
alterB.addVarCharColumn("CONJOINT_NOM", 256);
|
752 |
alterB.addColumn("CONJOINT_DATE_NAISSANCE", "date");
|
827 |
alterB.addColumn("CONJOINT_DATE_NAISSANCE", "date");
|
753 |
alterB.addVarCharColumn("CONJOINT_LIEU_NAISSANCE", 256);
|
828 |
alterB.addVarCharColumn("CONJOINT_LIEU_NAISSANCE", 256);
|
754 |
alterB.addVarCharColumn("CONJOINT_PROFESSION", 256);
|
829 |
alterB.addVarCharColumn("CONJOINT_PROFESSION", 256);
|
755 |
alterB.addColumn("DATE_DEBUT_PIECE", "date");
|
830 |
alterB.addColumn("DATE_DEBUT_PIECE", "date");
|
756 |
alterB.addColumn("DATE_FIN_PIECE", "date");
|
831 |
alterB.addColumn("DATE_FIN_PIECE", "date");
|
757 |
root.getBase().getDataSource().execute(alterB.asString());
|
832 |
root.getBase().getDataSource().execute(alterB.asString());
|
758 |
root.refetchTable("ETAT_CIVIL");
|
833 |
root.refetchTable("ETAT_CIVIL");
|
759 |
root.getSchema().updateVersion();
|
834 |
root.getSchema().updateVersion();
|
760 |
}
|
835 |
}
|
761 |
|
836 |
|
762 |
// ARTICLE CLIENT
|
837 |
// ARTICLE CLIENT
|
763 |
if (!root.contains("ARTICLE_CODE_CLIENT")) {
|
838 |
if (!root.contains("ARTICLE_CODE_CLIENT")) {
|
764 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ARTICLE_CODE_CLIENT");
|
839 |
final SQLCreateTable createTableEtat = new SQLCreateTable(root, "ARTICLE_CODE_CLIENT");
|
765 |
createTableEtat.addVarCharColumn("NOM", 512);
|
840 |
createTableEtat.addVarCharColumn("NOM", 512);
|
766 |
createTableEtat.addVarCharColumn("CODE", 512);
|
841 |
createTableEtat.addVarCharColumn("CODE", 512);
|
767 |
createTableEtat.addForeignColumn("CLIENT");
|
842 |
createTableEtat.addForeignColumn("CLIENT");
|
768 |
createTableEtat.addForeignColumn("ARTICLE");
|
843 |
createTableEtat.addForeignColumn("ARTICLE");
|
769 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
844 |
root.getBase().getDataSource().execute(createTableEtat.asString());
|
770 |
InstallationPanel.insertUndef(createTableEtat);
|
845 |
InstallationPanel.insertUndef(createTableEtat);
|
771 |
root.refetchTable("ARTICLE_CODE_CLIENT");
|
846 |
root.refetchTable("ARTICLE_CODE_CLIENT");
|
772 |
root.getSchema().updateVersion();
|
847 |
root.getSchema().updateVersion();
|
773 |
}
|
848 |
}
|
774 |
SQLTable tableClient = root.getTable("CLIENT");
|
849 |
SQLTable tableClient = root.getTable("CLIENT");
|
775 |
if (!tableClient.contains("CODE_FOURNISSEUR")) {
|
850 |
if (!tableClient.contains("CODE_FOURNISSEUR")) {
|
776 |
final AlterTable alter = new AlterTable(tableClient);
|
851 |
final AlterTable alter = new AlterTable(tableClient);
|
777 |
alter.addVarCharColumn("CODE_FOURNISSEUR", 256);
|
852 |
alter.addVarCharColumn("CODE_FOURNISSEUR", 256);
|
778 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
853 |
tableCompte.getBase().getDataSource().execute(alter.asString());
|
779 |
tableCompte.getSchema().updateVersion();
|
854 |
tableCompte.getSchema().updateVersion();
|
780 |
tableCompte.fetchFields();
|
855 |
tableCompte.fetchFields();
|
781 |
}
|
856 |
}
|
782 |
SQLTable tableArticle = root.getTable("ARTICLE");
|
857 |
SQLTable tableArticle = root.getTable("ARTICLE");
|
783 |
if (!tableArticle.contains("TARE")) {
|
858 |
if (!tableArticle.contains("TARE")) {
|
784 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
859 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
785 |
alterArticle.addDecimalColumn("TARE", 16, 8, BigDecimal.ZERO, true);
|
860 |
alterArticle.addDecimalColumn("TARE", 16, 8, BigDecimal.ZERO, true);
|
786 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
861 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
787 |
tableArticle.getSchema().updateVersion();
|
862 |
tableArticle.getSchema().updateVersion();
|
788 |
tableArticle.fetchFields();
|
863 |
tableArticle.fetchFields();
|
789 |
}
|
864 |
}
|
790 |
if (!tableArticle.contains("IFCO")) {
|
865 |
if (!tableArticle.contains("IFCO")) {
|
791 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
866 |
final AlterTable alterArticle = new AlterTable(tableArticle);
|
792 |
alterArticle.addIntegerColumn("IFCO", 0);
|
867 |
alterArticle.addIntegerColumn("IFCO", 0);
|
793 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
868 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
794 |
tableArticle.getSchema().updateVersion();
|
869 |
tableArticle.getSchema().updateVersion();
|
795 |
tableArticle.fetchFields();
|
870 |
tableArticle.fetchFields();
|
796 |
}
|
871 |
}
|
797 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
872 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
798 |
if (!tableFournisseur.contains("NUMERO_TVA")) {
|
873 |
if (!tableFournisseur.contains("NUMERO_TVA")) {
|
799 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
874 |
final AlterTable alter = new AlterTable(tableFournisseur);
|
800 |
alter.addVarCharColumn("NUMERO_TVA", 128);
|
875 |
alter.addVarCharColumn("NUMERO_TVA", 128);
|
801 |
alter.addVarCharColumn("SIRET", 128);
|
876 |
alter.addVarCharColumn("SIRET", 128);
|
802 |
tableFournisseur.getBase().getDataSource().execute(alter.asString());
|
877 |
tableFournisseur.getBase().getDataSource().execute(alter.asString());
|
803 |
tableFournisseur.getSchema().updateVersion();
|
878 |
tableFournisseur.getSchema().updateVersion();
|
804 |
tableFournisseur.fetchFields();
|
879 |
tableFournisseur.fetchFields();
|
805 |
}
|
880 |
}
|
806 |
|
881 |
|
807 |
// POS
|
882 |
// POS
|
808 |
final SQLTable caisseT = root.getTable("CAISSE");
|
883 |
final SQLTable caisseT = root.getTable("CAISSE");
|
809 |
final String registerLogTableName = "CAISSE_JOURNAL";
|
884 |
final String registerLogTableName = "CAISSE_JOURNAL";
|
810 |
if (!root.contains(registerLogTableName)) {
|
885 |
if (!root.contains(registerLogTableName)) {
|
811 |
final SQLTable receiptT = root.getTable("TICKET_CAISSE");
|
886 |
final SQLTable receiptT = root.getTable("TICKET_CAISSE");
|
812 |
final SQLTable userT = root.findTable("USER_COMMON", true);
|
887 |
final SQLTable userT = root.findTable("USER_COMMON", true);
|
813 |
|
888 |
|
814 |
final SQLCreateTable createLogT = new SQLCreateTable(caisseT.getDBRoot(), registerLogTableName);
|
889 |
final SQLCreateTable createLogT = new SQLCreateTable(caisseT.getDBRoot(), registerLogTableName);
|
815 |
createLogT.setCreateOrder(false);
|
890 |
createLogT.setCreateOrder(false);
|
816 |
AddMDFields.addFields(createLogT, userT);
|
891 |
AddMDFields.addFields(createLogT, userT);
|
817 |
createLogT.addForeignColumn("ID_CAISSE", caisseT);
|
892 |
createLogT.addForeignColumn("ID_CAISSE", caisseT);
|
818 |
createLogT.addDateAndTimeColumn("DATE");
|
893 |
createLogT.addDateAndTimeColumn("DATE");
|
819 |
createLogT.addForeignColumn("ID_USER", userT);
|
894 |
createLogT.addForeignColumn("ID_USER", userT);
|
820 |
createLogT.addVarCharColumn("EVT", 128);
|
895 |
createLogT.addVarCharColumn("EVT", 128);
|
821 |
createLogT.addVarCharColumn("CREATOR", 128);
|
896 |
createLogT.addVarCharColumn("CREATOR", 128);
|
822 |
createLogT.addVarCharColumn("CREATOR_VERSION", 128);
|
897 |
createLogT.addVarCharColumn("CREATOR_VERSION", 128);
|
823 |
createLogT.addUniqueConstraint("logSequence", Arrays.asList("ID_CAISSE", "DATE"));
|
898 |
createLogT.addUniqueConstraint("logSequence", Arrays.asList("ID_CAISSE", "DATE"));
|
824 |
|
899 |
|
825 |
final SQLCreateTable createClotureT = new SQLCreateTable(caisseT.getDBRoot(), "CAISSE_CLOTURE");
|
900 |
final SQLCreateTable createClotureT = new SQLCreateTable(caisseT.getDBRoot(), "CAISSE_CLOTURE");
|
826 |
createClotureT.setCreateOrder(false);
|
901 |
createClotureT.setCreateOrder(false);
|
827 |
AddMDFields.addFields(createClotureT, userT);
|
902 |
AddMDFields.addFields(createClotureT, userT);
|
828 |
createClotureT.addForeignColumn("ID_ENTREE_JOURNAL", createLogT);
|
903 |
createClotureT.addForeignColumn("ID_ENTREE_JOURNAL", createLogT);
|
829 |
createClotureT.addVarCharColumn("PERIODE", 32);
|
904 |
createClotureT.addVarCharColumn("PERIODE", 32);
|
830 |
final String dateType = createClotureT.getSyntax().getTypeNames(java.sql.Date.class).iterator().next();
|
905 |
final String dateType = createClotureT.getSyntax().getTypeNames(java.sql.Date.class).iterator().next();
|
831 |
createClotureT.addColumn("DEBUT", dateType, null, false);
|
906 |
createClotureT.addColumn("DEBUT", dateType, null, false);
|
832 |
createClotureT.addColumn("FIN", dateType, null, false);
|
907 |
createClotureT.addColumn("FIN", dateType, null, false);
|
833 |
createClotureT.addDecimalColumn("TOTAL_TTC", 16, 6, BigDecimal.ZERO, false);
|
908 |
createClotureT.addDecimalColumn("TOTAL_TTC", 16, 6, BigDecimal.ZERO, false);
|
834 |
// don't use foreign keys, we actually want redundant info so that we can check
|
909 |
// don't use foreign keys, we actually want redundant info so that we can check
|
835 |
// coherence
|
910 |
// coherence
|
836 |
// nullable to allow for days without any sales
|
911 |
// nullable to allow for days without any sales
|
837 |
createClotureT.addVarCharColumn("PREMIER_TICKET", 64, false, "null", true);
|
912 |
createClotureT.addVarCharColumn("PREMIER_TICKET", 64, false, "null", true);
|
838 |
createClotureT.addVarCharColumn("PREMIER_TICKET_HASH", 128, false, "null", true);
|
913 |
createClotureT.addVarCharColumn("PREMIER_TICKET_HASH", 128, false, "null", true);
|
839 |
createClotureT.addVarCharColumn("DERNIER_TICKET", 64, false, "null", true);
|
914 |
createClotureT.addVarCharColumn("DERNIER_TICKET", 64, false, "null", true);
|
840 |
createClotureT.addVarCharColumn("DERNIER_TICKET_HASH", 128, false, "null", true);
|
915 |
createClotureT.addVarCharColumn("DERNIER_TICKET_HASH", 128, false, "null", true);
|
841 |
createClotureT.addUniqueConstraint("uniqueness", Arrays.asList("ID_ENTREE_JOURNAL"));
|
916 |
createClotureT.addUniqueConstraint("uniqueness", Arrays.asList("ID_ENTREE_JOURNAL"));
|
842 |
|
917 |
|
843 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
918 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
844 |
alterRegister.addForeignColumn("ID_DERNIERE_ENTREE_JOURNAL", createLogT);
|
919 |
alterRegister.addForeignColumn("ID_DERNIERE_ENTREE_JOURNAL", createLogT);
|
845 |
alterRegister.addForeignColumn("ID_DERNIERE_CLOTURE", createClotureT);
|
920 |
alterRegister.addForeignColumn("ID_DERNIERE_CLOTURE", createClotureT);
|
846 |
|
921 |
|
847 |
final AlterTable alterReceipt = new AlterTable(receiptT);
|
922 |
final AlterTable alterReceipt = new AlterTable(receiptT);
|
848 |
alterReceipt.addVarCharColumn("FILE_HASH", 128, false, "null", true);
|
923 |
alterReceipt.addVarCharColumn("FILE_HASH", 128, false, "null", true);
|
849 |
alterReceipt.addVarCharColumn("FILE_HASH_PREVIOUS", 128, false, "null", true);
|
924 |
alterReceipt.addVarCharColumn("FILE_HASH_PREVIOUS", 128, false, "null", true);
|
850 |
alterReceipt.addUniqueConstraint("uniqueNumber", new UniqueConstraintCreatorHelper(Arrays.asList("NUMERO"), TicketCaisseSQLElement.UNARCHIVED_WHERE) {
|
925 |
alterReceipt.addUniqueConstraint("uniqueNumber", new UniqueConstraintCreatorHelper(Arrays.asList("NUMERO"), TicketCaisseSQLElement.UNARCHIVED_WHERE) {
|
851 |
@Override
|
926 |
@Override
|
852 |
public Object getObject(SQLSyntax s) {
|
927 |
public Object getObject(SQLSyntax s) {
|
853 |
if (s.getSystem() == SQLSystem.H2) {
|
928 |
if (s.getSystem() == SQLSystem.H2) {
|
854 |
return TicketCaisseSQLElement.UniqueNumber_PartialUniqueTrigger.class;
|
929 |
return TicketCaisseSQLElement.UniqueNumber_PartialUniqueTrigger.class;
|
855 |
} else {
|
930 |
} else {
|
856 |
return super.getObject(s);
|
931 |
return super.getObject(s);
|
857 |
}
|
932 |
}
|
858 |
}
|
933 |
}
|
859 |
});
|
934 |
});
|
860 |
alterReceipt.addUniqueConstraint("uniqueDate", new UniqueConstraintCreatorHelper(Arrays.asList("ID_CAISSE", "DATE"), TicketCaisseSQLElement.DATE_WHERE) {
|
935 |
alterReceipt.addUniqueConstraint("uniqueDate", new UniqueConstraintCreatorHelper(Arrays.asList("ID_CAISSE", "DATE"), TicketCaisseSQLElement.DATE_WHERE) {
|
861 |
@Override
|
936 |
@Override
|
862 |
public Object getObject(SQLSyntax s) {
|
937 |
public Object getObject(SQLSyntax s) {
|
863 |
if (s.getSystem() == SQLSystem.H2) {
|
938 |
if (s.getSystem() == SQLSystem.H2) {
|
864 |
return TicketCaisseSQLElement.UniqueDate_PartialUniqueTrigger.class;
|
939 |
return TicketCaisseSQLElement.UniqueDate_PartialUniqueTrigger.class;
|
865 |
} else {
|
940 |
} else {
|
866 |
return super.getObject(s);
|
941 |
return super.getObject(s);
|
867 |
}
|
942 |
}
|
868 |
}
|
943 |
}
|
869 |
});
|
944 |
});
|
870 |
|
945 |
|
871 |
root.createTables(createLogT, createClotureT);
|
946 |
root.createTables(createLogT, createClotureT);
|
872 |
root.getDBSystemRoot().getDataSource().execute(alterRegister.asString());
|
947 |
root.getDBSystemRoot().getDataSource().execute(alterRegister.asString());
|
873 |
root.getDBSystemRoot().getDataSource().execute(alterReceipt.asString());
|
948 |
root.getDBSystemRoot().getDataSource().execute(alterReceipt.asString());
|
874 |
caisseT.getSchema().updateVersion();
|
949 |
caisseT.getSchema().updateVersion();
|
875 |
alterRegister.getTable().fetchFields();
|
950 |
alterRegister.getTable().fetchFields();
|
876 |
alterReceipt.getTable().fetchFields();
|
951 |
alterReceipt.getTable().fetchFields();
|
877 |
}
|
952 |
}
|
878 |
|
953 |
|
879 |
SQLTable tableArt = root.getTable("ARTICLE");
|
954 |
SQLTable tableArt = root.getTable("ARTICLE");
|
880 |
if (!tableArt.contains("MASQUE_CAISSE")) {
|
955 |
if (!tableArt.contains("MASQUE_CAISSE")) {
|
881 |
final AlterTable alterArt = new AlterTable(tableArt);
|
956 |
final AlterTable alterArt = new AlterTable(tableArt);
|
882 |
alterArt.addBooleanColumn("MASQUE_CAISSE", Boolean.FALSE, false);
|
957 |
alterArt.addBooleanColumn("MASQUE_CAISSE", Boolean.FALSE, false);
|
883 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
958 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
884 |
tableArt.getSchema().updateVersion();
|
959 |
tableArt.getSchema().updateVersion();
|
885 |
tableArt.fetchFields();
|
960 |
tableArt.fetchFields();
|
886 |
}
|
961 |
}
|
887 |
|
962 |
|
888 |
if (!tableArt.contains("ADDITIONAL_TICKET_COPY")) {
|
963 |
if (!tableArt.contains("ADDITIONAL_TICKET_COPY")) {
|
889 |
final AlterTable alterArt = new AlterTable(tableArt);
|
964 |
final AlterTable alterArt = new AlterTable(tableArt);
|
890 |
alterArt.addBooleanColumn("ADDITIONAL_TICKET_COPY", Boolean.FALSE, false);
|
965 |
alterArt.addBooleanColumn("ADDITIONAL_TICKET_COPY", Boolean.FALSE, false);
|
891 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
966 |
tableArt.getBase().getDataSource().execute(alterArt.asString());
|
892 |
tableArt.getSchema().updateVersion();
|
967 |
tableArt.getSchema().updateVersion();
|
893 |
tableArt.fetchFields();
|
968 |
tableArt.fetchFields();
|
894 |
}
|
969 |
}
|
895 |
|
970 |
|
896 |
SQLTable tableDevisAcompte = root.getTable("DEVIS");
|
971 |
SQLTable tableDevisAcompte = root.getTable("DEVIS");
|
897 |
|
972 |
|
898 |
if (!tableDevisAcompte.contains("T_ACOMPTE")) {
|
973 |
if (!tableDevisAcompte.contains("T_ACOMPTE")) {
|
899 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
974 |
final AlterTable alterB = new AlterTable(tableDevisAcompte);
|
900 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
975 |
alterB.addLongColumn("T_ACOMPTE", 0L, false);
|
901 |
root.getBase().getDataSource().execute(alterB.asString());
|
976 |
root.getBase().getDataSource().execute(alterB.asString());
|
902 |
root.refetchTable("DEVIS");
|
977 |
root.refetchTable("DEVIS");
|
903 |
root.getSchema().updateVersion();
|
978 |
root.getSchema().updateVersion();
|
904 |
|
979 |
|
905 |
SQLTable tableEncaisse = root.getTable("ENCAISSER_MONTANT");
|
980 |
SQLTable tableEncaisse = root.getTable("ENCAISSER_MONTANT");
|
906 |
final AlterTable alterC = new AlterTable(tableEncaisse);
|
981 |
final AlterTable alterC = new AlterTable(tableEncaisse);
|
907 |
alterC.addBooleanColumn("ACOMPTE", Boolean.FALSE, false);
|
982 |
alterC.addBooleanColumn("ACOMPTE", Boolean.FALSE, false);
|
908 |
alterC.addForeignColumn("ID_DEVIS", tableDevisAcompte);
|
983 |
alterC.addForeignColumn("ID_DEVIS", tableDevisAcompte);
|
909 |
root.getBase().getDataSource().execute(alterC.asString());
|
984 |
root.getBase().getDataSource().execute(alterC.asString());
|
910 |
root.refetchTable("ENCAISSER_MONTANT");
|
985 |
root.refetchTable("ENCAISSER_MONTANT");
|
911 |
root.getSchema().updateVersion();
|
986 |
root.getSchema().updateVersion();
|
912 |
|
987 |
|
913 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
988 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
914 |
final AlterTable alterF = new AlterTable(tableVF);
|
989 |
final AlterTable alterF = new AlterTable(tableVF);
|
915 |
alterF.addLongColumn("T_ACOMPTE", 0L, false);
|
990 |
alterF.addLongColumn("T_ACOMPTE", 0L, false);
|
916 |
root.getBase().getDataSource().execute(alterF.asString());
|
991 |
root.getBase().getDataSource().execute(alterF.asString());
|
917 |
root.refetchTable("SAISIE_VENTE_FACTURE");
|
992 |
root.refetchTable("SAISIE_VENTE_FACTURE");
|
918 |
root.getSchema().updateVersion();
|
993 |
root.getSchema().updateVersion();
|
919 |
}
|
994 |
}
|
920 |
|
995 |
|
921 |
// Paye Simplifiée
|
996 |
// Paye Simplifiée
|
922 |
if (!tableFpaye.contains("ALLEGEMENT_COTISATION")) {
|
997 |
if (!tableFpaye.contains("ALLEGEMENT_COTISATION")) {
|
923 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
998 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
924 |
alterB.addDecimalColumn("ALLEGEMENT_COTISATION", 16, 2, BigDecimal.ZERO, false);
|
999 |
alterB.addDecimalColumn("ALLEGEMENT_COTISATION", 16, 2, BigDecimal.ZERO, false);
|
925 |
alterB.addDecimalColumn("CICE", 16, 2, BigDecimal.ZERO, false);
|
1000 |
alterB.addDecimalColumn("CICE", 16, 2, BigDecimal.ZERO, false);
|
926 |
alterB.addDecimalColumn("AVANTAGE_NATURE", 16, 2, BigDecimal.ZERO, false);
|
1001 |
alterB.addDecimalColumn("AVANTAGE_NATURE", 16, 2, BigDecimal.ZERO, false);
|
927 |
alterB.addDecimalColumn("HEURE_TRAV", 16, 2, BigDecimal.ZERO, false);
|
1002 |
alterB.addDecimalColumn("HEURE_TRAV", 16, 2, BigDecimal.ZERO, false);
|
928 |
root.getBase().getDataSource().execute(alterB.asString());
|
1003 |
root.getBase().getDataSource().execute(alterB.asString());
|
929 |
root.refetchTable("FICHE_PAYE");
|
1004 |
root.refetchTable("FICHE_PAYE");
|
930 |
root.getSchema().updateVersion();
|
1005 |
root.getSchema().updateVersion();
|
931 |
|
1006 |
|
932 |
final AlterTable alterC = new AlterTable(tableCpaye);
|
1007 |
final AlterTable alterC = new AlterTable(tableCpaye);
|
933 |
alterC.addDecimalColumn("ALLEGEMENT_COTISATION_C", 16, 2, BigDecimal.ZERO, false);
|
1008 |
alterC.addDecimalColumn("ALLEGEMENT_COTISATION_C", 16, 2, BigDecimal.ZERO, false);
|
934 |
alterC.addDecimalColumn("CICE_C", 16, 2, BigDecimal.ZERO, false);
|
1009 |
alterC.addDecimalColumn("CICE_C", 16, 2, BigDecimal.ZERO, false);
|
935 |
alterC.addDecimalColumn("AVANTAGE_NATURE_C", 16, 2, BigDecimal.ZERO, false);
|
1010 |
alterC.addDecimalColumn("AVANTAGE_NATURE_C", 16, 2, BigDecimal.ZERO, false);
|
936 |
root.getBase().getDataSource().execute(alterC.asString());
|
1011 |
root.getBase().getDataSource().execute(alterC.asString());
|
937 |
root.refetchTable("CUMULS_PAYE");
|
1012 |
root.refetchTable("CUMULS_PAYE");
|
938 |
root.getSchema().updateVersion();
|
1013 |
root.getSchema().updateVersion();
|
939 |
|
1014 |
|
940 |
}
|
1015 |
}
|
- |
|
1016 |
|
941 |
if (!tableFpaye.contains("DETAILS_CONGES")) {
|
1017 |
if (!tableFpaye.contains("DETAILS_CONGES")) {
|
942 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
1018 |
final AlterTable alterB = new AlterTable(tableFpaye);
|
943 |
alterB.addVarCharColumn("DETAILS_CONGES", 512);
|
1019 |
alterB.addVarCharColumn("DETAILS_CONGES", 512);
|
944 |
root.getBase().getDataSource().execute(alterB.asString());
|
1020 |
root.getBase().getDataSource().execute(alterB.asString());
|
945 |
root.refetchTable("FICHE_PAYE");
|
1021 |
root.refetchTable("FICHE_PAYE");
|
946 |
root.getSchema().updateVersion();
|
1022 |
root.getSchema().updateVersion();
|
947 |
}
|
1023 |
}
|
948 |
|
1024 |
|
949 |
SQLTable tableFPayeElt = root.getTable("FICHE_PAYE_ELEMENT");
|
1025 |
SQLTable tableFPayeElt = root.getTable("FICHE_PAYE_ELEMENT");
|
950 |
if (!tableFPayeElt.contains("ID_STYLE")) {
|
1026 |
if (!tableFPayeElt.contains("ID_STYLE")) {
|
951 |
final AlterTable alterB = new AlterTable(tableFPayeElt);
|
1027 |
final AlterTable alterB = new AlterTable(tableFPayeElt);
|
952 |
alterB.addForeignColumn("ID_STYLE", root.getTable("STYLE"));
|
1028 |
alterB.addForeignColumn("ID_STYLE", root.getTable("STYLE"));
|
953 |
root.getBase().getDataSource().execute(alterB.asString());
|
1029 |
root.getBase().getDataSource().execute(alterB.asString());
|
954 |
root.refetchTable("FICHE_PAYE_ELEMENT");
|
1030 |
root.refetchTable("FICHE_PAYE_ELEMENT");
|
955 |
root.getSchema().updateVersion();
|
1031 |
root.getSchema().updateVersion();
|
956 |
}
|
1032 |
}
|
957 |
|
1033 |
|
958 |
if (!tableVarSal.contains("IJSS_BRUT")) {
|
1034 |
if (!tableVarSal.contains("IJSS_BRUT")) {
|
959 |
final AlterTable alterB = new AlterTable(tableVarSal);
|
1035 |
final AlterTable alterB = new AlterTable(tableVarSal);
|
960 |
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT");
|
1036 |
List<String> f = Arrays.asList("IJSS_BRUT", "IJSS_NET", "FRAIS_PRO", "RBT_TRANSPORT");
|
961 |
for (String field : f) {
|
1037 |
for (String field : f) {
|
962 |
alterB.addColumn(field, "real DEFAULT 0");
|
1038 |
alterB.addColumn(field, "real DEFAULT 0");
|
963 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
1039 |
alterB.addColumn(field + "_DEFAULT_VAL", "real DEFAULT 0");
|
964 |
}
|
1040 |
}
|
965 |
root.getBase().getDataSource().execute(alterB.asString());
|
1041 |
root.getBase().getDataSource().execute(alterB.asString());
|
966 |
root.refetchTable(tableVarSal.getName());
|
1042 |
root.refetchTable(tableVarSal.getName());
|
967 |
root.getSchema().updateVersion();
|
1043 |
root.getSchema().updateVersion();
|
968 |
}
|
1044 |
}
|
969 |
|
1045 |
|
970 |
SQLTable tableDevis = root.getTable("DEVIS");
|
1046 |
SQLTable tableDevis = root.getTable("DEVIS");
|
971 |
if (!tableDevis.contains("ID_TAXE_PORT")) {
|
1047 |
if (!tableDevis.contains("ID_TAXE_PORT")) {
|
972 |
final AlterTable alterB = new AlterTable(tableDevis);
|
1048 |
final AlterTable alterB = new AlterTable(tableDevis);
|
973 |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
1049 |
alterB.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
974 |
root.getBase().getDataSource().execute(alterB.asString());
|
1050 |
root.getBase().getDataSource().execute(alterB.asString());
|
975 |
root.refetchTable(tableDevis.getName());
|
1051 |
root.refetchTable(tableDevis.getName());
|
976 |
root.getSchema().updateVersion();
|
1052 |
root.getSchema().updateVersion();
|
977 |
}
|
1053 |
}
|
978 |
|
1054 |
|
979 |
// 1.5.3
|
1055 |
// 1.5.3
|
980 |
List<String> tableRemiseF = Arrays.asList("COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
|
1056 |
List<String> tableRemiseF = Arrays.asList("COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
|
981 |
for (String t : tableRemiseF) {
|
1057 |
for (String t : tableRemiseF) {
|
982 |
|
1058 |
|
983 |
final SQLTable tableCommande = root.getTable(t);
|
1059 |
final SQLTable tableCommande = root.getTable(t);
|
984 |
AlterTable tCommande = new AlterTable(tableCommande);
|
1060 |
AlterTable tCommande = new AlterTable(tableCommande);
|
985 |
boolean updateCmd = false;
|
1061 |
boolean updateCmd = false;
|
986 |
if (!tableCommande.contains("ID_TAXE_PORT")) {
|
1062 |
if (!tableCommande.contains("ID_TAXE_PORT")) {
|
987 |
updateCmd = true;
|
1063 |
updateCmd = true;
|
988 |
tCommande.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
1064 |
tCommande.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
989 |
}
|
1065 |
}
|
990 |
|
1066 |
|
991 |
if (!tableCommande.contains("PORT_HT")) {
|
1067 |
if (!tableCommande.contains("PORT_HT")) {
|
992 |
updateCmd = true;
|
1068 |
updateCmd = true;
|
993 |
tCommande.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
1069 |
tCommande.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
994 |
}
|
1070 |
}
|
995 |
|
1071 |
|
996 |
if (!tableCommande.contains("REMISE_HT")) {
|
1072 |
if (!tableCommande.contains("REMISE_HT")) {
|
997 |
updateCmd = true;
|
1073 |
updateCmd = true;
|
998 |
tCommande.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
1074 |
tCommande.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
999 |
}
|
1075 |
}
|
1000 |
|
1076 |
|
1001 |
if (updateCmd) {
|
1077 |
if (updateCmd) {
|
1002 |
tableCommande.getBase().getDataSource().execute(tCommande.asString());
|
1078 |
tableCommande.getBase().getDataSource().execute(tCommande.asString());
|
1003 |
tableCommande.getSchema().updateVersion();
|
1079 |
tableCommande.getSchema().updateVersion();
|
1004 |
tableCommande.fetchFields();
|
1080 |
tableCommande.fetchFields();
|
1005 |
}
|
1081 |
}
|
1006 |
}
|
1082 |
}
|
1007 |
|
1083 |
|
1008 |
List<String> tableElement = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
1084 |
List<String> tableElement = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
1009 |
for (String tableName : tableElement) {
|
1085 |
for (String tableName : tableElement) {
|
1010 |
final SQLTable table = root.getTable(tableName);
|
1086 |
final SQLTable table = root.getTable(tableName);
|
1011 |
if (!table.contains("ID_FAMILLE_ARTICLE")) {
|
1087 |
if (!table.contains("ID_FAMILLE_ARTICLE")) {
|
1012 |
AlterTable t = new AlterTable(table);
|
1088 |
AlterTable t = new AlterTable(table);
|
1013 |
t.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
1089 |
t.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
1014 |
table.getBase().getDataSource().execute(t.asString());
|
1090 |
table.getBase().getDataSource().execute(t.asString());
|
1015 |
root.refetchTable(table.getName());
|
1091 |
root.refetchTable(table.getName());
|
1016 |
root.getSchema().updateVersion();
|
1092 |
root.getSchema().updateVersion();
|
1017 |
}
|
1093 |
}
|
1018 |
}
|
1094 |
}
|
1019 |
|
1095 |
|
1020 |
final SQLTable tableBlElt = root.getTable("BON_RECEPTION_ELEMENT");
|
1096 |
final SQLTable tableBlElt = root.getTable("BON_RECEPTION_ELEMENT");
|
1021 |
if (!tableBlElt.contains("QTE_ORIGINE")) {
|
1097 |
if (!tableBlElt.contains("QTE_ORIGINE")) {
|
1022 |
AlterTable t = new AlterTable(tableBlElt);
|
1098 |
AlterTable t = new AlterTable(tableBlElt);
|
1023 |
t.addIntegerColumn("QTE_ORIGINE", null, true);
|
1099 |
t.addIntegerColumn("QTE_ORIGINE", null, true);
|
1024 |
tableBlElt.getBase().getDataSource().execute(t.asString());
|
1100 |
tableBlElt.getBase().getDataSource().execute(t.asString());
|
1025 |
root.refetchTable(tableBlElt.getName());
|
1101 |
root.refetchTable(tableBlElt.getName());
|
1026 |
root.getSchema().updateVersion();
|
1102 |
root.getSchema().updateVersion();
|
1027 |
}
|
1103 |
}
|
1028 |
// Caisse 1.5.3
|
1104 |
// Caisse 1.5.3
|
1029 |
if (!root.getTable(registerLogTableName).contains("HOST_NAME")) {
|
1105 |
if (!root.getTable(registerLogTableName).contains("HOST_NAME")) {
|
1030 |
final AlterTable alterRegisterLog = new AlterTable(root.getTable(registerLogTableName));
|
1106 |
final AlterTable alterRegisterLog = new AlterTable(root.getTable(registerLogTableName));
|
1031 |
// to check for shared register installations
|
1107 |
// to check for shared register installations
|
1032 |
alterRegisterLog.addVarCharColumn("HOST_NAME", 128, true, null, true);
|
1108 |
alterRegisterLog.addVarCharColumn("HOST_NAME", 128, true, null, true);
|
1033 |
alterRegisterLog.addVarCharColumn("HOST_USER", 128, true, null, true);
|
1109 |
alterRegisterLog.addVarCharColumn("HOST_USER", 128, true, null, true);
|
1034 |
|
1110 |
|
1035 |
// no longer needed since we need more than the last entry, just remove the duplicate
|
1111 |
// no longer needed since we need more than the last entry, just remove the duplicate
|
1036 |
// data and select from CAISSE_JOURNAL
|
1112 |
// data and select from CAISSE_JOURNAL
|
1037 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
1113 |
final AlterTable alterRegister = new AlterTable(caisseT);
|
1038 |
alterRegister.dropColumn("ID_DERNIERE_ENTREE_JOURNAL");
|
1114 |
alterRegister.dropColumn("ID_DERNIERE_ENTREE_JOURNAL");
|
1039 |
|
1115 |
|
1040 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterRegisterLog, alterRegister))) {
|
1116 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterRegisterLog, alterRegister))) {
|
1041 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1117 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1042 |
}
|
1118 |
}
|
1043 |
caisseT.getSchema().updateVersion();
|
1119 |
caisseT.getSchema().updateVersion();
|
1044 |
alterRegisterLog.getTable().fetchFields();
|
1120 |
alterRegisterLog.getTable().fetchFields();
|
1045 |
alterRegister.getTable().fetchFields();
|
1121 |
alterRegister.getTable().fetchFields();
|
1046 |
}
|
1122 |
}
|
1047 |
// Prefs compte AN
|
1123 |
// Prefs compte AN
|
1048 |
SQLTable table = root.findTable("PREFS_COMPTE");
|
1124 |
SQLTable table = root.findTable("PREFS_COMPTE");
|
1049 |
|
1125 |
|
1050 |
if (!table.getFieldsName().contains("ID_JOURNAL_AN")) {
|
1126 |
if (!table.getFieldsName().contains("ID_JOURNAL_AN")) {
|
1051 |
AlterTable t = new AlterTable(table);
|
1127 |
AlterTable t = new AlterTable(table);
|
1052 |
t.addForeignColumn("ID_JOURNAL_AN", root.getTable("JOURNAL"));
|
1128 |
t.addForeignColumn("ID_JOURNAL_AN", root.getTable("JOURNAL"));
|
1053 |
t.addBooleanColumn("CREATE_NUL_SOLDE_ECR", Boolean.TRUE, false);
|
1129 |
t.addBooleanColumn("CREATE_NUL_SOLDE_ECR", Boolean.TRUE, false);
|
1054 |
table.getBase().getDataSource().execute(t.asString());
|
1130 |
table.getBase().getDataSource().execute(t.asString());
|
1055 |
table.getSchema().updateVersion();
|
1131 |
table.getSchema().updateVersion();
|
1056 |
table.fetchFields();
|
1132 |
table.fetchFields();
|
1057 |
}
|
1133 |
}
|
1058 |
|
1134 |
|
1059 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
1135 |
if (!table.getFieldsName().contains("AUTO_LETTRAGE")) {
|
1060 |
AlterTable t = new AlterTable(table);
|
1136 |
AlterTable t = new AlterTable(table);
|
1061 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1137 |
t.addBooleanColumn("AUTO_LETTRAGE", Boolean.FALSE, false);
|
1062 |
table.getBase().getDataSource().execute(t.asString());
|
1138 |
table.getBase().getDataSource().execute(t.asString());
|
1063 |
table.getSchema().updateVersion();
|
1139 |
table.getSchema().updateVersion();
|
1064 |
table.fetchFields();
|
1140 |
table.fetchFields();
|
1065 |
}
|
1141 |
}
|
- |
|
1142 |
// Etat stock
|
- |
|
1143 |
if (!root.contains("ETAT_STOCK")) {
|
- |
|
1144 |
|
- |
|
1145 |
try {
|
- |
|
1146 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ETAT_STOCK");
|
- |
|
1147 |
createTable.addColumn("DATE", "date");
|
- |
|
1148 |
createTable.addDecimalColumn("MONTANT_HA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1149 |
createTable.addDecimalColumn("MONTANT_VT", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1150 |
createTable.addBooleanColumn("INVENTAIRE", Boolean.FALSE, false);
|
- |
|
1151 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1152 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1153 |
root.refetchTable("ETAT_STOCK");
|
- |
|
1154 |
root.getSchema().updateVersion();
|
- |
|
1155 |
|
- |
|
1156 |
final SQLCreateTable createTableElt = new SQLCreateTable(root, "ETAT_STOCK_ELEMENT");
|
- |
|
1157 |
createTableElt.addForeignColumn("ARTICLE");
|
- |
|
1158 |
createTableElt.addForeignColumn("ETAT_STOCK");
|
- |
|
1159 |
createTableElt.addDecimalColumn("PA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1160 |
createTableElt.addDecimalColumn("PV", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1161 |
createTableElt.addDecimalColumn("T_PA", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1162 |
createTableElt.addDecimalColumn("T_PV", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1163 |
createTableElt.addDecimalColumn("QTE", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1164 |
createTableElt.addDecimalColumn("ECART", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1165 |
createTableElt.addVarCharColumn("CODE", 256);
|
- |
|
1166 |
createTableElt.addVarCharColumn("NOM", 2048);
|
- |
|
1167 |
|
- |
|
1168 |
root.getBase().getDataSource().execute(createTableElt.asString());
|
- |
|
1169 |
InstallationPanel.insertUndef(createTableElt);
|
- |
|
1170 |
root.refetchTable("ETAT_STOCK_ELEMENT");
|
- |
|
1171 |
root.getSchema().updateVersion();
|
- |
|
1172 |
|
- |
|
1173 |
} catch (SQLException ex) {
|
- |
|
1174 |
throw new IllegalStateException("Erreur lors de la création de la table ETAT_STOCK_ELEMENT", ex);
|
- |
|
1175 |
}
|
- |
|
1176 |
} else {
|
- |
|
1177 |
final SQLTable tableEtatStock = root.getTable("ETAT_STOCK_ELEMENT");
|
- |
|
1178 |
SQLField fieldNom = tableEtatStock.getField("NOM");
|
- |
|
1179 |
int size = fieldNom.getType().getSize();
|
- |
|
1180 |
if (size == 512) {
|
- |
|
1181 |
AlterTable alter = new AlterTable(tableEtatStock);
|
- |
|
1182 |
alter.alterColumn("NOM", EnumSet.allOf(Properties.class), "varchar(" + 2048 + ")", "''", false);
|
- |
|
1183 |
tableEtatStock.getBase().getDataSource().execute(alter.asString());
|
- |
|
1184 |
tableEtatStock.getSchema().updateVersion();
|
- |
|
1185 |
tableEtatStock.fetchFields();
|
- |
|
1186 |
}
|
1066 |
|
1187 |
|
- |
|
1188 |
}
|
- |
|
1189 |
SQLTable tableMvtStock = root.getTable("MOUVEMENT_STOCK");
|
- |
|
1190 |
if (!tableMvtStock.contains("ID_ETAT_STOCK")) {
|
- |
|
1191 |
final AlterTable alter = new AlterTable(tableMvtStock);
|
- |
|
1192 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
- |
|
1193 |
alter.addBooleanColumn("OUVERTURE", Boolean.FALSE, false);
|
- |
|
1194 |
alter.addForeignColumn("ID_ETAT_STOCK", root.getTable("ETAT_STOCK"));
|
- |
|
1195 |
tableMvtStock.getBase().getDataSource().execute(alter.asString());
|
- |
|
1196 |
tableMvtStock.getSchema().updateVersion();
|
- |
|
1197 |
tableMvtStock.fetchFields();
|
- |
|
1198 |
}
|
1067 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1199 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1068 |
if (!tableEcr.contains("CLOTURE")) {
|
1200 |
if (!tableEcr.contains("CLOTURE")) {
|
1069 |
final AlterTable alter = new AlterTable(tableEcr);
|
1201 |
final AlterTable alter = new AlterTable(tableEcr);
|
1070 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1202 |
alter.addBooleanColumn("CLOTURE", Boolean.FALSE, false);
|
1071 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
1203 |
alter.addBooleanColumn("RAN", Boolean.FALSE, false);
|
1072 |
tableEcr.getBase().getDataSource().execute(alter.asString());
|
1204 |
tableEcr.getBase().getDataSource().execute(alter.asString());
|
1073 |
tableEcr.getSchema().updateVersion();
|
1205 |
tableEcr.getSchema().updateVersion();
|
1074 |
tableEcr.fetchFields();
|
1206 |
tableEcr.fetchFields();
|
1075 |
}
|
1207 |
}
|
1076 |
|
1208 |
|
1077 |
// Jour Km Element
|
1209 |
// Jour Km Element
|
1078 |
final SQLTable tkmElt = root.getTable("SAISIE_KM_ELEMENT");
|
1210 |
final SQLTable tkmElt = root.getTable("SAISIE_KM_ELEMENT");
|
1079 |
if (!tkmElt.contains("JOUR")) {
|
1211 |
if (!tkmElt.contains("JOUR")) {
|
1080 |
final AlterTable alterKmElt = new AlterTable(tkmElt);
|
1212 |
final AlterTable alterKmElt = new AlterTable(tkmElt);
|
1081 |
alterKmElt.addIntegerColumn("JOUR", 1);
|
1213 |
alterKmElt.addIntegerColumn("JOUR", 1);
|
1082 |
tkmElt.getBase().getDataSource().execute(alterKmElt.asString());
|
1214 |
tkmElt.getBase().getDataSource().execute(alterKmElt.asString());
|
1083 |
tkmElt.getSchema().updateVersion();
|
1215 |
tkmElt.getSchema().updateVersion();
|
1084 |
tkmElt.fetchFields();
|
1216 |
tkmElt.fetchFields();
|
1085 |
}
|
1217 |
}
|
1086 |
// Ref bancaires fournisseurs et clients
|
1218 |
// Ref bancaires fournisseurs et clients
|
1087 |
for (final SQLTable bankT : Arrays.asList(tableFournisseur, tClient)) {
|
1219 |
for (final SQLTable bankT : Arrays.asList(tableFournisseur, tClient)) {
|
1088 |
if (!bankT.contains("IBAN")) {
|
1220 |
if (!bankT.contains("IBAN")) {
|
1089 |
final AlterTable alter = new AlterTable(bankT);
|
1221 |
final AlterTable alter = new AlterTable(bankT);
|
1090 |
alter.addVarCharColumn("IBAN", 128);
|
1222 |
alter.addVarCharColumn("IBAN", 128);
|
1091 |
alter.addVarCharColumn("BIC", 128);
|
1223 |
alter.addVarCharColumn("BIC", 128);
|
1092 |
bankT.getDBSystemRoot().getDataSource().execute(alter.asString());
|
1224 |
bankT.getDBSystemRoot().getDataSource().execute(alter.asString());
|
1093 |
bankT.getSchema().updateVersion();
|
1225 |
bankT.getSchema().updateVersion();
|
1094 |
bankT.fetchFields();
|
1226 |
bankT.fetchFields();
|
1095 |
}
|
1227 |
}
|
1096 |
}
|
1228 |
}
|
1097 |
final SQLTable typeReglT = root.getTable("TYPE_REGLEMENT");
|
1229 |
final SQLTable typeReglT = root.getTable("TYPE_REGLEMENT");
|
1098 |
if (typeReglT.getRow(TypeReglementSQLElement.PRELEVEMENT) == null) {
|
1230 |
if (typeReglT.getRow(TypeReglementSQLElement.PRELEVEMENT) == null) {
|
1099 |
final SQLRowValues directDebitVals = new SQLRowValues(typeReglT).put("NOM", "Prélèvement");
|
1231 |
final SQLRowValues directDebitVals = new SQLRowValues(typeReglT).put("NOM", "Prélèvement");
|
1100 |
directDebitVals.put("COMPTANT", Boolean.FALSE).put("ECHEANCE", Boolean.FALSE);
|
1232 |
directDebitVals.put("COMPTANT", Boolean.FALSE).put("ECHEANCE", Boolean.FALSE);
|
1101 |
directDebitVals.setID(TypeReglementSQLElement.PRELEVEMENT).insertVerbatim();
|
1233 |
directDebitVals.setID(TypeReglementSQLElement.PRELEVEMENT).insertVerbatim();
|
1102 |
}
|
1234 |
}
|
1103 |
if (!tableClient.contains("ACCEPTE_EMAIL")) {
|
1235 |
if (!tableClient.contains("ACCEPTE_EMAIL")) {
|
1104 |
final AlterTable alter = new AlterTable(tableClient);
|
1236 |
final AlterTable alter = new AlterTable(tableClient);
|
1105 |
alter.addBooleanColumn("ACCEPTE_EMAIL", Boolean.FALSE, false);
|
1237 |
alter.addBooleanColumn("ACCEPTE_EMAIL", Boolean.FALSE, false);
|
1106 |
alter.addBooleanColumn("ACCEPTE_COURRIER", Boolean.FALSE, false);
|
1238 |
alter.addBooleanColumn("ACCEPTE_COURRIER", Boolean.FALSE, false);
|
1107 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
1239 |
alter.addBooleanColumn("ACCEPTE_SMS", Boolean.FALSE, false);
|
1108 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
1240 |
alter.addBooleanColumn("ACCEPTE_TEL", Boolean.FALSE, false);
|
1109 |
exec(alter);
|
1241 |
exec(alter);
|
1110 |
}
|
1242 |
}
|
1111 |
final SQLTable contactT = root.getTable("CONTACT");
|
1243 |
final SQLTable contactT = root.getTable("CONTACT");
|
1112 |
if (!contactT.contains("DATE_NAISSANCE")) {
|
1244 |
if (contactT != null && !contactT.contains("DATE_NAISSANCE")) {
|
1113 |
final AlterTable alter = new AlterTable(contactT);
|
1245 |
final AlterTable alter = new AlterTable(contactT);
|
1114 |
alter.addColumn("DATE_NAISSANCE", "date");
|
1246 |
alter.addColumn("DATE_NAISSANCE", "date");
|
1115 |
exec(alter);
|
1247 |
exec(alter);
|
1116 |
}
|
1248 |
}
|
- |
|
1249 |
|
1117 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
1250 |
final SQLCreateTable createSDDMsgTable = SDDMessageSQLElement.getCreateTable(root);
|
1118 |
if (createSDDMsgTable != null) {
|
1251 |
if (createSDDMsgTable != null) {
|
1119 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
1252 |
final SQLCreateTable createMandate = SEPAMandateSQLElement.getCreateTable(root);
|
1120 |
root.createTables(createSDDMsgTable, createMandate);
|
1253 |
root.createTables(createSDDMsgTable, createMandate);
|
1121 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
1254 |
final SQLTable msgT = root.getTable(createSDDMsgTable.getName());
|
1122 |
final SQLTable mandateT = root.getTable(createMandate.getName());
|
1255 |
final SQLTable mandateT = root.getTable(createMandate.getName());
|
1123 |
|
1256 |
|
1124 |
final AlterTable alterFact = new AlterTable(root.getTable(SaisieVenteFactureSQLElement.TABLENAME));
|
1257 |
final AlterTable alterFact = new AlterTable(root.getTable(SaisieVenteFactureSQLElement.TABLENAME));
|
1125 |
alterFact.addForeignColumn(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, msgT);
|
1258 |
alterFact.addForeignColumn(SaisieVenteFactureSQLElement.MESSAGE_FIELD_NAME, msgT);
|
1126 |
alterFact.addVarCharColumn(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, 35);
|
1259 |
alterFact.addVarCharColumn(SaisieVenteFactureSQLElement.END2END_FIELD_NAME, 35);
|
1127 |
|
1260 |
|
1128 |
final AlterTable alterModeRegl = new AlterTable(root.getTable("MODE_REGLEMENT"));
|
1261 |
final AlterTable alterModeRegl = new AlterTable(root.getTable("MODE_REGLEMENT"));
|
1129 |
alterModeRegl.addForeignColumn(null, mandateT);
|
1262 |
alterModeRegl.addForeignColumn(null, mandateT);
|
1130 |
|
1263 |
|
1131 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterFact, alterModeRegl))) {
|
1264 |
for (final String sql : ChangeTable.cat(Arrays.asList(alterFact, alterModeRegl))) {
|
1132 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1265 |
root.getDBSystemRoot().getDataSource().execute(sql);
|
1133 |
}
|
1266 |
}
|
1134 |
root.getSchema().updateVersion();
|
1267 |
root.getSchema().updateVersion();
|
1135 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
1268 |
root.refetch(CollectionUtils.createSet(alterFact.getName(), alterModeRegl.getName()));
|
1136 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
1269 |
root.setMetadata(SDDMessageSQLElement.SERIAL_MD, "0");
|
- |
|
1270 |
} else {
|
- |
|
1271 |
// Before r24495 InstallationPanel.fixUnboundedVarchar() would change this field to
|
- |
|
1272 |
// varchar
|
- |
|
1273 |
final SQLField xmlField = root.getTable(SDDMessageSQLElement.TABLE_NAME).getField("XML");
|
- |
|
1274 |
if (xmlField.getTypeDecl().contains("char")) {
|
- |
|
1275 |
final AlterTable alterTable = new AlterTable(xmlField.getTable());
|
- |
|
1276 |
alterTable.alterColumn(xmlField.getName(), EnumSet.of(Properties.TYPE), alterTable.getSyntax().getTypeNames(Clob.class).iterator().next(), null, null);
|
- |
|
1277 |
root.getDBSystemRoot().getDataSource().execute(alterTable.asString());
|
- |
|
1278 |
root.getSchema().updateVersion();
|
- |
|
1279 |
xmlField.getTable().fetchFields();
|
- |
|
1280 |
}
|
1137 |
}
|
1281 |
}
|
1138 |
|
1282 |
|
1139 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
1283 |
final SQLTable vcT = root.getTable("SAISIE_VENTE_COMPTOIR");
|
1140 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
1284 |
if (!vcT.contains("ID_COMPTE_PCE_PRODUIT")) {
|
1141 |
final AlterTable alter = new AlterTable(vcT);
|
1285 |
final AlterTable alter = new AlterTable(vcT);
|
1142 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
1286 |
alter.addForeignColumn("ID_COMPTE_PCE_PRODUIT", root.getTable("COMPTE_PCE"));
|
1143 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
1287 |
alter.addForeignColumn("ID_COMPTE_PCE_SERVICE", root.getTable("COMPTE_PCE"));
|
1144 |
exec(alter);
|
1288 |
exec(alter);
|
1145 |
}
|
1289 |
}
|
1146 |
|
1290 |
|
- |
|
1291 |
// 1.6
|
- |
|
1292 |
// gestion depots des cheques
|
- |
|
1293 |
String chequeDepotTable = "DEPOT_CHEQUE";
|
- |
|
1294 |
if (!root.contains(chequeDepotTable)) {
|
- |
|
1295 |
|
- |
|
1296 |
// Table depot cheque
|
- |
|
1297 |
final SQLCreateTable createTableDepotCheque = new SQLCreateTable(root, chequeDepotTable);
|
- |
|
1298 |
createTableDepotCheque.addVarCharColumn("NOM", 512);
|
- |
|
1299 |
createTableDepotCheque.addLongColumn("MONTANT", 0L, false);
|
- |
|
1300 |
createTableDepotCheque.addColumn("DATE", "date");
|
- |
|
1301 |
if (root.contains("BANQUE")) {
|
- |
|
1302 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE"));
|
- |
|
1303 |
} else if (root.contains("BANQUE_POLE_PRODUIT")) {
|
- |
|
1304 |
createTableDepotCheque.addForeignColumn("ID_BANQUE", root.getTable("BANQUE_POLE_PRODUIT"));
|
- |
|
1305 |
}
|
- |
|
1306 |
createTableDepotCheque.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
- |
|
1307 |
createTableDepotCheque.addForeignColumn("ID_MOUVEMENT", root.getTable("MOUVEMENT"));
|
- |
|
1308 |
root.getBase().getDataSource().execute(createTableDepotCheque.asString());
|
- |
|
1309 |
InstallationPanel.insertUndef(createTableDepotCheque);
|
- |
|
1310 |
root.refetchTable(chequeDepotTable);
|
- |
|
1311 |
root.getSchema().updateVersion();
|
- |
|
1312 |
|
- |
|
1313 |
// Table depot cheque element
|
- |
|
1314 |
final SQLCreateTable createTableDepotElt = new SQLCreateTable(root, chequeDepotTable + "_ELEMENT");
|
- |
|
1315 |
createTableDepotElt.addVarCharColumn("NUMERO", 128);
|
- |
|
1316 |
createTableDepotElt.addVarCharColumn("BANQUE", 128);
|
- |
|
1317 |
createTableDepotElt.addVarCharColumn("PIECE", 512);
|
- |
|
1318 |
createTableDepotElt.addLongColumn("MONTANT", 0L, false);
|
- |
|
1319 |
createTableDepotElt.addColumn("DATE", "date");
|
- |
|
1320 |
createTableDepotElt.addForeignColumn("ID_CHEQUE_A_ENCAISSER", root.getTable("CHEQUE_A_ENCAISSER"));
|
- |
|
1321 |
createTableDepotElt.addForeignColumn("ID_ECRITURE", root.getTable("ECRITURE"));
|
- |
|
1322 |
createTableDepotElt.addForeignColumn("ID_CLIENT", root.getTable("CLIENT"));
|
- |
|
1323 |
createTableDepotElt.addForeignColumn("ID_DEPOT_CHEQUE", root.getTable(chequeDepotTable));
|
- |
|
1324 |
root.getBase().getDataSource().execute(createTableDepotElt.asString());
|
- |
|
1325 |
InstallationPanel.insertUndef(createTableDepotElt);
|
- |
|
1326 |
root.refetchTable(chequeDepotTable + "_ELEMENT");
|
- |
|
1327 |
root.getSchema().updateVersion();
|
- |
|
1328 |
}
|
- |
|
1329 |
|
- |
|
1330 |
final SQLTable articleT = root.getTable("ARTICLE");
|
- |
|
1331 |
if (!articleT.contains("QTE_UNITAIRE")) {
|
- |
|
1332 |
final AlterTable alter = new AlterTable(articleT);
|
- |
|
1333 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
- |
|
1334 |
exec(alter);
|
- |
|
1335 |
}
|
- |
|
1336 |
|
- |
|
1337 |
final SQLTable articleFT = root.getTable("ARTICLE_FOURNISSEUR");
|
- |
|
1338 |
if (!articleFT.contains("QTE_UNITAIRE")) {
|
- |
|
1339 |
final AlterTable alter = new AlterTable(articleFT);
|
- |
|
1340 |
alter.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ONE, false);
|
- |
|
1341 |
exec(alter);
|
- |
|
1342 |
}
|
- |
|
1343 |
|
- |
|
1344 |
// Cout de revient
|
- |
|
1345 |
if (!root.contains("COUT_REVIENT")) {
|
- |
|
1346 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "COUT_REVIENT");
|
- |
|
1347 |
createTableCR.addVarCharColumn("CODE", 48);
|
- |
|
1348 |
createTableCR.addVarCharColumn("NOM", 256);
|
- |
|
1349 |
createTableCR.addDecimalColumn("POURCENT", 16, 6, BigDecimal.ZERO, false);
|
- |
|
1350 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
- |
|
1351 |
InstallationPanel.insertUndef(createTableCR);
|
- |
|
1352 |
root.refetchTable("COUT_REVIENT");
|
- |
|
1353 |
root.getSchema().updateVersion();
|
- |
|
1354 |
|
- |
|
1355 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1356 |
alterArticle.addForeignColumn("ID_COUT_REVIENT", root.findTable("COUT_REVIENT"));
|
- |
|
1357 |
exec(alterArticle);
|
- |
|
1358 |
root.refetchTable("ARTICLE");
|
- |
|
1359 |
root.getSchema().updateVersion();
|
- |
|
1360 |
}
|
- |
|
1361 |
|
- |
|
1362 |
if (!root.getTable("ARTICLE").contains("MARGE_WITH_COUT_REVIENT")) {
|
- |
|
1363 |
final AlterTable alterArticle = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1364 |
alterArticle.addBooleanColumn("MARGE_WITH_COUT_REVIENT", Boolean.FALSE, false);
|
- |
|
1365 |
exec(alterArticle);
|
- |
|
1366 |
root.refetchTable("ARTICLE");
|
- |
|
1367 |
root.getSchema().updateVersion();
|
- |
|
1368 |
}
|
- |
|
1369 |
|
- |
|
1370 |
if (!root.getTable("FACTURE_FOURNISSEUR").contains("NET_A_PAYER")) {
|
- |
|
1371 |
final AlterTable alterFactF = new AlterTable(root.getTable("FACTURE_FOURNISSEUR"));
|
- |
|
1372 |
alterFactF.addLongColumn("NET_A_PAYER", 0L, false);
|
- |
|
1373 |
alterFactF.addLongColumn("AVOIR_TTC", 0L, false);
|
- |
|
1374 |
exec(alterFactF);
|
- |
|
1375 |
root.refetchTable("FACTURE_FOURNISSEUR");
|
- |
|
1376 |
root.getSchema().updateVersion();
|
- |
|
1377 |
}
|
- |
|
1378 |
|
- |
|
1379 |
// Frais Document
|
- |
|
1380 |
if (!root.contains("FRAIS_DOCUMENT")) {
|
- |
|
1381 |
final SQLCreateTable createTableCR = new SQLCreateTable(root, "FRAIS_DOCUMENT");
|
- |
|
1382 |
createTableCR.addVarCharColumn("CODE", 48);
|
- |
|
1383 |
createTableCR.addVarCharColumn("NOM", 256);
|
- |
|
1384 |
createTableCR.addLongColumn("MONTANT_HT", 0L, false);
|
- |
|
1385 |
createTableCR.addForeignColumn("ID_TAXE", root.getTable("TAXE"));
|
- |
|
1386 |
createTableCR.addLongColumn("MONTANT_TTC", 0L, false);
|
- |
|
1387 |
root.getBase().getDataSource().execute(createTableCR.asString());
|
- |
|
1388 |
InstallationPanel.insertUndef(createTableCR);
|
- |
|
1389 |
root.refetchTable("FRAIS_DOCUMENT");
|
- |
|
1390 |
|
- |
|
1391 |
final AlterTable alterClient = new AlterTable(root.getTable("CLIENT"));
|
- |
|
1392 |
alterClient.addForeignColumn("ID_FRAIS_DOCUMENT", root.findTable("FRAIS_DOCUMENT"));
|
- |
|
1393 |
exec(alterClient);
|
- |
|
1394 |
root.refetchTable("CLIENT");
|
- |
|
1395 |
|
- |
|
1396 |
List<String> tables = Arrays.asList("DEVIS", "COMMANDE_CLIENT", "BON_DE_LIVRAISON", "SAISIE_VENTE_FACTURE");
|
- |
|
1397 |
for (String tableToUp : tables) {
|
- |
|
1398 |
final AlterTable alter = new AlterTable(root.getTable(tableToUp));
|
- |
|
1399 |
alter.addLongColumn("FRAIS_DOCUMENT_HT", 0L, false);
|
- |
|
1400 |
alter.addForeignColumn("ID_TAXE_FRAIS_DOCUMENT", root.getTable("TAXE"));
|
- |
|
1401 |
exec(alter);
|
- |
|
1402 |
root.refetchTable(tableToUp);
|
- |
|
1403 |
}
|
- |
|
1404 |
root.getSchema().updateVersion();
|
- |
|
1405 |
}
|
- |
|
1406 |
|
- |
|
1407 |
final SQLTable chequeAvoirT = root.getTable("CHEQUE_AVOIR_CLIENT");
|
- |
|
1408 |
|
- |
|
1409 |
String tBanque = root.contains("BANQUE") ? "BANQUE" : "BANQUE_POLE_PRODUIT";
|
- |
|
1410 |
if (!chequeAvoirT.contains("ID_" + tBanque)) {
|
- |
|
1411 |
|
- |
|
1412 |
final AlterTable alterChqAvoir = new AlterTable(chequeAvoirT);
|
- |
|
1413 |
alterChqAvoir.addForeignColumn("ID_" + tBanque, root.findTable(tBanque));
|
- |
|
1414 |
exec(alterChqAvoir);
|
- |
|
1415 |
}
|
- |
|
1416 |
|
- |
|
1417 |
// Prelevement à la source
|
- |
|
1418 |
final SQLTable fichePayeT = root.getTable("FICHE_PAYE");
|
- |
|
1419 |
if (!fichePayeT.contains("ID_PAS")) {
|
- |
|
1420 |
final SQLCreateTable createTablePas = new SQLCreateTable(root, "PAS");
|
- |
|
1421 |
createTablePas.addForeignColumn("ID_TYPE_TAUX_PAS", root.findTable("TYPE_TAUX_PAS"));
|
- |
|
1422 |
createTablePas.addVarCharColumn("CODE_PAS", 256);
|
- |
|
1423 |
createTablePas.addDecimalColumn("TAUX_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1424 |
root.getBase().getDataSource().execute(createTablePas.asString());
|
- |
|
1425 |
InstallationPanel.insertUndef(createTablePas);
|
- |
|
1426 |
root.refetchTable("PAS");
|
- |
|
1427 |
root.getSchema().updateVersion();
|
- |
|
1428 |
|
- |
|
1429 |
final AlterTable alterFichePaye = new AlterTable(fichePayeT);
|
- |
|
1430 |
alterFichePaye.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
- |
|
1431 |
alterFichePaye.addDecimalColumn("TOTAL_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1432 |
alterFichePaye.addDecimalColumn("NET_AVANT_PAS", 16, 2, BigDecimal.ZERO, false);
|
- |
|
1433 |
exec(alterFichePaye);
|
- |
|
1434 |
|
- |
|
1435 |
final SQLTable tableSal = root.getTable("SALARIE");
|
- |
|
1436 |
final AlterTable alterSalarie = new AlterTable(tableSal);
|
- |
|
1437 |
alterSalarie.addForeignColumn("ID_PAS", root.findTable("PAS"));
|
- |
|
1438 |
exec(alterSalarie);
|
- |
|
1439 |
|
- |
|
1440 |
final AlterTable alterEtatCivil = new AlterTable(tableEtatCivil);
|
- |
|
1441 |
alterEtatCivil.addVarCharColumn("NTT", 50);
|
- |
|
1442 |
exec(alterEtatCivil);
|
- |
|
1443 |
|
- |
|
1444 |
Map<String, SQLRow> typeTauxPasMap = new HashMap<>();
|
- |
|
1445 |
SQLSelect selTypeTaux = new SQLSelect();
|
- |
|
1446 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getKey());
|
- |
|
1447 |
selTypeTaux.addSelect(root.findTable("TYPE_TAUX_PAS").getField("CODE"));
|
- |
|
1448 |
List<SQLRow> resultTypeTaux = SQLRowListRSH.execute(selTypeTaux);
|
- |
|
1449 |
for (SQLRow sqlRow : resultTypeTaux) {
|
- |
|
1450 |
typeTauxPasMap.put(sqlRow.getString("CODE"), sqlRow);
|
- |
|
1451 |
}
|
- |
|
1452 |
|
- |
|
1453 |
SQLSelect selSal = new SQLSelect();
|
- |
|
1454 |
selSal.addSelect(tableSal.getKey());
|
- |
|
1455 |
List<SQLRow> rowSal = SQLRowListRSH.execute(selSal);
|
- |
|
1456 |
for (SQLRow sqlRow : rowSal) {
|
- |
|
1457 |
SQLRowValues rowValsSal = sqlRow.createEmptyUpdateRow();
|
- |
|
1458 |
final SQLRowValues putRowValues = rowValsSal.putRowValues("ID_PAS");
|
- |
|
1459 |
putRowValues.put("ID_TYPE_TAUX_PAS", typeTauxPasMap.get("13").getID());
|
- |
|
1460 |
putRowValues.put("TAUX_PAS", BigDecimal.ZERO);
|
- |
|
1461 |
putRowValues.commit();
|
- |
|
1462 |
}
|
- |
|
1463 |
}
|
- |
|
1464 |
|
- |
|
1465 |
if (!root.contains("ARTICLE_TARIF_FOURNISSEUR")) {
|
- |
|
1466 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_TARIF_FOURNISSEUR");
|
- |
|
1467 |
|
- |
|
1468 |
createTable.addForeignColumn("ARTICLE");
|
- |
|
1469 |
createTable.addForeignColumn("FOURNISSEUR");
|
- |
|
1470 |
createTable.addVarCharColumn("REF_FOURNISSEUR", 500);
|
- |
|
1471 |
createTable.addVarCharColumn("TYPE_REAPPRO", 256);
|
- |
|
1472 |
createTable.addVarCharColumn("CONDITIONS", 1024);
|
- |
|
1473 |
createTable.addVarCharColumn("ACHETEUR", 256);
|
- |
|
1474 |
createTable.addVarCharColumn("CODE_PAYS_ORIGINE", 256);
|
- |
|
1475 |
createTable.addDecimalColumn("PRIX_ACHAT_DEVISE_F", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1476 |
createTable.addDecimalColumn("PRIX_ACHAT", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1477 |
createTable.addIntegerColumn("QTE", 1);
|
- |
|
1478 |
createTable.addDateAndTimeColumn("DATE_PRIX");
|
- |
|
1479 |
// createTable.addDecimalColumn("COEF_TRANSPORT_PORT", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1480 |
// false);
|
- |
|
1481 |
// createTable.addDecimalColumn("COEF_TAXE_D", 16, 6, BigDecimal.valueOf(0), false);
|
- |
|
1482 |
// createTable.addDecimalColumn("COEF_TRANSPORT_SIEGE", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1483 |
// false);
|
- |
|
1484 |
// createTable.addDecimalColumn("COEF_FRAIS_MOULE", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1485 |
// false);
|
- |
|
1486 |
// createTable.addDecimalColumn("COEF_FRAIS_INDIRECTS", 16, 6, BigDecimal.valueOf(0),
|
- |
|
1487 |
// false);
|
- |
|
1488 |
createTable.addIntegerColumn("DELAI_REAPPRO", 0);
|
- |
|
1489 |
createTable.addIntegerColumn("DELAI_TRANSPORT", 0);
|
- |
|
1490 |
createTable.addIntegerColumn("PRIORITE", 0);
|
- |
|
1491 |
createTable.addDecimalColumn("COEF_PRIX_MINI", 16, 2, BigDecimal.valueOf(0), false);
|
- |
|
1492 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1493 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1494 |
root.refetchTable("ARTICLE_TARIF_FOURNISSEUR");
|
- |
|
1495 |
root.getSchema().updateVersion();
|
- |
|
1496 |
}
|
- |
|
1497 |
|
- |
|
1498 |
// Gestion des catègories comptables
|
- |
|
1499 |
if (!root.contains("CATEGORIE_COMPTABLE")) {
|
- |
|
1500 |
final SQLCreateTable createTable = new SQLCreateTable(root, "CATEGORIE_COMPTABLE");
|
- |
|
1501 |
createTable.addVarCharColumn("NOM", 128);
|
- |
|
1502 |
createTable.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
- |
|
1503 |
createTable.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
- |
|
1504 |
createTable.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
- |
|
1505 |
createTable.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
- |
|
1506 |
|
- |
|
1507 |
try {
|
- |
|
1508 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1509 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1510 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
- |
|
1511 |
root.getSchema().updateVersion();
|
- |
|
1512 |
} catch (SQLException ex) {
|
- |
|
1513 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CATEGORIE_COMPTABLE", ex);
|
- |
|
1514 |
}
|
- |
|
1515 |
|
- |
|
1516 |
AlterTable tableClientCat = new AlterTable(root.getTable("CLIENT"));
|
- |
|
1517 |
tableClientCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1518 |
root.getBase().getDataSource().execute(tableClientCat.asString());
|
- |
|
1519 |
root.refetchTable("CLIENT");
|
- |
|
1520 |
root.getSchema().updateVersion();
|
- |
|
1521 |
|
- |
|
1522 |
AlterTable tableF = new AlterTable(root.getTable("FOURNISSEUR"));
|
- |
|
1523 |
tableF.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1524 |
root.getBase().getDataSource().execute(tableF.asString());
|
- |
|
1525 |
root.refetchTable("FOURNISSEUR");
|
- |
|
1526 |
root.getSchema().updateVersion();
|
- |
|
1527 |
|
- |
|
1528 |
final SQLCreateTable createTableArtCat = new SQLCreateTable(root, "ARTICLE_CATEGORIE_COMPTABLE");
|
- |
|
1529 |
createTableArtCat.addForeignColumn("ID_CATEGORIE_COMPTABLE", root.getTable("CATEGORIE_COMPTABLE"));
|
- |
|
1530 |
createTableArtCat.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
- |
|
1531 |
createTableArtCat.addForeignColumn("ID_TAXE_ACHAT", root.getTable("TAXE"));
|
- |
|
1532 |
createTableArtCat.addForeignColumn("ID_TAXE_VENTE", root.getTable("TAXE"));
|
- |
|
1533 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
- |
|
1534 |
createTableArtCat.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
- |
|
1535 |
|
- |
|
1536 |
try {
|
- |
|
1537 |
root.getBase().getDataSource().execute(createTableArtCat.asString());
|
- |
|
1538 |
InstallationPanel.insertUndef(createTableArtCat);
|
- |
|
1539 |
root.refetchTable("CATEGORIE_COMPTABLE");
|
- |
|
1540 |
root.getSchema().updateVersion();
|
- |
|
1541 |
} catch (SQLException ex) {
|
- |
|
1542 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_CATEGORIE_COMPTABLE", ex);
|
- |
|
1543 |
}
|
- |
|
1544 |
|
- |
|
1545 |
}
|
- |
|
1546 |
|
- |
|
1547 |
// Article fournisseur secondaire
|
- |
|
1548 |
if (!root.contains("ARTICLE_FOURNISSEUR_SECONDAIRE")) {
|
- |
|
1549 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_FOURNISSEUR_SECONDAIRE");
|
- |
|
1550 |
createTable.addForeignColumn("ARTICLE");
|
- |
|
1551 |
createTable.addForeignColumn("FOURNISSEUR");
|
- |
|
1552 |
try {
|
- |
|
1553 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1554 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1555 |
root.refetchTable("ARTICLE_FOURNISSEUR_SECONDAIRE");
|
- |
|
1556 |
root.getSchema().updateVersion();
|
- |
|
1557 |
} catch (SQLException ex) {
|
- |
|
1558 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_FOURNISSEUR_SECONDAIRE", ex);
|
- |
|
1559 |
}
|
- |
|
1560 |
}
|
- |
|
1561 |
|
- |
|
1562 |
if (!root.getTable("ARTICLE").contains("AUTO_PRIX_ACHAT_NOMENCLATURE")) {
|
- |
|
1563 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1564 |
t.addBooleanColumn("AUTO_PRIX_ACHAT_NOMENCLATURE", false, false);
|
- |
|
1565 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
- |
|
1566 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
- |
|
1567 |
root.getSchema().updateVersion();
|
- |
|
1568 |
}
|
- |
|
1569 |
|
- |
|
1570 |
// Gestion multidepot
|
- |
|
1571 |
{
|
- |
|
1572 |
// Ajout table depot
|
- |
|
1573 |
if (!root.contains("DEPOT_STOCK")) {
|
- |
|
1574 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DEPOT_STOCK");
|
- |
|
1575 |
createTable.addVarCharColumn("CODE", 25);
|
- |
|
1576 |
createTable.addVarCharColumn("NOM", 256);
|
- |
|
1577 |
createTable.addVarCharColumn("UI_LOCK", 256);
|
- |
|
1578 |
createTable.addForeignColumn("ID_USER_UI_LOCK", root.findTable("USER_COMMON"));
|
- |
|
1579 |
// sqlRowValues.put("UI_LOCK", "ro");
|
- |
|
1580 |
// sqlRowValues.put("ID_USER_UI_LOCK", 2);
|
- |
|
1581 |
|
- |
|
1582 |
try {
|
- |
|
1583 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1584 |
InstallationPanel.insertUndef(createTable);
|
- |
|
1585 |
|
- |
|
1586 |
root.refetchTable("DEPOT_STOCK");
|
- |
|
1587 |
root.getSchema().updateVersion();
|
- |
|
1588 |
|
- |
|
1589 |
SQLRowValues rowValsDefStock = new SQLRowValues(root.getTable("DEPOT_STOCK"));
|
- |
|
1590 |
rowValsDefStock.put("NOM", "Principal");
|
- |
|
1591 |
rowValsDefStock.put("UI_LOCK", "ro");
|
- |
|
1592 |
rowValsDefStock.commit();
|
- |
|
1593 |
} catch (SQLException ex) {
|
- |
|
1594 |
throw new IllegalStateException("Erreur lors de la création de la table " + "DEPOT_STOCK", ex);
|
- |
|
1595 |
}
|
- |
|
1596 |
}
|
- |
|
1597 |
|
- |
|
1598 |
List<String> tableElementDepot = Arrays.asList("FACTURE_FOURNISSEUR_ELEMENT", "DEVIS_ELEMENT", "COMMANDE_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT",
|
- |
|
1599 |
"BON_DE_LIVRAISON_ELEMENT", "SAISIE_VENTE_FACTURE_ELEMENT", "AVOIR_CLIENT_ELEMENT", "DEMANDE_PRIX_ELEMENT");
|
- |
|
1600 |
for (String tableName : tableElementDepot) {
|
- |
|
1601 |
final SQLTable tableToAddDepot = root.getTable(tableName);
|
- |
|
1602 |
if (!tableToAddDepot.contains("ID_DEPOT_STOCK")) {
|
- |
|
1603 |
AlterTable t = new AlterTable(tableToAddDepot);
|
- |
|
1604 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1605 |
tableToAddDepot.getBase().getDataSource().execute(t.asString());
|
- |
|
1606 |
root.refetchTable(tableToAddDepot.getName());
|
- |
|
1607 |
root.getSchema().updateVersion();
|
- |
|
1608 |
}
|
- |
|
1609 |
}
|
- |
|
1610 |
|
- |
|
1611 |
// Depot defaut
|
- |
|
1612 |
if (!root.getTable("ARTICLE").contains("ID_DEPOT_STOCK")) {
|
- |
|
1613 |
AlterTable t = new AlterTable(root.getTable("ARTICLE"));
|
- |
|
1614 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1615 |
root.getTable("ARTICLE").getBase().getDataSource().execute(t.asString());
|
- |
|
1616 |
root.refetchTable(root.getTable("ARTICLE").getName());
|
- |
|
1617 |
root.getSchema().updateVersion();
|
- |
|
1618 |
}
|
- |
|
1619 |
|
- |
|
1620 |
// Liason depot stock
|
- |
|
1621 |
if (!root.getTable("STOCK").contains("ID_DEPOT_STOCK")) {
|
- |
|
1622 |
AlterTable t = new AlterTable(root.getTable("STOCK"));
|
- |
|
1623 |
t.addForeignColumn("ID_DEPOT_STOCK", root.getTable("DEPOT_STOCK"));
|
- |
|
1624 |
t.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
- |
|
1625 |
t.addColumn("QTE_MIN", "real DEFAULT 0");
|
- |
|
1626 |
root.getTable("STOCK").getBase().getDataSource().execute(t.asString());
|
- |
|
1627 |
root.refetchTable(root.getTable("STOCK").getName());
|
- |
|
1628 |
root.getSchema().updateVersion();
|
- |
|
1629 |
}
|
- |
|
1630 |
|
- |
|
1631 |
// Ajout depot sur mvt
|
- |
|
1632 |
if (!root.getTable("MOUVEMENT_STOCK").contains("ID_STOCK")) {
|
- |
|
1633 |
AlterTable t = new AlterTable(root.getTable("MOUVEMENT_STOCK"));
|
- |
|
1634 |
t.addForeignColumn("ID_STOCK", root.getTable("STOCK"));
|
- |
|
1635 |
t.addIntegerColumn("SOURCE_ELEMENTID", 1);
|
- |
|
1636 |
root.getTable("MOUVEMENT_STOCK").getBase().getDataSource().execute(t.asString());
|
- |
|
1637 |
root.refetchTable(root.getTable("MOUVEMENT_STOCK").getName());
|
- |
|
1638 |
root.getSchema().updateVersion();
|
- |
|
1639 |
|
- |
|
1640 |
// REQUETE update STOCK.ID_ARTICLE et QTE_MIN
|
- |
|
1641 |
SQLTable tableStock = root.getTable("STOCK");
|
- |
|
1642 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
- |
|
1643 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
- |
|
1644 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
- |
|
1645 |
buildStockArt.setFromVirtualJoinField("QTE_MIN", tableArticle.getAlias(), "QTE_MIN");
|
- |
|
1646 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
- |
|
1647 |
|
- |
|
1648 |
// REQUETE UPDATE MVT ID_STOCK
|
- |
|
1649 |
UpdateBuilder buildMvtStock = new UpdateBuilder(tableMvtStock);
|
- |
|
1650 |
buildMvtStock.addForwardVirtualJoin(tableArticle, "ID_ARTICLE");
|
- |
|
1651 |
buildMvtStock.setFromVirtualJoinField("ID_STOCK", tableArticle.getAlias(), "ID_STOCK");
|
- |
|
1652 |
|
- |
|
1653 |
// REQUETE UPDATE STOCK ID_DEPOT_STOCK
|
- |
|
1654 |
UpdateBuilder buildStock = new UpdateBuilder(tableStock);
|
- |
|
1655 |
buildStock.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
- |
|
1656 |
|
- |
|
1657 |
UpdateBuilder buildArticleDepot = new UpdateBuilder(tableArticle);
|
- |
|
1658 |
buildArticleDepot.setObject("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID);
|
- |
|
1659 |
|
- |
|
1660 |
// REQUETE UPDATE ARTICLE_DEPOT_STOCK
|
- |
|
1661 |
// String req = "INSERT INTO " + root.getTable("ARTICLE_STOCK").getSQLName().quote()
|
- |
|
1662 |
// + " (" + root.getTable("ARTICLE_STOCK").getField("ID_ARTICLE").getQuotedName() +
|
- |
|
1663 |
// ",";
|
- |
|
1664 |
// req += root.getTable("ARTICLE_STOCK").getField("ID_STOCK").getQuotedName() + ", "
|
- |
|
1665 |
// + root.getTable("ARTICLE_STOCK").getField("QTE_MIN").getQuotedName() + ") SELECT
|
- |
|
1666 |
// "
|
- |
|
1667 |
// + root.getTable("ARTICLE").getKey().getQuotedName() + "," +
|
- |
|
1668 |
// root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + ", "
|
- |
|
1669 |
// + root.getTable("ARTICLE").getField("QTE_MIN").getQuotedName();
|
- |
|
1670 |
// req += " FROM " + root.getTable("ARTICLE").getSQLName().quote();
|
- |
|
1671 |
// req += " WHERE " + root.getTable("ARTICLE").getKey().getQuotedName() + " > 1 AND
|
- |
|
1672 |
// " + root.getTable("ARTICLE").getField("ID_STOCK").getQuotedName() + " >1 ";
|
- |
|
1673 |
// req += " AND " + root.getTable("ARTICLE").getArchiveField().getQuotedName() + " =
|
- |
|
1674 |
// 0";
|
- |
|
1675 |
|
- |
|
1676 |
tableStock.getDBSystemRoot().getDataSource().execute(buildArticleDepot.asString());
|
- |
|
1677 |
tableStock.getDBSystemRoot().getDataSource().execute(buildMvtStock.asString());
|
- |
|
1678 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStock.asString());
|
- |
|
1679 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
- |
|
1680 |
}
|
- |
|
1681 |
|
- |
|
1682 |
}
|
- |
|
1683 |
|
- |
|
1684 |
// Gestion Livraison depuis devis
|
- |
|
1685 |
SQLTable tableTrDevis = root.getTable("TR_DEVIS");
|
- |
|
1686 |
if (!tableTrDevis.contains("ID_BON_DE_LIVRAISON")) {
|
- |
|
1687 |
AlterTable t = new AlterTable(tableTrDevis);
|
- |
|
1688 |
t.addForeignColumn("ID_BON_DE_LIVRAISON", root.getTable("BON_DE_LIVRAISON"));
|
- |
|
1689 |
tableTrDevis.getBase().getDataSource().execute(t.asString());
|
- |
|
1690 |
root.refetchTable(tableTrDevis.getName());
|
- |
|
1691 |
root.getSchema().updateVersion();
|
- |
|
1692 |
}
|
- |
|
1693 |
SQLTable tableBLElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
- |
|
1694 |
if (!tableBLElt.contains("ID_DEVIS_ELEMENT")) {
|
- |
|
1695 |
AlterTable t = new AlterTable(tableBLElt);
|
- |
|
1696 |
t.addForeignColumn("ID_DEVIS_ELEMENT", root.getTable("DEVIS_ELEMENT"));
|
- |
|
1697 |
tableBLElt.getBase().getDataSource().execute(t.asString());
|
- |
|
1698 |
root.refetchTable(tableBLElt.getName());
|
- |
|
1699 |
root.getSchema().updateVersion();
|
- |
|
1700 |
}
|
- |
|
1701 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
- |
|
1702 |
if (!tableDevisElt.contains("QTE_LIVREE")) {
|
- |
|
1703 |
AlterTable t = new AlterTable(tableDevisElt);
|
- |
|
1704 |
t.addBooleanColumn("LIVRE_FORCED", Boolean.FALSE, false);
|
- |
|
1705 |
t.addBooleanColumn("LIVRE", Boolean.FALSE, false);
|
- |
|
1706 |
t.addDecimalColumn("QTE_LIVREE", 16, 6, BigDecimal.ZERO, true);
|
- |
|
1707 |
tableDevisElt.getBase().getDataSource().execute(t.asString());
|
- |
|
1708 |
root.refetchTable(tableDevisElt.getName());
|
- |
|
1709 |
root.getSchema().updateVersion();
|
- |
|
1710 |
|
- |
|
1711 |
// Move show devise pref in global
|
- |
|
1712 |
SQLSelect sel = new SQLSelect();
|
- |
|
1713 |
sel.addSelect(root.getTable("DEVISE_HISTORIQUE").getKey(), "COUNT");
|
- |
|
1714 |
Number n = (Number) root.getDBSystemRoot().getDataSource().executeScalar(sel.asString());
|
- |
|
1715 |
if (n.intValue() > 0) {
|
- |
|
1716 |
SQLPreferences prefs = new SQLPreferences(root);
|
- |
|
1717 |
prefs.putBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, true);
|
- |
|
1718 |
try {
|
- |
|
1719 |
prefs.sync();
|
- |
|
1720 |
} catch (BackingStoreException e) {
|
- |
|
1721 |
// TODO Auto-generated catch block
|
- |
|
1722 |
e.printStackTrace();
|
- |
|
1723 |
}
|
- |
|
1724 |
}
|
- |
|
1725 |
}
|
- |
|
1726 |
|
- |
|
1727 |
SQLTable tablePosteAn = root.getTable("POSTE_ANALYTIQUE");
|
- |
|
1728 |
if (!tablePosteAn.contains("OBSOLETE")) {
|
- |
|
1729 |
AlterTable t = new AlterTable(tablePosteAn);
|
- |
|
1730 |
t.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
- |
|
1731 |
tablePosteAn.getBase().getDataSource().execute(t.asString());
|
- |
|
1732 |
root.refetchTable(tablePosteAn.getName());
|
- |
|
1733 |
root.getSchema().updateVersion();
|
- |
|
1734 |
}
|
- |
|
1735 |
|
- |
|
1736 |
SQLTable tableCheque = root.getTable("CHEQUE_A_ENCAISSER");
|
- |
|
1737 |
if (!tableCheque.contains("ID_COMPTE_PCE_TIERS")) {
|
- |
|
1738 |
AlterTable t = new AlterTable(tableCheque);
|
- |
|
1739 |
t.addVarCharColumn("TIERS", 256);
|
- |
|
1740 |
t.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1741 |
tableCheque.getBase().getDataSource().execute(t.asString());
|
- |
|
1742 |
root.refetchTable(tableCheque.getName());
|
- |
|
1743 |
|
- |
|
1744 |
SQLTable tableEnc = root.getTable("ENCAISSER_MONTANT");
|
- |
|
1745 |
AlterTable tEnc = new AlterTable(tableEnc);
|
- |
|
1746 |
tEnc.addVarCharColumn("TIERS", 256);
|
- |
|
1747 |
tEnc.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1748 |
tableEnc.getBase().getDataSource().execute(tEnc.asString());
|
- |
|
1749 |
root.refetchTable(tableEnc.getName());
|
- |
|
1750 |
root.getSchema().updateVersion();
|
- |
|
1751 |
|
- |
|
1752 |
SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
- |
|
1753 |
AlterTable tEch = new AlterTable(tableEch);
|
- |
|
1754 |
tEch.addVarCharColumn("TIERS", 256);
|
- |
|
1755 |
tEch.addForeignColumn("ID_COMPTE_PCE_TIERS", root.getTable("COMPTE_PCE"));
|
- |
|
1756 |
tableEch.getBase().getDataSource().execute(tEch.asString());
|
- |
|
1757 |
root.refetchTable(tableEch.getName());
|
- |
|
1758 |
root.getSchema().updateVersion();
|
- |
|
1759 |
|
- |
|
1760 |
SQLTable tableChq = root.getTable("DEPOT_CHEQUE_ELEMENT");
|
- |
|
1761 |
AlterTable tChq = new AlterTable(tableChq);
|
- |
|
1762 |
tChq.addVarCharColumn("TIERS", 256);
|
- |
|
1763 |
tableChq.getBase().getDataSource().execute(tChq.asString());
|
- |
|
1764 |
root.refetchTable(tableChq.getName());
|
- |
|
1765 |
root.getSchema().updateVersion();
|
- |
|
1766 |
}
|
- |
|
1767 |
|
- |
|
1768 |
if (!tableEcr.contains("DATE_ECHEANCE")) {
|
- |
|
1769 |
AlterTable t = new AlterTable(tableEcr);
|
- |
|
1770 |
t.addColumn("DATE_ECHEANCE", "date");
|
- |
|
1771 |
tableEcr.getBase().getDataSource().execute(t.asString());
|
- |
|
1772 |
root.refetchTable(tableEcr.getName());
|
- |
|
1773 |
root.getSchema().updateVersion();
|
- |
|
1774 |
}
|
- |
|
1775 |
|
- |
|
1776 |
if (!tableVarSal.contains("HEURE_ABS_CUMUL_VAL")) {
|
- |
|
1777 |
|
- |
|
1778 |
final AlterTable alterB = new AlterTable(root.getTable("VARIABLE_SALARIE"));
|
- |
|
1779 |
|
- |
|
1780 |
for (org.openconcerto.sql.model.SQLField sqlField : tableVarSal.getContentFields()) {
|
- |
|
1781 |
|
- |
|
1782 |
String field = sqlField.getName();
|
- |
|
1783 |
if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
|
- |
|
1784 |
&& !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL")) {
|
- |
|
1785 |
alterB.addColumn(field + "_CUMUL_VAL", "real DEFAULT 0");
|
- |
|
1786 |
}
|
- |
|
1787 |
}
|
- |
|
1788 |
|
- |
|
1789 |
root.getBase().getDataSource().execute(alterB.asString());
|
- |
|
1790 |
root.refetchTable("VARIABLE_SALARIE");
|
- |
|
1791 |
root.getSchema().updateVersion();
|
- |
|
1792 |
}
|
- |
|
1793 |
|
- |
|
1794 |
// fix stock
|
- |
|
1795 |
{
|
- |
|
1796 |
SQLTable tableStock = root.getTable("STOCK");
|
- |
|
1797 |
|
- |
|
1798 |
// Doublon depot stock
|
- |
|
1799 |
SQLSelect sel = new SQLSelect();
|
- |
|
1800 |
sel.addSelectFunctionStar("COUNT");
|
- |
|
1801 |
sel.addSelect(tableStock.getField("ID_DEPOT_STOCK"));
|
- |
|
1802 |
sel.addSelect(tableStock.getField("ID_ARTICLE"));
|
- |
|
1803 |
sel.addGroupBy(tableStock.getField("ID_DEPOT_STOCK"));
|
- |
|
1804 |
sel.addGroupBy(tableStock.getField("ID_ARTICLE"));
|
- |
|
1805 |
sel.setHaving(Where.createRaw("COUNT(*)>1", Collections.emptyList()));
|
- |
|
1806 |
System.err.println(sel.asString());
|
- |
|
1807 |
|
- |
|
1808 |
List<Object[]> resultStockDoublon = (List<Object[]>) tableStock.getDBSystemRoot().getDataSource().execute(sel.asString(), new ArrayListHandler());
|
- |
|
1809 |
for (Object[] objects : resultStockDoublon) {
|
- |
|
1810 |
|
- |
|
1811 |
if (((Number) objects[2]).intValue() == 1) {
|
- |
|
1812 |
|
- |
|
1813 |
UpdateBuilder buildStockArt = new UpdateBuilder(tableStock);
|
- |
|
1814 |
buildStockArt.addBackwardVirtualJoin(tableArticle, "ID_STOCK");
|
- |
|
1815 |
buildStockArt.setFromVirtualJoinField("ID_ARTICLE", tableArticle.getAlias(), "ID");
|
- |
|
1816 |
buildStockArt.setWhere(new Where(tableStock.getKey(), "!=", 1));
|
- |
|
1817 |
tableStock.getDBSystemRoot().getDataSource().execute(buildStockArt.asString());
|
- |
|
1818 |
} else {
|
- |
|
1819 |
SQLSelect selD = new SQLSelect();
|
- |
|
1820 |
selD.addSelectStar(tableStock);
|
- |
|
1821 |
Where w = new Where(tableStock.getField("ID_ARTICLE"), "=", objects[2]);
|
- |
|
1822 |
w = w.and(new Where(tableStock.getField("ID_DEPOT_STOCK"), "=", objects[1]));
|
- |
|
1823 |
selD.setWhere(w);
|
- |
|
1824 |
List<SQLRow> badStock = SQLRowListRSH.execute(selD);
|
- |
|
1825 |
if (badStock.size() > 1) {
|
- |
|
1826 |
SQLRowValues stock = badStock.get(0).createUpdateRow();
|
- |
|
1827 |
List<String> fieldsToMerge = Arrays.asList("QTE_REEL", "QTE_TH", "QTE_RECEPT_ATTENTE", "QTE_LIV_ATTENTE");
|
- |
|
1828 |
List<Integer> listBadIds = new ArrayList<>();
|
- |
|
1829 |
for (int i = 1; i < badStock.size(); i++) {
|
- |
|
1830 |
SQLRow rowBad = badStock.get(i);
|
- |
|
1831 |
listBadIds.add(rowBad.getID());
|
- |
|
1832 |
for (String field : fieldsToMerge) {
|
- |
|
1833 |
stock.put(field, stock.getFloat(field) + rowBad.getFloat(field));
|
- |
|
1834 |
}
|
- |
|
1835 |
rowBad.createEmptyUpdateRow().put("ARCHIVE", 1).commit();
|
- |
|
1836 |
}
|
- |
|
1837 |
List<SQLTable> tablesToMErge = Arrays.asList(root.getTable("MOUVEMENT_STOCK"), root.getTable("ARTICLE"));
|
- |
|
1838 |
for (SQLTable mergeTable : tablesToMErge) {
|
- |
|
1839 |
UpdateBuilder up = new UpdateBuilder(mergeTable);
|
- |
|
1840 |
up.setObject("ID_STOCK", stock.getID());
|
- |
|
1841 |
up.setWhere(new Where(mergeTable.getField("ID_STOCK"), listBadIds));
|
- |
|
1842 |
mergeTable.getDBSystemRoot().getDataSource().execute(up.asString());
|
- |
|
1843 |
}
|
- |
|
1844 |
stock.commit();
|
- |
|
1845 |
|
- |
|
1846 |
}
|
- |
|
1847 |
}
|
- |
|
1848 |
}
|
- |
|
1849 |
|
- |
|
1850 |
SQLSelect selArt = new SQLSelect();
|
- |
|
1851 |
selArt.addSelectStar(tableArt);
|
- |
|
1852 |
Where w = new Where(tableArt.getField("ID_STOCK"), "=", 1);
|
- |
|
1853 |
selArt.setWhere(w);
|
- |
|
1854 |
List<SQLRow> badStock = SQLRowListRSH.execute(selArt);
|
- |
|
1855 |
for (SQLRow sqlRow : badStock) {
|
- |
|
1856 |
initStock(sqlRow);
|
- |
|
1857 |
}
|
- |
|
1858 |
}
|
- |
|
1859 |
|
- |
|
1860 |
|
- |
|
1861 |
}
|
- |
|
1862 |
|
- |
|
1863 |
public static void initStock(SQLRow row) {
|
- |
|
1864 |
SQLSelect sel = new SQLSelect();
|
- |
|
1865 |
sel.addSelectStar(row.getTable().getTable("DEPOT_STOCK"));
|
- |
|
1866 |
List<SQLRow> rowsDepot = SQLRowListRSH.execute(sel);
|
- |
|
1867 |
|
- |
|
1868 |
SQLSelect selStock = new SQLSelect();
|
- |
|
1869 |
selStock.addSelectStar(row.getTable().getTable("STOCK"));
|
- |
|
1870 |
selStock.setWhere(new Where(row.getTable().getTable("STOCK").getField("ID_ARTICLE"), "=", row.getID()));
|
- |
|
1871 |
List<SQLRow> rowsStock = SQLRowListRSH.execute(selStock);
|
- |
|
1872 |
Map<Integer, SQLRow> initedDepot = new HashMap<>();
|
- |
|
1873 |
for (SQLRow sqlRow : rowsStock) {
|
- |
|
1874 |
initedDepot.put(sqlRow.getForeignID("ID_DEPOT_STOCK"), sqlRow);
|
- |
|
1875 |
}
|
- |
|
1876 |
|
- |
|
1877 |
List<StockItem> stockItems = new ArrayList<StockItem>();
|
- |
|
1878 |
for (SQLRow sqlRow : rowsDepot) {
|
- |
|
1879 |
try {
|
- |
|
1880 |
if (!initedDepot.keySet().contains(sqlRow.getID())) {
|
- |
|
1881 |
SQLRowValues rowVals = new SQLRowValues(row.getTable().getTable("STOCK"));
|
- |
|
1882 |
rowVals.put("ID_ARTICLE", row.getID());
|
- |
|
1883 |
rowVals.put("ID_DEPOT_STOCK", sqlRow.getID());
|
- |
|
1884 |
|
- |
|
1885 |
SQLRow rowStock = rowVals.commit();
|
- |
|
1886 |
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
|
- |
|
1887 |
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
- |
|
1888 |
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
|
- |
|
1889 |
row.createEmptyUpdateRow().put("ID_STOCK", rowStock.getID()).commit();
|
- |
|
1890 |
}
|
- |
|
1891 |
stockItems.add(new StockItem(row, rowStock));
|
- |
|
1892 |
|
- |
|
1893 |
} else {
|
- |
|
1894 |
SQLRow rowExisting = initedDepot.get(sqlRow.getID());
|
- |
|
1895 |
if ((row.getObject("ID_DEPOT_STOCK") == null || row.isForeignEmpty("ID_DEPOT_STOCK")) && sqlRow.getID() == DepotStockSQLElement.DEFAULT_ID) {
|
- |
|
1896 |
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).put("ID_DEPOT_STOCK", DepotStockSQLElement.DEFAULT_ID).commit();
|
- |
|
1897 |
} else if (sqlRow.getID() == row.getForeignID("ID_DEPOT_STOCK")) {
|
- |
|
1898 |
row.createEmptyUpdateRow().put("ID_STOCK", rowExisting.getID()).commit();
|
- |
|
1899 |
}
|
- |
|
1900 |
stockItems.add(new StockItem(row, rowExisting));
|
- |
|
1901 |
}
|
- |
|
1902 |
} catch (SQLException e) {
|
- |
|
1903 |
ExceptionHandler.handle("Erreur lors de l'initialisation du stock de l'article", e);
|
- |
|
1904 |
}
|
- |
|
1905 |
}
|
- |
|
1906 |
// if
|
- |
|
1907 |
// (row.getReferentRows(row.getTable().getTable("ARTICLE_ELEMENT").getField("ID_ARTICLE_PARENT")).size()
|
- |
|
1908 |
// > 0) {
|
- |
|
1909 |
// ComposedItemStockUpdater up = new ComposedItemStockUpdater(row.getTable().getDBRoot(),
|
- |
|
1910 |
// stockItems);
|
- |
|
1911 |
// try {
|
- |
|
1912 |
// up.updateNomenclature(stockItems);
|
- |
|
1913 |
// } catch (SQLException e) {
|
- |
|
1914 |
// ExceptionHandler.handle("Erreur lors de l'actualisation du stock!", e);
|
- |
|
1915 |
// }
|
- |
|
1916 |
// }
|
1147 |
}
|
1917 |
}
|
1148 |
|
1918 |
|
1149 |
public static void exec(final AlterTable alter) throws SQLException {
|
1919 |
public static void exec(final AlterTable alter) throws SQLException {
|
1150 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
1920 |
alter.getTable().getDBSystemRoot().getDataSource().execute(alter.asString());
|
1151 |
alter.getTable().getSchema().updateVersion();
|
1921 |
alter.getTable().getSchema().updateVersion();
|
1152 |
alter.getTable().fetchFields();
|
1922 |
alter.getTable().fetchFields();
|
1153 |
}
|
1923 |
}
|
1154 |
}
|
1924 |
}
|