OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 174
Line 29... Line 29...
29
    private int idTaxe;
29
    private int idTaxe;
30
    private BigDecimal priceHT;
30
    private BigDecimal priceHT;
31
    private String barCode = "empty barcode";
31
    private String barCode = "empty barcode";
32
    private String code = "";
32
    private String code = "";
33
    private final int id;
33
    private final int id;
-
 
34
    // unité de vente (null si à la pièce)
-
 
35
    private String salesUnit;
34
    private static Map<String, Article> codes = new HashMap<String, Article>();
36
    private static Map<String, Article> codes = new HashMap<String, Article>();
35
 
37
 
36
    public Article(Categorie s1, String string, int id) {
38
    public Article(Categorie s1, String string, int id) {
37
        this.s = s1;
39
        this.s = s1;
38
        this.id = id;
40
        this.id = id;
Line 46... Line 48...
46
        this.priceTTC = a.priceTTC;
48
        this.priceTTC = a.priceTTC;
47
        this.idTaxe = a.idTaxe;
49
        this.idTaxe = a.idTaxe;
48
        this.priceHT = a.priceHT;
50
        this.priceHT = a.priceHT;
49
        this.barCode = a.barCode;
51
        this.barCode = a.barCode;
50
        this.id = a.id;
52
        this.id = a.id;
-
 
53
        this.salesUnit = a.salesUnit;
51
        this.s.addArticle(this);
54
        this.s.addArticle(this);
52
    }
55
    }
53
 
56
 
54
    public boolean isAdditionalCopyRequested() {
57
    public boolean isAdditionalCopyRequested() {
55
        return additionalCopyRequested;
58
        return this.additionalCopyRequested;
56
    }
59
    }
57
 
60
 
58
    public void setAdditionalCopyRequested(boolean additionalCopyRequested) {
61
    public void setAdditionalCopyRequested(boolean additionalCopyRequested) {
59
        this.additionalCopyRequested = additionalCopyRequested;
62
        this.additionalCopyRequested = additionalCopyRequested;
60
    }
63
    }
Line 112... Line 115...
112
        return this.s;
115
        return this.s;
113
    }
116
    }
114
 
117
 
115
    @Override
118
    @Override
116
    public String toString() {
119
    public String toString() {
117
        return "Article:" + this.name + " " + this.priceTTC + " cents" + "(HT:" + priceHT + ")";
120
        return "Article:" + this.name + " " + this.priceTTC + " cents" + "(HT:" + this.priceHT + ") " + getSalesUnit();
118
    }
121
    }
119
 
122
 
120
    public static Article getArticleFromBarcode(String code) {
123
    public static Article getArticleFromBarcode(String code) {
121
        return codes.get(code);
124
        return codes.get(code);
122
    }
125
    }
Line 137... Line 140...
137
        this.priceHT = ht;
140
        this.priceHT = ht;
138
        this.priceTTC = computePriceWithTax(ht, this.getIdTaxe());
141
        this.priceTTC = computePriceWithTax(ht, this.getIdTaxe());
139
    }
142
    }
140
 
143
 
141
    public static BigDecimal computePriceWithTax(BigDecimal ht, int idTaxe) {
144
    public static BigDecimal computePriceWithTax(BigDecimal ht, int idTaxe) {
142
        final BigDecimal tax = new BigDecimal(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
145
        final BigDecimal tax = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
143
        return ht.multiply(tax).setScale(2, RoundingMode.HALF_UP);
146
        return ht.multiply(tax).setScale(2, RoundingMode.HALF_UP);
144
    }
147
    }
145
 
148
 
146
    public static BigDecimal computePriceWithoutTax(BigDecimal ttc, int idTaxe) {
149
    public static BigDecimal computePriceWithoutTax(BigDecimal ttc, int idTaxe) {
147
        final BigDecimal tax = new BigDecimal(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
150
        final BigDecimal tax = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(idTaxe)).movePointLeft(2).add(BigDecimal.ONE);
148
        return ttc.divide(tax, DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP);
151
        return ttc.divide(tax, DecimalUtils.HIGH_PRECISION).setScale(6, RoundingMode.HALF_UP);
149
    }
152
    }
-
 
153
 
-
 
154
    public void setSalesUnit(String name) {
-
 
155
        this.salesUnit = name;
-
 
156
    }
-
 
157
 
-
 
158
    public String getSalesUnit() {
-
 
159
        return this.salesUnit;
-
 
160
    }
150
}
161
}