OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 25 | 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
 *
182 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
18 ilm 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.generationDoc.gestcomm;
15
 
16
import org.openconcerto.erp.generationDoc.SheetInterface;
17
import org.openconcerto.erp.generationDoc.SheetXml;
18
import org.openconcerto.sql.model.SQLRow;
19
import org.openconcerto.sql.model.SQLTable;
20
import org.openconcerto.utils.GestionDevise;
21
import org.openconcerto.utils.Tuple2;
22
 
23
import java.util.Date;
24
import java.util.HashMap;
25
import java.util.List;
26
 
27
public class ReleveChequeEmisSheet extends SheetInterface {
28
 
29
    private static final SQLTable tableCheque = base.getTable("CHEQUE_FOURNISSEUR");
30
    private static final SQLTable tableFourn = base.getTable("FOURNISSEUR");
31
    private List<Integer> listeCheques;
32
 
33
    public ReleveChequeEmisSheet(List<Integer> idCheques) {
34
        this.mapReplace = new HashMap();
35
        this.mapStyleRow = new HashMap();
36
        this.mCell = new HashMap();
37
        this.row = tableCheque.getRow(idCheques.get(0));
38
        // super(idCheques.get(0), tableCheque);
39
        this.listeCheques = idCheques;
40
        init();
41
        createMap();
42
    }
43
 
25 ilm 44
    public static final String TEMPLATE_ID = "ReleveChequeEmis";
45
    public static final String TEMPLATE_PROPERTY_NAME = "LocationReleveCheque";
18 ilm 46
 
47
    private void init() {
48
        this.modele = "ReleveChequeEmis.ods";
49
    }
50
 
25 ilm 51
    @Override
52
    public String getTemplateId() {
53
        return TEMPLATE_ID;
54
    }
55
 
56
    @Override
57
    protected String getYear() {
58
        return "";
59
    }
60
 
18 ilm 61
    protected void createMap() {
62
 
63
        long montantTotal = 0;
64
        // Element Cheques
65
        int pos = 5;
66
        for (Integer i : this.listeCheques) {
67
 
68
            SQLRow rowTmp = tableCheque.getRow(i.intValue());
69
            SQLRow rowFournTmp = tableFourn.getRow(rowTmp.getInt("ID_FOURNISSEUR"));
70
 
71
            Object nomTmp = rowFournTmp.getObject("NOM");
72
            this.mCell.put("B" + pos, nomTmp);
73
 
74
            Long montant = (Long) rowTmp.getObject("MONTANT");
75
            montantTotal += montant;
76
            this.mCell.put("L" + pos, new Double(GestionDevise.currencyToString(montant.longValue(), false)));
77
 
78
            pos++;
79
        }
80
 
81
        // Date
82
        this.mCell.put("C45", (Date) this.row.getObject("DATE_DECAISSE"));
83
 
84
        // Total
85
        this.mCell.put("L45", new Double(GestionDevise.currencyToString(montantTotal, false)));
182 ilm 86
        this.nbPage = 1;
18 ilm 87
    }
88
}