OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 180
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 /*
14
 /*
15
 * Créé le 25 oct. 2012
15
 * Créé le 25 oct. 2012
16
 */
16
 */
17
package org.openconcerto.erp.generationDoc.provider;
17
package org.openconcerto.erp.generationDoc.provider;
18
 
18
 
19
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
19
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueContext;
20
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
20
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProvider;
21
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
21
import org.openconcerto.erp.generationDoc.SpreadSheetCellValueProviderManager;
22
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.sql.model.SQLRowAccessor;
23
 
23
 
24
public class ConditionsReglementDetailsProvider implements SpreadSheetCellValueProvider {
24
public class ConditionsReglementDetailsProvider implements SpreadSheetCellValueProvider {
25
 
25
 
26
    public ConditionsReglementDetailsProvider() {
26
    public ConditionsReglementDetailsProvider() {
27
 
27
 
28
    }
28
    }
29
 
29
 
30
    @Override
30
    @Override
31
    public Object getValue(SpreadSheetCellValueContext context) {
31
    public Object getValue(SpreadSheetCellValueContext context) {
32
        SQLRowAccessor row = context.getRow();
32
        SQLRowAccessor row = context.getRow();
33
        String r = "";
33
        String r = "";
34
        final SQLRowAccessor foreignRow = row.getForeign("ID_MODE_REGLEMENT");
34
        final SQLRowAccessor foreignRow = row.getForeign("ID_MODE_REGLEMENT");
35
        if (foreignRow != null) {
35
        if (foreignRow != null) {
36
            if (foreignRow.getForeign("ID_TYPE_REGLEMENT") != null) {
36
            if (foreignRow.getForeign("ID_TYPE_REGLEMENT") != null) {
37
                SQLRowAccessor rowT = foreignRow.getForeign("ID_TYPE_REGLEMENT");
37
                SQLRowAccessor rowT = foreignRow.getForeign("ID_TYPE_REGLEMENT");
38
                if (!rowT.getString("NOM").equalsIgnoreCase("Indéfini")) {
38
                if (!rowT.getString("NOM").equalsIgnoreCase("Indéfini")) {
39
                    r = rowT.getString("NOM");
39
                    r = rowT.getString("NOM");
40
                }
40
                }
41
            }
41
            }
42
            int ajours = foreignRow.getInt("AJOURS");
42
            int ajours = foreignRow.getInt("AJOURS");
43
            int njour = foreignRow.getInt("LENJOUR");
43
            int njour = foreignRow.getInt("LENJOUR");
44
 
44
 
45
            if (ajours == 0 && njour == 0) {
45
            if (ajours == 0 && njour == 0) {
46
                if (foreignRow.getBoolean("COMPTANT") != null && !foreignRow.getBoolean("COMPTANT")) {
46
                if (foreignRow.getBoolean("COMPTANT") != null && !foreignRow.getBoolean("COMPTANT")) {
47
                    r = "Date de facture";
47
                    r += " Date de facture";
48
                } else {
48
                } else {
49
                    r = "Comptant";
49
                    r += " Comptant";
50
                }
50
                }
51
            } else {
51
            } else {
52
 
52
 
53
                if (ajours != 0) {
53
                if (ajours != 0) {
54
 
54
 
55
                    r = "à" + ajours + ((ajours > 1) ? " jours" : " jour");
55
                    r += " à " + ajours + ((ajours > 1) ? " jours" : " jour");
56
                }
56
                }
57
                if (njour > 0 && njour < 31) {
57
                if (njour > 0 && njour < 31) {
58
                    r += " le " + njour;
58
                    r += " le " + njour;
59
                } else {
59
                } else {
60
                    if (njour == 0) {
60
                    if (njour == 0) {
61
                        r += " date de facture";
61
                        r += " date de facture";
62
                    } else {
62
                    } else {
63
                        r += " fin de mois";
63
                        r += " fin de mois";
64
                    }
64
                    }
65
                }
65
                }
66
            }
66
            }
67
        }
67
        }
68
        return r;
68
        return r;
69
    }
69
    }
70
 
70
 
71
    public static void register() {
71
    public static void register() {
72
        SpreadSheetCellValueProviderManager.put("conditions.paiement.details", new ConditionsReglementDetailsProvider());
72
        SpreadSheetCellValueProviderManager.put("conditions.paiement.details", new ConditionsReglementDetailsProvider());
73
 
73
 
74
    }
74
    }
75
 
75
 
76
}
76
}