Exemplo n.º 1
0
 public BigDecimal calculate(Formula fomular, UnitDataGroup unitDataGroup) {
   BigDecimal result = fomular.getConstant();
   for (Multinomial multinomial : fomular.getMultinomials()) {
     UnitData unit = unitDataGroup.getUnitData(multinomial.getCode());
     if (unit == null || unit == UnitData.DUMMY) {
       return null;
     } else {
       result = result.add(multinomial.getCoefficient().multiply(unit.getPrice()));
     }
   }
   return result.setScale(2, RoundingMode.FLOOR);
 }
Exemplo n.º 2
0
 public BigDecimal calculate(Formula fomular, KLineGroup group) {
   BigDecimal result = fomular.getConstant();
   for (Multinomial multinomial : fomular.getMultinomials()) {
     KLine kLine = group.getkLineMap().get(multinomial.getCode());
     if (kLine == null) {
       return null;
     } else {
       result = result.add(multinomial.getCoefficient().multiply(kLine.getEndPrice()));
     }
   }
   return result.setScale(2, RoundingMode.FLOOR);
 }