if (rowsResponse.isError())
throw new Exception(rowsResponse.getErrorMessage());
java.util.List discounts = ((VOListResponse)rowsResponse).getRows();
// apply header discounts to all taxable incomes...
SaleDocDiscountVO discVO = null;
for(int k=0;k<discounts.size();k++) {
discVO = (SaleDocDiscountVO)discounts.get(k);
if (discVO.getPercDOC05()!=null) {
// the current discount is % discount...
for(int i=0;i<detailItemRows.size();i++) {
detailItemVO = (DetailSaleDocRowVO)detailItemRows.get(i);
detailItemVO.setTaxableIncomeDOC02(
detailItemVO.getTaxableIncomeDOC02().subtract(detailItemVO.getTaxableIncomeDOC02().multiply(discVO.getPercDOC05().divide(new BigDecimal(100),BigDecimal.ROUND_HALF_UP))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
for(int i=0;i<actsRows.size();i++) {
actVO = (SaleDocActivityVO)actsRows.get(i);
actVO.setTaxableIncomeDOC13(
actVO.getTaxableIncomeDOC13().subtract(actVO.getTaxableIncomeDOC13().multiply(discVO.getPercDOC05().divide(new BigDecimal(100),BigDecimal.ROUND_HALF_UP))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
for(int i=0;i<chargesRows.size();i++) {
chargeVO = (SaleDocChargeVO)chargesRows.get(i);
if (chargeVO.getValueDOC03()!=null) {
chargeVO.setTaxableIncomeDOC03(
chargeVO.getTaxableIncomeDOC03().subtract(chargeVO.getTaxableIncomeDOC03().multiply(discVO.getPercDOC05().divide(new BigDecimal(100),BigDecimal.ROUND_HALF_UP))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
}
}
else if (discVO.getValueDOC05()!=null) {
// the current discount is a value discount...
for(int i=0;i<detailItemRows.size();i++) {
detailItemVO = (DetailSaleDocRowVO)detailItemRows.get(i);
detailItemVO.setTaxableIncomeDOC02(
detailItemVO.getTaxableIncomeDOC02().subtract(discVO.getValueDOC05().multiply((BigDecimal)coeff.get(detailItemVO))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
for(int i=0;i<actsRows.size();i++) {
actVO = (SaleDocActivityVO)actsRows.get(i);
actVO.setTaxableIncomeDOC13(
actVO.getTaxableIncomeDOC13().subtract(discVO.getValueDOC05().multiply((BigDecimal)coeff.get(actVO))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
for(int i=0;i<chargesRows.size();i++) {
chargeVO = (SaleDocChargeVO)chargesRows.get(i);
if (chargeVO.getValueDOC03()!=null) {
chargeVO.setTaxableIncomeDOC03(
chargeVO.getTaxableIncomeDOC03().subtract(discVO.getValueDOC05().multiply((BigDecimal)coeff.get(chargeVO))).
setScale(vo.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
}
}