OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 83 Rev 182
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 46... Line 46...
46
        final SQLTable ecritureT = ecritureMvtFF.getTable();
46
        final SQLTable ecritureT = ecritureMvtFF.getTable();
47
 
47
 
48
        final SQLSelect selUnbalanced = new SQLSelect();
48
        final SQLSelect selUnbalanced = new SQLSelect();
49
        selUnbalanced.addSelect(ecritureMvtFF);
49
        selUnbalanced.addSelect(ecritureMvtFF);
50
        selUnbalanced.addGroupBy(ecritureMvtFF);
50
        selUnbalanced.addGroupBy(ecritureMvtFF);
51
        selUnbalanced.setHaving(Where.quote(ecritureT.getBase().quote("SUM(%n) != SUM(%n)", ecritureT.getField("DEBIT"), ecritureT.getField("CREDIT"))));
51
        selUnbalanced.setHaving(Where.quote(selUnbalanced.getSyntax(), ecritureT.getBase().quote("SUM(%n) != SUM(%n)", ecritureT.getField("DEBIT"), ecritureT.getField("CREDIT"))));
52
        return selUnbalanced;
52
        return selUnbalanced;
53
    }
53
    }
54
 
54
 
55
    public CorrectMouvement(DBSystemRoot b) {
55
    public CorrectMouvement(DBSystemRoot b) {
56
        super(b);
56
        super(b);
Line 110... Line 110...
110
            update.addRawTable("( " + selIdentifiableNonUsed.asString() + " )", "e");
110
            update.addRawTable("( " + selIdentifiableNonUsed.asString() + " )", "e");
111
 
111
 
112
            Where joinEcritureW = null;
112
            Where joinEcritureW = null;
113
            for (final String uniqField : uniqueFields) {
113
            for (final String uniqField : uniqueFields) {
114
                final SQLTable t = uniqField.equals("ID_MOUVEMENT") ? saisieKmT : saisieKmElemT;
114
                final SQLTable t = uniqField.equals("ID_MOUVEMENT") ? saisieKmT : saisieKmElemT;
115
                joinEcritureW = Where.quote("e." + SQLBase.quoteIdentifier(uniqField) + "= %f", t.getField(uniqField)).and(joinEcritureW);
115
                joinEcritureW = Where.quote(getSyntax(), "e." + SQLBase.quoteIdentifier(uniqField) + "= %f", t.getField(uniqField)).and(joinEcritureW);
116
            }
116
            }
117
            final Where dontOverwrite = new Where(saisieKmElemT.getField("ID_ECRITURE"), Where.NULL_IS_DATA_EQ, ecritureT.getUndefinedIDNumber());
117
            final Where dontOverwrite = new Where(saisieKmElemT.getField("ID_ECRITURE"), Where.NULL_IS_DATA_EQ, ecritureT.getUndefinedIDNumber());
118
            final Where dontUpdateUndef = new Where(saisieKmElemT.getKey(), Where.NULL_IS_DATA_NEQ, saisieKmElemT.getUndefinedIDNumber());
118
            final Where dontUpdateUndef = new Where(saisieKmElemT.getKey(), Where.NULL_IS_DATA_NEQ, saisieKmElemT.getUndefinedIDNumber());
119
            final Where unarchived = new Where(saisieKmElemT.getArchiveField(), "=", 0);
119
            final Where unarchived = new Where(saisieKmElemT.getArchiveField(), "=", 0);
120
            update.setWhere(joinEcritureW.and(dontOverwrite).and(dontUpdateUndef).and(unarchived));
120
            update.setWhere(joinEcritureW.and(dontOverwrite).and(dontUpdateUndef).and(unarchived));