java.util.List taxableIncomes = ((VOListResponse)res).getRows();
TaxableIncomeVO tVO = null;
JournalRowVO jrVO = null;
BigDecimal totalVat = new BigDecimal(0);
Hashtable vats = new Hashtable(); // collections of: vat code,VatRowVO
VatRowVO vatVO = null;
for(int i=0;i<taxableIncomes.size();i++) {
tVO = (TaxableIncomeVO)taxableIncomes.get(i);
totalVat = totalVat.add(tVO.getVatValue());
jrVO = new JournalRowVO();
jrVO.setCompanyCodeSys01ACC06(jhVO.getCompanyCodeSys01ACC05());
if (tVO.getRowType()==tVO.ITEM_ROW_TYPE) {
jrVO.setAccountCodeAcc02ACC06(itemsAccountCodeAcc02);
jrVO.setAccountCodeACC06(itemsAccountCodeAcc02);
}
else if (tVO.getRowType()==tVO.ACTIVITY_ROW_TYPE) {
jrVO.setAccountCodeAcc02ACC06(actAccountCodeAcc02);
jrVO.setAccountCodeACC06(actAccountCodeAcc02);
}
else if (tVO.getRowType()==tVO.CHARGE_ROW_TYPE) {
jrVO.setAccountCodeAcc02ACC06(chargesAccountCodeAcc02);
jrVO.setAccountCodeACC06(chargesAccountCodeAcc02);
}
jrVO.setAccountCodeTypeACC06(ApplicationConsts.ACCOUNT_TYPE_ACCOUNT);
if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
jrVO.setCreditAmountACC06(tVO.getTaxableIncome().negate());
else
jrVO.setCreditAmountACC06(tVO.getTaxableIncome());
jrVO.setCreditAmountACC06(CurrencyConversionUtils.convertCurrencyToCurrency(jrVO.getCreditAmountACC06(),conv));
jrVO.setDescriptionACC06("");
jrVO.setItemYearAcc05ACC06(jhVO.getItemYearACC05());
jrVO.setProgressiveAcc05ACC06(jhVO.getProgressiveACC05());
jhVO.addJournalRow(jrVO);
// prepare vat row for sale vat register...
vatVO = (VatRowVO)vats.get(tVO.getVatCode());
if (vatVO==null) {
vatVO = new VatRowVO();
vatVO.setCompanyCodeSys01ACC07(docVO.getCompanyCodeSys01DOC01());
if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_DESK_DOC_TYPE))
vatVO.setRegisterCodeAcc04ACC07(ApplicationConsts.VAT_REGISTER_RETAIL);
else
vatVO.setRegisterCodeAcc04ACC07(ApplicationConsts.VAT_REGISTER_SELLING);
vatVO.setTaxableIncomeACC07(tVO.getTaxableIncome());
vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
vatVO.setVatCodeACC07(tVO.getVatCode());
vatVO.setVatDateACC07(new java.sql.Date(System.currentTimeMillis()));
vatVO.setVatDescriptionACC07(tVO.getVatDescription());
if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
vatVO.setVatValueACC07(tVO.getVatValue().negate());
else
vatVO.setVatValueACC07(tVO.getVatValue());
vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));
vatVO.setVatYearACC07(new BigDecimal(Calendar.getInstance().get(Calendar.YEAR)));
}
else {
vatVO.setTaxableIncomeACC07(vatVO.getTaxableIncomeACC07().add(tVO.getTaxableIncome()));
vatVO.setTaxableIncomeACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getTaxableIncomeACC07(),conv));
if (docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_CREDIT_NOTE_DOC_TYPE))
vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()).negate());
else
vatVO.setVatValueACC07(vatVO.getVatValueACC07().add(tVO.getVatValue()));
vatVO.setVatValueACC07(CurrencyConversionUtils.convertCurrencyToCurrency(vatVO.getVatValueACC07(),conv));
}
vats.put(tVO.getVatCode(),vatVO);
}
// add total vat value to the accounting item...