OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 182 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
132 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
182 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
132 ilm 5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.config;
15
 
156 ilm 16
import org.openconcerto.erp.config.DsnBrutCode.DsnTypeCodeBrut;
132 ilm 17
import org.openconcerto.sql.model.DBRoot;
18
import org.openconcerto.sql.model.SQLBase;
142 ilm 19
import org.openconcerto.sql.model.SQLName;
132 ilm 20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRowListRSH;
22
import org.openconcerto.sql.model.SQLRowValues;
23
import org.openconcerto.sql.model.SQLSelect;
24
import org.openconcerto.sql.model.SQLSyntax;
25
import org.openconcerto.sql.model.SQLTable;
26
import org.openconcerto.sql.model.Where;
27
import org.openconcerto.sql.request.Inserter;
28
import org.openconcerto.sql.request.Inserter.Insertion;
142 ilm 29
import org.openconcerto.sql.request.UpdateBuilder;
132 ilm 30
import org.openconcerto.sql.utils.AlterTable;
31
import org.openconcerto.sql.utils.ReOrder;
32
import org.openconcerto.sql.utils.SQLCreateTable;
33
import org.openconcerto.utils.Tuple2;
156 ilm 34
import org.openconcerto.utils.Tuple3;
132 ilm 35
 
36
import java.sql.SQLException;
37
import java.util.ArrayList;
38
import java.util.Arrays;
142 ilm 39
import java.util.HashMap;
132 ilm 40
import java.util.List;
142 ilm 41
import java.util.Map;
132 ilm 42
 
43
public class DSNInstallationUtils {
44
 
45
    private void insertUndef(final SQLCreateTable ct) throws SQLException {
46
        // check that we can use insertReturnFirstField()
47
        if (ct.getPrimaryKey().size() != 1)
48
            throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
49
        final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
50
        assert insertion.getCount() == 1;
51
        if (insertion.getRows().size() != 1)
52
            throw new IllegalStateException("Missing ID " + insertion.getRows());
53
        SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
54
    }
55
 
56
    private void insertValues(List<Tuple2<String, String>> values, SQLTable table) throws SQLException {
142 ilm 57
        SQLSelect sel = new SQLSelect();
58
        sel.addSelect(table.getField("CODE"));
182 ilm 59
        List<String> codes = (List<String>) table.getDBSystemRoot().getDataSource().executeCol(sel.asString());
132 ilm 60
        for (Tuple2<String, String> tuple2 : values) {
142 ilm 61
            if (!codes.contains(tuple2.get0())) {
62
                SQLRowValues rowVals = new SQLRowValues(table);
63
                rowVals.put("CODE", tuple2.get0());
64
                rowVals.put("NOM", tuple2.get1());
65
                rowVals.commit();
66
            }
132 ilm 67
        }
68
    }
69
 
70
    public void updateDSNCommonTable(final DBRoot root) throws SQLException {
71
 
72
        SQLTable societeCommonT = root.getTable("SOCIETE_COMMON");
73
        if (!societeCommonT.contains("IBAN")) {
74
            AlterTable t = new AlterTable(societeCommonT);
75
            t.addVarCharColumn("IBAN", 256);
76
            t.addVarCharColumn("BIC", 256);
77
            root.getBase().getDataSource().execute(t.asString());
78
            root.refetchTable("SOCIETE_COMMON");
79
            root.getSchema().updateVersion();
80
        }
81
        if (!societeCommonT.contains("ORG_PROTECTION_SOCIAL_ID")) {
82
            AlterTable t = new AlterTable(societeCommonT);
83
            t.addVarCharColumn("ORG_PROTECTION_SOCIAL_ID", 256);
84
            root.getBase().getDataSource().execute(t.asString());
85
            root.refetchTable("SOCIETE_COMMON");
86
            root.getSchema().updateVersion();
87
        }
88
 
182 ilm 89
        if (!societeCommonT.contains("ORG_PROTECTION_SOCIAL_ID")) {
90
            AlterTable t = new AlterTable(societeCommonT);
91
            t.addVarCharColumn("ORG_PROTECTION_SOCIAL_ID", 256);
92
            root.getBase().getDataSource().execute(t.asString());
93
            root.refetchTable("SOCIETE_COMMON");
94
            root.getSchema().updateVersion();
95
        }
96
 
132 ilm 97
        SQLTable tableRubCot = root.getTable("RUBRIQUE_COTISATION");
98
        if (!tableRubCot.contains("ASSIETTE_PLAFONNEE")) {
99
            AlterTable tableRub = new AlterTable(tableRubCot);
100
            tableRub.addBooleanColumn("ASSIETTE_PLAFONNEE", false, false);
101
            root.getBase().getDataSource().execute(tableRub.asString());
102
            root.refetchTable("RUBRIQUE_COTISATION");
103
            root.getSchema().updateVersion();
104
        }
105
 
185 ilm 106
        if (!tableRubCot.contains("NUMERO_COMPTE_PCE")) {
107
            final AlterTable alter = new AlterTable(tableRubCot);
108
            alter.addVarCharColumn("NUMERO_COMPTE_PCE", 128);
109
            alter.addVarCharColumn("NUMERO_COMPTE_PCE_CHARGES", 128);
110
            final String req = alter.asString();
111
            root.getDBSystemRoot().getDataSource().execute(req);
112
            root.refetchTable(tableRubCot.getName());
113
            root.getSchema().updateVersion();
114
        }
115
 
144 ilm 116
        if (!tableRubCot.contains("TAXABLE_CM")) {
117
            AlterTable tableRub = new AlterTable(tableRubCot);
118
            tableRub.addBooleanColumn("TAXABLE_CM", Boolean.FALSE, false);
119
            root.getBase().getDataSource().execute(tableRub.asString());
120
            root.refetchTable("RUBRIQUE_COTISATION");
121
            root.getSchema().updateVersion();
122
        }
123
 
132 ilm 124
        if (!root.contains("CODE_CAISSE_TYPE_RUBRIQUE")) {
125
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "CODE_CAISSE_TYPE_RUBRIQUE");
126
            createTableCode.addVarCharColumn("CODE", 25);
127
            createTableCode.addVarCharColumn("NOM", 512);
128
            createTableCode.addVarCharColumn("CAISSE_COTISATION", 512);
129
 
130
            try {
131
                root.getBase().getDataSource().execute(createTableCode.asString());
132
                insertUndef(createTableCode);
133
                root.refetchTable("CODE_CAISSE_TYPE_RUBRIQUE");
134
 
135
                final SQLTable table = root.getTable("CODE_CAISSE_TYPE_RUBRIQUE");
136
 
137
                DsnUrssafCode codeUrssaf = new DsnUrssafCode();
138
                codeUrssaf.insertCode(table);
139
 
140
                List<String> tableRubName = Arrays.asList("RUBRIQUE_BRUT", "RUBRIQUE_COTISATION", "RUBRIQUE_NET");
141
                for (String t : tableRubName) {
142
                    AlterTable tableRub = new AlterTable(root.getTable(t));
143
                    tableRub.addForeignColumn("ID_CODE_CAISSE_TYPE_RUBRIQUE", table);
144
                    root.getBase().getDataSource().execute(tableRub.asString());
145
                    root.refetchTable(t);
146
                }
147
                root.getSchema().updateVersion();
148
 
149
            } catch (SQLException ex) {
150
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_CAISSE_TYPE_RUBRIQUE", ex);
151
            }
152
        }
153
 
154
        if (!root.contains("MOTIF_ARRET_TRAVAIL")) {
155
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_ARRET_TRAVAIL");
156
            createTableMotif.addVarCharColumn("CODE", 25);
157
            createTableMotif.addVarCharColumn("NOM", 512);
158
 
159
            try {
160
                root.getBase().getDataSource().execute(createTableMotif.asString());
161
                insertUndef(createTableMotif);
162
                root.refetchTable("MOTIF_ARRET_TRAVAIL");
163
                root.getSchema().updateVersion();
164
 
165
                final SQLTable table = root.getTable("MOTIF_ARRET_TRAVAIL");
166
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
167
                v.add(Tuple2.create("01", "maladie"));
168
                v.add(Tuple2.create("02", "maternité /adoption"));
169
                v.add(Tuple2.create("03", "paternité / accueil de l’enfant"));
170
                v.add(Tuple2.create("04", "congé suite à un accident de trajet"));
171
                v.add(Tuple2.create("05", "congé suite à maladie professionnelle"));
172
                v.add(Tuple2.create("06", "congé suite à accident de travail ou de service"));
173
                v.add(Tuple2.create("07", "femme enceinte dispensée de travail"));
174
                v.add(Tuple2.create("99", "annulation"));
175
 
176
                insertValues(v, table);
177
            } catch (SQLException ex) {
178
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_ARRET_TRAVAIL", ex);
179
            }
180
        }
182 ilm 181
 
180 ilm 182
        if (!root.contains("DIPLOME_PREPARE")) {
183
            final SQLCreateTable createTableDiplome = new SQLCreateTable(root, "DIPLOME_PREPARE");
184
            createTableDiplome.addVarCharColumn("CODE", 25);
185
            createTableDiplome.addVarCharColumn("NOM", 512);
132 ilm 186
 
180 ilm 187
            try {
188
                root.getBase().getDataSource().execute(createTableDiplome.asString());
189
                insertUndef(createTableDiplome);
190
                root.refetchTable("DIPLOME_PREPARE");
191
                root.getSchema().updateVersion();
192
 
193
                final SQLTable table = root.getTable("DIPLOME_PREPARE");
194
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
195
                v.add(Tuple2.create("03", "Niveau de formation équivalent au CAP (certificat d'aptitude professionnelle) ou au BEP (brevet d'études professionnelles)"));
196
                v.add(Tuple2.create("04", "Formation de niveau du bac (général, technologique ou professionnel), du brevet de technicien (BT) ou du brevet professionnel"));
197
                v.add(Tuple2.create("05", "Formation de niveau bac+2 : licence 2, BTS (brevet de technicien supérieur), DUT (diplôme universitaire de technologie), etc."));
198
                v.add(Tuple2.create("06", "Formation de niveau bac+3 et bac+4 : licence 3, licence professionnelle, master 1, etc."));
199
                v.add(Tuple2.create("07", "Formation de niveau bac+5 : master 2, diplôme d'études approfondies, diplôme d'études supérieures spécialisées, diplôme d'ingénieur, etc."));
200
                v.add(Tuple2.create("08", "Formation de niveau bac+8 : doctorat, habilitation à diriger des recherches, etc. "));
201
 
202
                insertValues(v, table);
203
            } catch (SQLException ex) {
204
                throw new IllegalStateException("Erreur lors de la création de la table " + "DIPLOME_PREPARE", ex);
205
            }
206
        }
207
 
142 ilm 208
        if (!root.contains("TYPE_PREAVIS")) {
209
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_PREAVIS");
210
            createTableMotif.addVarCharColumn("CODE", 25);
211
            createTableMotif.addVarCharColumn("NOM", 512);
212
 
213
            try {
214
                root.getBase().getDataSource().execute(createTableMotif.asString());
215
                insertUndef(createTableMotif);
216
                root.refetchTable("TYPE_PREAVIS");
217
                root.getSchema().updateVersion();
218
 
219
                final SQLTable table = root.getTable("TYPE_PREAVIS");
220
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
221
                v.add(Tuple2.create("01", "préavis effectué et payé"));
222
                v.add(Tuple2.create("02", "préavis non effectué et payé"));
223
                v.add(Tuple2.create("03", "préavis non effectué et non payé"));
224
                v.add(Tuple2.create("10", "préavis non effectué non payé dans le cadre d’un contrat de sécurisation professionnelle (CSP)"));
225
                v.add(Tuple2.create("50", "préavis non effectué et payé dans le cadre d’un congé de reclassement"));
226
                v.add(Tuple2.create("51", "préavis non effectué et payé dans le cadre d’un congé de mobilité"));
227
                v.add(Tuple2.create("60", "Délai de prévenance"));
228
                v.add(Tuple2.create("90", "pas de clause de préavis applicable"));
229
 
230
                insertValues(v, table);
231
            } catch (SQLException ex) {
232
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_PREAVIS", ex);
233
            }
234
        }
235
 
132 ilm 236
        if (!root.contains("CODE_BASE_ASSUJETTIE")) {
237
            final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_BASE_ASSUJETTIE");
238
            createTableCodeBase.addVarCharColumn("CODE", 25);
239
            createTableCodeBase.addVarCharColumn("NOM", 512);
240
 
241
            try {
242
                root.getBase().getDataSource().execute(createTableCodeBase.asString());
243
                insertUndef(createTableCodeBase);
244
                root.refetchTable("CODE_BASE_ASSUJETTIE");
245
                root.getSchema().updateVersion();
246
 
247
                final SQLTable table = root.getTable("CODE_BASE_ASSUJETTIE");
248
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
249
 
250
                v.add(Tuple2.create("02", "Assiette brute plafonnée"));
251
                v.add(Tuple2.create("03", "Assiette brute déplafonnée"));
252
                v.add(Tuple2.create("04", "Assiette de la contribution sociale généralisée"));
253
                v.add(Tuple2.create("07", "Assiette des contributions d'Assurance Chômage"));
254
                v.add(Tuple2.create("08", "Assiette retraite CPRP SNCF"));
255
                v.add(Tuple2.create("09", "Assiette de compensation bilatérale maladie CPRP SNCF"));
256
                v.add(Tuple2.create("10", "Base brute fiscale"));
257
                v.add(Tuple2.create("11", "Base forfaitaire soumise aux cotisations de Sécurité Sociale"));
258
                v.add(Tuple2.create("12", "Assiette du crédit d'impôt compétitivité-emploi"));
259
                v.add(Tuple2.create("13", "Assiette du forfait social à 8%"));
260
                v.add(Tuple2.create("14", "Assiette du forfait social à 20%"));
261
 
262
                insertValues(v, table);
263
            } catch (SQLException ex) {
264
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
265
            }
266
        }
267
        if (!tableRubCot.contains("ID_CODE_BASE_ASSUJETTIE")) {
268
            AlterTable alterTableCot = new AlterTable(tableRubCot);
269
            alterTableCot.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
270
            root.getBase().getDataSource().execute(alterTableCot.asString());
271
            root.refetchTable("RUBRIQUE_COTISATION");
272
            root.getSchema().updateVersion();
273
        }
274
 
275
        if (!root.contains("CODE_TYPE_RUBRIQUE_BRUT")) {
276
            final SQLCreateTable createTableCodeBase = new SQLCreateTable(root, "CODE_TYPE_RUBRIQUE_BRUT");
277
            createTableCodeBase.addVarCharColumn("CODE", 25);
278
            createTableCodeBase.addVarCharColumn("NOM", 512);
279
            createTableCodeBase.addVarCharColumn("TYPE", 512);
280
 
281
            try {
282
                root.getBase().getDataSource().execute(createTableCodeBase.asString());
283
                insertUndef(createTableCodeBase);
284
                root.refetchTable("CODE_TYPE_RUBRIQUE_BRUT");
285
                root.getSchema().updateVersion();
286
 
287
                DsnBrutCode brutCode = new DsnBrutCode();
288
                brutCode.insertCode(root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
289
            } catch (SQLException ex) {
290
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_BASE_ASSUJETTIE", ex);
291
            }
292
        }
293
 
294
        SQLTable tableRubBrut = root.getTable("RUBRIQUE_BRUT");
295
        if (!tableRubBrut.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
296
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
297
            alterTableBrut.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
298
            root.getBase().getDataSource().execute(alterTableBrut.asString());
299
            root.refetchTable("RUBRIQUE_BRUT");
300
            root.getSchema().updateVersion();
301
        }
302
 
144 ilm 303
        if (!tableRubBrut.contains("COTISABLE")) {
304
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
305
            alterTableBrut.addBooleanColumn("COTISABLE", Boolean.TRUE, false);
306
            root.getBase().getDataSource().execute(alterTableBrut.asString());
307
            root.refetchTable("RUBRIQUE_BRUT");
308
            root.getSchema().updateVersion();
309
        }
310
 
311
        if (!tableRubBrut.contains("TAXABLE_CM")) {
312
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
313
            alterTableBrut.addBooleanColumn("TAXABLE_CM", Boolean.TRUE, false);
314
            root.getBase().getDataSource().execute(alterTableBrut.asString());
315
            root.refetchTable("RUBRIQUE_BRUT");
316
            root.getSchema().updateVersion();
317
        }
318
 
177 ilm 319
        if (!tableRubBrut.contains("CSG_NORMAL")) {
320
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
321
            alterTableBrut.addBooleanColumn("CSG_NORMAL", Boolean.TRUE, false);
322
            root.getBase().getDataSource().execute(alterTableBrut.asString());
323
            root.refetchTable("RUBRIQUE_BRUT");
324
            root.getSchema().updateVersion();
325
        }
326
        if (!tableRubBrut.contains("CSG_REDUIT")) {
327
            AlterTable alterTableBrut = new AlterTable(tableRubBrut);
328
            alterTableBrut.addBooleanColumn("CSG_REDUIT", Boolean.FALSE, false);
329
            root.getBase().getDataSource().execute(alterTableBrut.asString());
330
            root.refetchTable("RUBRIQUE_BRUT");
331
            root.getSchema().updateVersion();
332
        }
333
 
142 ilm 334
        SQLTable tableRubNet = root.getTable("RUBRIQUE_NET");
335
        if (!tableRubNet.contains("ID_CODE_TYPE_RUBRIQUE_BRUT")) {
336
 
337
            AlterTable alterTableNet = new AlterTable(tableRubNet);
338
            alterTableNet.addForeignColumn("ID_CODE_TYPE_RUBRIQUE_BRUT", root.getTable("CODE_TYPE_RUBRIQUE_BRUT"));
339
            root.getBase().getDataSource().execute(alterTableNet.asString());
340
            root.refetchTable("RUBRIQUE_NET");
341
            root.getSchema().updateVersion();
342
        }
343
 
132 ilm 344
        if (!root.contains("DSN_REGIME_LOCAL")) {
345
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_REGIME_LOCAL");
346
            createTableMotif.addVarCharColumn("CODE", 25);
347
            createTableMotif.addVarCharColumn("NOM", 512);
348
 
349
            try {
350
                root.getBase().getDataSource().execute(createTableMotif.asString());
351
                insertUndef(createTableMotif);
352
                root.refetchTable("DSN_REGIME_LOCAL");
353
                root.getSchema().updateVersion();
354
 
355
                final SQLTable table = root.getTable("DSN_REGIME_LOCAL");
356
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
357
                v.add(Tuple2.create("99", "non applicable"));
358
                v.add(Tuple2.create("01", "régime local Alsace Moselle"));
359
                insertValues(v, table);
360
            } catch (SQLException ex) {
361
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_REGIME_LOCAL", ex);
362
            }
363
        }
364
 
365
        if (!root.contains("CONTRAT_MODALITE_TEMPS")) {
366
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MODALITE_TEMPS");
367
            createTableMotif.addVarCharColumn("CODE", 25);
368
            createTableMotif.addVarCharColumn("NOM", 512);
369
 
370
            try {
371
                root.getBase().getDataSource().execute(createTableMotif.asString());
372
                insertUndef(createTableMotif);
373
                root.refetchTable("CONTRAT_MODALITE_TEMPS");
374
                root.getSchema().updateVersion();
375
 
376
                final SQLTable table = root.getTable("CONTRAT_MODALITE_TEMPS");
377
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
378
                v.add(Tuple2.create("10", "temps plein"));
379
                v.add(Tuple2.create("20", "temps partiel"));
380
                v.add(Tuple2.create("21", "temps partiel thérapeutique"));
381
                v.add(Tuple2.create("99", "salarié non concerné"));
382
                insertValues(v, table);
383
            } catch (SQLException ex) {
384
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MODALITE_TEMPS", ex);
385
            }
386
        }
387
 
388
        if (!root.contains("CONTRAT_REGIME_MALADIE")) {
389
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_MALADIE");
390
            createTableMotif.addVarCharColumn("CODE", 25);
391
            createTableMotif.addVarCharColumn("NOM", 512);
392
 
393
            try {
394
                root.getBase().getDataSource().execute(createTableMotif.asString());
395
                insertUndef(createTableMotif);
396
                root.refetchTable("CONTRAT_REGIME_MALADIE");
397
                root.getSchema().updateVersion();
398
 
399
                final SQLTable table = root.getTable("CONTRAT_REGIME_MALADIE");
400
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
401
                v.add(Tuple2.create("134", "régime spécial de la SNCF"));
402
                v.add(Tuple2.create("135", "régime spécial de la RATP"));
403
                v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
404
                v.add(Tuple2.create("137", "mineurs ou assimilés (CANMSS)"));
405
                v.add(Tuple2.create("138", "militaires de carrière (CNMSS)"));
406
                v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
407
                v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
408
                v.add(Tuple2.create("144", "Assemblée Nationale"));
409
                v.add(Tuple2.create("145", "Sénat"));
410
                v.add(Tuple2.create("146", "port autonome de Bordeaux"));
411
                v.add(Tuple2.create("147", "industries électriques et gazières (CAMIEG)"));
412
                v.add(Tuple2.create("149", "régimes des cultes (CAVIMAC)"));
413
                v.add(Tuple2.create("200", "régime général (CNAM)"));
414
                v.add(Tuple2.create("300", "régime agricole (MSA)"));
415
                v.add(Tuple2.create("400", "régime spécial Banque de France"));
416
                v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie)"));
417
                v.add(Tuple2.create("999", "autre"));
418
 
419
                insertValues(v, table);
420
            } catch (SQLException ex) {
421
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_MALADIE", ex);
422
            }
423
        }
424
 
425
        if (!root.contains("CONTRAT_REGIME_VIEILLESSE")) {
426
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_REGIME_VIEILLESSE");
427
            createTableMotif.addVarCharColumn("CODE", 25);
428
            createTableMotif.addVarCharColumn("NOM", 512);
429
 
430
            try {
431
                root.getBase().getDataSource().execute(createTableMotif.asString());
432
                insertUndef(createTableMotif);
433
                root.refetchTable("CONTRAT_REGIME_VIEILLESSE");
434
                root.getSchema().updateVersion();
435
 
436
                final SQLTable table = root.getTable("CONTRAT_REGIME_VIEILLESSE");
437
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
438
                v.add(Tuple2.create("120", "retraite des agents des collectivités locales (CNRACL)"));
439
                v.add(Tuple2.create("121", "pensions des ouvriers des établissements industriels de l'Etat (FSPOEIE)"));
440
                v.add(Tuple2.create("122", "pensions civiles et militaires de retraite de l'Etat (SRE)"));
441
                v.add(Tuple2.create("134", "régime spécial de la SNCF"));
442
                v.add(Tuple2.create("135", "régime spécial de la RATP"));
443
                v.add(Tuple2.create("136", "établissement des invalides de la marine (ENIM)"));
444
                v.add(Tuple2.create("137", "mineurs ou assimilés (fonds Caisse des Dépôts)"));
445
                v.add(Tuple2.create("139", "Banque de France"));
446
                v.add(Tuple2.create("140", "clercs et employés de notaires (CRPCEN)"));
447
                v.add(Tuple2.create("141", "chambre de commerce et d'industrie de Paris"));
448
                v.add(Tuple2.create("144", "Assemblée Nationale"));
449
                v.add(Tuple2.create("145", "Sénat"));
450
                v.add(Tuple2.create("147", "industries électriques et gazières (CNIEG)"));
451
                v.add(Tuple2.create("149", "régime des cultes (CAVIMAC)"));
452
                v.add(Tuple2.create("157", "régime de retraite des avocats (CNBF)"));
453
                v.add(Tuple2.create("158", "SEITA"));
454
                v.add(Tuple2.create("159", "Comédie Française"));
455
                v.add(Tuple2.create("160", "Opéra de Paris"));
456
                v.add(Tuple2.create("200", "régime général (CNAV)"));
457
                v.add(Tuple2.create("300", "régime agricole (MSA)"));
458
                v.add(Tuple2.create("900", "autre régime (réservé Polynésie Française, Nouvelle Calédonie, Principauté de Monaco)"));
459
                v.add(Tuple2.create("903", "salariés étrangers exemptés d'affiliation pour le risque vieillesse"));
460
                v.add(Tuple2.create("999", "cas particuliers d'affiliation"));
461
 
462
                insertValues(v, table);
463
            } catch (SQLException ex) {
464
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_REGIME_VIEILLESSE", ex);
465
            }
466
        }
467
 
468
        if (!root.contains("CONTRAT_MOTIF_RECOURS")) {
469
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_MOTIF_RECOURS");
470
            createTableMotif.addVarCharColumn("CODE", 25);
471
            createTableMotif.addVarCharColumn("NOM", 512);
472
 
473
            try {
474
                root.getBase().getDataSource().execute(createTableMotif.asString());
475
                insertUndef(createTableMotif);
476
                root.refetchTable("CONTRAT_MOTIF_RECOURS");
477
                root.getSchema().updateVersion();
478
 
479
                final SQLTable table = root.getTable("CONTRAT_MOTIF_RECOURS");
480
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
481
                v.add(Tuple2.create("01", "Remplacement d'un salarié"));
482
                v.add(Tuple2.create("02", "Accroissement temporaire de l'activité de l'entreprise"));
483
                v.add(Tuple2.create("03", "Emplois à caractère saisonnier"));
484
                v.add(Tuple2.create("04", "Contrat vendanges"));
485
                v.add(Tuple2.create("05", "Contrat à durée déterminée d’usage"));
486
                v.add(Tuple2.create("06", "Contrat à durée déterminée à objet défini"));
487
                v.add(Tuple2.create("07", "Remplacement d'un chef d'entreprise"));
488
                v.add(Tuple2.create("08", "Remplacement du chef d'une exploitation agricole"));
489
                v.add(Tuple2.create("09", "Recrutement de personnes sans emploi rencontrant des difficultés sociales et professionnelles particulières"));
490
                v.add(Tuple2.create("10", "Complément de formation professionnelle au salarié"));
491
                v.add(Tuple2.create("11",
492
                        "Formation professionnelle au salarié par la voie de l'apprentissage, en vue de l'obtention d'une qualification professionnelle sanctionnée par un diplôme ou un titre à finalité professionnelle enregistré au répertoire national des certifications professionnelles"));
493
                v.add(Tuple2.create("12", "Remplacement d’un salarié passé provisoirement à temps partiel"));
494
                v.add(Tuple2.create("13", "Attente de la suppression définitive du poste du salarié ayant quitté définitivement l’entreprise"));
495
                insertValues(v, table);
496
            } catch (SQLException ex) {
497
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_MOTIF_RECOURS", ex);
498
            }
499
        }
500
 
501
        if (!root.contains("CONTRAT_DETACHE_EXPATRIE")) {
502
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DETACHE_EXPATRIE");
503
            createTableMotif.addVarCharColumn("CODE", 25);
504
            createTableMotif.addVarCharColumn("NOM", 512);
505
 
506
            try {
507
                root.getBase().getDataSource().execute(createTableMotif.asString());
508
                insertUndef(createTableMotif);
509
                root.refetchTable("CONTRAT_DETACHE_EXPATRIE");
510
                root.getSchema().updateVersion();
511
 
512
                final SQLTable table = root.getTable("CONTRAT_DETACHE_EXPATRIE");
513
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
514
                v.add(Tuple2.create("01", "Détaché"));
515
                v.add(Tuple2.create("02", "Expatrié"));
516
                v.add(Tuple2.create("03", "Frontalier"));
517
                v.add(Tuple2.create("99", "Salarié non concerné"));
518
                insertValues(v, table);
519
            } catch (SQLException ex) {
520
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DETACHE_EXPATRIE", ex);
521
            }
522
        }
523
 
524
        if (!root.contains("DSN_NATURE")) {
525
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_NATURE");
526
            createTableMotif.addVarCharColumn("CODE", 25);
527
            createTableMotif.addVarCharColumn("NOM", 512);
528
 
529
            try {
530
                root.getBase().getDataSource().execute(createTableMotif.asString());
531
                insertUndef(createTableMotif);
532
                root.refetchTable("DSN_NATURE");
533
                root.getSchema().updateVersion();
534
 
535
                final SQLTable table = root.getTable("DSN_NATURE");
536
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
537
                v.add(Tuple2.create("01", "DSN Mensuelle"));
538
                v.add(Tuple2.create("02", "Signalement Fin du contrat de travail"));
539
                v.add(Tuple2.create("04", "Signalement Arrêt de travail"));
540
                v.add(Tuple2.create("05", "Signalement Reprise suite à arrêt de travail"));
541
                v.add(Tuple2.create("06", "DSN reprise d'historique"));
185 ilm 542
                v.add(Tuple2.create("07", "Signalement Fin du contrat de travail unique"));
132 ilm 543
                insertValues(v, table);
544
            } catch (SQLException ex) {
545
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_NATURE", ex);
546
            }
185 ilm 547
        } else {
548
            final SQLTable table = root.getTable("DSN_NATURE");
549
            List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
550
            // DSN 2023
551
            v.add(Tuple2.create("07", "Signalement Fin du contrat de travail unique"));
552
            insertValues(v, table);
132 ilm 553
        }
554
 
555
        if (!root.contains("DSN_TYPE")) {
556
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "DSN_TYPE");
557
            createTableMotif.addVarCharColumn("CODE", 25);
558
            createTableMotif.addVarCharColumn("NOM", 512);
559
 
560
            try {
561
                root.getBase().getDataSource().execute(createTableMotif.asString());
562
                insertUndef(createTableMotif);
563
                root.refetchTable("DSN_TYPE");
564
                root.getSchema().updateVersion();
565
 
566
                final SQLTable table = root.getTable("DSN_TYPE");
567
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
568
                v.add(Tuple2.create("01", "déclaration normale"));
569
                v.add(Tuple2.create("02", "déclaration normale néant"));
570
                v.add(Tuple2.create("03", "déclaration annule et remplace intégral"));
571
                v.add(Tuple2.create("04", "déclaration annule"));
572
                v.add(Tuple2.create("05", "annule et remplace néant"));
573
                insertValues(v, table);
574
            } catch (SQLException ex) {
575
                throw new IllegalStateException("Erreur lors de la création de la table " + "DSN_TYPE", ex);
576
            }
577
        }
578
 
579
        if (!root.contains("CONTRAT_DISPOSITIF_POLITIQUE")) {
580
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CONTRAT_DISPOSITIF_POLITIQUE");
581
            createTableMotif.addVarCharColumn("CODE", 25);
582
            createTableMotif.addVarCharColumn("NOM", 512);
583
 
584
            try {
585
                root.getBase().getDataSource().execute(createTableMotif.asString());
586
                insertUndef(createTableMotif);
587
                root.refetchTable("CONTRAT_DISPOSITIF_POLITIQUE");
588
                root.getSchema().updateVersion();
589
 
590
                final SQLTable table = root.getTable("CONTRAT_DISPOSITIF_POLITIQUE");
591
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
592
                v.add(Tuple2.create("21", "CUI - Contrat Initiative Emploi"));
593
                v.add(Tuple2.create("41", "CUI - Contrat d'Accompagnement dans l'Emploi"));
594
                v.add(Tuple2.create("42", "CUI - Contrat d'accès à l'emploi - DOM"));
595
                v.add(Tuple2.create("50", "Emploi d'avenir secteur marchand"));
596
                v.add(Tuple2.create("51", "Emploi d'avenir secteur non marchand"));
597
                v.add(Tuple2.create("61", "Contrat de Professionnalisation"));
598
                v.add(Tuple2.create("64", "Contrat d'apprentissage entreprises artisanales ou de moins de 11 salariés (loi du 3 janvier 1979)"));
599
                v.add(Tuple2.create("65", "Contrat d’apprentissage entreprises non inscrites au répertoire des métiers d’au moins 11 salariés (loi de 1987)"));
600
                v.add(Tuple2.create("70", "Contrat à durée déterminée pour les séniors"));
601
                v.add(Tuple2.create("71", "Contrat à durée déterminée d’insertion"));
602
                v.add(Tuple2.create("80", "Contrat de génération"));
603
                v.add(Tuple2.create("81", "Contrat d'apprentissage secteur public (Loi de 1992)"));
604
                v.add(Tuple2.create("82", "Contrat à durée indéterminée intérimaire"));
605
                v.add(Tuple2.create("99", "Non concerné"));
606
                insertValues(v, table);
607
            } catch (SQLException ex) {
608
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_DISPOSITIF_POLITIQUE", ex);
609
            }
610
        }
611
 
177 ilm 612
        if (!root.contains("CODE_AMENAGEMENT_PARTIEL")) {
613
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_AMENAGEMENT_PARTIEL");
614
            createTableMotif.addVarCharColumn("CODE", 25);
615
            createTableMotif.addVarCharColumn("NOM", 512);
616
 
617
            try {
618
                root.getBase().getDataSource().execute(createTableMotif.asString());
619
                insertUndef(createTableMotif);
620
                root.refetchTable("CODE_AMENAGEMENT_PARTIEL");
621
                root.getSchema().updateVersion();
622
 
623
                final SQLTable table = root.getTable("CODE_AMENAGEMENT_PARTIEL");
624
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
625
 
626
                v.add(Tuple2.create("01", "Forfait hebdomadaire"));
627
                v.add(Tuple2.create("02", "Autre temps de travail hebdomadaire"));
628
                v.add(Tuple2.create("03", "Equivalent à 35h - 39h (Mayotte)"));
629
                v.add(Tuple2.create("04", "Forfait mensuel"));
630
                v.add(Tuple2.create("05", "Forfait annuel en jour"));
631
                v.add(Tuple2.create("06", "Forfait annuel en heures"));
632
                v.add(Tuple2.create("07", "Cycle"));
633
                v.add(Tuple2.create("08", "Modulation"));
634
                v.add(Tuple2.create("09", "Aménagement du temps de travail (Loi du 20 août 2008)"));
635
                v.add(Tuple2.create("10", "Personnel navigant ou autres"));
636
 
637
                insertValues(v, table);
638
            } catch (SQLException ex) {
639
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_AMENAGEMENT_PARTIEL", ex);
640
            }
641
        }
642
 
643
        if (!root.contains("CODE_SUSPENSION")) {
644
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "CODE_SUSPENSION");
645
            createTableMotif.addVarCharColumn("CODE", 25);
646
            createTableMotif.addVarCharColumn("NOM", 512);
647
 
648
            try {
649
                root.getBase().getDataSource().execute(createTableMotif.asString());
650
                insertUndef(createTableMotif);
651
                root.refetchTable("CODE_SUSPENSION");
652
                root.getSchema().updateVersion();
653
 
654
                final SQLTable table = root.getTable("CODE_SUSPENSION");
655
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
656
 
657
                v.add(Tuple2.create("112", "Invalidité catégorie 1"));
658
                v.add(Tuple2.create("114", "Invalidité catégorie 2"));
659
                v.add(Tuple2.create("116", "Invalidité catégorie 3"));
660
                v.add(Tuple2.create("200", "COP (Congés payés)"));
661
                v.add(Tuple2.create("301", "Congé de Formation Professionnelle"));
662
                v.add(Tuple2.create("501", "Congé divers non rémunéré"));
663
                v.add(Tuple2.create("507", "Chômage intempéries"));
664
                v.add(Tuple2.create("601", "Mobilité volontaire sécurisée"));
665
                v.add(Tuple2.create("602", "Chômage sans rupture de contrat"));
666
                v.add(Tuple2.create("603", "Détention provisoire"));
667
                v.add(Tuple2.create("604", "Journée de perception de l'allocation journalière de présence parentale"));
668
                v.add(Tuple2.create("605", "Congé statutaire"));
669
                v.add(Tuple2.create("606", "Détachement d'un salarié IEG en France"));
670
                v.add(Tuple2.create("607", "Congé de présence parentale"));
671
                v.add(Tuple2.create("608", "CASA"));
672
                v.add(Tuple2.create("609", "CIF (Congé Individuel de Formation)"));
673
                v.add(Tuple2.create("611", "Congé de bilan de compétences"));
674
                v.add(Tuple2.create("612", "Congé de candidat parlementaire ou élu à un mandat local"));
675
                v.add(Tuple2.create("615", "Congé de formation de cadres et d'animateurs pour la jeunesse"));
676
                v.add(Tuple2.create("617", "Congé de formation pour les salariés de moins de 25 ans"));
677
                v.add(Tuple2.create("618", "Congé de formation économique, sociale et syndicale"));
678
                v.add(Tuple2.create("620", "Congé de mobilité"));
679
                v.add(Tuple2.create("621", "Congé de participation aux instances d'emploi ou de formation professionnelle"));
680
                v.add(Tuple2.create("625", "Congé de reclassement"));
681
                v.add(Tuple2.create("626", "Congé de représentation"));
682
                v.add(Tuple2.create("627", "Congé de solidarité familiale"));
683
                v.add(Tuple2.create("628", "Congé de solidarité internationale"));
684
                v.add(Tuple2.create("630", "Congé d'enseignement ou de recherche"));
685
                v.add(Tuple2.create("631", "Congé mutualiste de formation"));
686
                v.add(Tuple2.create("632", "Congé parental d'éducation"));
687
                v.add(Tuple2.create("633", "Congé pour acquisition de la nationalité"));
688
                v.add(Tuple2.create("634", "Congé pour catastrophe naturelle"));
689
                v.add(Tuple2.create("635", "Congé pour création ou reprise d'entreprise"));
690
                v.add(Tuple2.create("636", "Congé pour enfant malade"));
691
                v.add(Tuple2.create("637", "Congé pour évènement familial"));
692
                v.add(Tuple2.create("638", "Congé pour validation des acquis de l'expérience"));
693
                v.add(Tuple2.create("639", "Congé sabbatique"));
694
                v.add(Tuple2.create("642", "Convention FNE d'aide au passage à temps partiel"));
695
                v.add(Tuple2.create("643", "Congé de conversion avec prise en charge par l'Etat"));
696
                v.add(Tuple2.create("644", "Congé de conversion sans prise en charge par l'Etat"));
697
                v.add(Tuple2.create("645", "Préretraite progressive"));
698
                v.add(Tuple2.create("646", "Préretraite d'entreprise sans rupture de contrat de travail"));
699
                v.add(Tuple2.create("647", "Réduction temps d'emploi"));
700
                v.add(Tuple2.create("648", "Conventions d'Allocations Spéciales du FNE (ASFNE)"));
701
                v.add(Tuple2.create("650", "Congé de proche aidant"));
702
                v.add(Tuple2.create("651", "Congé pour mandat parlementaire"));
703
                v.add(Tuple2.create("652", "Inaptitude temporaire liée à la grossesse"));
704
                v.add(Tuple2.create("653", "Maintien de salaire – personnel navigant de l’aéronautique civile"));
705
                v.add(Tuple2.create("654", "Inactivité temps alterné – personnel navigant de l’aéronautique civile"));
706
                v.add(Tuple2.create("655", "[FP] Détachement conduisant à pension (ECP)"));
707
                v.add(Tuple2.create("656", "[FP] Congé pour cessation anticipée d’activité du fait d’une maladie professionnelle provoquée par l’amiante"));
708
                v.add(Tuple2.create("657", "[FP] Absence concertée de travail"));
709
                v.add(Tuple2.create("658", "[FP] Congé spécial"));
710
                v.add(Tuple2.create("659", "[FP] Période d'instruction militaire ou réserve opérationnelle"));
711
                v.add(Tuple2.create("660", "[FP] Congé avec traitement période d'instruction militaire obligatoire"));
712
                v.add(Tuple2.create("661", "[FP] Congé organisations de jeunesse"));
713
                v.add(Tuple2.create("662", "[FP] Congé pour siéger auprès d’une association, d’une mutuelle, d’une instance de l’Etat ou d’une collectivité territoriale"));
714
                v.add(Tuple2.create("663", "[FP] Congé non rémunéré de 18 jours pour mandats municipaux ou départementaux ou régionaux"));
715
                v.add(Tuple2.create("664", "[FP] Congé avec traitement pour période d'activité dans la réserve de sécurité civile"));
716
                v.add(Tuple2.create("665", "[FP] Congé pour période d'activité dans la réserve sanitaire"));
717
                v.add(Tuple2.create("666", "[FP] Congé pour recherches ou conversions thématiques"));
718
                v.add(Tuple2.create("667", "[FP] Congé pour raisons opérationnelles et activités privées des sapeurs"));
719
                v.add(Tuple2.create("668", "[FP] Congé pour raisons opérationnelles cotisé des sapeurs"));
720
                v.add(Tuple2.create("669", "[FP] Congé pour difficultés opérationnelles des sapeurs"));
721
                v.add(Tuple2.create("670", "[FP] Congé pour période d'activité dans la réserve civile de la police"));
722
                v.add(Tuple2.create("671", "[FP] Exclusion temporaire de fonctions"));
723
                v.add(Tuple2.create("672", "[FP] Suspension"));
724
                v.add(Tuple2.create("673", "[FP] Absences irrégulières (service non fait)"));
725
                v.add(Tuple2.create("674", "[FP] Détachement ne conduisant pas à pension (ENCP)"));
726
                v.add(Tuple2.create("675", "[FP] Disponibilité"));
727
                v.add(Tuple2.create("676", "[FP] Disponibilité pour maladie"));
728
                v.add(Tuple2.create("677", "[FP] Disponibilité pour élever un enfant âgé de moins de 8 ans"));
729
                v.add(Tuple2.create("678", "[FP] Position hors cadres"));
730
                v.add(Tuple2.create("680", "Congé sans solde cotisés"));
731
                v.add(Tuple2.create("681", "Détachement hors IEG"));
732
                v.add(Tuple2.create("998", "Annulation"));
733
 
734
                insertValues(v, table);
735
            } catch (SQLException ex) {
736
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_SUSPENSION", ex);
737
            }
738
        }
739
 
132 ilm 740
        if (!root.contains("MOTIF_REPRISE_ARRET_TRAVAIL")) {
741
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_REPRISE_ARRET_TRAVAIL");
742
            createTableMotif.addVarCharColumn("CODE", 25);
743
            createTableMotif.addVarCharColumn("NOM", 512);
744
 
745
            try {
746
                root.getBase().getDataSource().execute(createTableMotif.asString());
747
                insertUndef(createTableMotif);
748
                root.refetchTable("MOTIF_REPRISE_ARRET_TRAVAIL");
749
                root.getSchema().updateVersion();
750
 
751
                final SQLTable table = root.getTable("MOTIF_REPRISE_ARRET_TRAVAIL");
752
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
753
                v.add(Tuple2.create("01", "reprise normale"));
754
                v.add(Tuple2.create("02", "reprise temps partiel thérapeutique"));
755
                v.add(Tuple2.create("03", "reprise temps partiel raison personnelle"));
756
                insertValues(v, table);
757
            } catch (SQLException ex) {
758
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_REPRISE_ARRET_TRAVAIL", ex);
759
            }
760
        }
761
 
762
        if (!root.contains("MOTIF_FIN_CONTRAT")) {
763
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "MOTIF_FIN_CONTRAT");
764
            createTableMotif.addVarCharColumn("CODE", 25);
765
            createTableMotif.addVarCharColumn("NOM", 512);
766
 
767
            try {
768
                root.getBase().getDataSource().execute(createTableMotif.asString());
769
                insertUndef(createTableMotif);
770
                root.refetchTable("MOTIF_FIN_CONTRAT");
771
                root.getSchema().updateVersion();
772
 
773
                final SQLTable table = root.getTable("MOTIF_FIN_CONTRAT");
774
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
775
                v.add(Tuple2.create("011", "licenciement suite à liquidation judiciaire ou à redressement judiciaire"));
776
                v.add(Tuple2.create("012", "licenciement suite à fermeture définitive de l'établissement"));
777
                v.add(Tuple2.create("014", "licenciement pour motif économique"));
778
                v.add(Tuple2.create("015", "licenciement pour fin de chantier"));
779
                v.add(Tuple2.create("020", "licenciement pour autre motif"));
780
                v.add(Tuple2.create("025", "autre fin de contrat pour motif économique"));
781
                v.add(Tuple2.create("026", "rupture pour motif économique dans le cadre d’un contrat de sécurisation professionnelle CSP"));
782
                v.add(Tuple2.create("031", "fin de contrat à durée déterminée ou fin d'accueil occasionnel"));
783
                v.add(Tuple2.create("032", "fin de mission d'intérim"));
784
                v.add(Tuple2.create("033", "rupture anticipée d’un CDD ou d’un contrat de mission en cas d’inaptitude physique constatée par le médecin du travail"));
785
                v.add(Tuple2.create("034", "fin de période d'essai à l'initiative de l'employeur"));
786
                v.add(Tuple2.create("035", "fin de période d'essai à l'initiative du salarié"));
787
                v.add(Tuple2.create("036", " rupture anticipée d'un CDD, d'un contrat d'apprentissage ou d’un contrat de mission à l'initiative de l'employeur"));
788
                v.add(Tuple2.create("037", "rupture anticipée d'un CDD, d'un contrat d'apprentissage ou d’un contrat de mission à l'initiative du salarié"));
789
                v.add(Tuple2.create("038", "mise à la retraite par l'employeur"));
790
                v.add(Tuple2.create("039", "départ à la retraite à l'initiative du salarié"));
791
                v.add(Tuple2.create("043", "rupture conventionnelle"));
792
                v.add(Tuple2.create("058", "prise d'acte de la rupture de contrat de travail"));
793
                v.add(Tuple2.create("059", "démission"));
794
                v.add(Tuple2.create("065", "décès de l'employeur ou internement / conduit à un licenciement autre motif"));
795
                v.add(Tuple2.create("066", "décès du salarié / rupture force majeure"));
796
                v.add(Tuple2.create("081", "fin de contrat d'apprentissage"));
797
                v.add(Tuple2.create("082", "résiliation judiciaire du contrat de travail"));
798
                v.add(Tuple2.create("083", "rupture de contrat de travail ou d’un contrat de mission pour force majeure"));
799
                v.add(Tuple2.create("084", "rupture d'un commun accord du CDD, du contrat d'apprentissage ou d’un contrat de mission"));
800
                v.add(Tuple2.create("085", "fin de mandat"));
801
                v.add(Tuple2.create("086", "licenciement convention CATS"));
802
                v.add(Tuple2.create("087", "licenciement pour faute grave"));
803
                v.add(Tuple2.create("088", "licenciement pour faute lourde"));
804
                v.add(Tuple2.create("089", "licenciement pour force majeure"));
805
                v.add(Tuple2.create("091", "licenciement pour inaptitude physique d'origine non professionnelle"));
806
                v.add(Tuple2.create("092", "licenciement pour inaptitude physique d'origine professionnelle"));
807
                v.add(Tuple2.create("093", "licenciement suite à décision d'une autorité administrative"));
808
                v.add(Tuple2.create("094", "rupture anticipée du contrat de travail pour arrêt de tournage"));
809
                v.add(Tuple2.create("095", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute grave"));
810
                v.add(Tuple2.create("096", "rupture anticipée du contrat de travail ou d’un contrat de mission pour faute lourde"));
811
                v.add(Tuple2.create("097", "rupture anticipée d’un contrat de travail ou d’un contrat de mission suite à fermeture de l'établissement"));
812
                v.add(Tuple2.create("098", "retrait d'enfant"));
813
                v.add(Tuple2.create("998", "transfert du contrat de travail sans rupture du contrat vers un autre établissement n'effectuant pas encore de DSN"));
814
                v.add(Tuple2.create("999", "fin de relation avec l’employeur (autres que contrat de travail) pour les cas ne portant aucun impact sur l’Assurance chômage"));
815
                insertValues(v, table);
816
            } catch (SQLException ex) {
817
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_FIN_CONTRAT", ex);
818
            }
819
        }
820
 
821
        DSNUpdateRubrique dsnUpdateRubrique = new DSNUpdateRubrique(root);
822
        dsnUpdateRubrique.updateRubriqueCotisation();
142 ilm 823
 
824
        // PHASE 3
156 ilm 825
        final SQLTable caisseCot = root.getTable("CAISSE_COTISATION");
142 ilm 826
        {
827
            SQLTable tableCaisseCotisation = root.findTable("CAISSE_COTISATION");
828
            if (!tableCaisseCotisation.contains("ORG_PROTECTION_SOCIALE")) {
829
                final AlterTable alterCaisse = new AlterTable(tableCaisseCotisation);
830
                alterCaisse.addBooleanColumn("ORG_PROTECTION_SOCIALE", Boolean.FALSE, false);
831
                alterCaisse.addBooleanColumn("URSSAF", Boolean.FALSE, false);
832
 
833
                root.getBase().getDataSource().execute(alterCaisse.asString());
834
                root.refetchTable("CAISSE_COTISATION");
835
                root.getSchema().updateVersion();
836
 
837
                {
838
                    UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
839
                    upCaisse.setObject("ORG_PROTECTION_SOCIALE", Boolean.TRUE);
840
                    upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF", "AGIRC", "ARRCO")));
841
                    root.getBase().getDataSource().execute(upCaisse.asString());
842
                }
843
                {
844
                    UpdateBuilder upCaisse = new UpdateBuilder(tableCaisseCotisation);
845
                    upCaisse.setObject("URSSAF", Boolean.TRUE);
846
                    upCaisse.setWhere(new Where(tableCaisseCotisation.getField("NOM"), Arrays.asList("URSSAF")));
847
                    root.getBase().getDataSource().execute(upCaisse.asString());
848
                }
849
            }
850
            if (!root.contains("CAISSE_MODE_PAIEMENT")) {
851
                final SQLCreateTable createCaisseMode = new SQLCreateTable(root, "CAISSE_MODE_PAIEMENT");
852
                createCaisseMode.addVarCharColumn("CODE", 25);
853
                createCaisseMode.addVarCharColumn("NOM", 512);
854
 
855
                try {
856
                    root.getBase().getDataSource().execute(createCaisseMode.asString());
857
                    insertUndef(createCaisseMode);
858
                    root.refetchTable("CAISSE_MODE_PAIEMENT");
859
                    root.getSchema().updateVersion();
860
 
861
                    final SQLTable table = root.getTable("CAISSE_MODE_PAIEMENT");
862
                    List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
863
                    v.add(Tuple2.create("01", "chèque"));
864
                    v.add(Tuple2.create("02", "virement"));
865
                    v.add(Tuple2.create("03", "prélèvement"));
866
                    v.add(Tuple2.create("04", "titre inter-bancaire de paiement"));
867
                    v.add(Tuple2.create("05", "prélèvement SEPA"));
868
                    v.add(Tuple2.create("06", "versement réalisé par un autre établissement"));
869
 
870
                    insertValues(v, table);
871
                } catch (SQLException ex) {
872
                    throw new IllegalStateException("Erreur lors de la création de la table " + "CAISSE_MODE_PAIEMENT", ex);
873
                }
874
 
875
                final SQLCreateTable createCaisseREnseignement = new SQLCreateTable(root, "CAISSE_COTISATION_RENSEIGNEMENT");
876
                createCaisseREnseignement.addVarCharColumn("IDENTIFIANT", 256);
877
                createCaisseREnseignement.addVarCharColumn("SIRET", 256);
878
                createCaisseREnseignement.addVarCharColumn("BIC", 256);
879
                createCaisseREnseignement.addVarCharColumn("IBAN", 256);
880
                createCaisseREnseignement.addVarCharColumn("ENTITE_AFFECTATION", 256);
881
                createCaisseREnseignement.addBooleanColumn("ORGANISME_COMPLEMENTAIRE", Boolean.FALSE, false);
882
                createCaisseREnseignement.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
883
                createCaisseREnseignement.addVarCharColumn("CODE_DELEGATAIRE", 256);
884
                createCaisseREnseignement.addForeignColumn("ID_CAISSE_MODE_PAIEMENT", root.getTable("CAISSE_MODE_PAIEMENT"));
156 ilm 885
                createCaisseREnseignement.addForeignColumn("ID_CAISSE_COTISATION", caisseCot);
142 ilm 886
                createCaisseREnseignement.addForeignColumn("ID_SOCIETE_COMMON", root.getTable("SOCIETE_COMMON"));
887
                root.getBase().getDataSource().execute(createCaisseREnseignement.asString());
888
                insertUndef(createCaisseREnseignement);
889
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
890
                root.getSchema().updateVersion();
891
            }
892
            SQLTable tableCR = root.getTable("CAISSE_COTISATION_RENSEIGNEMENT");
893
            if (!tableCR.contains("PAIEMENT_TRIMESTRIEL")) {
894
                AlterTable alter = new AlterTable(tableCR);
895
                alter.addBooleanColumn("PAIEMENT_TRIMESTRIEL", Boolean.FALSE, false);
896
                root.getBase().getDataSource().execute(alter.asString());
897
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
898
                root.getSchema().updateVersion();
899
            }
144 ilm 900
 
901
            if (!tableCR.contains("JOUR_PAIEMENT")) {
902
                AlterTable alter = new AlterTable(tableCR);
903
                alter.addIntegerColumn("JOUR_PAIEMENT", 0);
904
                root.getBase().getDataSource().execute(alter.asString());
905
                root.refetchTable("CAISSE_COTISATION_RENSEIGNEMENT");
906
                root.getSchema().updateVersion();
907
            }
142 ilm 908
        }
909
 
910
        if (!root.contains("TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
911
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "TYPE_COMPOSANT_BASE_ASSUJETTIE");
912
            createTableTypeComposant.addVarCharColumn("CODE", 25);
913
            createTableTypeComposant.addVarCharColumn("NOM", 512);
914
 
915
            try {
916
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
917
                insertUndef(createTableTypeComposant);
918
                root.refetchTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
919
                root.getSchema().updateVersion();
920
 
921
                final SQLTable table = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
922
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
923
 
924
                v.add(Tuple2.create("01", "Montant du SMIC retenu pour le calcul de la Réduction générale des cotisations patronales de sécurité sociale"));
925
                v.add(Tuple2.create("02", "Montant du SMIC retenu pour le calcul du crédit d'impôt compétitivité-emploi"));
926
                v.add(Tuple2.create("03", "Contributions patronales à des régimes complémentaires de retraite"));
927
                v.add(Tuple2.create("04", "Contributions patronales destinées au financement des prestations de prévoyance complémentaire"));
928
                v.add(Tuple2.create("05", "Contributions patronales destinées au financement des prestations de retraite supplémentaire"));
929
                v.add(Tuple2.create("06", "Plafond calculé pour salarié poly-employeurs"));
930
                v.add(Tuple2.create("10", "Salaire brut Prévoyance"));
931
                v.add(Tuple2.create("11", "Tranche A Prévoyance"));
932
                v.add(Tuple2.create("12", "Tranche 2 Prévoyance"));
933
                v.add(Tuple2.create("13", "Tranche B Prévoyance"));
934
                v.add(Tuple2.create("14", "Tranche C Prévoyance"));
935
                v.add(Tuple2.create("15", "Tranche D Prévoyance"));
936
                v.add(Tuple2.create("16", "Tranche D1 Prévoyance"));
937
                v.add(Tuple2.create("17", "Base spécifique Prévoyance"));
938
                v.add(Tuple2.create("18", "Base forfaitaire Prévoyance"));
939
                v.add(Tuple2.create("19", "Base fictive Prévoyance reconstituée"));
940
                v.add(Tuple2.create("20", "Montant forfaitaire Prévoyance"));
941
                v.add(Tuple2.create("21", "Montant Prévoyance libre ou exceptionnel"));
942
                v.add(Tuple2.create("22", "Montant des indemnités journalières CRPCEN"));
943
                v.add(Tuple2.create("90", "Retenue sur salaire"));
944
                v.add(Tuple2.create("91", "Base de taxe sur les salaires au taux normal"));
945
 
946
                insertValues(v, table);
947
 
948
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
949
                tableRubCotis.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
950
                root.getBase().getDataSource().execute(tableRubCotis.asString());
951
                root.refetchTable(tableRubCot.getName());
952
                root.getSchema().updateVersion();
953
            } catch (SQLException ex) {
954
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_COMPOSANT_BASE_ASSUJETTIE", ex);
955
            }
956
        }
957
        if (!root.contains("CODE_COTISATION_INDIVIDUELLE")) {
958
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_INDIVIDUELLE");
959
            createTableTypeComposant.addVarCharColumn("CODE", 25);
960
            createTableTypeComposant.addVarCharColumn("NOM", 512);
961
 
962
            try {
963
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
964
                insertUndef(createTableTypeComposant);
965
                root.refetchTable("CODE_COTISATION_INDIVIDUELLE");
966
                root.getSchema().updateVersion();
967
 
968
                final SQLTable table = root.getTable("CODE_COTISATION_INDIVIDUELLE");
969
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
970
 
971
                v.add(Tuple2.create("001", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1979)"));
972
                v.add(Tuple2.create("002", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1987)"));
973
                v.add(Tuple2.create("003", "Exonération de cotisations au titre de l'emploi d'un apprenti (loi de 1992)"));
974
                v.add(Tuple2.create("004", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accès à l'emploi"));
975
                v.add(Tuple2.create("006", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat d'accompagnement dans l'emploi"));
976
                v.add(Tuple2.create("008", "Exonération de cotisations au titre de l'emploi d'un salarié en contrat de professionnalisation"));
977
                v.add(Tuple2.create("009", "Exonération de cotisations applicable aux associations intermédiaires"));
978
                v.add(Tuple2.create("010", "Exonération de cotisations applicable aux entreprises des bassins d'emploi à redynamiser"));
979
                v.add(Tuple2.create("011", "Exonération de cotisations applicable au créateur ou repreneur d'entreprise"));
980
                v.add(Tuple2.create("012", "Exonération de cotisations applicable dans les DOM"));
981
                v.add(Tuple2.create("013", "Exonération de cotisations applicable aux entreprises et associations d'aide à domicile"));
982
                v.add(Tuple2.create("014", "Exonérations de cotisations applicable aux entreprises innovantes ou universitaires"));
983
                v.add(Tuple2.create("015", "Exonération de cotisations applicable aux entreprises en zones franches urbaines"));
984
                v.add(Tuple2.create("016", "Exonération de cotisations applicable aux organismes d'intérêt général en zones de revitalisation rurale"));
985
                v.add(Tuple2.create("017", "Exonération de cotisations applicable aux structures agréées de l'aide sociale"));
986
                v.add(Tuple2.create("018", "Réduction générale des cotisations patronales de sécurité sociale"));
987
                v.add(Tuple2.create("019", "Réduction de cotisations applicable aux entreprises des zones de restructuration de la défense"));
988
                v.add(Tuple2.create("020", "Réduction de cotisations au titre de l'embauche du 1er au 50ème salarié en zones de revitalisation rurale"));
989
                v.add(Tuple2.create("021", "Déduction patronale au titre des heures supplémentaires"));
990
                v.add(Tuple2.create("022", "Exonération de cotisations applicable à une gratification de stage"));
991
                v.add(Tuple2.create("023", "Exonération de cotisation des sommes provenant d'un CET et réaffectées à un PERCO ou à un régime de retraite supplémentaire"));
992
                v.add(Tuple2.create("025", "Exonération de cotisations au titre de l’emploi d’un salarié en chantier et atelier d'insertion"));
993
                v.add(Tuple2.create("027", "Exonération Personnel technique CUMA, hors ateliers"));
994
                v.add(Tuple2.create("028", "Réduction Travailleur Occasionnel"));
995
                v.add(Tuple2.create("029", "CNIEG Réduction employeurs petit pool"));
996
                v.add(Tuple2.create("030", "Camieg Cotisation employeurs Régime spécial Complémentaire"));
997
                v.add(Tuple2.create("031", "Camieg Cotisation salariés Régime spécial Complémentaire"));
998
                v.add(Tuple2.create("032", "Camieg Cotisation salariés Régime spécial Solidarité"));
999
                v.add(Tuple2.create("033", "CNIEG Cotisation employeurs complément d'invalidité"));
1000
                v.add(Tuple2.create("034", "CNIEG Cotisation employeurs régime de droit commun (population adossée)"));
1001
                v.add(Tuple2.create("035", "CNIEG Cotisation employeurs Régime spécial (population adossée)"));
1002
                v.add(Tuple2.create("036", "CNIEG Cotisation employeurs régime spécial (population non adossée)"));
1003
                v.add(Tuple2.create("037", "CNIEG Cotisation salariés régime de droit commun (population adossée)"));
1004
                v.add(Tuple2.create("038", "CNIEG Cotisation salariés régime spécial (population non adossée)"));
1005
                v.add(Tuple2.create("039", "CNIEG Cotisations employeurs petit pool"));
1006
                v.add(Tuple2.create("040", "Cotisation AC : assurance chômage sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la SS"));
1007
                v.add(Tuple2.create("041", "Cotisation AC majorée 1 : application d’une majoration AC + 0,5% sur les contrats d’usage inférieurs ou égaux à 3 mois"));
1008
                v.add(Tuple2.create("042", "Cotisation AC majorée 2 : application d’une majoration AC + 3% sur les contrats d’accroissement temporaire d’activité inférieurs ou égaux à 1 mois"));
1009
                v.add(Tuple2.create("043",
1010
                        "Cotisation AC majorée 3 : application d’une majoration AC + 1,5% sur les contrats d’accroissement temporaire d’activité supérieurs à 1 mois mais inférieurs ou égaux à 3 mois"));
1011
                v.add(Tuple2.create("044", "Exonération de cotisation chômage pour les moins de 26 ans"));
1012
                v.add(Tuple2.create("045", "Cotisation Accident du travail"));
1013
                v.add(Tuple2.create("046", "Cotisation AEF Bourse de l'emploi"));
1014
                v.add(Tuple2.create("047", "Cotisation AEF CESA"));
1015
                v.add(Tuple2.create("048", "Cotisation AGS : assurance garantie des salaires sur rémunérations brutes après déduction, limitées à 4 fois le plafond de la sécurité sociale"));
1016
                v.add(Tuple2.create("049", "Cotisation Allocation de logement (FNAL)"));
1017
                v.add(Tuple2.create("051", "Cotisation Formation professionnelle ADEFA"));
1018
                v.add(Tuple2.create("052", "Cotisation AFNCA, ANEFA, PROVEA, ASCPA"));
1019
                v.add(Tuple2.create("053", "Cotisation Formation professionnelle additionnelle FAFSEA"));
1020
                v.add(Tuple2.create("054", "Cotisation Formation professionnelle AREFA"));
1021
                v.add(Tuple2.create("055", "Cotisation Formation professionnelle CEREFAR"));
1022
                v.add(Tuple2.create("056", "Cotisation Formation professionnelle FAFSEA"));
1023
                v.add(Tuple2.create("057", "Cotisation Formation professionnelle FAFSEA CDD"));
1024
                v.add(Tuple2.create("058", "Cotisation Formation professionnelle FAFSEA des communes forestières"));
1025
                v.add(Tuple2.create("059", "Cotisation individuelle Prévoyance-Assurance-Mutuelle pour la période et l'affiliation concernées"));
1026
                v.add(Tuple2.create("060", "Cotisation IRCANTEC Tranche A"));
1027
                v.add(Tuple2.create("061", "Cotisation IRCANTEC Tranche B"));
1028
                v.add(Tuple2.create("063", "RETA Montant de cotisation Arrco"));
1029
                v.add(Tuple2.create("064", "RETC Montant de cotisation Agirc"));
1030
                v.add(Tuple2.create("065", "Cotisation CRPCEN"));
1031
                v.add(Tuple2.create("066", "Cotisation caisse de congés spectacles"));
1032
                v.add(Tuple2.create("068", "Contribution solidarité autonomie"));
1033
                v.add(Tuple2.create("069", "Contribution sur avantage de pré-retraite entreprise à dater du 11/10/2007 (CAPE)"));
1034
                v.add(Tuple2.create("070", "Contribution sur avantage de pré-retraite entreprise aux taux normal (CAPE)"));
1035
                v.add(Tuple2.create("071", "Contribution forfait social"));
1036
                v.add(Tuple2.create("072", "Contribution sociale généralisée/salaires partiellement déductibles"));
1037
                v.add(Tuple2.create("073", "CSG/CRDS sur participation intéressement épargne salariale"));
1038
                v.add(Tuple2.create("074", "Cotisation Allocation familiale taux normal  "));
1039
                v.add(Tuple2.create("075", "Cotisation Assurance Maladie"));
1040
                v.add(Tuple2.create("076", "Cotisation Assurance Vieillesse"));
1041
                v.add(Tuple2.create("077", "Montant de la retenue à la source effectuée sur les salaires versés aux personnes domiciliées hors de France"));
1042
                v.add(Tuple2.create("078", "Pénalité de 1% emploi sénior"));
1043
                v.add(Tuple2.create("079", "Remboursement de la dette sociale"));
1044
                v.add(Tuple2.create("081", "Versement transport"));
1045
                v.add(Tuple2.create("082", "Versement transport additionnel"));
1046
                v.add(Tuple2.create("086", "Cotisation pénibilité mono exposition"));
1047
                v.add(Tuple2.create("087", "Cotisation pénibilité multi exposition"));
1048
                v.add(Tuple2.create("088", "Exonération versement transport"));
1049
                v.add(Tuple2.create("089", "Exonération Contrat Initiative Emploi"));
1050
                v.add(Tuple2.create("090", "Exonération accueillants familiaux"));
1051
                v.add(Tuple2.create("091", "Cotisation Service de santé au travail"));
1052
                v.add(Tuple2.create("092", "Cotisation Association pour l'emploi des cadres ingénieurs et techniciens de l'agriculture (APECITA)"));
1053
                v.add(Tuple2.create("093", "Contribution sur indemnités de mise à la retraite"));
1054
                v.add(Tuple2.create("094", "Exonération cotisations Allocations familiales (SICAE)"));
1055
                v.add(Tuple2.create("096", "Cotisation CRPNPAC au fonds de retraite"));
1056
                v.add(Tuple2.create("097", "Cotisation CRPNPAC au fonds d'assurance"));
1057
                v.add(Tuple2.create("098", "Cotisation CRPNPAC au fonds de majoration"));
1058
                v.add(Tuple2.create("099", "Contribution stock options"));
1059
                v.add(Tuple2.create("100", "Contribution pour le financement des organisations syndicales de salariés et organisations professionnelles d'employeurs"));
1060
                v.add(Tuple2.create("101", "Association Mutualisation du Coût Inaptitude"));
1061
                v.add(Tuple2.create("102", "Cotisation Allocation Familiale - taux réduit"));
1062
                v.add(Tuple2.create("103", "Contribution actions gratuites"));
1063
                v.add(Tuple2.create("226", "Assiette du Versement Transport"));
182 ilm 1064
 
142 ilm 1065
                v.add(Tuple2.create("901", "Cotisation épargne retraite"));
1066
 
1067
                insertValues(v, table);
1068
 
1069
                List<Tuple2<String, String>> vCodeBase = new ArrayList<Tuple2<String, String>>();
1070
                vCodeBase.add(Tuple2.create("15", "CNIEG-Assiette brute du régime spécial"));
1071
                vCodeBase.add(Tuple2.create("16", "CNIEG-Assiette brute du complément invalidité"));
1072
                vCodeBase.add(Tuple2.create("17", "CNIEG - Assiette brute du petit pool"));
1073
                vCodeBase.add(Tuple2.create("18", "Camieg - assiette brute plafonnée"));
1074
                vCodeBase.add(Tuple2.create("19", "Assiette CRPCEN"));
1075
                vCodeBase.add(Tuple2.create("20", "CIBTP - Base brute de cotisations congés payés"));
1076
                vCodeBase.add(Tuple2.create("21", "CIBTP - Base brute de cotisations OPPBTP permanents"));
1077
                vCodeBase.add(Tuple2.create("22", "Base brute spécifique"));
1078
                vCodeBase.add(Tuple2.create("23", "Base exceptionnelle (Agirc Arrco)"));
1079
                vCodeBase.add(Tuple2.create("24", "Base plafonnée spécifique"));
1080
                vCodeBase.add(Tuple2.create("25", "Assiette de contribution libératoire"));
1081
                vCodeBase.add(Tuple2.create("27", "Assiette Caisse de congés spectacles"));
1082
                vCodeBase.add(Tuple2.create("28", "Base IRCANTEC cotisée"));
1083
                vCodeBase.add(Tuple2.create("29", "Base IRCANTEC non cotisée (arrêt de travail)"));
1084
                vCodeBase.add(Tuple2.create("31", "Eléments de cotisation Prévoyance, Santé, retraite supplémentaire"));
1085
                vCodeBase.add(Tuple2.create("33", "Assiette Contribution sur les avantages de préretraite entreprise"));
1086
                vCodeBase.add(Tuple2.create("34", "CIBTP -Base plafonnée de cotisations intempéries gros oeuvre travaux publics"));
1087
                vCodeBase.add(Tuple2.create("35", "CIBTP -Base plafonnée de cotisations intempéries second oeuvre"));
1088
                vCodeBase.add(Tuple2.create("36", "CIBTP -Base \"A\" de cotisations organisme professionnel BTP"));
1089
                vCodeBase.add(Tuple2.create("37", "Assiette de pénibilité"));
1090
                vCodeBase.add(Tuple2.create("38", "Rémunération pour le calcul de la réduction Travailleur Occasionnel"));
1091
                vCodeBase.add(Tuple2.create("39", "CIBTP -Base \"B\" de cotisations organisme professionnel BTP"));
1092
                vCodeBase.add(Tuple2.create("40", "CIBTP -Base \"C\" de cotisations organisme professionnel BTP"));
1093
                vCodeBase.add(Tuple2.create("41", "CRPNPAC-Assiette soumise au taux normal (non-plafonnée)"));
1094
                vCodeBase.add(Tuple2.create("42", "CRPNPAC-Assiette soumise au taux majoré (non-plafonnée)"));
1095
                vCodeBase.add(Tuple2.create("43", "Base plafonnée exceptionnelle Agirc Arrco"));
1096
                vCodeBase.add(Tuple2.create("44", "Assiette du forfait social à 16%"));
1097
                vCodeBase.add(Tuple2.create("45", "Base plafonnée ICP Agirc-Arrco"));
1098
                vCodeBase.add(Tuple2.create("90", "Autre revenu net imposable"));
1099
                insertValues(vCodeBase, root.getTable("CODE_BASE_ASSUJETTIE"));
1100
 
1101
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
1102
                tableRubCotis.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
1103
                root.getBase().getDataSource().execute(tableRubCotis.asString());
1104
                root.refetchTable(tableRubCot.getName());
1105
                root.getSchema().updateVersion();
1106
            } catch (SQLException ex) {
1107
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_INDIVIDUELLE", ex);
1108
            }
1109
            {
1110
                final SQLTable tableCodeBase = root.getTable("CODE_BASE_ASSUJETTIE");
1111
                SQLSelect selCodeBase = new SQLSelect();
1112
                selCodeBase.addSelectStar(tableCodeBase);
1113
                List<SQLRow> rowsCodeBase = SQLRowListRSH.execute(selCodeBase);
1114
                Map<String, SQLRow> mapCodeBase = new HashMap<String, SQLRow>();
1115
                for (SQLRow sqlRow : rowsCodeBase) {
1116
 
1117
                    final String string = sqlRow.getString("CODE");
1118
                    mapCodeBase.put(string, sqlRow);
1119
                }
1120
                final SQLTable tableCodeTypeComp = root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE");
1121
                SQLSelect selCodeTypeComp = new SQLSelect();
1122
                selCodeTypeComp.addSelectStar(tableCodeTypeComp);
1123
                List<SQLRow> rowsTypeComp = SQLRowListRSH.execute(selCodeTypeComp);
1124
                Map<String, SQLRow> mapTypeComp = new HashMap<String, SQLRow>();
1125
                for (SQLRow sqlRow : rowsTypeComp) {
1126
                    final String string = sqlRow.getString("CODE");
1127
                    mapTypeComp.put(string, sqlRow);
1128
                }
1129
                final SQLTable tableCodeCotInd = root.getTable("CODE_COTISATION_INDIVIDUELLE");
1130
                SQLSelect selCodeCodeInd = new SQLSelect();
1131
                selCodeCodeInd.addSelectStar(tableCodeCotInd);
1132
                List<SQLRow> rowsCodeInd = SQLRowListRSH.execute(selCodeCodeInd);
1133
                Map<String, SQLRow> mapCodeInd = new HashMap<String, SQLRow>();
1134
                for (SQLRow sqlRow : rowsCodeInd) {
1135
                    final String string = sqlRow.getString("CODE");
1136
                    mapCodeInd.put(string, sqlRow);
1137
                }
156 ilm 1138
                final SQLTable tableCaisse = caisseCot;
142 ilm 1139
                SQLSelect selCodeCodeCaisse = new SQLSelect();
1140
                selCodeCodeCaisse.addSelectStar(tableCaisse);
1141
                List<SQLRow> rowsCodeCaisse = SQLRowListRSH.execute(selCodeCodeCaisse);
1142
                Map<String, SQLRow> mapCodeCaisse = new HashMap<String, SQLRow>();
1143
                for (SQLRow sqlRow : rowsCodeCaisse) {
1144
                    final String string = sqlRow.getString("NOM");
1145
                    mapCodeCaisse.put(string, sqlRow);
1146
                }
1147
                if (mapCodeCaisse.containsKey("ARRCO")) {
1148
                    UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
1149
                    updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("02").getID());
1150
                    updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("063").getID());
1151
                    // updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
1152
                    // mapTypeComp.get("03").getID());
1153
                    updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("ARRCO").getID()));
1154
                    root.getBase().getDataSource().execute(updaterRubCot.asString());
1155
                }
1156
                if (mapCodeCaisse.containsKey("AGIRC")) {
1157
                    UpdateBuilder updaterRubCot = new UpdateBuilder(tableRubCot);
1158
                    updaterRubCot.setObject("ID_CODE_BASE_ASSUJETTIE", mapCodeBase.get("03").getID());
1159
                    updaterRubCot.setObject("ID_CODE_COTISATION_INDIVIDUELLE", mapCodeInd.get("064").getID());
1160
                    // updaterRubCot.setObject("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE",
1161
                    // mapTypeComp.get("03").getID());
1162
                    updaterRubCot.setWhere(new Where(tableRubCot.getField("ID_CAISSE_COTISATION"), "=", mapCodeCaisse.get("AGIRC").getID()));
1163
                    root.getBase().getDataSource().execute(updaterRubCot.asString());
1164
                }
1165
            }
1166
        }
1167
 
1168
        if (!tableRubNet.contains("ID_CODE_COTISATION_INDIVIDUELLE")) {
1169
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1170
            alterRubNet.addForeignColumn("ID_CODE_COTISATION_INDIVIDUELLE", root.getTable("CODE_COTISATION_INDIVIDUELLE"));
1171
            root.getBase().getDataSource().execute(alterRubNet.asString());
1172
            root.refetchTable(tableRubNet.getName());
1173
            root.getSchema().updateVersion();
1174
        }
1175
        if (!tableRubNet.contains("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE")) {
1176
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1177
            alterRubNet.addForeignColumn("ID_TYPE_COMPOSANT_BASE_ASSUJETTIE", root.getTable("TYPE_COMPOSANT_BASE_ASSUJETTIE"));
1178
            root.getBase().getDataSource().execute(alterRubNet.asString());
1179
            root.refetchTable(tableRubNet.getName());
1180
            root.getSchema().updateVersion();
1181
        }
1182
        if (!tableRubNet.contains("ID_CODE_BASE_ASSUJETTIE")) {
1183
            AlterTable alterRubNet = new AlterTable(tableRubNet);
1184
            alterRubNet.addForeignColumn("ID_CODE_BASE_ASSUJETTIE", root.getTable("CODE_BASE_ASSUJETTIE"));
1185
            root.getBase().getDataSource().execute(alterRubNet.asString());
1186
            root.refetchTable(tableRubNet.getName());
1187
            root.getSchema().updateVersion();
1188
        }
1189
 
1190
        if (!tableRubNet.contains("ID_CAISSE_COTISATION")) {
1191
            AlterTable alterRubNet = new AlterTable(tableRubNet);
156 ilm 1192
            alterRubNet.addForeignColumn("ID_CAISSE_COTISATION", caisseCot);
142 ilm 1193
            root.getBase().getDataSource().execute(alterRubNet.asString());
1194
            root.refetchTable(tableRubNet.getName());
1195
            root.getSchema().updateVersion();
1196
        }
1197
 
1198
        if (!root.contains("CODE_COTISATION_ETABLISSEMENT")) {
1199
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_COTISATION_ETABLISSEMENT");
1200
            createTableTypeComposant.addVarCharColumn("CODE", 25);
1201
            createTableTypeComposant.addVarCharColumn("NOM", 512);
1202
 
1203
            try {
1204
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
1205
                insertUndef(createTableTypeComposant);
1206
                root.refetchTable("CODE_COTISATION_ETABLISSEMENT");
1207
                root.getSchema().updateVersion();
1208
 
1209
                final SQLTable table = root.getTable("CODE_COTISATION_ETABLISSEMENT");
1210
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1211
 
1212
                v.add(Tuple2.create("001", "Cotisation ADPFA (Association pour le Développement du Paritarisme des Fleuristes et Animaliers)"));
1213
                v.add(Tuple2.create("002", "Cotisation APNAB (Association Paritaire Nationale pour le développement de la négociation collective dans l'Artisanat du Bâtiment)"));
1214
                v.add(Tuple2.create("003 ", "Cotisation sur assiette avec congés payés CCCA-BTP (Comité de Concertation et de Coordination de l'apprentissage du Bâtiment et des Travaux Publics)"));
1215
                v.add(Tuple2.create("004 ", "Cotisation CPPNTT (Commission Paritaire Professionnelle Nationale du Travail Temporaire)"));
1216
                v.add(Tuple2.create("005 ", "Cotisation Développement du paritarisme"));
1217
                v.add(Tuple2.create("006 ", "Cotisation Dialogue social"));
1218
                v.add(Tuple2.create("007 ", "Cotisation FAF (Fonds d'Assurance formation)"));
1219
                v.add(Tuple2.create("009 ", "Cotisation FAPS (Fonds d'action professionnelle et sociale)"));
1220
                v.add(Tuple2.create("010 ", "Cotisation FASTT (Fonds d'Action Sociale du Travail Temporaire)"));
1221
                v.add(Tuple2.create("011 ", "Cotisation Fonds de péréquation"));
1222
                v.add(Tuple2.create("012 ", "Cotisation IFC (Indemnités de fin de carrière)"));
1223
                v.add(Tuple2.create("017 ", "Cotisation ORGA (Organisations Syndicales  du Travail Temporaire)"));
1224
                v.add(Tuple2.create("018 ", "Cotisation Promotion et recrutement"));
1225
                v.add(Tuple2.create("019 ", "Cotisations attachées à une population de non salariés ayants"));
1226
                v.add(Tuple2.create("020 ", "Cotisations attachées à une population de non salariés retraités"));
1227
                v.add(Tuple2.create("021 ", "Cotisations FMSE (Fond national agricole de mutualisation des risques sanitaires et environnementaux)"));
1228
                v.add(Tuple2.create("022 ", "Cotisations VAL'HOR (association française pour la valorisation des produits et métiers de l'horticulture et du paysage)"));
1229
                v.add(Tuple2.create("023 ", "Chiffre d'affaire"));
1230
                v.add(Tuple2.create("024 ", "Nombre d'heures d'intérim"));
1231
                v.add(Tuple2.create("025 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Rente"));
1232
                v.add(Tuple2.create("026 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Prime"));
1233
                v.add(Tuple2.create("027 ", "Contribution aux régimes supplémentaires de retraite à prestations définies - Dotations"));
1234
                v.add(Tuple2.create("028 ", "Contribution additionnelle sur les rentes liquidées"));
1235
                v.add(Tuple2.create("029 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 7%"));
1236
                v.add(Tuple2.create("030 ", "Contribution aux régimes supplémentaires de retraite à prestations définies. Rente à taux 14%"));
1237
                v.add(Tuple2.create("031 ", "Contribution additionnelle de solidarité pour l'autonomie"));
1238
                v.add(Tuple2.create("032 ", "Contribution Sociale généralisée au taux de 3,80% + RDS sur revenu de remplacement "));
1239
                v.add(Tuple2.create("033 ", "Contribution Sociale généralisée au taux de 6,20% + RDS sur revenu de remplacement "));
1240
                v.add(Tuple2.create("034 ", "Contribution Sociale généralisée au taux de 6,60% + RDS sur revenu de remplacement "));
1241
                v.add(Tuple2.create("035 ", "Contribution Sociale généralisée au taux de 7,50% + RDS sur revenu de remplacement "));
1242
                v.add(Tuple2.create("036 ", "Cotisation TTC sur assiette CDD avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1243
                v.add(Tuple2.create("037 ", "Cotisation TTC sur assiette avec congés payés pour le secteur du BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1244
                v.add(Tuple2.create("038 ", "Cotisation TTC  sur assiette sans  congés payés (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1245
                v.add(Tuple2.create("039 ",
1246
                        "Cotisation TTC  sur assiette avec congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1247
                v.add(Tuple2.create("040 ",
1248
                        "Cotisation TTC  sur assiette hors congés payés pour les salariés non soumis à la cotisation CCCA-BTP (Constructys Organisme Paritaire Collecteur Agréé pour le BTP)"));
1249
                v.add(Tuple2.create("041 ", "Cotisation maladie sur les avantages de préretraite"));
1250
                v.add(Tuple2.create("042 ", "Cotisation maladie sur les avantages de retraite"));
1251
                v.add(Tuple2.create("043 ", "Cotisation maladie Alsace-Moselle sur les avantages de retraite"));
1252
                v.add(Tuple2.create("044 ", "Cotisation forfait social à 8%"));
1253
                v.add(Tuple2.create("045 ", "Cotisation forfait social à 20%"));
1254
                v.add(Tuple2.create("090 ", "Cotisation spécifique Prévoyance"));
1255
 
1256
                insertValues(v, table);
1257
 
1258
                AlterTable tableRubCotis = new AlterTable(tableRubCot);
1259
                tableRubCotis.addForeignColumn("ID_CODE_COTISATION_ETABLISSEMENT", root.getTable("CODE_COTISATION_ETABLISSEMENT"));
1260
                root.getBase().getDataSource().execute(tableRubCotis.asString());
1261
                root.refetchTable(tableRubCot.getName());
1262
                root.getSchema().updateVersion();
1263
            } catch (SQLException ex) {
1264
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_COTISATION_ETABLISSEMENT", ex);
1265
            }
1266
        }
1267
 
1268
        if (!root.contains("CODE_PENIBILITE")) {
1269
            final SQLCreateTable createTableTypeComposant = new SQLCreateTable(root, "CODE_PENIBILITE");
1270
            createTableTypeComposant.addVarCharColumn("CODE", 25);
1271
            createTableTypeComposant.addVarCharColumn("NOM", 512);
1272
 
1273
            try {
1274
                root.getBase().getDataSource().execute(createTableTypeComposant.asString());
1275
                insertUndef(createTableTypeComposant);
1276
                root.refetchTable("CODE_PENIBILITE");
1277
                root.getSchema().updateVersion();
1278
 
1279
                final SQLTable table = root.getTable("CODE_PENIBILITE");
1280
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1281
 
1282
                v.add(Tuple2.create("01", "les manutentions manuelles de charges"));
1283
                v.add(Tuple2.create("02", "les postures pénibles (positions forcées des articulations)"));
1284
                v.add(Tuple2.create("03", "les vibrations mécaniques"));
1285
                v.add(Tuple2.create("04", "les agents chimiques dangereux"));
1286
                v.add(Tuple2.create("05", "les activités exercées en milieu hyperbare"));
1287
                v.add(Tuple2.create("06", "les températures extrêmes"));
1288
                v.add(Tuple2.create("07", "le bruit"));
1289
                v.add(Tuple2.create("08", "le travail de nuit"));
1290
                v.add(Tuple2.create("09", "le travail en équipes successives alternantes"));
1291
                v.add(Tuple2.create("10", "le travail répétitif (répétition d'un même geste, à une cadence contrainte avec un temps de cycle défini)"));
1292
                v.add(Tuple2.create("99", "annulation"));
1293
 
1294
                insertValues(v, table);
1295
 
1296
            } catch (SQLException ex) {
1297
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE", ex);
1298
            }
1299
        }
1300
 
1301
        if (!root.contains("AYANT_DROIT_TYPE")) {
1302
            final SQLCreateTable createTableTypeAyantDroit = new SQLCreateTable(root, "AYANT_DROIT_TYPE");
1303
            createTableTypeAyantDroit.addVarCharColumn("CODE", 25);
1304
            createTableTypeAyantDroit.addVarCharColumn("NOM", 512);
1305
 
1306
            try {
1307
                root.getBase().getDataSource().execute(createTableTypeAyantDroit.asString());
1308
                insertUndef(createTableTypeAyantDroit);
1309
                root.refetchTable("AYANT_DROIT_TYPE");
1310
                root.getSchema().updateVersion();
1311
 
1312
                final SQLTable table = root.getTable("AYANT_DROIT_TYPE");
1313
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1314
 
1315
                v.add(Tuple2.create("01", "Adultes (conjoint, concubin, pacs)"));
1316
                v.add(Tuple2.create("02", "Enfant"));
1317
                v.add(Tuple2.create("03", "Autre (ascendant, collatéraux, ...)"));
1318
 
1319
                insertValues(v, table);
1320
 
1321
            } catch (SQLException ex) {
1322
                throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT_TYPE", ex);
1323
            }
1324
        }
1325
 
156 ilm 1326
        if (!root.contains("TYPE_TAUX_PAS")) {
1327
            final SQLCreateTable createTableMotif = new SQLCreateTable(root, "TYPE_TAUX_PAS");
1328
            createTableMotif.addVarCharColumn("CODE", 25);
1329
            createTableMotif.addVarCharColumn("NOM", 512);
1330
 
1331
            try {
1332
                root.getBase().getDataSource().execute(createTableMotif.asString());
1333
                insertUndef(createTableMotif);
1334
                root.refetchTable("TYPE_TAUX_PAS");
1335
                root.getSchema().updateVersion();
1336
 
1337
                final SQLTable table = root.getTable("TYPE_TAUX_PAS");
1338
                List<Tuple2<String, String>> v = new ArrayList<Tuple2<String, String>>();
1339
                v.add(Tuple2.create("01", " Taux transmis par la DGFIP"));
1340
                v.add(Tuple2.create("10", " Barème horaire métropole"));
1341
                v.add(Tuple2.create("11", " Barème quotidien métropole"));
1342
                v.add(Tuple2.create("12", " Barème hebdomadaire métropole"));
1343
                v.add(Tuple2.create("13", " Barème mensuel métropole"));
1344
                v.add(Tuple2.create("14", " Barème trimestriel métropole"));
1345
                v.add(Tuple2.create("15", " Barème semestriel métropole"));
1346
                v.add(Tuple2.create("16", " Barème annuel métropole"));
1347
                v.add(Tuple2.create("17", " Barème mathématique sur base mensuelle métropole"));
1348
                v.add(Tuple2.create("18", " Barème mathématique sur base annuelle métropole"));
1349
                v.add(Tuple2.create("20", " Barème horaire Guadeloupe, Réunion et Martinique"));
1350
                v.add(Tuple2.create("21", " Barème quotidien Guadeloupe, Réunion et Martinique"));
1351
                v.add(Tuple2.create("22", " Barème hebdomadaire Guadeloupe, Réunion et Martinique"));
1352
                v.add(Tuple2.create("23", " Barème mensuel Guadeloupe, Réunion et Martinique"));
1353
                v.add(Tuple2.create("24", " Barème trimestriel Guadeloupe, Réunion et Martinique"));
1354
                v.add(Tuple2.create("25", " Barème semestriel Guadeloupe, Réunion et Martinique"));
1355
                v.add(Tuple2.create("26", " Barème annuel Guadeloupe, Réunion et Martinique"));
1356
                v.add(Tuple2.create("27", " Barème mathématique sur base mensuelle Guadeloupe, Réunion et Martinique"));
1357
                v.add(Tuple2.create("28", " Barème mathématique sur base annuelle Guadeloupe, Réunion et Martinique"));
1358
                v.add(Tuple2.create("30", " Barème horaire Guyane et Mayotte"));
1359
                v.add(Tuple2.create("31", " Barème quotidien Guyane et Mayotte"));
1360
                v.add(Tuple2.create("32", " Barème hebdomadaire Guyane et Mayotte"));
1361
                v.add(Tuple2.create("33", " Barème mensuel Guyane et Mayotte"));
1362
                v.add(Tuple2.create("34", " Barème trimestriel Guyane et Mayotte"));
1363
                v.add(Tuple2.create("35", " Barème semestriel Guyane et Mayotte"));
1364
                v.add(Tuple2.create("36", " Barème annuel Guyane et Mayotte"));
1365
                v.add(Tuple2.create("37", " Barème mathématique sur base mensuelle Guyane et Mayotte"));
1366
                v.add(Tuple2.create("38", " Barème mathématique sur base annuelle Guyane et Mayotte"));
1367
                v.add(Tuple2.create("99", " Indu relatif à un exercice antérieur – pas de taux de PAS"));
1368
 
1369
                insertValues(v, table);
1370
            } catch (SQLException ex) {
1371
                throw new IllegalStateException("Erreur lors de la création de la table " + "TYPE_TAUX_PAS", ex);
1372
            }
1373
        }
1374
 
1375
        // P19V01.2
1376
        final SQLTable tableCotInd = root.getTable("CODE_COTISATION_INDIVIDUELLE");
1377
        List<Tuple2<String, String>> vCodeIndiv = new ArrayList<>();
182 ilm 1378
        vCodeIndiv.add(Tuple2.create("104", " Pénibilité Cotisation de base"));
1379
        vCodeIndiv.add(Tuple2.create("105", " Montant de cotisation Régime Unifié Agirc Arrco, y compris Apec"));
1380
        vCodeIndiv.add(Tuple2.create("106", " Réduction générale des cotisations patronales de retraite complémentaire"));
1381
        vCodeIndiv.add(Tuple2.create("107", " Forfait marin"));
1382
        vCodeIndiv.add(Tuple2.create("108", " Demi rôle marin"));
1383
        vCodeIndiv.add(Tuple2.create("109", " Exonération de cotisations salariales de retraite complémentaire au titre de l'emploi d'un apprenti"));
1384
        vCodeIndiv.add(Tuple2.create("110", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 130% à 220%"));
1385
        vCodeIndiv.add(Tuple2.create("111", " Exonération de cotisations de retraite complémentaire applicable aux entreprises et associations d'aide à domicile"));
1386
        vCodeIndiv.add(Tuple2.create("112", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 170% à 270%"));
1387
        vCodeIndiv.add(Tuple2.create("113", " Exonération de cotisations patronales de retraite complémentaire applicable dans les DOM (LODEOM) SMIC 170% à 350%"));
1388
        vCodeIndiv.add(Tuple2.create("114", " Montant de réduction des heures supplémentaires/complémentaires"));
1389
        vCodeIndiv.add(Tuple2.create("115", " Cotisation Assurance Maladie pour le Régime Local Alsace Moselle"));
1390
        vCodeIndiv.add(Tuple2.create("116", " Cotisation absente de la norme en cas de régularisation prud'homale"));
1391
        vCodeIndiv.add(Tuple2.create("128", " Contribution à la formation professionnelle (CFP)"));
1392
        vCodeIndiv.add(Tuple2.create("129", " Contribution dédiée au financement du Compte Professionnel de Formation pour les titulaires de CDD (CPFCDD)"));
1393
        vCodeIndiv.add(Tuple2.create("130", " Part principale de la taxe d'apprentissage"));
1394
        vCodeIndiv.add(Tuple2.create("131", " Cotisation régime unifié Agirc Arrco"));
1395
        vCodeIndiv.add(Tuple2.create("132", " Cotisation Apec"));
1396
        vCodeIndiv.add(Tuple2.create("133", " Contribution maladie spécifique Mayotte"));
1397
        vCodeIndiv.add(Tuple2.create("902", " Contribution à la formation professionnelle des Artisans assimilés salariés"));
1398
        vCodeIndiv.add(Tuple2.create("903", " Cotisation AFNCA"));
1399
        vCodeIndiv.add(Tuple2.create("904", " Cotisation ANEFA"));
1400
        vCodeIndiv.add(Tuple2.create("905", " Cotisation ASCPA"));
1401
        vCodeIndiv.add(Tuple2.create("906", " Cotisation PROVEA"));
1402
        vCodeIndiv.add(Tuple2.create("907", " Complément de cotisation Assurance Maladie"));
1403
        vCodeIndiv.add(Tuple2.create("908", " Taxe forfaitaire CDDU Assurance Chômage"));
1404
        vCodeIndiv.add(Tuple2.create("909", " Cotisation au titre du financement des régimes de retraites supplémentaires à prestation définies"));
1405
        vCodeIndiv.add(Tuple2.create("910", " Exonération de cotisations patronales pour les entreprises affectées par la crise sanitaire"));
1406
        vCodeIndiv.add(Tuple2.create("911", " Réduction de cotisations patronales pour les entreprises du secteur de la vigne affectées par la crise sanitaire"));
1407
        vCodeIndiv.add(Tuple2.create("912", " Exonération du forfait social à 10%"));
1408
        vCodeIndiv.add(Tuple2.create("913", " Potentielle nouvelle cotisation C"));
1409
        vCodeIndiv.add(Tuple2.create("914", " Potentielle nouvelle cotisation A"));
1410
        vCodeIndiv.add(Tuple2.create("915", " Potentielle nouvelle cotisation B"));
1411
 
156 ilm 1412
        insertValues(vCodeIndiv, tableCotInd);
1413
 
1414
        final SQLTable tableCTP = root.getTable("CODE_CAISSE_TYPE_RUBRIQUE");
1415
        List<Tuple2<String, String>> vCTP = new ArrayList<>();
1416
        vCTP.add(Tuple2.create("003", "Réduction cotisations salariale heures supplémentaires"));
1417
        vCTP.add(Tuple2.create("510", "Prime exceptionnelle de pouvoir d’achat"));
177 ilm 1418
        vCTP.add(Tuple2.create("060", "RR Chômage CSG-CRDS taux plein"));
182 ilm 1419
        vCTP.add(Tuple2.create("917", "MOBILITE ADD JOURNALISTE TX MINO 20%"));
1420
        vCTP.add(Tuple2.create("920", "EMPL AGRIC (1500 TONNES CANNE) RMI OM"));
1421
        vCTP.add(Tuple2.create("921", "MOBILITE ARTISTES TX MINORE 30%"));
1422
        vCTP.add(Tuple2.create("922", "ENTR.DE PRODUCTION D ELECTRICITE"));
1423
        vCTP.add(Tuple2.create("922", "ENTR.DE PRODUCTION D ELECTRICITE"));
1424
        vCTP.add(Tuple2.create("926", "AT SEULEMENT - GESTION TOTALE"));
1425
        vCTP.add(Tuple2.create("927", "MOBILITE ADD ARTISTES TX MINO 30%"));
1426
        vCTP.add(Tuple2.create("936", "CNIEG PRESTATION COMPL. INVALIDITE"));
1427
        vCTP.add(Tuple2.create("937", "COTISATIONS AGS CAS GENERAL U2"));
1428
        vCTP.add(Tuple2.create("938", "CONTRATS AIDES ATELIER INSERTION"));
1429
        vCTP.add(Tuple2.create("939", "ATELIER INSERTION MAYOTTE"));
1430
        vCTP.add(Tuple2.create("939", "ATELIER INSERTION MAYOTTE"));
1431
        vCTP.add(Tuple2.create("940", "CNIEG DROITS SPE. PASSES NON REGULES"));
1432
        vCTP.add(Tuple2.create("948", "CONTRAT EMPLOI SOLIDARITE"));
1433
        vCTP.add(Tuple2.create("950", "CONTRAT EMPLOI SOLIDARITE CAS PART"));
1434
        vCTP.add(Tuple2.create("951", "CONTRATS EMPLOI SOLIDARITE CAS PART"));
1435
        vCTP.add(Tuple2.create("952", "CONTRAT EMPLOI CONSOLIDE CAS GENERAL"));
1436
        vCTP.add(Tuple2.create("954", "CONTRAT EMPLOI CONSOLIDE CAS PART"));
1437
        vCTP.add(Tuple2.create("955", "CNIEG PETIT POOL"));
1438
        vCTP.add(Tuple2.create("959", "CFP ENTREPRISE < 11 SALARIES"));
1439
        vCTP.add(Tuple2.create("967", "CONTR.ROYALTIES ART.ET MANNEQUINS"));
1440
        vCTP.add(Tuple2.create("969", "COT.MAL.ROYALTIES ART.ETRANGER"));
1441
        vCTP.add(Tuple2.create("971", "CFP ENTREPRISE >= 11 SALARIES"));
1442
        vCTP.add(Tuple2.create("983", "CFP INTERMITTENTS DU SPECTACLE"));
1443
        vCTP.add(Tuple2.create("985", "PENALITE PENIBILITE"));
1444
        vCTP.add(Tuple2.create("987", "CONTRIBUTION CPF CDD "));
1445
        vCTP.add(Tuple2.create("992", "TA PRINCIPALE HORS ALSACE MOSELLE"));
1446
        vCTP.add(Tuple2.create("993", "TA ALSACE MOSELLE"));
1447
        vCTP.add(Tuple2.create("994", "TA DEDUCTION CFA ET OFFRE NOUVELLE"));
1448
        vCTP.add(Tuple2.create("995", "TA - SOLDE VERSEMENT LIBERATOIRE"));
1449
        vCTP.add(Tuple2.create("995", "TA - SOLDE VERSEMENT LIBERATOIRE"));
1450
        vCTP.add(Tuple2.create("996", "TA - DEDUCTION AU SOLDE CFA"));
1451
        vCTP.add(Tuple2.create("997", "TA - DEDUCTION SOLDE CREANCE ALTERN"));
1452
        vCTP.add(Tuple2.create("998", "CSA CONTRIBUTION ANNUELLE"));
156 ilm 1453
        insertValues(vCTP, tableCTP);
1454
 
1455
        final SQLTable tableTypeBrut = root.getTable("CODE_TYPE_RUBRIQUE_BRUT");
1456
        List<Tuple3<String, String, String>> vbrutType = new ArrayList<>();
1457
        vbrutType.add(Tuple3.create("016", "[FP] Heures affectées à un travail d’aide à domicile", DsnTypeCodeBrut.REMUNERATION.getName()));
1458
        vbrutType.add(Tuple3.create("017", "Heures supplémentaires ou complémentaires aléatoires", DsnTypeCodeBrut.REMUNERATION.getName()));
1459
        vbrutType.add(Tuple3.create("018", "Heures supplémentaires structurelles", DsnTypeCodeBrut.REMUNERATION.getName()));
177 ilm 1460
        vbrutType.add(Tuple3.create("019", "Heures d'activité partielle", DsnTypeCodeBrut.REMUNERATION.getName()));
1461
        vbrutType.add(Tuple3.create("020", "Heures affectées à un travail d’aide à domicile de publics fragiles", DsnTypeCodeBrut.REMUNERATION.getName()));
182 ilm 1462
 
1463
        vbrutType.add(Tuple3.create("021", "[FP] Taux de rémunération de la situation administrative", DsnTypeCodeBrut.REMUNERATION.getName()));
1464
        vbrutType.add(Tuple3.create("022", "Potentiel nouveau type de rémunération B", DsnTypeCodeBrut.REMUNERATION.getName()));
1465
        vbrutType.add(Tuple3.create("023", "Potentiel nouveau type de rémunération C", DsnTypeCodeBrut.REMUNERATION.getName()));
1466
        vbrutType.add(Tuple3.create("025", "Heures correspondant à du chômage intempéries", DsnTypeCodeBrut.REMUNERATION.getName()));
1467
        vbrutType.add(Tuple3.create("026", "Heures supplémentaires exonérées", DsnTypeCodeBrut.REMUNERATION.getName()));
1468
        vbrutType.add(Tuple3.create("027", "Potentiel nouveau type de rémunération A", DsnTypeCodeBrut.REMUNERATION.getName()));
1469
 
156 ilm 1470
        DsnBrutCode dsnBurCode = new DsnBrutCode();
1471
        dsnBurCode.updateTable(vbrutType, tableTypeBrut);
1472
 
182 ilm 1473
        // P21
1474
        final SQLTable tableArret = root.getTable("MOTIF_ARRET_TRAVAIL");
1475
        List<Tuple2<String, String>> vArret = new ArrayList<Tuple2<String, String>>();
1476
        vArret.add(Tuple2.create("09", "adoption"));
1477
        vArret.add(Tuple2.create("15", "temps partiel thérapeutique (risque maladie)"));
1478
        vArret.add(Tuple2.create("16", "temps partiel thérapeutique (risque accident de travail)"));
1479
        vArret.add(Tuple2.create("17", "temps partiel thérapeutique (risque accident de trajet)"));
1480
        vArret.add(Tuple2.create("18", "temps partiel thérapeutique (risque maladie professionnelle)"));
1481
        insertValues(vArret, tableArret);
1482
 
1483
        if (!root.contains("CODE_CAISSE_CONGES_PAYES")) {
1484
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "CODE_CAISSE_CONGES_PAYES");
1485
            createTableCode.addVarCharColumn("CODE", 25);
1486
            createTableCode.addVarCharColumn("NOM", 512);
1487
 
1488
            try {
1489
                root.getBase().getDataSource().execute(createTableCode.asString());
1490
                insertUndef(createTableCode);
1491
                root.refetchTable("CODE_CAISSE_CONGES_PAYES");
1492
                root.getSchema().updateVersion();
1493
 
1494
            } catch (SQLException ex) {
1495
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_CAISSE_CONGES_PAYES", ex);
1496
            }
1497
        }
1498
 
1499
        if (!root.contains("MOTIF_NON_ASSUJETIS_TA")) {
1500
            final SQLCreateTable createTableCode = new SQLCreateTable(root, "MOTIF_NON_ASSUJETIS_TA");
1501
            createTableCode.addVarCharColumn("CODE", 25);
1502
            createTableCode.addVarCharColumn("NOM", 512);
1503
 
1504
            try {
1505
                root.getBase().getDataSource().execute(createTableCode.asString());
1506
                insertUndef(createTableCode);
1507
                root.refetchTable("MOTIF_NON_ASSUJETIS_TA");
1508
                root.getSchema().updateVersion();
1509
 
1510
                final SQLTable tableMotif = root.getTable("MOTIF_NON_ASSUJETIS_TA");
1511
                List<Tuple2<String, String>> vMotif = new ArrayList<Tuple2<String, String>>();
1512
                vMotif.add(Tuple2.create("001", "Non assujetti par choix du régime fiscal (option IR en catégorie BNC)"));
1513
                vMotif.add(Tuple2.create("002", "Collectivités publiques"));
1514
                vMotif.add(Tuple2.create("003", "Etablissements publics de recherche et les établissements publics d'enseignement supérieurs"));
1515
                vMotif.add(Tuple2.create("004", "Personnes morales créées pour la gestion d'un pôle de recherche et d'enseignement supérieur ou d'un réseau thématique de recherche avancée"));
1516
                vMotif.add(Tuple2.create("005", "Fondations reconnues d'utilité public du secteur de la recherche"));
1517
                vMotif.add(Tuple2.create("006", "Sociétés et personnes morales ayant pour objet exclusif l'enseignement"));
1518
                vMotif.add(Tuple2.create("007", "Associations sans but lucratif"));
1519
                vMotif.add(Tuple2.create("008", "Syndicats professionnels"));
1520
                vMotif.add(Tuple2.create("009", "Entreprises sans établissement en France (ESEF)"));
1521
                vMotif.add(Tuple2.create("010", "Sociétés civiles de moyens (SCM) non commerciale"));
1522
                vMotif.add(Tuple2.create("011", "Personnes physiques ou morales assujetties aux BNC ou BA"));
1523
                vMotif.add(Tuple2.create("012", "Les coopératives agricoles"));
1524
                vMotif.add(Tuple2.create("013", "Les coopératives artisanales, transport (y compris fluvial et maritime) et leurs unions"));
1525
                vMotif.add(Tuple2.create("014", "Les groupements d'employeurs dont agricoles"));
1526
                vMotif.add(Tuple2.create("015", "Les sociétés civiles agricoles"));
1527
                vMotif.add(Tuple2.create("016", "Les mutuelles et organismes mutualistes"));
1528
                vMotif.add(Tuple2.create("017",
1529
                        "Les organismes HLM, SA de crédit immobilier (I et au II de l'article L. 422-4 du code de la construction et de l'habitation ) et unions d'économie sociale"));
1530
                vMotif.add(Tuple2.create("018", "Les sociétés coopératives de construction désignées à l'article L. 432-2 du code de la construction et de l'habitation."));
1531
                vMotif.add(Tuple2.create("019", "Organismes chargés de l'organisation en France d'une compétition sportive internationale en France (Article L6131-1 du code du travail)"));
1532
 
1533
                insertValues(vMotif, tableMotif);
1534
            } catch (SQLException ex) {
1535
                throw new IllegalStateException("Erreur lors de la création de la table " + "MOTIF_NON_ASSUJETIS_TA", ex);
1536
            }
1537
        }
1538
        if (!societeCommonT.contains("ASSUJETTISSEMENT_TA")) {
1539
            AlterTable alterSoc = new AlterTable(societeCommonT);
1540
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_TA", Boolean.TRUE, false);
1541
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_CFP", Boolean.TRUE, false);
1542
            alterSoc.addBooleanColumn("ASSUJETTISSEMENT_CFP_CDD", Boolean.TRUE, false);
1543
            alterSoc.addForeignColumn("ID_MOTIF_NON_ASSUJETIS_TA", root.findTable("MOTIF_NON_ASSUJETIS_TA"));
1544
 
1545
            root.getBase().getDataSource().execute(alterSoc.asString());
1546
            root.getSchema().updateVersion();
1547
        }
132 ilm 1548
    }
1549
 
1550
    public void updateDSN(final DBRoot root) throws SQLException {
1551
        final SQLTable tableCodeStatutCat = root.getTable("CODE_STATUT_CATEGORIEL");
1552
        SQLRow rowNonCadre = tableCodeStatutCat.getRow(4);
1553
        if (rowNonCadre != null) {
1554
            rowNonCadre.createEmptyUpdateRow().put("CODE", "04").commit();
1555
        }
1556
        SQLRow rowSansStatut = tableCodeStatutCat.getRow(4);
1557
        if (rowSansStatut != null) {
1558
            rowSansStatut.createEmptyUpdateRow().put("CODE", "99").commit();
1559
        }
142 ilm 1560
        // 04 non cadre
1561
        UpdateBuilder up04 = new UpdateBuilder(tableCodeStatutCat);
1562
        up04.setObject("NOM", "Non cadre");
1563
        up04.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "04"));
1564
        root.getBase().getDataSource().execute(up04.asString());
132 ilm 1565
 
142 ilm 1566
        // 99 - pas de retraite complémentaire
1567
        UpdateBuilder up99 = new UpdateBuilder(tableCodeStatutCat);
1568
        up99.setObject("NOM", "Pas de retraite complémentaire");
1569
        up99.setWhere(new Where(tableCodeStatutCat.getField("CODE"), "=", "99"));
1570
        root.getBase().getDataSource().execute(up99.asString());
1571
 
132 ilm 1572
        if (!root.contains("ARRET_TRAVAIL")) {
1573
 
1574
            final SQLCreateTable createTable = new SQLCreateTable(root, "ARRET_TRAVAIL");
1575
            createTable.addForeignColumn("SALARIE");
1576
            createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
1577
            createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1578
            createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1579
            createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1580
            createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1581
            createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
1582
            createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1583
            createTable.addDateAndTimeColumn("DATE_REPRISE");
1584
            createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1585
 
1586
            try {
1587
                root.getBase().getDataSource().execute(createTable.asString());
1588
                insertUndef(createTable);
1589
                root.refetchTable("ARRET_TRAVAIL");
1590
                root.getSchema().updateVersion();
1591
            } catch (SQLException ex) {
1592
                throw new IllegalStateException("Erreur lors de la création de la table " + "ARRET_TRAVAIL", ex);
1593
            }
1594
        }
1595
 
142 ilm 1596
        if (!root.contains("FIN_CONTRAT")) {
1597
 
1598
            final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
1599
            createTable.addForeignColumn("FICHE_PAYE");
1600
            createTable.addForeignColumn("ID_MOTIF_FIN_CONTRAT", root.findTable("MOTIF_FIN_CONTRAT"));
1601
            createTable.addDateAndTimeColumn("DATE_FIN");
1602
            createTable.addDateAndTimeColumn("DATE_NOTIFICATION");
1603
            createTable.addDateAndTimeColumn("DATE_SIGNATURE_CONVENTION");
1604
            createTable.addDateAndTimeColumn("DATE_ENGAGEMENT_PROCEDURE");
1605
            createTable.addDateAndTimeColumn("DERNIER_JOUR_TRAV_PAYE");
1606
            createTable.addBooleanColumn("TRANSACTION_EN_COURS", Boolean.FALSE, false);
1607
            createTable.addBooleanColumn("PORTABILITE_PREVOYANCE", Boolean.FALSE, false);
1608
            createTable.addIntegerColumn("NB_DIF_RESTANT", null, true);
1609
            createTable.addIntegerColumn("NB_MOIS_CSP", null, true);
1610
            createTable.addDecimalColumn("SALAIRE_NET_HORAIRE", 16, 8, null, true);
1611
            createTable.addDecimalColumn("INDEMNITE_VERSE", 16, 8, null, true);
1612
            createTable.addForeignColumn("ID_TYPE_PREAVIS", root.findTable("TYPE_PREAVIS"));
1613
            createTable.addDateAndTimeColumn("DATE_DEBUT_PREAVIS");
1614
            createTable.addDateAndTimeColumn("DATE_FIN_PREAVIS");
1615
            createTable.addVarCharColumn("INFOS", 2048);
1616
 
1617
            try {
1618
                root.getBase().getDataSource().execute(createTable.asString());
1619
                insertUndef(createTable);
1620
                root.refetchTable("FIN_CONTRAT");
1621
                root.getSchema().updateVersion();
1622
            } catch (SQLException ex) {
1623
                throw new IllegalStateException("Erreur lors de la création de la table " + "FIN_CONTRAT", ex);
1624
            }
1625
        }
1626
 
132 ilm 1627
        if (!root.contains("REPRISE_TRAVAIL")) {
1628
 
1629
            final SQLCreateTable createTable = new SQLCreateTable(root, "REPRISE_TRAVAIL");
1630
            createTable.addForeignColumn("SALARIE");
1631
            createTable.addDateAndTimeColumn("DATE_DERNIER_JOUR_TRAV");
1632
            createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1633
            createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1634
            createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1635
            createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1636
            createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL", root.findTable("MOTIF_ARRET_TRAVAIL"));
1637
            createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL", root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1638
            createTable.addDateAndTimeColumn("DATE_REPRISE");
1639
            createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1640
            createTable.addDateAndTimeColumn("DATE");
1641
            createTable.addVarCharColumn("COMMENTAIRES", 2048);
1642
 
1643
            try {
1644
                root.getBase().getDataSource().execute(createTable.asString());
1645
                insertUndef(createTable);
1646
                root.refetchTable("REPRISE_TRAVAIL");
1647
                root.getSchema().updateVersion();
1648
            } catch (SQLException ex) {
1649
                throw new IllegalStateException("Erreur lors de la création de la table " + "REPRISE_TRAVAIL", ex);
1650
            }
1651
        }
1652
 
1653
        if (!root.contains("DECLARATION_DSN")) {
1654
 
1655
            final SQLCreateTable createTable = new SQLCreateTable(root, "DECLARATION_DSN");
1656
            createTable.addForeignColumn("ID_DSN_NATURE", root.findTable("DSN_NATURE"));
1657
 
1658
            createTable.addDateAndTimeColumn("DATE");
1659
            createTable.addDateAndTimeColumn("DATE_ENVOI");
1660
            createTable.addBooleanColumn("TEST", Boolean.FALSE, false);
1661
            createTable.addBooleanColumn("ENVOYE", Boolean.FALSE, false);
1662
            createTable.addVarCharColumn("COMMENTAIRE", 1024);
1663
            createTable.addVarCharColumn("DSN_FILE", 75000);
1664
            createTable.addIntegerColumn("NUMERO", 1);
1665
            createTable.addIntegerColumn("ANNEE", 2016);
1666
            createTable.addForeignColumn("MOIS");
1667
 
1668
            try {
1669
                root.getBase().getDataSource().execute(createTable.asString());
1670
                insertUndef(createTable);
1671
                root.refetchTable("DECLARATION_DSN");
1672
                root.getSchema().updateVersion();
1673
            } catch (SQLException ex) {
1674
                throw new IllegalStateException("Erreur lors de la création de la table " + "DECLARATION_DSN", ex);
1675
            }
1676
        }
1677
 
1678
        SQLTable tableArret = root.getTable("ARRET_TRAVAIL");
1679
        if (!tableArret.contains("DATE")) {
1680
            AlterTable alter = new AlterTable(tableArret);
1681
            alter.addDateAndTimeColumn("DATE");
1682
            alter.addVarCharColumn("COMMENTAIRES", 2048);
1683
            root.getBase().getDataSource().execute(alter.asString());
1684
            root.refetchTable("ARRET_TRAVAIL");
1685
            root.getSchema().updateVersion();
1686
        }
1687
 
1688
        SQLTable tableDsn = root.getTable("DECLARATION_DSN");
1689
        if (!tableDsn.contains("ID_ARRET_TRAVAIL")) {
1690
            AlterTable alter = new AlterTable(tableDsn);
1691
            alter.addForeignColumn("ID_ARRET_TRAVAIL", root.findTable("ARRET_TRAVAIL"));
1692
            root.getBase().getDataSource().execute(alter.asString());
1693
            root.getSchema().updateVersion();
1694
        }
142 ilm 1695
        if (!tableDsn.contains("ID_FIN_CONTRAT")) {
1696
            AlterTable alter = new AlterTable(tableDsn);
1697
            alter.addForeignColumn("ID_FIN_CONTRAT", root.findTable("FIN_CONTRAT"));
1698
            root.getBase().getDataSource().execute(alter.asString());
1699
            root.getSchema().updateVersion();
1700
        }
1701
 
132 ilm 1702
        if (!tableDsn.contains("ID_REPRISE_TRAVAIL")) {
1703
            AlterTable alter = new AlterTable(tableDsn);
1704
            alter.addForeignColumn("ID_REPRISE_TRAVAIL", root.findTable("REPRISE_TRAVAIL"));
1705
            root.getBase().getDataSource().execute(alter.asString());
1706
            root.getSchema().updateVersion();
1707
        }
1708
        if (!tableDsn.contains("ID_MOIS_REGUL")) {
1709
            AlterTable alter = new AlterTable(tableDsn);
1710
            alter.addForeignColumn("ID_MOIS_REGUL", root.findTable("MOIS"));
1711
            root.getBase().getDataSource().execute(alter.asString());
1712
            root.getSchema().updateVersion();
1713
        }
1714
 
1715
        if (!tableDsn.contains("ANNULE_REMPLACE")) {
1716
            AlterTable alter = new AlterTable(tableDsn);
1717
            alter.addBooleanColumn("ANNULE_REMPLACE", Boolean.FALSE, false);
1718
            root.getBase().getDataSource().execute(alter.asString());
1719
            root.getSchema().updateVersion();
1720
        }
142 ilm 1721
        if (!tableDsn.contains("NUMERO_REFERENCE")) {
1722
            AlterTable alter = new AlterTable(tableDsn);
1723
            alter.addVarCharColumn("NUMERO_REFERENCE", 256);
1724
            root.getBase().getDataSource().execute(alter.asString());
1725
            root.getSchema().updateVersion();
1726
        }
1727
        if (!tableDsn.contains("ID_DECLARATION_DSN_ANNULATION")) {
1728
            AlterTable alter = new AlterTable(tableDsn);
1729
            alter.addForeignColumn("ID_DECLARATION_DSN_ANNULATION", tableDsn);
1730
            root.getBase().getDataSource().execute(alter.asString());
1731
            root.getSchema().updateVersion();
1732
        }
1733
        if (!tableDsn.contains("EFFECTIF_CVAE")) {
1734
            AlterTable alter = new AlterTable(tableDsn);
1735
            alter.addIntegerColumn("EFFECTIF_CVAE", null, true);
1736
            alter.addVarCharColumn("CODE_INSEE_CVAE", 32);
1737
            root.getBase().getDataSource().execute(alter.asString());
1738
            root.getSchema().updateVersion();
1739
            root.refetchTable(tableDsn.getName());
1740
        }
132 ilm 1741
 
142 ilm 1742
        if (!tableDsn.contains("PERIODE_CVAE_DEBUT")) {
1743
            AlterTable alter = new AlterTable(tableDsn);
1744
            alter.addColumn("PERIODE_CVAE_DEBUT", "date");
1745
            alter.addColumn("PERIODE_CVAE_FIN", "date");
1746
            root.getBase().getDataSource().execute(alter.asString());
1747
            root.getSchema().updateVersion();
1748
        }
1749
 
132 ilm 1750
        // if (!root.contains("FIN_CONTRAT")) {
1751
        //
1752
        // final SQLCreateTable createTable = new SQLCreateTable(root, "FIN_CONTRAT");
1753
        // createTable.addForeignColumn("SALARIE");
1754
        // createTable.addDateAndTimeColumn("DATE_FIN");
1755
        // createTable.addDateAndTimeColumn("DATE_FIN_PREV");
1756
        // createTable.addBooleanColumn("SUBROGATION", Boolean.FALSE, false);
1757
        // createTable.addDateAndTimeColumn("DATE_DEBUT_SUBROGATION");
1758
        // createTable.addDateAndTimeColumn("DATE_FIN_SUBROGATION");
1759
        // createTable.addForeignColumn("ID_MOTIF_ARRET_TRAVAIL",
1760
        // root.findTable("MOTIF_ARRET_TRAVAIL"));
1761
        // createTable.addForeignColumn("ID_MOTIF_REPRISE_ARRET_TRAVAIL",
1762
        // root.findTable("MOTIF_REPRISE_ARRET_TRAVAIL"));
1763
        // createTable.addDateAndTimeColumn("DATE_REPRISE");
1764
        // createTable.addDateAndTimeColumn("DATE_ACCIDENT");
1765
        //
1766
        // try {
1767
        // root.getBase().getDataSource().execute(createTable.asString());
1768
        // insertUndef(createTable);
1769
        // root.refetchTable("FIN_CONTRAT");
1770
        // root.getSchema().updateVersion();
1771
        // } catch (SQLException ex) {
1772
        // throw new IllegalStateException("Erreur lors de la création de la table " +
1773
        // "FIN_CONTRAT", ex);
1774
        // }
1775
        // }
1776
 
1777
        SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
1778
        if (!tableContrat.contains("NUMERO")) {
1779
            AlterTable alter = new AlterTable(tableContrat);
1780
            alter.addColumn("NUMERO", "varchar(" + 128 + ") default '00000' NOT NULL");
1781
            root.getBase().getDataSource().execute(alter.asString());
1782
            root.getSchema().updateVersion();
1783
        }
1784
 
1785
        if (!tableContrat.contains("CODE_REGIME_RETRAITE_DSN")) {
1786
            AlterTable alter = new AlterTable(tableContrat);
1787
            alter.addColumn("CODE_REGIME_RETRAITE_DSN", "varchar(" + 128 + ") default '00000' NOT NULL");
1788
            root.getBase().getDataSource().execute(alter.asString());
1789
            root.getSchema().updateVersion();
1790
        }
1791
 
1792
        if (!tableContrat.contains("DATE_PREV_FIN")) {
1793
            AlterTable alter = new AlterTable(tableContrat);
1794
            alter.addDateAndTimeColumn("DATE_PREV_FIN");
1795
            root.getBase().getDataSource().execute(alter.asString());
1796
            root.getSchema().updateVersion();
1797
        }
1798
 
1799
        boolean updateContrat = false;
1800
        if (!tableContrat.contains("ID_CONTRAT_MODALITE_TEMPS")) {
1801
            updateContrat = true;
1802
            AlterTable alter = new AlterTable(tableContrat);
1803
            alter.addForeignColumn("ID_CONTRAT_MODALITE_TEMPS", root.findTable("CONTRAT_MODALITE_TEMPS"));
1804
            root.getBase().getDataSource().execute(alter.asString());
1805
            root.getSchema().updateVersion();
1806
        }
1807
        if (!tableContrat.contains("ID_CONTRAT_REGIME_MALADIE")) {
1808
            AlterTable alter = new AlterTable(tableContrat);
1809
            alter.addForeignColumn("ID_CONTRAT_REGIME_MALADIE", root.findTable("CONTRAT_REGIME_MALADIE"));
1810
            root.getBase().getDataSource().execute(alter.asString());
1811
            root.getSchema().updateVersion();
1812
        }
1813
        if (!tableContrat.contains("ID_CONTRAT_REGIME_VIEILLESSE")) {
1814
            AlterTable alter = new AlterTable(tableContrat);
1815
            alter.addForeignColumn("ID_CONTRAT_REGIME_VIEILLESSE", root.findTable("CONTRAT_REGIME_VIEILLESSE"));
1816
            root.getBase().getDataSource().execute(alter.asString());
1817
            root.getSchema().updateVersion();
1818
        }
1819
        if (!tableContrat.contains("ID_CONTRAT_MOTIF_RECOURS")) {
1820
            AlterTable alter = new AlterTable(tableContrat);
1821
            alter.addForeignColumn("ID_CONTRAT_MOTIF_RECOURS", root.findTable("CONTRAT_MOTIF_RECOURS"));
1822
            root.getBase().getDataSource().execute(alter.asString());
1823
            root.getSchema().updateVersion();
1824
        }
1825
        if (!tableContrat.contains("ID_CONTRAT_DETACHE_EXPATRIE")) {
1826
            AlterTable alter = new AlterTable(tableContrat);
1827
            alter.addForeignColumn("ID_CONTRAT_DETACHE_EXPATRIE", root.findTable("CONTRAT_DETACHE_EXPATRIE"));
1828
            root.getBase().getDataSource().execute(alter.asString());
1829
            root.getSchema().updateVersion();
1830
        }
1831
        if (!tableContrat.contains("ID_CONTRAT_DISPOSITIF_POLITIQUE")) {
1832
            AlterTable alter = new AlterTable(tableContrat);
1833
            alter.addForeignColumn("ID_CONTRAT_DISPOSITIF_POLITIQUE", root.findTable("CONTRAT_DISPOSITIF_POLITIQUE"));
1834
            root.getBase().getDataSource().execute(alter.asString());
1835
            root.getSchema().updateVersion();
1836
        }
177 ilm 1837
        if (!tableContrat.contains("ID_CODE_AMENAGEMENT_PARTIEL")) {
1838
            updateContrat = true;
1839
            AlterTable alter = new AlterTable(tableContrat);
1840
            alter.addForeignColumn("ID_CODE_AMENAGEMENT_PARTIEL", root.findTable("CODE_AMENAGEMENT_PARTIEL"));
1841
            alter.addColumn("DATE_DEBUT_SUSPENSION", "date");
1842
            alter.addColumn("DATE_FIN_SUSPENSION", "date");
1843
            root.getBase().getDataSource().execute(alter.asString());
1844
            root.getSchema().updateVersion();
1845
        }
132 ilm 1846
 
177 ilm 1847
        if (!tableContrat.contains("ID_CODE_SUSPENSION")) {
1848
            updateContrat = true;
1849
            AlterTable alter = new AlterTable(tableContrat);
1850
            alter.addForeignColumn("ID_CODE_SUSPENSION", root.findTable("CODE_SUSPENSION"));
1851
            root.getBase().getDataSource().execute(alter.asString());
1852
            root.getSchema().updateVersion();
1853
        }
182 ilm 1854
 
180 ilm 1855
        if (!tableContrat.contains("ID_DIPLOME_PREPARE")) {
1856
            updateContrat = true;
1857
            AlterTable alter = new AlterTable(tableContrat);
1858
            alter.addForeignColumn("ID_DIPLOME_PREPARE", root.findTable("DIPLOME_PREPARE"));
1859
            root.getBase().getDataSource().execute(alter.asString());
1860
            root.getSchema().updateVersion();
1861
        }
177 ilm 1862
 
132 ilm 1863
        if (updateContrat) {
1864
            root.refetchTable("CONTRAT_SALARIE");
1865
            tableContrat = root.findTable("CONTRAT_SALARIE");
1866
            SQLSelect sel = new SQLSelect();
1867
            sel.addSelectStar(tableContrat);
1868
            List<SQLRow> contrats = SQLRowListRSH.execute(sel);
1869
 
1870
            SQLSelect selModal = new SQLSelect();
1871
            final SQLTable tableModaliteTemps = root.findTable("CONTRAT_MODALITE_TEMPS");
1872
            selModal.addSelectStar(tableModaliteTemps);
1873
            selModal.setWhere(new Where(tableModaliteTemps.getField("CODE"), "=", "10"));
1874
            SQLRow contratModalite = SQLRowListRSH.execute(selModal).get(0);
1875
 
1876
            SQLSelect selMaladie = new SQLSelect();
1877
            final SQLTable tableMaladie = root.findTable("CONTRAT_REGIME_MALADIE");
1878
            selMaladie.addSelectStar(tableMaladie);
1879
            selMaladie.setWhere(new Where(tableMaladie.getField("CODE"), "=", "200"));
1880
            SQLRow contratMaladie = SQLRowListRSH.execute(selMaladie).get(0);
1881
 
1882
            SQLSelect selViel = new SQLSelect();
1883
            final SQLTable tableViel = root.findTable("CONTRAT_REGIME_VIEILLESSE");
1884
            selViel.addSelectStar(tableViel);
1885
            selViel.setWhere(new Where(tableViel.getField("CODE"), "=", "200"));
1886
            SQLRow contratViel = SQLRowListRSH.execute(selViel).get(0);
1887
 
1888
            SQLSelect selDetacheExp = new SQLSelect();
1889
            final SQLTable tableDetacheExp = root.findTable("CONTRAT_DETACHE_EXPATRIE");
1890
            selDetacheExp.addSelectStar(tableDetacheExp);
1891
            selDetacheExp.setWhere(new Where(tableDetacheExp.getField("CODE"), "=", "99"));
1892
            SQLRow contratDetacheExp = SQLRowListRSH.execute(selDetacheExp).get(0);
1893
 
1894
            SQLSelect selDispoPolitique = new SQLSelect();
1895
            final SQLTable tableDispoPol = root.findTable("CONTRAT_DISPOSITIF_POLITIQUE");
1896
            selDispoPolitique.addSelectStar(tableDispoPol);
1897
            selDispoPolitique.setWhere(new Where(tableDispoPol.getField("CODE"), "=", "99"));
1898
            SQLRow contratDispoPol = SQLRowListRSH.execute(selDispoPolitique).get(0);
1899
 
1900
            for (SQLRow contrat : contrats) {
1901
 
1902
                final SQLRowValues createEmptyUpdateRow = contrat.createEmptyUpdateRow();
1903
                createEmptyUpdateRow.put("ID_CONTRAT_MODALITE_TEMPS", contratModalite.getID());
1904
                createEmptyUpdateRow.put("ID_CONTRAT_REGIME_MALADIE", contratMaladie.getID());
1905
                createEmptyUpdateRow.put("ID_CONTRAT_REGIME_VIEILLESSE", contratViel.getID());
1906
                createEmptyUpdateRow.put("ID_CONTRAT_DETACHE_EXPATRIE", contratDetacheExp.getID());
1907
                createEmptyUpdateRow.put("ID_CONTRAT_DISPOSITIF_POLITIQUE", contratDispoPol.getID());
1908
                createEmptyUpdateRow.commit();
1909
            }
1910
        }
142 ilm 1911
        if (!root.contains("CONTRAT_PREVOYANCE")) {
132 ilm 1912
 
142 ilm 1913
            final SQLCreateTable createTable = new SQLCreateTable(root, "CONTRAT_PREVOYANCE");
1914
            createTable.addVarCharColumn("REFERENCE", 256);
1915
            createTable.addDateAndTimeColumn("DATE_DEBUT");
1916
            createTable.addDateAndTimeColumn("DATE_FIN");
1917
            createTable.addVarCharColumn("CODE_ORGANISME", 256);
1918
            createTable.addVarCharColumn("CODE_DELEGATAIRE", 256);
1919
            createTable.addVarCharColumn("CODE_UNIQUE", 256);
1920
            createTable.addVarCharColumn("NOM", 256);
1921
            try {
1922
                root.getBase().getDataSource().execute(createTable.asString());
1923
                insertUndef(createTable);
1924
                root.refetchTable("CONTRAT_PREVOYANCE");
1925
                root.getSchema().updateVersion();
1926
            } catch (SQLException ex) {
1927
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE", ex);
1928
            }
1929
        }
1930
        if (!root.getTable("CONTRAT_PREVOYANCE").contains("COTISATION_ETABLISSEMENT")) {
1931
            AlterTable tableContratP = new AlterTable(root.getTable("CONTRAT_PREVOYANCE"));
1932
            tableContratP.addBooleanColumn("COTISATION_ETABLISSEMENT", Boolean.FALSE, false);
1933
            root.getBase().getDataSource().execute(tableContratP.asString());
1934
            root.refetchTable("CONTRAT_PREVOYANCE");
1935
            root.getSchema().updateVersion();
1936
        }
1937
 
1938
        if (!root.contains("CONTRAT_PREVOYANCE_CONTRAT_SALARIE")) {
1939
 
1940
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
1941
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
1942
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
1943
            createTableSal.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1944
            createTableSal.addVarCharColumn("CODE_OPTION", 256);
1945
            createTableSal.addVarCharColumn("CODE_POPULATION", 256);
1946
            createTableSal.addIntegerColumn("NB_ENFANT_CHARGE", null, true);
1947
            createTableSal.addIntegerColumn("NB_ADULTE_AYANT_DROIT", null, true);
1948
            createTableSal.addIntegerColumn("NB_AYANT_DROIT", null, true);
1949
            createTableSal.addIntegerColumn("NB_AYANT_DROIT_AUTRE", null, true);
1950
            createTableSal.addIntegerColumn("NB_ENFANT_AYANT_DROIT", null, true);
1951
 
1952
            try {
1953
                root.getBase().getDataSource().execute(createTableSal.asString());
1954
                insertUndef(createTableSal);
1955
                root.refetchTable("CONTRAT_PREVOYANCE_CONTRAT_SALARIE");
1956
                root.getSchema().updateVersion();
1957
 
1958
                String up = "UPDATE " + new SQLName(root.getName(), tableInfosSalarie.getName()).quote() + " i SET \"ID_SALARIE\" = (SELECT s.\"ID\" FROM "
1959
                        + new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote() + " s WHERE s.\"ID_INFOS_SALARIE_PAYE\"=i.\"ID\" and s.\"ARCHIVE\"=0)"
1960
                        + " WHERE i.\"ID\" IN (SELECT i2.\"ID_INFOS_SALARIE_PAYE\" FROM " + new SQLName(root.getName(), tableInfosSalarie.getForeignTable("ID_SALARIE").getName()).quote();
1961
                up += " i2 WHERE i2.\"ARCHIVE\"=0)";
1962
 
1963
                root.getBase().getDataSource().execute(up);
1964
 
1965
            } catch (SQLException ex) {
1966
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_SALARIE", ex);
1967
            }
1968
        }
1969
        if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE"))
1970
 
1971
        {
1972
 
1973
            final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE");
1974
            createTableRub.addForeignColumn("ID_RUBRIQUE_COTISATION", root.findTable("RUBRIQUE_COTISATION"));
1975
            createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1976
 
1977
            try {
1978
                root.getBase().getDataSource().execute(createTableRub.asString());
1979
                insertUndef(createTableRub);
1980
                root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE");
1981
                root.getSchema().updateVersion();
1982
            } catch (SQLException ex) {
1983
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE", ex);
1984
            }
1985
        }
1986
 
1987
        if (!root.contains("CONTRAT_PREVOYANCE_RUBRIQUE_NET"))
1988
 
1989
        {
1990
 
1991
            final SQLCreateTable createTableRub = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_RUBRIQUE_NET");
1992
            createTableRub.addForeignColumn("ID_RUBRIQUE_NET", root.findTable("RUBRIQUE_NET"));
1993
            createTableRub.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
1994
 
1995
            try {
1996
                root.getBase().getDataSource().execute(createTableRub.asString());
1997
                insertUndef(createTableRub);
1998
                root.refetchTable("CONTRAT_PREVOYANCE_RUBRIQUE_NET");
1999
                root.getSchema().updateVersion();
2000
            } catch (SQLException ex) {
2001
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_RUBRIQUE_NET", ex);
2002
            }
2003
        }
2004
        if (!root.contains("AYANT_DROIT")) {
2005
 
2006
            final SQLCreateTable createTableAyantDroit = new SQLCreateTable(root, "AYANT_DROIT");
2007
            createTableAyantDroit.addVarCharColumn("NOM", 256);
2008
            createTableAyantDroit.addForeignColumn("ID_SALARIE", root.findTable("SALARIE"));
2009
            createTableAyantDroit.addForeignColumn("ID_AYANT_DROIT_TYPE", root.findTable("AYANT_DROIT_TYPE"));
2010
            createTableAyantDroit.addBooleanColumn("REGIME_ALSACE", Boolean.FALSE, false);
2011
            createTableAyantDroit.addVarCharColumn("NIR", 256);
2012
            createTableAyantDroit.addVarCharColumn("PRENOMS", 256);
2013
            createTableAyantDroit.addVarCharColumn("CODE_ORGANISME_AFFILIATION", 256);
2014
            createTableAyantDroit.addVarCharColumn("CODE_OPTION", 256);
2015
            createTableAyantDroit.addVarCharColumn("NIR_OUVRANT_DROIT", 256);
2016
            createTableAyantDroit.addDateAndTimeColumn("DATE_DEBUT_RATTACHEMENT");
2017
            createTableAyantDroit.addDateAndTimeColumn("DATE_FIN_RATTACHEMENT");
2018
            createTableAyantDroit.addDateAndTimeColumn("DATE_NAISSANCE");
2019
            try {
2020
                root.getBase().getDataSource().execute(createTableAyantDroit.asString());
2021
                insertUndef(createTableAyantDroit);
2022
                root.refetchTable("AYANT_DROIT");
2023
                root.getSchema().updateVersion();
2024
            } catch (SQLException ex) {
2025
                throw new IllegalStateException("Erreur lors de la création de la table " + "AYANT_DROIT", ex);
2026
            }
2027
 
2028
            final SQLCreateTable createTablePrevAyant = new SQLCreateTable(root, "CONTRAT_PREVOYANCE_AYANT_DROIT");
2029
            createTablePrevAyant.addForeignColumn("ID_AYANT_DROIT", root.getTable("AYANT_DROIT"));
2030
            createTablePrevAyant.addForeignColumn("ID_CONTRAT_PREVOYANCE", root.getTable("CONTRAT_PREVOYANCE"));
2031
 
2032
            try {
2033
                root.getBase().getDataSource().execute(createTablePrevAyant.asString());
2034
                insertUndef(createTablePrevAyant);
2035
                root.refetchTable("CONTRAT_PREVOYANCE_AYANT_DROIT");
2036
                root.getSchema().updateVersion();
2037
            } catch (SQLException ex) {
2038
                throw new IllegalStateException("Erreur lors de la création de la table " + "CONTRAT_PREVOYANCE_AYANT_DROIT", ex);
2039
            }
2040
        }
2041
        if (!root.contains("CODE_PENIBILITE_CONTRAT_SALARIE")) {
2042
 
2043
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "CODE_PENIBILITE_CONTRAT_SALARIE");
2044
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
2045
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
2046
            createTableSal.addForeignColumn("ID_CODE_PENIBILITE", root.findTable("CODE_PENIBILITE"));
2047
 
2048
            try {
2049
                root.getBase().getDataSource().execute(createTableSal.asString());
2050
                insertUndef(createTableSal);
2051
                root.refetchTable("CODE_PENIBILITE_CONTRAT_SALARIE");
2052
                root.getSchema().updateVersion();
2053
 
2054
            } catch (SQLException ex) {
2055
                throw new IllegalStateException("Erreur lors de la création de la table " + "CODE_PENIBILITE_CONTRAT_SALARIE", ex);
2056
            }
2057
        }
182 ilm 2058
 
2059
        if (!root.contains("ARRET_CHOMAGE_INTEMPERIE")) {
2060
 
2061
            final SQLCreateTable createTableSal = new SQLCreateTable(root, "ARRET_CHOMAGE_INTEMPERIE");
2062
            final SQLTable tableInfosSalarie = root.getTable("INFOS_SALARIE_PAYE");
2063
            createTableSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", tableInfosSalarie);
2064
            createTableSal.addForeignColumn("ID_CODE_AMENAGEMENT_PARTIEL", root.findTable("CODE_AMENAGEMENT_PARTIEL"));
2065
            createTableSal.addForeignColumn("ID_CODE_SUSPENSION", root.findTable("CODE_SUSPENSION"));
2066
            createTableSal.addColumn("DATE_DEBUT_SUSPENSION", "date");
2067
            createTableSal.addColumn("DATE_FIN_SUSPENSION", "date");
2068
 
2069
            try {
2070
                root.getBase().getDataSource().execute(createTableSal.asString());
2071
                insertUndef(createTableSal);
2072
                root.refetchTable("ARRET_CHOMAGE_INTEMPERIE");
2073
                root.getSchema().updateVersion();
2074
            } catch (SQLException ex) {
2075
                throw new IllegalStateException("Erreur lors de la création de la table " + "ARRET_CHOMAGE_INTEMPERIE", ex);
2076
            }
2077
        }
2078
 
2079
        if (!tableContrat.contains("ID_CODE_CAISSE_CONGES_PAYES")) {
2080
            AlterTable alterContrat = new AlterTable(tableContrat);
2081
            alterContrat.addForeignColumn("ID_CODE_CAISSE_CONGES_PAYES", root.findTable("CODE_CAISSE_CONGES_PAYES"));
2082
            alterContrat.addDecimalColumn("TAUX_FRAIS_PROFESSIONNELS", 16, 4, null, true);
2083
            root.getBase().getDataSource().execute(alterContrat.asString());
2084
            root.getSchema().updateVersion();
2085
        }
2086
 
132 ilm 2087
    }
2088
 
2089
}