OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | 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.core.finance.accounting.report;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
177 ilm 17
import org.openconcerto.erp.element.objet.Compte;
25 ilm 18
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
18 ilm 19
import org.openconcerto.erp.generationDoc.SheetInterface;
20
import org.openconcerto.erp.preferences.PrinterNXProps;
21
import org.openconcerto.sql.Configuration;
177 ilm 22
import org.openconcerto.sql.model.SQLBase;
18 ilm 23
import org.openconcerto.sql.model.SQLRow;
132 ilm 24
import org.openconcerto.sql.model.SQLRowListRSH;
18 ilm 25
import org.openconcerto.sql.model.SQLSelect;
26
import org.openconcerto.sql.model.SQLTable;
27
import org.openconcerto.sql.model.Where;
28
import org.openconcerto.utils.GestionDevise;
29
 
30
import java.text.DateFormat;
177 ilm 31
import java.util.ArrayList;
18 ilm 32
import java.util.Calendar;
33
import java.util.Date;
34
import java.util.HashMap;
35
import java.util.List;
132 ilm 36
import java.util.Map;
18 ilm 37
 
38
import org.apache.commons.dbutils.handlers.ArrayListHandler;
39
 
40
public class BalanceSheet extends SheetInterface {
41
 
42
    private static int debutFill, endFill;
43
    private final static SQLTable tableEcriture = base.getTable("ECRITURE");
44
    private final static SQLTable tableCompte = base.getTable("COMPTE_PCE");
132 ilm 45
    private boolean centralClient, centralFourn, centralFournImmo;
142 ilm 46
    private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
47
    private final DateFormat dateFormatEcr = DateFormat.getDateInstance(DateFormat.SHORT);
25 ilm 48
    public static String TEMPLATE_ID = "Balance";
49
    public static String TEMPLATE_PROPERTY_NAME = "LocationBalance";
132 ilm 50
    private Date dateAu, dateDu;
18 ilm 51
    private String compteDeb, compteEnd;
52
 
53
    public static void setSize(int debut, int fin) {
54
        debutFill = debut;
55
        endFill = fin;
56
    }
57
 
58
    static {
59
        setSize(7, 69);
60
 
61
    }
62
 
25 ilm 63
    @Override
64
    protected String getYear() {
65
        return "";
66
    }
18 ilm 67
 
25 ilm 68
    @Override
69
    public String getTemplateId() {
70
        return TEMPLATE_ID;
18 ilm 71
    }
72
 
177 ilm 73
    public BalanceSheet(Date du, Date au, String compteDeb, String compteEnd, boolean centralClient, boolean centralFourn, boolean centralFournImmo, boolean displayAll) {
18 ilm 74
        super();
75
 
76
        Calendar cal = Calendar.getInstance();
77
        cal.setTime(au);
78
 
79
        // Initialisation des Valeur
80
        this.nbRowsPerPage = 72;
81
        this.printer = PrinterNXProps.getInstance().getStringProperty("BalancePrinter");
82
        this.modele = "Balance.ods";
25 ilm 83
 
84
        final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
85
 
86
        // this.locationOO = storage.getDocumentOutputDirectory(TEMPLATE_ID);
87
        // this.locationPDF = storage.getPDFOutputDirectory(TEMPLATE_ID);
18 ilm 88
        this.dateAu = au;
132 ilm 89
        this.dateDu = du;
177 ilm 90
        this.viewMode = displayAll;
18 ilm 91
        this.compteDeb = compteDeb;
92
        this.compteEnd = compteEnd;
93
        this.centralClient = centralClient;
94
        this.centralFourn = centralFourn;
132 ilm 95
        this.centralFournImmo = centralFournImmo;
18 ilm 96
        createMap();
97
    }
98
 
99
    private void makeEntete(int rowDeb) {
100
        SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
101
        this.mCell.put("A" + rowDeb, rowSociete.getObject("NOM"));
102
        this.mCell.put("D" + rowDeb, "Edition du " + dateFormat.format(new Date()));
103
        // this.mCell.put("D" + (rowDeb + 2), "Grand livre");
104
        System.err.println("MAKE ENTETE");
105
    }
106
 
107
    private void makePiedPage(int row) {
132 ilm 108
        if (this.dateDu == null) {
109
            this.mCell.put("C" + row, "Balance au " + dateFormatEcr.format(this.dateAu));
110
        } else {
111
            this.mCell.put("C" + row, "Balance du " + dateFormatEcr.format(this.dateDu) + " au " + dateFormatEcr.format(this.dateAu));
112
        }
18 ilm 113
        this.mCell.put("B" + row, "Du compte " + this.compteDeb + " à " + this.compteEnd);
114
    }
115
 
116
    private void makeSousTotalClasse(int row, long debit, long credit, String classe) {
117
        this.mCell.put("A" + row, "Total classe " + classe);
118
        this.mCell.put("B" + row, "");
119
 
120
        this.mCell.put("C" + row, new Double(GestionDevise.currencyToString(debit, false)));
121
        this.mCell.put("D" + row, new Double(GestionDevise.currencyToString(credit, false)));
122
        this.mCell.put("E" + row, new Double(GestionDevise.currencyToString(debit - credit, false)));
123
 
124
        this.mapStyleRow.put(new Integer(row), "Titre 1");
125
    }
126
 
177 ilm 127
    private boolean viewMode = true;
128
 
18 ilm 129
    protected void createMap() {
130
        int posLine = 1;
131
        int firstLine = 1;
132
        this.nbPage = 0;
133
        long totalDebit, totalCredit, sousTotalDebit, sousTotalCredit;
134
 
135
        totalDebit = 0;
136
        totalCredit = 0;
137
        sousTotalDebit = 0;
138
        sousTotalCredit = 0;
139
 
140
        long totalDebitClient = 0;
141
        long totalCreditClient = 0;
142
 
143
        long totalDebitFourn = 0;
144
        long totalCreditFourn = 0;
145
 
132 ilm 146
        long totalDebitFournImmo = 0;
147
        long totalCreditFournImmo = 0;
148
 
18 ilm 149
        String numCptClient = "411";
150
        String nomCptClient = "Clients";
151
        String numCptFourn = "401";
152
        String nomCptFourn = "Fournisseurs";
132 ilm 153
        String numCptFournImmo = "404";
154
        String nomCptFournImmo = "Fournisseurs d'immobilisations";
18 ilm 155
        boolean addedLine = false;
132 ilm 156
        boolean addedLineImmo = false;
157
        boolean addedLineFourn = false;
18 ilm 158
        int j = 0;
159
        String classe = "";
132 ilm 160
 
177 ilm 161
        if (viewMode) {
162
            getBalance();
132 ilm 163
 
177 ilm 164
            for (int i = 0; i < this.vecteurCompte.size();) {
18 ilm 165
 
177 ilm 166
                System.err.println("START NEW PAGE; POS : " + posLine);
18 ilm 167
 
177 ilm 168
                /***************************************************************************************
169
                 * ENTETE
170
                 **************************************************************************************/
171
                makeEntete(posLine);
172
                posLine += debutFill - 1;
18 ilm 173
 
177 ilm 174
                /***************************************************************************************
175
                 * CONTENU
176
                 **************************************************************************************/
177
                for (j = 0; (j < endFill - debutFill + 1) && i < this.vecteurCompte.size(); j++) {
178
                    Compte compte = this.vecteurCompte.get(i);
18 ilm 179
 
177 ilm 180
                    String numeroCpt = compte.getNumero();
181
                    String nomCpt = compte.getNom();
18 ilm 182
 
177 ilm 183
                    long deb = compte.getTotalDebit();
184
                    long cred = compte.getTotalCredit();
18 ilm 185
 
186
                    totalCredit += cred;
187
                    sousTotalCredit += cred;
188
                    totalDebit += deb;
189
                    sousTotalDebit += deb;
190
 
177 ilm 191
                    this.mCell.put("A" + posLine, numeroCpt);
192
                    this.mCell.put("B" + posLine, nomCpt);
193
                    this.mCell.put("C" + posLine, new Double(GestionDevise.currencyToString(deb, false)));
194
                    this.mCell.put("D" + posLine, new Double(GestionDevise.currencyToString(cred, false)));
195
                    this.mCell.put("E" + posLine, new Double(GestionDevise.currencyToString(deb - cred, false)));
196
 
197
                    if (compte.getSousCompte().isEmpty()) {
198
                        this.mapStyleRow.put(new Integer(posLine), "Normal");
199
                    } else {
200
                        this.mapStyleRow.put(new Integer(posLine), "Titre 1");
18 ilm 201
                    }
177 ilm 202
                    i++;
18 ilm 203
 
177 ilm 204
                    posLine++;
205
                }
18 ilm 206
 
177 ilm 207
                if (i >= this.vecteurCompte.size() && j < endFill - debutFill + 1) {
18 ilm 208
 
177 ilm 209
                    makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
210
                }
132 ilm 211
 
177 ilm 212
                posLine = firstLine + endFill;
213
                /*
214
                 * if (this.mapStyleRow.get(new Integer(posLine - 1)) != null) {
215
                 * this.mapStyleRow.put(new Integer(posLine - 1), "Titre 2"); }
216
                 */
18 ilm 217
 
177 ilm 218
                // Total
219
                this.mCell.put("C" + posLine, ((totalDebit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit, false))));
220
                this.mCell.put("D" + posLine, ((totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalCredit, false))));
221
                this.mCell.put("E" + posLine, (totalDebit - totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit - totalCredit, false)));
18 ilm 222
 
177 ilm 223
                posLine += 2;
18 ilm 224
 
177 ilm 225
                // bas de page
226
                makePiedPage(posLine);
227
 
18 ilm 228
                posLine++;
177 ilm 229
                firstLine = posLine;
230
                this.nbPage++;
231
 
232
                // if (i >= this.vecteurCompte.size() && j >= (endFill - debutFill + 1)) {
233
                //
234
                // makeEntete(posLine);
235
                // posLine += debutFill - 1;
236
                //
237
                // makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
238
                //
239
                // this.nbPage++;
240
                // }
241
 
18 ilm 242
            }
177 ilm 243
        } else {
18 ilm 244
 
177 ilm 245
            this.mapReplace = new HashMap();
246
            this.mCell = new HashMap();
247
            this.mapStyleRow = new HashMap();
18 ilm 248
 
177 ilm 249
            SQLSelect sel = new SQLSelect();
250
            sel.addSelect(tableCompte.getField("ID"));
251
            sel.addSelect(tableEcriture.getField("DEBIT"), "SUM");
252
            sel.addSelect(tableEcriture.getField("CREDIT"), "SUM");
253
 
254
            Where w = (new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
255
            if (dateDu == null) {
256
                w = (new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
18 ilm 257
            }
258
 
177 ilm 259
            if (compteDeb.equals(this.compteEnd)) {
260
                w = w.and(new Where(tableCompte.getField("NUMERO"), "=", this.compteDeb));
261
            } else {
262
                w = w.and(new Where(tableCompte.getField("NUMERO"), (Object) this.compteDeb, (Object) this.compteEnd));
263
            }
18 ilm 264
 
177 ilm 265
            // FIXME use flag cloture
266
            Where wCloture = new Where(tableEcriture.getField("NOM"), "NOT LIKE", "Fermeture du compte%");
267
            wCloture = wCloture.and(new Where(tableEcriture.getField("DATE"), "=", this.dateAu));
268
            wCloture = wCloture.or(new Where(tableEcriture.getField("DATE"), "<", this.dateAu));
269
            w = w.and(wCloture);
18 ilm 270
 
177 ilm 271
            sel.setWhere(w);
18 ilm 272
 
177 ilm 273
            String req = sel.asString() + " AND \"ECRITURE\".\"ID_COMPTE_PCE\" = \"COMPTE_PCE\".\"ID\" GROUP BY  \"COMPTE_PCE\".\"NUMERO\", \"COMPTE_PCE\".\"ID\" ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
18 ilm 274
 
177 ilm 275
            System.err.println(req);
18 ilm 276
 
177 ilm 277
            List l = (List) base.getDataSource().execute(req, new ArrayListHandler());
18 ilm 278
 
177 ilm 279
            SQLSelect selCompte = new SQLSelect();
280
            selCompte.addSelectStar(tableCompte);
281
            List<SQLRow> compteRows = SQLRowListRSH.execute(selCompte);
282
            Map<Integer, SQLRow> mapCompte = new HashMap<Integer, SQLRow>();
283
            for (SQLRow sqlRow : compteRows) {
284
                mapCompte.put(sqlRow.getID(), sqlRow);
285
            }
286
 
287
            for (int i = 0; i < l.size();) {
288
 
289
                System.err.println("START NEW PAGE; POS : " + posLine);
290
 
291
                /***************************************************************************************
292
                 * ENTETE
293
                 **************************************************************************************/
18 ilm 294
                makeEntete(posLine);
295
                posLine += debutFill - 1;
296
 
177 ilm 297
                /***************************************************************************************
298
                 * CONTENU
299
                 **************************************************************************************/
300
                for (j = 0; (j < endFill - debutFill + 1) && i < l.size(); j++) {
301
                    Object[] o = (Object[]) l.get(i);
302
                    int idCpt = Integer.parseInt(o[0].toString());
303
                    // SQLRow rowCpt = tableCompte.getRow(idCpt);
304
                    SQLRow rowCpt = mapCompte.get(idCpt);
18 ilm 305
 
177 ilm 306
                    String numeroCpt = rowCpt.getString("NUMERO").trim();
307
                    String nomCpt = rowCpt.getString("NOM");
308
                    // Changement de classe de compte
309
                    if (classe.trim().length() != 0 && numeroCpt.length() > 0 && !classe.trim().equalsIgnoreCase(numeroCpt.substring(0, 1))) {
310
 
311
                        makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
312
 
313
                        sousTotalCredit = 0;
314
                        sousTotalDebit = 0;
315
                        classe = numeroCpt.substring(0, 1);
316
 
317
                    } else {
318
                        if (classe.trim().length() == 0 && numeroCpt.trim().length() > 0) {
319
                            classe = numeroCpt.substring(0, 1);
320
                        }
321
 
322
                        long deb = new Double(o[1].toString()).longValue();
323
                        long cred = new Double(o[2].toString()).longValue();
324
 
325
                        totalCredit += cred;
326
                        sousTotalCredit += cred;
327
                        totalDebit += deb;
328
                        sousTotalDebit += deb;
329
 
330
                        // Centralisation compte client
331
                        if (this.centralClient && (numeroCpt.equalsIgnoreCase("411") || numeroCpt.startsWith("411"))) {
332
                            totalDebitClient += deb;
333
                            totalCreditClient += cred;
334
                            deb = totalDebitClient;
335
                            cred = totalCreditClient;
336
                        }
337
                        // Centralisation compte fournisseur immo
338
                        else if (this.centralFournImmo && (numeroCpt.equalsIgnoreCase("404") || numeroCpt.startsWith("404"))) {
339
                            totalDebitFournImmo += deb;
340
                            totalCreditFournImmo += cred;
341
                            deb = totalDebitFournImmo;
342
                            cred = totalCreditFournImmo;
343
                        }
344
                        // Centralisation compte fournisseur
345
                        else if (this.centralFourn && (numeroCpt.equalsIgnoreCase("401") || numeroCpt.startsWith("401"))) {
346
                            totalDebitFourn += deb;
347
                            totalCreditFourn += cred;
348
                            deb = totalDebitFourn;
349
                            cred = totalCreditFourn;
350
                        }
351
 
352
                        if (this.centralClient && !numeroCpt.equalsIgnoreCase("411") && numeroCpt.startsWith("411")) {
353
                            if (addedLine || !this.centralFournImmo) {
354
                                posLine--;
355
                                j--;
356
                            } else {
357
                                addedLine = true;
358
                            }
359
                            this.mCell.put("A" + posLine, numCptClient);
360
                            this.mCell.put("B" + posLine, nomCptClient);
361
                        } else if (this.centralFourn && !numeroCpt.equalsIgnoreCase("401") && numeroCpt.startsWith("401")) {
362
 
363
                            if (addedLineFourn) {
364
                                posLine--;
365
                                j--;
366
                            } else {
367
                                addedLineFourn = true;
368
                            }
369
 
370
                            this.mCell.put("A" + posLine, numCptFourn);
371
                            this.mCell.put("B" + posLine, nomCptFourn);
372
                        } else if (this.centralFournImmo && !numeroCpt.equalsIgnoreCase("404") && numeroCpt.startsWith("404")) {
373
                            if (addedLineImmo || !this.centralFourn) {
374
                                posLine--;
375
                                j--;
376
                            } else {
377
                                addedLineImmo = true;
378
                            }
379
 
380
                            this.mCell.put("A" + posLine, numCptFournImmo);
381
                            this.mCell.put("B" + posLine, nomCptFournImmo);
382
                        } else {
383
                            this.mCell.put("A" + posLine, numeroCpt);
384
                            this.mCell.put("B" + posLine, nomCpt);
385
                        }
386
 
387
                        this.mCell.put("C" + posLine, new Double(GestionDevise.currencyToString(deb, false)));
388
                        this.mCell.put("D" + posLine, new Double(GestionDevise.currencyToString(cred, false)));
389
                        this.mCell.put("E" + posLine, new Double(GestionDevise.currencyToString(deb - cred, false)));
390
 
391
                        this.mapStyleRow.put(new Integer(posLine), "Normal");
392
                        i++;
393
                    }
394
 
395
                    posLine++;
396
                }
397
 
398
                if (i >= l.size() && j < endFill - debutFill + 1) {
399
 
400
                    makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
401
                }
402
 
403
                posLine = firstLine + endFill;
404
                /*
405
                 * if (this.mapStyleRow.get(new Integer(posLine - 1)) != null) {
406
                 * this.mapStyleRow.put(new Integer(posLine - 1), "Titre 2"); }
407
                 */
408
 
409
                // Total
410
                this.mCell.put("C" + posLine, ((totalDebit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit, false))));
411
                this.mCell.put("D" + posLine, ((totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalCredit, false))));
412
                this.mCell.put("E" + posLine, (totalDebit - totalCredit == 0) ? new Double(0) : new Double(GestionDevise.currencyToString(totalDebit - totalCredit, false)));
413
 
414
                posLine += 2;
415
 
416
                // bas de page
417
                makePiedPage(posLine);
418
 
419
                posLine++;
420
                firstLine = posLine;
18 ilm 421
                this.nbPage++;
177 ilm 422
 
423
                if (i >= l.size() && j >= (endFill - debutFill + 1)) {
424
 
425
                    makeEntete(posLine);
426
                    posLine += debutFill - 1;
427
 
428
                    makeSousTotalClasse(posLine, sousTotalDebit, sousTotalCredit, classe);
429
 
430
                    this.nbPage++;
431
                }
432
 
18 ilm 433
            }
434
        }
435
 
436
        // on conserve la page d'origine du model
437
        if (this.nbPage > 0) {
438
            this.nbPage--;
439
        }
440
    }
177 ilm 441
 
442
    private long totalDebitBalance = 0;
443
    private long totalCreditBalance = 0;
444
    private List<Compte> vecteurCompte = new ArrayList<Compte>();
445
 
446
    public void getBalance() {
447
 
448
        // Compte numero -- totalDebit
449
        Map<Number, Long> mapCompteDebit = new HashMap<Number, Long>();
450
        Map<Number, Long> mapCompteCredit = new HashMap<Number, Long>();
451
        List<Compte> comptes = new ArrayList<Compte>();
452
        this.totalDebitBalance = 0;
453
        this.totalCreditBalance = 0;
454
 
455
        SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
456
        SQLTable compteTable = base.getTable("COMPTE_PCE");
457
        SQLTable ecritureTable = base.getTable("ECRITURE");
458
 
459
        SQLSelect sel = new SQLSelect();
460
 
461
        // On recupere le solde des comptes
462
        sel.addSelect(compteTable.getField("ID"));
463
        sel.addSelect(ecritureTable.getField("DEBIT"), "SUM");
464
        sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
465
        sel.addSelect(compteTable.getField("NUMERO"));
466
        sel.setDistinct(true);
467
        Where w = (new Where(tableEcriture.getField("DATE"), this.dateDu, this.dateAu));
468
        if (dateDu == null) {
469
            w = (new Where(tableEcriture.getField("DATE"), "<=", this.dateAu));
470
        }
471
        sel.setWhere(w.and(new Where(compteTable.getField("ID"), "=", ecritureTable.getField("ID_COMPTE_PCE"))));
472
 
473
        String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\"  ORDER BY \"COMPTE_PCE\".\"NUMERO\"";
474
 
475
        System.out.println(req);
476
 
477
        Object ob = base.getDataSource().execute(req, new ArrayListHandler());
478
 
479
        List myList = (List) ob;
480
 
481
        if (myList.size() != 0) {
482
 
483
            for (int i = 0; i < myList.size(); i++) {
484
 
485
                Object[] tmp = (Object[]) myList.get(i);
486
 
487
                mapCompteDebit.put((Number) tmp[0], Long.parseLong(tmp[1].toString()));
488
                mapCompteCredit.put((Number) tmp[0], Long.parseLong(tmp[2].toString()));
489
            }
490
        }
491
 
492
        // Création du vecteur balance
493
        sel = new SQLSelect();
494
 
495
        sel.addSelect(compteTable.getKey());
496
        sel.addSelect(compteTable.getField("NUMERO"));
497
        sel.addSelect(compteTable.getField("NOM"));
498
 
499
        sel.addRawOrder("\"COMPTE_PCE\".\"NUMERO\"");
500
 
501
        String reqCompte = sel.asString();
502
        System.out.println(req);
503
 
504
        Object obCompte = base.getDataSource().execute(reqCompte, new ArrayListHandler());
505
 
506
        List myListCompte = (List) obCompte;
507
 
508
        if (myListCompte.size() != 0) {
509
 
510
            for (int i = 0; i < myListCompte.size(); i++) {
511
 
512
                Object[] tmp = (Object[]) myListCompte.get(i);
513
                System.err.println("Compte " + tmp[1].toString().trim());
514
 
515
                long totalDebit = 0;
516
                long totalCredit = 0;
517
                if (mapCompteDebit.get(tmp[0]) != null) {
518
                    totalDebit = Long.parseLong(mapCompteDebit.get(tmp[0]).toString());
519
                }
520
 
521
                if (mapCompteCredit.get(tmp[0]) != null) {
522
                    totalCredit = Long.parseLong(mapCompteCredit.get(tmp[0]).toString());
523
                }
524
 
525
                this.totalDebitBalance += totalDebit;
526
                this.totalCreditBalance += totalCredit;
527
 
528
                List<String> sousCompte = new ArrayList<>();
529
                for (int j = i + 1; j < (myListCompte.size() - 1); j++) {
530
                    Object[] tmpNext = (Object[]) myListCompte.get(j);
531
                    if (tmpNext[1].toString().trim().startsWith(tmp[1].toString().trim())) {
532
                        System.err.println("Sous Compte " + tmpNext[1].toString().trim());
533
                        sousCompte.add(tmpNext[1].toString().trim());
534
                        if (mapCompteDebit.get(tmpNext[0]) != null) {
535
                            totalDebit += Long.parseLong(mapCompteDebit.get(tmpNext[0]).toString());
536
                        }
537
 
538
                        if (mapCompteCredit.get(tmpNext[0]) != null) {
539
                            totalCredit += Long.parseLong(mapCompteCredit.get(tmpNext[0]).toString());
540
                        }
541
                    } else {
542
                        break;
543
                    }
544
                }
545
                if ((totalDebit != 0.0) || (totalCredit != 0.0)) {
546
                    Compte cpt = new Compte(((Number) tmp[0]).intValue(), tmp[1].toString(), tmp[2].toString(), "", totalDebit, totalCredit);
547
                    cpt.addSousCompte(sousCompte);
548
                    comptes.add(cpt);
549
                }
550
            }
551
        }
552
 
553
        this.vecteurCompte = comptes;
554
    }
18 ilm 555
}