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.core.sales.invoice.report;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.generationDoc.SheetInterface;
18
import org.openconcerto.erp.model.PrixTTC;
19
import org.openconcerto.sql.Configuration;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLTable;
22
 
19 ilm 23
import java.text.DateFormat;
24
import java.util.Date;
25
import java.util.HashMap;
26
 
18 ilm 27
public class VenteComptoirSheet extends SheetInterface {
28
 
29
    private static final SQLTable tableComptoir = base.getTable("SAISIE_VENTE_COMPTOIR");
30
    private static final SQLTable tableClient = base.getTable("CLIENT");
31
    private static final SQLTable tableAdresse = base.getTable("ADRESSE");
32
    private static final SQLTable tableArticle = base.getTable("ARTICLE");
33
    private static final SQLTable tableTaxe = base.getTable("TAXE");
34
    private static final SQLTable tableModeRegl = base.getTable("MODE_REGLEMENT");
35
    private static final SQLTable tableTypeRegl = base.getTable("TYPE_REGLEMENT");
25 ilm 36
    public static final String TEMPLATE_ID = "VenteComptoir";
37
    public static final String TEMPLATE_PROPERTY_NAME = "LocationVenteComptoir";
18 ilm 38
 
39
    public VenteComptoirSheet(int idFact) {
40
        super(idFact, tableComptoir);
41
    }
42
 
43
    public VenteComptoirSheet(SQLRow rowSaisie) {
44
        super(rowSaisie);
45
    }
46
 
25 ilm 47
    @Override
48
    protected String getYear() {
49
        return "";
50
    }
51
 
52
    @Override
53
    public String getTemplateId() {
54
        return TEMPLATE_ID;
55
    }
56
 
18 ilm 57
    protected void createMap() {
58
        // TODO Auto-generated method stub
59
        this.mCell = new HashMap();
60
 
61
        // Infos societe
62
        SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
63
        this.mCell.put("A1", rowSociete.getObject("TYPE") + " " + rowSociete.getObject("NOM"));
64
        this.mCell.put("A2", rowSociete.getObject("ADRESSE"));
65
        this.mCell.put("A3", "Tél  " + rowSociete.getObject("NUM_TEL"));
66
        this.mCell.put("A4", "Fax " + rowSociete.getObject("NUM_FAX"));
67
 
68
        // infos facture
69
        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
70
        this.mCell.put("A7", this.row.getObject("NOM"));
71
        this.mCell.put("F7", "Le " + dateFormat.format((Date) this.row.getObject("DATE")));
72
 
73
        // infos client
74
        SQLRow rowClient = tableClient.getRow(this.row.getInt("ID_CLIENT"));
75
        this.mCell.put("B9", rowClient.getObject("NOM"));
76
        SQLRow rowAdrCli = tableAdresse.getRow(rowClient.getInt("ID_ADRESSE"));
77
        this.mCell.put("B10", rowAdrCli.getObject("RUE") + "\n" + rowAdrCli.getObject("CODE_POSTAL") + " " + rowAdrCli.getObject("VILLE"));
78
 
79
        // mode de reglement
80
        SQLRow rowRegl = tableModeRegl.getRow(this.row.getInt("ID_MODE_REGLEMENT"));
81
        SQLRow rowTypeRegl = tableTypeRegl.getRow(rowRegl.getInt("ID_TYPE_REGLEMENT"));
82
        this.mCell.put("F10", rowTypeRegl.getObject("NOM"));
83
 
84
        // Infos article
85
        SQLRow rowArticle = tableArticle.getRow(this.row.getInt("ID_ARTICLE"));
86
        this.mCell.put("A13", rowArticle.getObject("CODE"));
87
        this.mCell.put("B13", rowArticle.getObject("NOM"));
88
        this.mCell.put("C13", new Integer(1));
89
        this.mCell.put("D13", rowArticle.getObject("PV_HT"));
90
 
91
        SQLRow rowTaxe = tableTaxe.getRow(this.row.getInt("ID_TAXE"));
92
        this.mCell.put("E13", rowTaxe.getObject("TAUX"));
93
        PrixTTC ttc = new PrixTTC(this.row.getFloat("MONTANT_TTC"));
94
        this.mCell.put("F13", new Float(ttc.calculHT(rowTaxe.getFloat("TAUX") / 100.0)));
95
        this.mCell.put("G13", this.row.getObject("MONTANT_TTC"));
96
 
97
        this.mCell.put("G30", new Float(ttc.calculHT(rowTaxe.getFloat("TAUX") / 100.0)));
98
        this.mCell.put("G31", new Float(ttc.calculTVA(rowTaxe.getFloat("TAUX") / 100.0)));
99
        this.mCell.put("G32", new Float(ttc.getValue()));
100
 
101
        this.mCell.put("A35", this.row.getObject("INFOS"));
102
    }
25 ilm 103
 
182 ilm 104
    @Override
105
    public int getNbPage() {
106
        return 1;
107
    }
18 ilm 108
}