OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 177 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
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.generationEcritures;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
83 ilm 17
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
18
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18 ilm 19
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
21
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
22
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
23
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
24
import org.openconcerto.erp.model.PrixTTC;
144 ilm 25
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
18 ilm 26
import org.openconcerto.sql.Configuration;
83 ilm 27
import org.openconcerto.sql.element.SQLElement;
18 ilm 28
import org.openconcerto.sql.model.SQLRow;
83 ilm 29
import org.openconcerto.sql.model.SQLRowAccessor;
18 ilm 30
import org.openconcerto.sql.model.SQLRowValues;
83 ilm 31
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
32
import org.openconcerto.sql.model.SQLSelect;
18 ilm 33
import org.openconcerto.sql.model.SQLTable;
83 ilm 34
import org.openconcerto.sql.model.Where;
144 ilm 35
import org.openconcerto.sql.preferences.SQLPreferences;
83 ilm 36
import org.openconcerto.utils.cc.ITransformer;
18 ilm 37
 
38
import java.sql.SQLException;
39
import java.sql.Timestamp;
40
import java.util.ArrayList;
41
import java.util.Calendar;
42
import java.util.Date;
43
import java.util.List;
44
 
45
public class GenerationReglementVenteNG extends GenerationEcritures {
46
 
47
    private static final SQLTable tableMouvement = base.getTable("MOUVEMENT");
48
    private static final SQLTable tableEncaisse = base.getTable("ENCAISSER_MONTANT");
49
    private static final SQLTable tableEncaisseElt = base.getTable("ENCAISSER_MONTANT_ELEMENT");
50
    private static final SQLTable tableSaisieVenteFacture = base.getTable("SAISIE_VENTE_FACTURE");
51
    private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
52
    private static final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
53
 
83 ilm 54
    public SQLRow ecrClient = null;
55
 
73 ilm 56
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource) throws Exception {
18 ilm 57
        this(label, rowClient, ttc, d, modeReglement, source, mvtSource, true);
58
    }
59
 
73 ilm 60
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse) throws Exception {
142 ilm 61
        this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, false);
62
    }
18 ilm 63
 
142 ilm 64
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance)
65
            throws Exception {
156 ilm 66
        this(label, rowClient, ttc, d, modeReglement, source, mvtSource, createEncaisse, avance, rowClient.getString("NOM"), null);
67
    }
142 ilm 68
 
156 ilm 69
    public GenerationReglementVenteNG(String label, SQLRow rowClient, PrixTTC ttc, Date d, SQLRow modeReglement, SQLRow source, SQLRow mvtSource, boolean createEncaisse, boolean avance, String tiers,
70
            SQLRowAccessor cptTiers) throws Exception {
71
 
18 ilm 72
        SQLRow typeRegRow = modeReglement.getForeignRow("ID_TYPE_REGLEMENT");
94 ilm 73
        setRowAnalytiqueSource(source);
18 ilm 74
        // iniatilisation des valeurs de la map
75
        this.date = d;
149 ilm 76
        if (typeRegRow.getID() == TypeReglementSQLElement.CB && modeReglement.getObject("DATE") != null) {
77
            this.date = (Date) modeReglement.getObject("DATE");
78
        }
18 ilm 79
 
80
        // TODO Nommage des ecritures
81
 
82
        this.nom = label;
83
 
149 ilm 84
        this.putValue("DATE", this.date);
85
        this.putValue("NOM", this.nom);
83 ilm 86
        fillJournalBanqueFromRow(modeReglement);
18 ilm 87
 
149 ilm 88
        this.putValue("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
18 ilm 89
        if (source.getTable().getName().equalsIgnoreCase("ENCAISSER_MONTANT")) {
149 ilm 90
            if (source.getBoolean("ACOMPTE")) {
91
                final String numeroDevis = source.asRow().getForeign("ID_DEVIS").getString("NUMERO");
92
                this.idMvt = getNewMouvement(source.getTable().getName(), source.getID(), 1, numeroDevis);
93
                this.putValue("NOM_PIECE", numeroDevis);
94
            } else {
95
                List<SQLRow> l = source.getReferentRows(source.getTable().getTable("ENCAISSER_MONTANT_ELEMENT"));
96
                for (SQLRow sqlRow : l) {
97
                    SQLRow mvtEch = sqlRow.getForeignRow("ID_MOUVEMENT_ECHEANCE");
98
                    if (mvtEch.getID() != mvtSource.getID()) {
99
                        getNewMouvement(source.getTable().getName(), source.getID(), mvtEch.getID(), mvtEch.getInt("ID_PIECE"));
100
                    }
18 ilm 101
                }
102
            }
103
        }
104
        // si paiement comptant
105
        if ((!typeRegRow.getBoolean("ECHEANCE"))
106
                && ((modeReglement.getBoolean("COMPTANT")) || (!modeReglement.getBoolean("DATE_FACTURE") && (modeReglement.getInt("AJOURS") == 0 && modeReglement.getInt("LENJOUR") == 0)))) {
107
 
108
            SQLRow rowEncaisse = source;
109
 
110
            SQLRow rowEncaisseElt = null;
83 ilm 111
            // On cre un encaissement
18 ilm 112
            if (createEncaisse) {
73 ilm 113
                SQLRowValues rowVals = new SQLRowValues(tableEncaisse);
114
                rowVals.put("MONTANT", ttc.getLongValue());
156 ilm 115
                rowVals.put("ID_CLIENT", rowClient != null ? rowClient.getID() : null);
116
                rowVals.put("TIERS", tiers);
73 ilm 117
                rowVals.put("DATE", this.date);
118
                if (typeRegRow.getID() >= TypeReglementSQLElement.TRAITE) {
119
                    Calendar c2 = modeReglement.getDate("DATE_VIREMENT");
120
                    if (c2 != null) {
121
                        rowVals.put("DATE", c2.getTime());
18 ilm 122
                    }
73 ilm 123
                }
124
                SQLRowValues rowValsRegl = new SQLRowValues(modeReglement.asRowValues());
125
                SQLRow copy = rowValsRegl.insert();
126
                rowVals.put("ID_MODE_REGLEMENT", copy.getID());
127
                rowVals.put("NOM", label);
128
                rowEncaisse = rowVals.insert();
129
                SQLRowValues rowValsElt = new SQLRowValues(tableEncaisseElt);
130
                rowValsElt.put("MONTANT_REGLE", ttc.getLongValue());
131
                rowValsElt.put("ID_ENCAISSER_MONTANT", rowEncaisse.getID());
132
                rowEncaisseElt = rowValsElt.insert();
18 ilm 133
 
134
            }
149 ilm 135
            if (!source.getTable().getName().equalsIgnoreCase("ENCAISSER_MONTANT") || !source.getBoolean("ACOMPTE")) {
136
                this.idMvt = getNewMouvement(rowEncaisse.getTable().getName(), rowEncaisse.getID(), mvtSource.getID(), mvtSource.getInt("ID_PIECE"));
137
            }
138
            this.putValue("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
18 ilm 139
 
140
            SQLRowValues rowVals = rowEncaisse.createEmptyUpdateRow();
141
            rowVals.put("ID_MOUVEMENT", this.idMvt);
73 ilm 142
 
143
            rowVals.update();
144
 
18 ilm 145
            if (rowEncaisseElt != null) {
146
                SQLRowValues rowVals2 = rowEncaisseElt.createEmptyUpdateRow();
147
                rowVals2.put("ID_MOUVEMENT_ECHEANCE", this.idMvt);
73 ilm 148
                rowVals2.update();
18 ilm 149
            }
150
 
151
            // Cheque
152
            if (typeRegRow.getID() == TypeReglementSQLElement.CHEQUE) {
153
 
154
                Date dateTmp = this.date;
155
                if (modeReglement.getObject("DATE") != null) {
156
                    dateTmp = modeReglement.getDate("DATE").getTime();
157
                }
158
                // On fixe la date du règlement de la facture
73 ilm 159
                setDateReglement(source, dateTmp);
18 ilm 160
 
161
                Calendar c = modeReglement.getDate("DATE_DEPOT");
162
                if (c != null) {
156 ilm 163
                    paiementCheque(c.getTime(), source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance, tiers, cptTiers);
18 ilm 164
                } else {
156 ilm 165
                    paiementCheque(this.date, source, ttc, rowClient, modeReglement, mvtSource.getTable().getRow(idMvt), avance, tiers, cptTiers);
18 ilm 166
                }
167
 
168
            } else {
169
                // On fixe la date du règlement de la facture
170
                if (typeRegRow.getID() >= TypeReglementSQLElement.TRAITE) {
171
                    Calendar c2 = modeReglement.getDate("DATE_VIREMENT");
172
                    if (c2 == null) {
173
                        setDateReglement(source, this.date);
174
                    } else {
175
                        setDateReglement(source, c2.getTime());
176
                    }
177
 
178
                } else {
179
                    setDateReglement(source, this.date);
180
                }
181
                if (typeRegRow.getID() == TypeReglementSQLElement.ESPECE) {
149 ilm 182
                    this.putValue("ID_JOURNAL", JournalSQLElement.CAISSES);
18 ilm 183
                }
184
 
156 ilm 185
                int idCompteClient = cptTiers != null && !cptTiers.isUndefined() ? cptTiers.getID() : rowClient.getInt("ID_COMPTE_PCE");
142 ilm 186
                if (avance) {
187
                    idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
18 ilm 188
                    if (idCompteClient <= 1) {
142 ilm 189
                        idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
18 ilm 190
                    }
142 ilm 191
                } else {
192
 
193
                    // compte Clients
194
 
195
                    if (idCompteClient <= 1) {
196
                        idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
197
                        if (idCompteClient <= 1) {
198
                            idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
199
                        }
200
                    }
73 ilm 201
                }
149 ilm 202
                this.putValue("ID_COMPTE_PCE", idCompteClient);
203
                this.putValue("DEBIT", Long.valueOf(0));
204
                this.putValue("CREDIT", Long.valueOf(ttc.getLongValue()));
142 ilm 205
 
83 ilm 206
                this.ecrClient = ajoutEcriture();
18 ilm 207
 
73 ilm 208
                // compte de reglement, caisse, cheque, ...
83 ilm 209
                if (typeRegRow.getID() == TypeReglementSQLElement.ESPECE) {
210
                    int idCompteRegl = typeRegRow.getInt("ID_COMPTE_PCE_CLIENT");
211
                    if (idCompteRegl <= 1) {
212
                        idCompteRegl = ComptePCESQLElement.getIdComptePceDefault("VenteEspece");
213
                    }
214
 
149 ilm 215
                    this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
83 ilm 216
                } else {
217
                    fillCompteBanqueFromRow(modeReglement, "VenteCB", false);
218
                }
149 ilm 219
                this.putValue("DEBIT", Long.valueOf(ttc.getLongValue()));
220
                this.putValue("CREDIT", Long.valueOf(0));
73 ilm 221
                ajoutEcriture();
222
 
151 ilm 223
                List<Integer> pieceIDs = new ArrayList<Integer>();
224
                if (source.getTable().getName().equals("ENCAISSER_MONTANT")) {
225
                    List<SQLRow> l = source.getReferentRows(base.getTable("ENCAISSER_MONTANT_ELEMENT"));
226
                    for (SQLRow sqlRow : l) {
227
                        pieceIDs.add(sqlRow.getForeign("ID_MOUVEMENT_ECHEANCE").getForeignID("ID_PIECE"));
228
                    }
229
                } else {
230
                    pieceIDs.add(mvtSource.getForeignID("ID_PIECE"));
231
                }
232
                lettrageAuto(pieceIDs, d);
18 ilm 233
            }
234
        } else {
235
 
236
                Date dateEch = ModeDeReglementSQLElement.calculDate(modeReglement.getInt("AJOURS"), modeReglement.getInt("LENJOUR"), this.date);
237
 
83 ilm 238
                System.out.println("Echance client");
18 ilm 239
 
240
                // Ajout dans echeance
21 ilm 241
                final SQLTable tableEch = base.getTable("ECHEANCE_CLIENT");
242
                SQLRowValues valEcheance = new SQLRowValues(tableEch);
18 ilm 243
 
244
                this.idMvt = getNewMouvement("ECHEANCE_CLIENT", 1, mvtSource.getID(), mvtSource.getInt("ID_PIECE"));
245
                valEcheance.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
246
                valEcheance.put("DATE", dateEch);
247
                valEcheance.put("MONTANT", Long.valueOf(ttc.getLongValue()));
156 ilm 248
                valEcheance.put("ID_CLIENT", rowClient == null ? null : rowClient.getID());
249
                valEcheance.put("TIERS", tiers);
250
                valEcheance.put("ID_COMPTE_PCE_TIERS", cptTiers == null || !cptTiers.isUndefined() ? null : cptTiers.getID());
73 ilm 251
                if (source.getTable().equals(tableSaisieVenteFacture)) {
252
                    valEcheance.put("ID_SAISIE_VENTE_FACTURE", source.getID());
253
                }
18 ilm 254
 
73 ilm 255
                // ajout de l'ecriture
256
                SQLRow row = valEcheance.insert();
257
                SQLRowValues rowVals = new SQLRowValues(tableMouvement);
258
                rowVals.put("IDSOURCE", row.getID());
259
                rowVals.update(this.idMvt);
18 ilm 260
 
261
        }
262
    }
263
 
73 ilm 264
    private void setDateReglement(SQLRow source, Date d) throws SQLException {
18 ilm 265
        List<SQLRow> sources = new ArrayList<SQLRow>();
266
        if (source.getTable().getName().equalsIgnoreCase("ENCAISSER_MONTANT")) {
267
 
268
            List<SQLRow> rows = source.getReferentRows(source.getTable().getTable("ENCAISSER_MONTANT_ELEMENT"));
269
            for (SQLRow sqlRow : rows) {
270
                SQLRow rowEch = sqlRow.getForeignRow("ID_ECHEANCE_CLIENT");
271
                if (rowEch != null && rowEch.getID() > 1) {
272
                    SQLRow rowMvt = tableMouvement.getRow(MouvementSQLElement.getSourceId(rowEch.getInt("ID_MOUVEMENT")));
273
                    if (rowMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
274
                        sources.add(tableSaisieVenteFacture.getRow(rowMvt.getInt("IDSOURCE")));
275
                    }
276
                }
277
            }
278
 
279
        } else {
280
            sources.add(source);
281
        }
282
        for (SQLRow sqlRow : sources) {
283
            if (sqlRow.getTable().getName().equalsIgnoreCase("SAISIE_VENTE_FACTURE")) {
284
                SQLRowValues rowValsUpdateVF = sqlRow.createEmptyUpdateRow();
285
                rowValsUpdateVF.put("DATE_REGLEMENT", new Timestamp(d.getTime()));
73 ilm 286
                rowValsUpdateVF.update();
18 ilm 287
            }
288
        }
289
 
290
    }
291
 
83 ilm 292
    public void doLettrageAuto(final SQLRowAccessor source, Date dateLettrage) {
293
        // A. On lettre les critures client (facture ET reglement)
294
        // A1. Recherche criture client de facturation
295
 
296
        final SQLRowValues g1 = new SQLRowValues(ecritureTable);
297
        g1.put("DEBIT", null);
298
        final SQLRowValuesListFetcher fetch1 = new SQLRowValuesListFetcher(g1);
299
        fetch1.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
300
            @Override
301
            public SQLSelect transformChecked(SQLSelect input) {
302
                input.setWhere(new Where(ecritureTable.getField("ID_MOUVEMENT"), "=", source.getForeignID("ID_MOUVEMENT")));
303
                input.andWhere(new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", ecrClient.getForeignID("ID_COMPTE_PCE")));
304
                input.andWhere(new Where(ecritureTable.getField("JOURNAL_CODE"), "=", "VE"));
305
                return input;
306
            }
307
 
308
        });
309
        final List<SQLRowValues> rowsEcriture1 = fetch1.fetch();
310
        if (rowsEcriture1.size() != 1) {
311
            System.out.println("critures VE trouves. Erreur");
312
            return;
313
        }
314
        final SQLRowValues rEcriture1 = rowsEcriture1.get(0);
315
        System.out.println("Ecriture vente: " + rEcriture1.getID());
316
        System.out.println("Ecriture paiement: " + this.ecrClient);
317
 
318
        // Récupère lettrage
319
        String codeLettre = NumerotationAutoSQLElement.getNextCodeLettrage();
320
 
321
        // TODO: vérifier somme = 0
322
 
323
        // Met à  jour les 2 écritures
324
        SQLRowValues rowVals = new SQLRowValues(ecritureTable);
325
        rowVals.put("LETTRAGE", codeLettre);
326
        rowVals.put("DATE_LETTRAGE", dateLettrage);
327
        try {
328
            rowVals.update(rEcriture1.getID());
329
            rowVals.update(this.ecrClient.getID());
330
        } catch (SQLException e1) {
331
            e1.printStackTrace();
332
        }
333
 
334
        // Mise à  jour du code de lettrage
335
        SQLElement numElt = Configuration.getInstance().getDirectory().getElement("NUMEROTATION_AUTO");
336
        SQLRowValues rowVals1 = numElt.getTable().getRow(2).createEmptyUpdateRow();
337
        rowVals1.put("CODE_LETTRAGE", codeLettre);
338
        try {
339
            rowVals1.update();
340
        } catch (SQLException e) {
341
            e.printStackTrace();
342
        }
343
    }
344
 
156 ilm 345
    private void paiementCheque(Date dateEch, SQLRow source, PrixTTC ttc, SQLRow rowClient, SQLRow modeRegl, SQLRow mvtSource, boolean avance, String tiers, SQLRowAccessor cptTiers) throws Exception {
18 ilm 346
 
347
        SQLRowValues valCheque = new SQLRowValues(base.getTable("CHEQUE_A_ENCAISSER"));
144 ilm 348
        SQLPreferences prefs = SQLPreferences.getMemCached(valCheque.getTable().getDBRoot());
349
        boolean createEcr = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CREATE_ECR_CHQ, true);
350
 
156 ilm 351
        valCheque.put("ID_CLIENT", rowClient == null ? null : rowClient.getID());
352
        valCheque.put("ID_COMPTE_PCE_TIERS", cptTiers == null ? null : cptTiers.getID());
353
        valCheque.put("TIERS", tiers);
144 ilm 354
        valCheque.put("SANS_VALEUR_ENCAISSEMENT", !createEcr);
83 ilm 355
        final String foreignBanqueFieldName = "ID_" + BanqueSQLElement.TABLENAME;
356
        if (valCheque.getTable().contains(foreignBanqueFieldName))
357
            valCheque.put(foreignBanqueFieldName, modeRegl.getInt(foreignBanqueFieldName));
358
 
18 ilm 359
        valCheque.put("NUMERO", modeRegl.getObject("NUMERO"));
360
        valCheque.put("DATE", modeRegl.getObject("DATE"));
361
        valCheque.put("ETS", modeRegl.getObject("ETS"));
362
        valCheque.put("DATE_VENTE", this.date);
363
        this.idMvt = getNewMouvement("CHEQUE_A_ENCAISSER", 1, mvtSource.getID(), mvtSource.getInt("ID_PIECE"));
364
        valCheque.put("DATE_MIN_DEPOT", dateEch);
365
        valCheque.put("ID_MOUVEMENT", Integer.valueOf(this.idMvt));
366
        valCheque.put("MONTANT", Long.valueOf(ttc.getLongValue()));
367
 
73 ilm 368
        if (valCheque.getInvalid() == null) {
369
            // ajout de l'ecriture
370
            SQLRow row = valCheque.insert();
371
            SQLRowValues rowVals = new SQLRowValues(tableMouvement);
372
            rowVals.put("IDSOURCE", row.getID());
373
            rowVals.update(this.idMvt);
18 ilm 374
        }
73 ilm 375
 
144 ilm 376
        if (createEcr) {
156 ilm 377
            int idCompteClient = cptTiers == null || cptTiers.isUndefined() ? rowClient.getInt("ID_COMPTE_PCE") : cptTiers.getID();
144 ilm 378
            if (avance) {
379
                idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_AVANCE_CLIENT");
380
                if (idCompteClient <= 1) {
381
                    idCompteClient = ComptePCESQLElement.getIdComptePceDefault("AvanceClients");
382
                }
383
            } else {
142 ilm 384
 
144 ilm 385
                // compte Clients
142 ilm 386
 
387
                if (idCompteClient <= 1) {
144 ilm 388
                    idCompteClient = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
389
                    if (idCompteClient <= 1) {
390
                        idCompteClient = ComptePCESQLElement.getIdComptePceDefault("Clients");
391
                    }
142 ilm 392
                }
393
            }
394
 
174 ilm 395
            int idJournal = JournalSQLElement.BANQUES;
396
            if (rowPrefsCompte.getObject("ID_JOURNAL_VALEUR_ENCAISSEMENT") != null && !rowPrefsCompte.isForeignEmpty("ID_JOURNAL_VALEUR_ENCAISSEMENT")) {
397
                idJournal = rowPrefsCompte.getForeignID("ID_JOURNAL_VALEUR_ENCAISSEMENT");
398
            }
399
 
400
            this.putValue("ID_JOURNAL", idJournal);
149 ilm 401
            this.putValue("ID_COMPTE_PCE", idCompteClient);
402
            this.putValue("DEBIT", Long.valueOf(0));
403
            this.putValue("CREDIT", Long.valueOf(ttc.getLongValue()));
142 ilm 404
 
144 ilm 405
            this.ecrClient = ajoutEcriture();
406
 
407
            // compte de reglement, caisse, cheque, ...
408
            int idCompteRegl = rowPrefsCompte.getInt("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT");
409
            if (idCompteRegl <= 1) {
410
                idCompteRegl = ComptePCESQLElement.getIdComptePceDefault("ValeurEncaissement");
411
            }
149 ilm 412
            this.putValue("ID_COMPTE_PCE", Integer.valueOf(idCompteRegl));
413
            this.putValue("DEBIT", Long.valueOf(ttc.getLongValue()));
414
            this.putValue("CREDIT", Long.valueOf(0));
144 ilm 415
 
416
            ajoutEcriture();
142 ilm 417
        }
418
 
18 ilm 419
    }
420
}