OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 83 | Rev 93 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83 Rev 90
Line 1485... Line 1485...
1485
        patchFieldElt1Dot4(tableAvoirElt, root);
1485
        patchFieldElt1Dot4(tableAvoirElt, root);
1486
 
1486
 
1487
        addContact(root);
1487
        addContact(root);
1488
 
1488
 
1489
        final SQLTable tableDevis = root.getTable("DEVIS");
1489
        final SQLTable tableDevis = root.getTable("DEVIS");
-
 
1490
        AlterTable tDevis = new AlterTable(tableDevis);
-
 
1491
        boolean updateDevis = false;
-
 
1492
        if (!tableDevis.contains("POURCENT_REMISE")) {
-
 
1493
            updateDevis = true;
-
 
1494
            tDevis.addColumn("POURCENT_REMISE", "numeric (12,8)");
-
 
1495
        }
1490
        if (!tableDevis.contains("MONTANT_REMISE")) {
1496
        if (!tableDevis.contains("MONTANT_REMISE")) {
1491
            AlterTable t = new AlterTable(tableDevis);
1497
            updateDevis = true;
1492
            t.addColumn("POURCENT_REMISE", "numeric (12,8)");
1498
            tDevis.addColumn("MONTANT_REMISE", "numeric (16,8)");
-
 
1499
        }
-
 
1500
        if (!tableDevis.contains("T_HA")) {
-
 
1501
            updateDevis = true;
1493
            t.addColumn("MONTANT_REMISE", "numeric (16,8)");
1502
            tDevis.addColumn("T_HA", "bigint", "0", false);
-
 
1503
        }
-
 
1504
        if (updateDevis) {
1494
            tableDevis.getBase().getDataSource().execute(t.asString());
1505
            tableDevis.getBase().getDataSource().execute(tDevis.asString());
1495
            tableDevis.getSchema().updateVersion();
1506
            tableDevis.getSchema().updateVersion();
1496
            tableDevis.fetchFields();
1507
            tableDevis.fetchFields();
1497
        }
1508
        }
1498
 
1509
 
1499
        final SQLTable tableKmElt = root.getTable("SAISIE_KM_ELEMENT");
1510
        final SQLTable tableKmElt = root.getTable("SAISIE_KM_ELEMENT");
Line 1505... Line 1516...
1505
            tableKmElt.fetchFields();
1516
            tableKmElt.fetchFields();
1506
 
1517
 
1507
        }
1518
        }
1508
 
1519
 
1509
        final SQLTable tableAdresse = root.getTable("ADRESSE");
1520
        final SQLTable tableAdresse = root.getTable("ADRESSE");
1510
        if (tableAdresse != null && !tableAdresse.contains("PROVINCE")) {
1521
        if (tableAdresse != null) {
1511
            AlterTable t = new AlterTable(tableAdresse);
1522
            AlterTable t = new AlterTable(tableAdresse);
-
 
1523
            boolean updateADr = false;
-
 
1524
            if (!tableAdresse.contains("PROVINCE")) {
1512
            t.addVarCharColumn("PROVINCE", 256);
1525
                t.addVarCharColumn("PROVINCE", 256);
-
 
1526
                updateADr = true;
-
 
1527
            }
-
 
1528
            if (!tableAdresse.contains("LIBELLE")) {
-
 
1529
                t.addVarCharColumn("LIBELLE", 256);
-
 
1530
                updateADr = true;
-
 
1531
            }
-
 
1532
            if (!tableAdresse.contains("TYPE")) {
1513
            t.addVarCharColumn("TYPE", 256);
1533
                t.addVarCharColumn("TYPE", 256);
-
 
1534
                updateADr = true;
-
 
1535
            }
-
 
1536
            if (!tableAdresse.contains("EMAIL_CONTACT")) {
1514
            t.addVarCharColumn("EMAIL_CONTACT", 256);
1537
                t.addVarCharColumn("EMAIL_CONTACT", 256);
-
 
1538
                updateADr = true;
-
 
1539
            }
-
 
1540
            if (updateADr) {
1515
            tableAdresse.getBase().getDataSource().execute(t.asString());
1541
                tableAdresse.getBase().getDataSource().execute(t.asString());
1516
            tableAdresse.getSchema().updateVersion();
1542
                tableAdresse.getSchema().updateVersion();
1517
            tableAdresse.fetchFields();
1543
                tableAdresse.fetchFields();
1518
        }
1544
            }
-
 
1545
        }
1519
        final SQLTable tableClient = root.getTable("CLIENT");
1546
        final SQLTable tableClient = root.getTable("CLIENT");
1520
        if (tableClient != null && !tableClient.contains("BLOQUE_LIVRAISON")) {
1547
        if (tableClient != null && !tableClient.contains("BLOQUE_LIVRAISON")) {
1521
            AlterTable t = new AlterTable(tableClient);
1548
            AlterTable t = new AlterTable(tableClient);
1522
            t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
1549
            t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
1523
            if (!tableClient.contains("BLOQUE")) {
1550
            if (!tableClient.contains("BLOQUE")) {
Line 1533... Line 1560...
1533
            t.addBooleanColumn("GESTION_AUTO", false, false);
1560
            t.addBooleanColumn("GESTION_AUTO", false, false);
1534
            tableAssoc.getBase().getDataSource().execute(t.asString());
1561
            tableAssoc.getBase().getDataSource().execute(t.asString());
1535
            tableAssoc.getSchema().updateVersion();
1562
            tableAssoc.getSchema().updateVersion();
1536
            tableAssoc.fetchFields();
1563
            tableAssoc.fetchFields();
1537
        }
1564
        }
-
 
1565
        if (!root.contains("CALENDAR_ITEM")) {
-
 
1566
            final SQLCreateTable createTaskGroupTable = new SQLCreateTable(root, "CALENDAR_ITEM_GROUP");
-
 
1567
            createTaskGroupTable.addVarCharColumn("NAME", 1024);
-
 
1568
            createTaskGroupTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
-
 
1569
 
-
 
1570
            final SQLCreateTable createTaskTable = new SQLCreateTable(root, "CALENDAR_ITEM");
-
 
1571
            createTaskTable.addDateAndTimeColumn("START");
-
 
1572
            createTaskTable.addDateAndTimeColumn("END");
-
 
1573
            createTaskTable.addLongColumn("DURATION_S", 0L, false);
-
 
1574
            createTaskTable.addVarCharColumn("SUMMARY", 1024);
-
 
1575
            createTaskTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
-
 
1576
            createTaskTable.addVarCharColumn("FLAGS", 1024);
-
 
1577
            createTaskTable.addVarCharColumn("STATUS", 128);
-
 
1578
            createTaskTable.addForeignColumn(createTaskGroupTable);
-
 
1579
            createTaskTable.addLongColumn("SOURCE_ID", null, true);
-
 
1580
            createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
-
 
1581
            try {
-
 
1582
                root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
-
 
1583
                insertUndef(createTaskGroupTable);
-
 
1584
                root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
-
 
1585
                insertUndef(createTaskTable);
-
 
1586
                tableDevis.getSchema().updateVersion();
-
 
1587
            } catch (SQLException ex) {
-
 
1588
                throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
-
 
1589
            }
1538
 
1590
 
-
 
1591
        }
1539
        addArticleFournisseur(root);
1592
        addArticleFournisseur(root);
1540
    }
1593
    }
1541
 
1594
 
1542
    private void updateStyle(final DBRoot root) throws SQLException {
1595
    private void updateStyle(final DBRoot root) throws SQLException {
1543
        SQLTable style = root.getTable("STYLE");
1596
        SQLTable style = root.getTable("STYLE");
Line 1966... Line 2019...
1966
        SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
2019
        SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
1967
        addVenteEltField(tableAvoirElt, root);
2020
        addVenteEltField(tableAvoirElt, root);
1968
 
2021
 
1969
        SQLTable tableCmdFournElt = root.getTable("COMMANDE_ELEMENT");
2022
        SQLTable tableCmdFournElt = root.getTable("COMMANDE_ELEMENT");
1970
        addHAElementField(tableCmdFournElt, root);
2023
        addHAElementField(tableCmdFournElt, root);
-
 
2024
        if (root.contains("DEMANDE_PRIX_ELEMENT")) {
-
 
2025
            SQLTable tableDmdFournElt = root.getTable("DEMANDE_PRIX_ELEMENT");
-
 
2026
            addHAElementField(tableDmdFournElt, root);
-
 
2027
        }
1971
 
2028
 
1972
        SQLTable tableBonRecptElt = root.getTable("BON_RECEPTION_ELEMENT");
2029
        SQLTable tableBonRecptElt = root.getTable("BON_RECEPTION_ELEMENT");
1973
        addHAElementField(tableBonRecptElt, root);
2030
        addHAElementField(tableBonRecptElt, root);
1974
 
2031
 
1975
        SQLTable tableBonRecpt = root.getTable("BON_RECEPTION");
2032
        SQLTable tableBonRecpt = root.getTable("BON_RECEPTION");
Line 2338... Line 2395...
2338
 
2395
 
2339
    private void patchFieldElt1Dot3(SQLTable table, DBRoot root) {
2396
    private void patchFieldElt1Dot3(SQLTable table, DBRoot root) {
2340
 
2397
 
2341
        List<String> cols = Arrays.asList("PV_HT", "PA_DEVISE_T", "T_PV_HT", "T_PA_TTC", "T_PA_HT", "PA_HT", "T_PV_TTC", "PRIX_METRIQUE_HA_2", "PRIX_METRIQUE_HA_1", "PRIX_METRIQUE_HA_3",
2398
        List<String> cols = Arrays.asList("PV_HT", "PA_DEVISE_T", "T_PV_HT", "T_PA_TTC", "T_PA_HT", "PA_HT", "T_PV_TTC", "PRIX_METRIQUE_HA_2", "PRIX_METRIQUE_HA_1", "PRIX_METRIQUE_HA_3",
2342
                "PRIX_METRIQUE_VT_2", "PRIX_METRIQUE_VT_1", "MONTANT_HT", "MONTANT_INITIAL", "PRIX_METRIQUE_VT_3", "MARGE_HT", "PA_DEVISE", "PV_U_DEVISE", "PV_T_DEVISE", "PV_TTC", "TARIF_Q18_HT",
2399
                "PRIX_METRIQUE_VT_2", "PRIX_METRIQUE_VT_1", "MONTANT_HT", "MONTANT_INITIAL", "PRIX_METRIQUE_VT_3", "MARGE_HT", "PA_DEVISE", "PV_U_DEVISE", "PV_T_DEVISE", "PV_TTC", "TARIF_Q18_HT",
2343
                "T_PRIX_FINAL_TTC", "PRIX_FINAL_TTC", "PV_UNIT_HT");
2400
                "T_PRIX_FINAL_TTC", "PRIX_FINAL_TTC", "PV_UNIT_HT", "PREBILAN", "MARGE_PREBILAN_HT");
2344
 
2401
 
2345
        if ((table.contains("PV_HT") && table.getField("PV_HT").getType().getDecimalDigits() == 0) || (table.contains("PV_UNIT_HT") && table.getField("PV_UNIT_HT").getType().getDecimalDigits() == 0)) {
2402
        if ((table.contains("PV_HT") && table.getField("PV_HT").getType().getDecimalDigits() == 0) || (table.contains("PV_UNIT_HT") && table.getField("PV_UNIT_HT").getType().getDecimalDigits() == 0)) {
2346
            AlterTable t = new AlterTable(table);
2403
            AlterTable t = new AlterTable(table);
2347
            UpdateBuilder builder = new UpdateBuilder(table);
2404
            UpdateBuilder builder = new UpdateBuilder(table);
2348
            List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();
2405
            List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();