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 180
Line 22... Line 22...
22
import java.util.Collection;
22
import java.util.Collection;
23
 
23
 
24
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider {
24
public class TotalCommandeClientProvider implements SpreadSheetCellValueProvider {
25
 
25
 
26
    public enum TypeTotalCommandeClientProvider {
26
    public enum TypeTotalCommandeClientProvider {
27
        HT, TTC;
27
        HT, TTC, TVA;
28
    };
28
    };
29
 
29
 
30
    private final TypeTotalCommandeClientProvider type;
30
    private final TypeTotalCommandeClientProvider type;
31
 
31
 
32
    public TotalCommandeClientProvider(TypeTotalCommandeClientProvider t) {
32
    public TotalCommandeClientProvider(TypeTotalCommandeClientProvider t) {
Line 38... Line 38...
38
        Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
38
        Collection<? extends SQLRowAccessor> rows = row.getReferentRows(row.getTable().getTable("TR_COMMANDE_CLIENT"));
39
        long total = 0;
39
        long total = 0;
40
        for (SQLRowAccessor sqlRowAccessor : rows) {
40
        for (SQLRowAccessor sqlRowAccessor : rows) {
41
            if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
41
            if (!sqlRowAccessor.isForeignEmpty("ID_COMMANDE_CLIENT")) {
42
                SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
42
                SQLRowAccessor rowCmd = sqlRowAccessor.getForeign("ID_COMMANDE_CLIENT");
-
 
43
                if (this.type == TypeTotalCommandeClientProvider.HT) {
-
 
44
                    total += rowCmd.getLong("T_HT");
-
 
45
                } else if (this.type == TypeTotalCommandeClientProvider.TVA) {
-
 
46
                    total += rowCmd.getLong("T_TVA");
43
                total += (this.type == TypeTotalCommandeClientProvider.HT ? rowCmd.getLong("T_HT") : rowCmd.getLong("T_TTC"));
47
                } else if (this.type == TypeTotalCommandeClientProvider.TTC) {
-
 
48
                    total += rowCmd.getLong("T_TTC");
-
 
49
                }
-
 
50
 
44
            }
51
            }
45
        }
52
        }
46
        return new BigDecimal(total).movePointLeft(2);
53
        return new BigDecimal(total).movePointLeft(2);
47
    }
54
    }
48
 
55
 
49
    public static void register() {
56
    public static void register() {
50
        SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT));
57
        SpreadSheetCellValueProviderManager.put("sales.account.command.total", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.HT));
51
        SpreadSheetCellValueProviderManager.put("sales.account.command.total.ttc", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC));
58
        SpreadSheetCellValueProviderManager.put("sales.account.command.total.ttc", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TTC));
-
 
59
        SpreadSheetCellValueProviderManager.put("sales.account.command.total.tva", new TotalCommandeClientProvider(TypeTotalCommandeClientProvider.TVA));
52
    }
60
    }
53
 
61
 
54
}
62
}