OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 185
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 480... Line 480...
480
            rowValsPort.put("ID_TAXE", rowTVAPort.getIDNumber());
480
            rowValsPort.put("ID_TAXE", rowTVAPort.getIDNumber());
481
 
481
 
482
            final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
482
            final SQLTable tablePrefCompte = Configuration.getInstance().getRoot().findTable("PREFS_COMPTE");
483
            final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
483
            final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
484
            SQLRow rowDefaultCptPort;
484
            SQLRow rowDefaultCptPort;
-
 
485
            if (achat) {
-
 
486
                if (rowTVAPort.getFloat("TAUX") > 0) {
-
 
487
                    rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_SOUMIS_ACHAT"));
-
 
488
                    if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
-
 
489
                        try {
-
 
490
                            rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortAchatSoumisTVA");
-
 
491
                        } catch (Exception e) {
-
 
492
                            e.printStackTrace();
-
 
493
                        }
-
 
494
                    }
-
 
495
                } else {
-
 
496
                    rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_NON_SOUMIS_ACHAT"));
-
 
497
                    if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
-
 
498
                        try {
-
 
499
                            rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortAchatNonSoumisTVA");
-
 
500
                        } catch (Exception e) {
-
 
501
                            e.printStackTrace();
-
 
502
                        }
-
 
503
                    }
-
 
504
                }
-
 
505
            } else {
485
            if (rowTVAPort.getFloat("TAUX") > 0) {
506
                if (rowTVAPort.getFloat("TAUX") > 0) {
486
                rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_SOUMIS"));
507
                    rowDefaultCptPort = cacheCompte.getRowFromId(rowPrefsCompte.getForeignID("ID_COMPTE_PCE_PORT_SOUMIS"));
487
                if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
508
                    if (rowDefaultCptPort == null || rowDefaultCptPort.isUndefined()) {
488
                    try {
509
                        try {
489
                        rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteSoumisTVA");
510
                            rowDefaultCptPort = ComptePCESQLElement.getRowComptePceDefault("PortVenteSoumisTVA");
Line 499... Line 520...
499
                    } catch (Exception e) {
520
                        } catch (Exception e) {
500
                        e.printStackTrace();
521
                            e.printStackTrace();
501
                    }
522
                        }
502
                }
523
                    }
503
            }
524
                }
-
 
525
            }
504
            final SQLRowValues rowValsArt = rowValsPort.putRowValues("ID_ARTICLE");
526
            final SQLRowValues rowValsArt = rowValsPort.putRowValues("ID_ARTICLE");
505
            rowValsArt.put(achat ? "ID_COMPTE_PCE_ACHAT" : "ID_COMPTE_PCE", rowDefaultCptPort.getID());
527
            rowValsArt.put(achat ? "ID_COMPTE_PCE_ACHAT" : "ID_COMPTE_PCE", rowDefaultCptPort.getID());
506
            rowValsArt.put("ID_TAXE_COMPLEMENTAIRE", null);
528
            rowValsArt.put("ID_TAXE_COMPLEMENTAIRE", null);
507
            rowValsArt.put("ID_FAMILLE_ARTICLE", null);
529
            rowValsArt.put("ID_FAMILLE_ARTICLE", null);
508
            calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
530
            calc.addLine(rowValsPort, rowValsPort.getForeign("ID_ARTICLE"), 1, false);
Line 604... Line 626...
604
            SQLRow rowBanque = sqlRow.getForeignRow("ID_" + BanqueSQLElement.TABLENAME);
626
            SQLRow rowBanque = sqlRow.getForeignRow("ID_" + BanqueSQLElement.TABLENAME);
605
            if (!rowBanque.isForeignEmpty("ID_JOURNAL")) {
627
            if (!rowBanque.isForeignEmpty("ID_JOURNAL")) {
606
                SQLRow rowJournal = rowBanque.getForeignRow("ID_JOURNAL");
628
                SQLRow rowJournal = rowBanque.getForeignRow("ID_JOURNAL");
607
                this.mEcritures.put("ID_JOURNAL", rowJournal.getID());
629
                this.mEcritures.put("ID_JOURNAL", rowJournal.getID());
608
            }
630
            }
-
 
631
        } else if (sqlRow.getTable().contains("ID_TYPE_REGLEMENT") && !sqlRow.isForeignEmpty("ID_TYPE_REGLEMENT")) {
-
 
632
            SQLRow rowType = sqlRow.getForeignRow("ID_TYPE_REGLEMENT");
-
 
633
            if (rowType.getTable().contains("ID_JOURNAL") && !rowType.isForeignEmpty("ID_JOURNAL")) {
-
 
634
                SQLRow rowJournal = rowType.getForeignRow("ID_JOURNAL");
-
 
635
                this.mEcritures.put("ID_JOURNAL", rowJournal.getID());
-
 
636
            }
609
        }
637
        }
610
    }
638
    }
611
 
639
 
612
    /**
640
    /**
613
     * Définit le compte en fonction de la banque sélectionnée
641
     * Définit le compte en fonction de la banque sélectionnée
614
     * 
642
     * 
615
     * @param sqlRow sqlRow contenant la foreignKey Banque
643
     * @param sqlRow sqlRow contenant la foreignKey Banque
616
     * @throws Exception
644
     * @throws Exception
617
     */
645
     */
618
    protected void fillCompteBanqueFromRow(SQLRow sqlRow, String defaultProps, boolean achat) throws Exception {
646
    protected void fillCompteBanqueFromRow(SQLRow sqlRow, String defaultProps, boolean achat) throws SQLException {
619
        int idPce = -1;
647
        int idPce = -1;
620
        if (sqlRow.getTable().contains("ID_TYPE_REGLEMENT")) {
648
        if (sqlRow.getTable().contains("ID_TYPE_REGLEMENT")) {
621
            idPce = sqlRow.getForeign("ID_TYPE_REGLEMENT").getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
649
            idPce = sqlRow.getForeign("ID_TYPE_REGLEMENT").getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
622
        } else {
650
        } else {
623
            idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));
651
            idPce = base.getTable("TYPE_REGLEMENT").getRow(2).getInt("ID_COMPTE_PCE_" + (achat ? "FOURN" : "CLIENT"));