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
102 ilm 1
package org.openconcerto.modules.common.batchprocessing.product;
2
 
3
import java.math.BigDecimal;
4
 
5
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
6
import org.openconcerto.erp.utils.ConvertDevise;
7
import org.openconcerto.modules.common.batchprocessing.NumberProcessor;
8
import org.openconcerto.sql.model.SQLField;
9
import org.openconcerto.sql.model.SQLRow;
10
import org.openconcerto.sql.model.SQLRowAccessor;
11
import org.openconcerto.sql.model.SQLRowValues;
12
 
13
public class TTCProcessor extends NumberProcessor {
14
 
15
    public TTCProcessor(SQLField field) {
16
        super(field);
17
    }
18
 
19
    @Override
20
    public void processBeforeUpdate(SQLRowAccessor from, SQLRowValues to) {
21
        // M.A.J. du HT et du HT métrique
22
        final SQLRow r = from.asRow();
23
        final BigDecimal taux = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(r.getForeignID("ID_TAXE")));
24
        final BigDecimal ttc = to.getBigDecimal("PV_TTC");
25
        final BigDecimal ht = ConvertDevise.getHtFromTtc(ttc, taux, from.getTable().getField("PV_HT").getType().getDecimalDigits());
26
        to.put("PV_HT", ht);
27
        to.put("PRIX_METRIQUE_VT_1", ht);
28
    }
29
}