Search in sources :

Example 1 with VoucherType

use of org.mifos.platform.accounting.VoucherType in project head by mifos.

the class TallyMessageGenerator method generateTallyMessages.

public final List<TallyMessage> generateTallyMessages(List<AccountingDto> accountingData) throws TallyMessageBuilderException, ParseException {
    List<TallyMessage> tallyMessages = new ArrayList<TallyMessage>();
    for (int i = 1; i < accountingData.size(); i++) {
        List<AccountingDto> voucher = new ArrayList<AccountingDto>();
        voucher.add(accountingData.get(i - 1));
        AccountingDto prevLine = accountingData.get(i - 1);
        AccountingDto currentLine = accountingData.get(i);
        while (i < accountingData.size() && prevLine.getBranchName().equals(currentLine.getBranchName()) && prevLine.getVoucherDate().equals(currentLine.getVoucherDate()) && prevLine.getVoucherType().equals(currentLine.getVoucherType())) {
            voucher.add(currentLine);
            i++;
            prevLine = accountingData.get(i - 1);
            if (i < accountingData.size()) {
                currentLine = accountingData.get(i);
            }
        }
        VoucherType voucherType = getVoucherType(voucher.get(0).getVoucherType());
        TallyMessageBuilder builder = new TallyMessageBuilder(voucherType, voucher.get(0).getBranchName());
        builder.withVoucherDate(getVoucherDate(voucher.get(0).getVoucherDate()));
        for (AccountingDto voucherEntry : voucher) {
            builder.addCreditEntry(voucherEntry);
            builder.addDebitEntry(voucherEntry);
        }
        tallyMessages.add(builder.build());
    }
    return tallyMessages;
}
Also used : TallyMessage(org.mifos.platform.accounting.tally.message.TallyMessage) TallyMessageBuilder(org.mifos.platform.accounting.tally.message.TallyMessageBuilder) ArrayList(java.util.ArrayList) AccountingDto(org.mifos.platform.accounting.AccountingDto) VoucherType(org.mifos.platform.accounting.VoucherType)

Aggregations

ArrayList (java.util.ArrayList)1 AccountingDto (org.mifos.platform.accounting.AccountingDto)1 VoucherType (org.mifos.platform.accounting.VoucherType)1 TallyMessage (org.mifos.platform.accounting.tally.message.TallyMessage)1 TallyMessageBuilder (org.mifos.platform.accounting.tally.message.TallyMessageBuilder)1