OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 182
Line 19... Line 19...
19
 
19
 
20
public class AdresseFullClientValueProvider extends AdresseClientProvider {
20
public class AdresseFullClientValueProvider extends AdresseClientProvider {
21
 
21
 
22
    private final int type;
22
    private final int type;
23
    private final boolean withName;
23
    private final boolean withName;
-
 
24
    private final boolean noCountry;
24
 
25
 
25
    public AdresseFullClientValueProvider(int type, boolean withName) {
26
    public AdresseFullClientValueProvider(int type, boolean withName, boolean noCountry) {
26
        this.type = type;
27
        this.type = type;
27
        this.withName = withName;
28
        this.withName = withName;
-
 
29
        this.noCountry = noCountry;
28
    }
30
    }
29
 
31
 
30
    @Override
32
    @Override
31
    public Object getValue(SpreadSheetCellValueContext context) {
33
    public Object getValue(SpreadSheetCellValueContext context) {
32
        final SQLRowAccessor r = getAdresse(context.getRow(), this.type);
34
        final SQLRowAccessor r = getAdresse(context.getRow(), this.type);
33
        String result = "";
35
        String result = "";
34
        if (this.withName) {
36
        if (this.withName) {
35
            result = context.getRow().getForeign("ID_CLIENT").getString("NOM") + "\n";
37
            result = context.getRow().getForeign("ID_CLIENT").getString("NOM") + "\n\n";
36
        }
38
        }
37
        result = getFormattedAddress(r, result);
39
        result = getFormattedAddress(r, result, !this.noCountry);
38
 
40
 
39
        return result;
41
        return result;
40
    }
42
    }
41
 
43
 
42
    public static String getFormattedAddress(final SQLRowAccessor rAddress, String prefix) {
44
    public static String getFormattedAddress(final SQLRowAccessor rAddress, String prefix) {
-
 
45
        return getFormattedAddress(rAddress, prefix, true);
-
 
46
    }
-
 
47
 
-
 
48
    public static String getFormattedAddress(final SQLRowAccessor rAddress, String prefix, boolean withCountry) {
43
        String result = prefix;
49
        String result = prefix;
44
        if (getStringTrimmed(rAddress, "LIBELLE").length() > 0) {
50
        boolean notEmptyLib = getStringTrimmed(rAddress, "LIBELLE").length() > 0;
-
 
51
        if (notEmptyLib) {
45
            result = getStringTrimmed(rAddress, "LIBELLE") + "\n";
52
            result = getStringTrimmed(rAddress, "LIBELLE") + "\n";
46
        }
53
        }
47
        if (getStringTrimmed(rAddress, "DEST").length() > 0) {
54
        boolean notEmptyDest = getStringTrimmed(rAddress, "DEST").length() > 0;
-
 
55
        if (notEmptyDest) {
48
            result = getStringTrimmed(rAddress, "DEST") + "\n";
56
            result = getStringTrimmed(rAddress, "DEST") + "\n";
49
        }
57
        }
50
        if (getStringTrimmed(rAddress, "RUE").length() > 0) {
58
        boolean notEmptyRue = getStringTrimmed(rAddress, "RUE").length() > 0;
-
 
59
        if (notEmptyRue) {
51
            result += getStringTrimmed(rAddress, "RUE") + "\n";
60
            result += getStringTrimmed(rAddress, "RUE") + "\n";
52
        }
61
        }
53
        result += "\n" + getStringTrimmed(rAddress, "CODE_POSTAL");
62
        result += notEmptyDest && notEmptyLib && notEmptyLib ? ("\n" + getStringTrimmed(rAddress, "CODE_POSTAL")) : getStringTrimmed(rAddress, "CODE_POSTAL");
54
        result += " ";
63
        result += " ";
55
        if (rAddress.getTable().contains("DISTRICT")) {
64
        if (rAddress.getTable().contains("DISTRICT")) {
56
            result += getStringTrimmed(rAddress, "DISTRICT") + " ";
65
            result += getStringTrimmed(rAddress, "DISTRICT") + " ";
57
        }
66
        }
58
        result += getStringTrimmed(rAddress, "VILLE");
67
        result += getStringTrimmed(rAddress, "VILLE");
Line 62... Line 71...
62
            if (cedex.length() > 0) {
71
            if (cedex.length() > 0) {
63
                result += " " + cedex;
72
                result += " " + cedex;
64
            }
73
            }
65
        }
74
        }
66
        if (rAddress.getTable().contains("PROVINCE")) {
75
        if (rAddress.getTable().contains("PROVINCE")) {
-
 
76
            String province = getStringTrimmed(rAddress, "PROVINCE");
-
 
77
            boolean department = rAddress.getTable().contains("DEPARTEMENT");
-
 
78
            if (province.length() > 0 || (department && getStringTrimmed(rAddress, "DEPARTEMENT").length() > 0)) {
67
            result += "\n";
79
                result += "\n";
-
 
80
            }
68
            if (getStringTrimmed(rAddress, "PROVINCE").length() > 0) {
81
            if (province.length() > 0) {
-
 
82
 
69
                result += getStringTrimmed(rAddress, ("PROVINCE")) + " ";
83
                result += getStringTrimmed(rAddress, ("PROVINCE")) + " ";
70
            }
84
            }
71
 
85
 
72
            if (rAddress.getTable().contains("DEPARTEMENT")) {
86
            if (department && getStringTrimmed(rAddress, "DEPARTEMENT").length() > 0) {
-
 
87
 
73
                result += getStringTrimmed(rAddress, "DEPARTEMENT");
88
                result += getStringTrimmed(rAddress, "DEPARTEMENT");
74
            }
89
            }
75
        }
90
        }
76
 
91
 
77
        if (getStringTrimmed(rAddress, "PAYS").length() > 0) {
92
        if (withCountry && getStringTrimmed(rAddress, "PAYS").length() > 0) {
78
            result += "\n" + getStringTrimmed(rAddress, "PAYS");
93
            result += "\n" + getStringTrimmed(rAddress, "PAYS");
79
        }
94
        }
80
        return result;
95
        return result;
81
    }
96
    }
82
 
97
 
Line 86... Line 101...
86
            return "";
101
            return "";
87
        return result.trim();
102
        return result.trim();
88
    }
103
    }
89
 
104
 
90
    public static void register() {
105
    public static void register() {
91
        SpreadSheetCellValueProviderManager.put("address.customer.full", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, false));
106
        SpreadSheetCellValueProviderManager.put("address.customer.full", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, false, false));
92
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, false));
107
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, false, false));
93
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, false));
108
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, false, false));
-
 
109
        SpreadSheetCellValueProviderManager.put("address.customer.full.nocountry", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, false, true));
-
 
110
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full.nocountry", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, false, true));
-
 
111
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full.nocountry", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, false, true));
94
        SpreadSheetCellValueProviderManager.put("address.customer.full.withname", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, true));
112
        SpreadSheetCellValueProviderManager.put("address.customer.full.withname", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, true, false));
95
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full.withname", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, true));
113
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full.withname", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, true, false));
96
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full.withname", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, true));
114
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full.withname", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, true, false));
-
 
115
        SpreadSheetCellValueProviderManager.put("address.customer.full.withname.nocountry", new AdresseFullClientValueProvider(ADRESSE_PRINCIPALE, true, true));
-
 
116
        SpreadSheetCellValueProviderManager.put("address.customer.invoice.full.withname.nocountry", new AdresseFullClientValueProvider(ADRESSE_FACTURATION, true, true));
-
 
117
        SpreadSheetCellValueProviderManager.put("address.customer.shipment.full.withname.nocountry", new AdresseFullClientValueProvider(ADRESSE_LIVRAISON, true, true));
97
    }
118
    }
98
}
119
}