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 26... |
Line 26... |
26 |
|
26 |
|
27 |
package org.openconcerto.erp.generationEcritures;
|
27 |
package org.openconcerto.erp.generationEcritures;
|
28 |
|
28 |
|
29 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
29 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
30 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
30 |
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
|
- |
|
31 |
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
|
- |
|
32 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
- |
|
33 |
import org.openconcerto.erp.preferences.DefaultNXProps;
|
31 |
import org.openconcerto.sql.model.SQLRow;
|
34 |
import org.openconcerto.sql.model.SQLRow;
|
32 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
35 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
33 |
import org.openconcerto.sql.model.SQLRowValues;
|
36 |
import org.openconcerto.sql.model.SQLRowValues;
|
34 |
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
|
37 |
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
|
35 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
38 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
Line 88... |
Line 91... |
88 |
fillJournalBanqueFromRow(depot);
|
91 |
fillJournalBanqueFromRow(depot);
|
89 |
} else {
|
92 |
} else {
|
90 |
int idJrnl = this.banque.getForeignID("ID_JOURNAL");
|
93 |
int idJrnl = this.banque.getForeignID("ID_JOURNAL");
|
91 |
this.putValue("ID_JOURNAL", idJrnl);
|
94 |
this.putValue("ID_JOURNAL", idJrnl);
|
92 |
}
|
95 |
}
|
- |
|
96 |
if (!depot.isForeignEmpty("ID_" + BanqueSQLElement.TABLENAME)) {
|
- |
|
97 |
SQLRow rowBanque = depot.getForeignRow("ID_" + BanqueSQLElement.TABLENAME);
|
- |
|
98 |
if (rowBanque.getTable().contains("TYPE_CAISSE") && rowBanque.getBoolean("TYPE_CAISSE")) {
|
- |
|
99 |
final SQLRow row = rowBanque.getTable().getTable("TYPE_REGLEMENT").getRow(TypeReglementSQLElement.CHEQUE);
|
- |
|
100 |
if (row.getTable().contains("ID_COMPTE_PCE_CAISSE")) {
|
- |
|
101 |
Number n = row.getNonEmptyForeignIDNumber("ID_COMPTE_PCE_CAISSE");
|
- |
|
102 |
if (n != null) {
|
- |
|
103 |
this.putValue("ID_JOURNAL", JournalSQLElement.CAISSES);
|
- |
|
104 |
}
|
- |
|
105 |
}
|
- |
|
106 |
}
|
- |
|
107 |
}
|
- |
|
108 |
|
- |
|
109 |
boolean genEcrDisabled = DefaultNXProps.getInstance().getBooleanValue(GenerationMvtSaisieVenteFacture.NOT_GEN_ECRITURE, false);
|
93 |
|
110 |
|
94 |
List<Integer> pieceIDs = new ArrayList<Integer>();
|
111 |
List<Integer> pieceIDs = new ArrayList<Integer>();
|
95 |
SQLRowValues rowValsDepotElt = new SQLRowValues(depot.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
|
112 |
SQLRowValues rowValsDepotElt = new SQLRowValues(depot.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
|
96 |
rowValsDepotElt.putNulls("MONTANT", "TIERS", "PIECE");
|
113 |
rowValsDepotElt.putNulls("MONTANT", "TIERS", "PIECE");
|
97 |
rowValsDepotElt.putRowValues("ID_CLIENT").putNulls("NOM", "ID_COMPTE_PCE");
|
114 |
rowValsDepotElt.putRowValues("ID_CLIENT").putNulls("NOM", "ID_COMPTE_PCE");
|
Line 129... |
Line 146... |
129 |
}
|
146 |
}
|
130 |
|
147 |
|
131 |
this.putValue("ID_COMPTE_PCE", new Integer(idCompteClient));
|
148 |
this.putValue("ID_COMPTE_PCE", new Integer(idCompteClient));
|
132 |
this.putValue("DEBIT", new Long(0));
|
149 |
this.putValue("DEBIT", new Long(0));
|
133 |
this.putValue("CREDIT", new Long(sqlRowAccessor.getLong("MONTANT")));
|
150 |
this.putValue("CREDIT", new Long(sqlRowAccessor.getLong("MONTANT")));
|
- |
|
151 |
if (!genEcrDisabled) {
|
134 |
SQLRow insertedRow = ajoutEcriture();
|
152 |
SQLRow insertedRow = ajoutEcriture();
|
135 |
|
- |
|
136 |
sqlRowAccessor.createEmptyUpdateRow().put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
|
153 |
sqlRowAccessor.createEmptyUpdateRow().put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
|
- |
|
154 |
}
|
137 |
sqlRowAccessor.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.TRUE).getGraph().store(StoreMode.COMMIT, false);
|
155 |
sqlRowAccessor.getForeign("ID_CHEQUE_A_ENCAISSER").createEmptyUpdateRow().put("ENCAISSE", Boolean.TRUE).getGraph().store(StoreMode.COMMIT, false);
|
138 |
}
|
156 |
}
|
139 |
// compte de reglement cheque, ...
|
157 |
// compte de reglement cheque, ...
|
140 |
fillCompteBanqueFromRow(depot, "VenteCheque", false);
|
158 |
fillCompteBanqueFromRow(depot, "VenteCheque", false);
|
- |
|
159 |
if (!depot.isForeignEmpty("ID_" + BanqueSQLElement.TABLENAME)) {
|
- |
|
160 |
SQLRow rowBanque = depot.getForeignRow("ID_" + BanqueSQLElement.TABLENAME);
|
- |
|
161 |
if (rowBanque.getTable().contains("TYPE_CAISSE") && rowBanque.getBoolean("TYPE_CAISSE")) {
|
- |
|
162 |
final SQLRow row = rowBanque.getTable().getTable("TYPE_REGLEMENT").getRow(TypeReglementSQLElement.CHEQUE);
|
- |
|
163 |
if (row.getTable().contains("ID_COMPTE_PCE_CAISSE")) {
|
- |
|
164 |
Number n = row.getNonEmptyForeignIDNumber("ID_COMPTE_PCE_CAISSE");
|
- |
|
165 |
if (n != null) {
|
- |
|
166 |
this.putValue("ID_COMPTE_PCE", n);
|
- |
|
167 |
}
|
- |
|
168 |
}
|
- |
|
169 |
}
|
- |
|
170 |
}
|
- |
|
171 |
|
141 |
this.putValue("NOM", this.nom);
|
172 |
this.putValue("NOM", this.nom);
|
142 |
this.putValue("DEBIT", new Long(this.montant));
|
173 |
this.putValue("DEBIT", new Long(this.montant));
|
143 |
this.putValue("CREDIT", new Long(0));
|
174 |
this.putValue("CREDIT", new Long(0));
|
- |
|
175 |
if (!genEcrDisabled) {
|
144 |
SQLRow insertedRow = ajoutEcriture();
|
176 |
SQLRow insertedRow = ajoutEcriture();
|
145 |
|
- |
|
146 |
depot.createEmptyUpdateRow().put("ID_MOUVEMENT", idMvt).put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
|
177 |
depot.createEmptyUpdateRow().put("ID_MOUVEMENT", idMvt).put("ID_ECRITURE", insertedRow.getID()).getGraph().store(StoreMode.COMMIT, false);
|
- |
|
178 |
} else {
|
- |
|
179 |
depot.createEmptyUpdateRow().put("ID_MOUVEMENT", idMvt).getGraph().store(StoreMode.COMMIT, false);
|
147 |
|
180 |
}
|
148 |
pieceIDs.add(mouvementTable.getRow(idMvt).getForeignID("ID_PIECE"));
|
181 |
pieceIDs.add(mouvementTable.getRow(idMvt).getForeignID("ID_PIECE"));
|
149 |
lettrageAuto(pieceIDs, this.date);
|
182 |
lettrageAuto(pieceIDs, this.date);
|
150 |
|
183 |
|
151 |
System.err.println("Ecritures générées pour le mouvement " + this.idMvt);
|
184 |
System.err.println("Ecritures générées pour le mouvement " + this.idMvt);
|
152 |
|
185 |
|