OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
149 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
 /*
15
 * Créé le 25 oct. 2012
16
 */
17
package org.openconcerto.erp.generationDoc.provider;
18
 
19
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
20
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
21
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
22
import org.openconcerto.sql.model.SQLRowAccessor;
23
 
24
public class ConditionsReglementDetailsProvider implements SpreadSheetCellValueProvider {
25
 
26
    public ConditionsReglementDetailsProvider() {
27
 
28
    }
29
 
30
    @Override
31
    public Object getValue(SpreadSheetCellValueContext context) {
32
        SQLRowAccessor row = context.getRow();
33
        String r = "";
34
        final SQLRowAccessor foreignRow = row.getForeign("ID_MODE_REGLEMENT");
35
        if (foreignRow != null) {
36
            if (foreignRow.getForeign("ID_TYPE_REGLEMENT") != null) {
37
                SQLRowAccessor rowT = foreignRow.getForeign("ID_TYPE_REGLEMENT");
38
                if (!rowT.getString("NOM").equalsIgnoreCase("Indéfini")) {
39
                    r = rowT.getString("NOM");
40
                }
41
            }
42
            int ajours = foreignRow.getInt("AJOURS");
43
            int njour = foreignRow.getInt("LENJOUR");
44
 
45
            if (ajours == 0 && njour == 0) {
46
                if (foreignRow.getBoolean("COMPTANT") != null && !foreignRow.getBoolean("COMPTANT")) {
47
                    r = "Date de facture";
48
                } else {
49
                    r = "Comptant";
50
                }
51
            } else {
52
 
53
                if (ajours != 0) {
54
 
55
                    r = "à" + ajours + ((ajours > 1) ? " jours" : " jour");
56
                }
57
                if (njour > 0 && njour < 31) {
58
                    r += " le " + njour;
59
                } else {
60
                    if (njour == 0) {
61
                        r += " date de facture";
62
                    } else {
63
                        r += " fin de mois";
64
                    }
65
                }
66
            }
67
        }
68
        return r;
69
    }
70
 
71
    public static void register() {
72
        SpreadSheetCellValueProviderManager.put("conditions.paiement.details", new ConditionsReglementDetailsProvider());
73
 
74
    }
75
 
76
}