OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Rev 21 | 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.core.sales.invoice.report;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.generationDoc.AbstractSheetXml;
18
import org.openconcerto.erp.generationDoc.SheetXml;
19
import org.openconcerto.erp.preferences.PrinterNXProps;
20
import org.openconcerto.sql.Configuration;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLTable;
23
import org.openconcerto.utils.Tuple2;
24
 
25
import java.io.File;
26
import java.util.Calendar;
27
import java.util.Date;
28
import java.util.List;
29
 
30
public class VenteFactureXmlSheet extends AbstractSheetXml {
31
 
32
    private String startName;
33
 
34
    private static final Tuple2<String, String> tuple = Tuple2.create("LocationFacture", "Factures");
35
 
36
    public static Tuple2<String, String> getTuple2Location() {
37
        return tuple;
38
    }
39
 
19 ilm 40
    @Override
41
    public String getReference() {
42
        return this.row.getString("NOM");
43
    }
44
 
45
    @Override
46
    public SQLRow getRowLanguage() {
47
        SQLRow rowClient = this.row.getForeignRow("ID_CLIENT");
48
        if (rowClient.getTable().contains("ID_LANGUE")) {
49
            return rowClient.getForeignRow("ID_LANGUE");
50
        } else {
51
            return super.getRowLanguage();
52
        }
53
    }
54
 
18 ilm 55
    public VenteFactureXmlSheet(SQLRow row) {
56
        super(row);
57
        this.printer = PrinterNXProps.getInstance().getStringProperty("FacturePrinter");
58
        this.elt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
59
        Calendar cal = Calendar.getInstance();
60
        cal.setTime((Date) row.getObject("DATE"));
61
        this.locationOO = SheetXml.getLocationForTuple(tuple, false) + File.separator + cal.get(Calendar.YEAR);
62
        this.locationPDF = SheetXml.getLocationForTuple(tuple, true) + File.separator + cal.get(Calendar.YEAR);
63
        if (row.getBoolean("COMPLEMENT")) {
64
            this.startName = "FactureComplement_";
65
            this.modele = "VenteFactureComplement";
66
        } else {
67
            if (row.getBoolean("ACOMPTE")) {
68
                this.startName = "FactureAcompte_";
69
                this.modele = "VenteFactureAcompte";
70
            } else {
71
                this.startName = "Facture_";
72
                this.modele = "VenteFacture";
73
            }
74
        }
75
    }
76
 
77
    public String getFileName() {
78
 
79
        return getValidFileName(this.startName + this.row.getString("NUMERO"));
80
    }
81
}