OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 102 | Details | Compare with Previous | 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;
181 ilm 7
import org.openconcerto.modules.common.batchprocessing.BatchField;
102 ilm 8
import org.openconcerto.modules.common.batchprocessing.ReferenceProcessor;
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 TVAProcessor extends ReferenceProcessor {
14
 
181 ilm 15
    public TVAProcessor(BatchField field) {
102 ilm 16
        super(field);
17
    }
18
 
19
    @Override
20
    public void processBeforeUpdate(SQLRowAccessor from, SQLRowValues to) {
21
        // M.A.J. du TTC
22
        final SQLRow r = from.asRow();
23
        final BigDecimal taux = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(to.getForeignID("ID_TAXE")));
24
        final BigDecimal ht = r.getBigDecimal("PV_HT");
25
        final BigDecimal ttc = ConvertDevise.getTtcFromHt(ht, taux, r.getTable().getField("PV_TTC").getType().getDecimalDigits());
26
        to.put("PV_TTC", ttc);
27
    }
28
}