Search in sources :

Example 1 with AccountingDto

use of org.mifos.platform.accounting.AccountingDto 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)

Example 2 with AccountingDto

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

the class AccountingDataController method showAccountingDataFor.

@RequestMapping("renderAccountingData.ftl")
public final ModelAndView showAccountingDataFor(@RequestParam(value = FROM_DATE) String paramFromDate, @RequestParam(value = TO_DATE) String paramToDate) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
    LocalDate fromDate = fmt.parseDateTime(paramFromDate).toLocalDate();
    LocalDate toDate = fmt.parseDateTime(paramToDate).toLocalDate();
    Boolean hasAlreadyRanQuery = Boolean.FALSE;
    String fileName = null;
    List<AccountingDto> accountingData = new ArrayList<AccountingDto>();
    try {
        fileName = accountingService.getExportOutputFileName(fromDate, toDate).replace(".xml", "");
        hasAlreadyRanQuery = accountingService.hasAlreadyRanQuery(fromDate, toDate);
        accountingData = accountingService.getExportDetails(fromDate, toDate);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    ModelAndView mav = new ModelAndView("renderAccountingData");
    List<BreadCrumbsLinks> breadcrumbs = new AdminBreadcrumbBuilder().withLink("accounting.viewaccountingexports", "renderAccountingDataCacheInfo.ftl").withLink(fileName, "").build();
    mav.addObject("breadcrumbs", breadcrumbs);
    mav.addObject("accountingData", accountingData);
    mav.addObject("hasAlreadyRanQuery", hasAlreadyRanQuery);
    mav.addObject("fileName", fileName);
    mav.addObject("fromDate", fromDate);
    mav.addObject("toDate", toDate);
    return mav;
}
Also used : ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) BreadCrumbsLinks(org.mifos.ui.core.controller.BreadCrumbsLinks) AccountingDto(org.mifos.platform.accounting.AccountingDto) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) LocalDate(org.joda.time.LocalDate) AdminBreadcrumbBuilder(org.mifos.ui.core.controller.AdminBreadcrumbBuilder) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with AccountingDto

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

the class AccountingDaoTest method shouldCallQueryAndReturnData.

@Test
@Ignore
public void shouldCallQueryAndReturnData() {
    List<AccountingDto> accountData = accountingDao.getAccountingDataByDate(new LocalDate(2010, 8, 10), new LocalDate(2010, 8, 10));
    Assert.assertNull(accountData);
}
Also used : AccountingDto(org.mifos.platform.accounting.AccountingDto) LocalDate(org.joda.time.LocalDate) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with AccountingDto

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

the class TallyXMLOutputTest method testAccoutingDataOutPut.

/**
     * failing on windows -suspect it could be a carraige return or something like that.
     */
@Ignore
@Test
public void testAccoutingDataOutPut() throws Exception {
    String fileName = "Mifos Accounting Export 2010-08-10 to 2010-08-10.xml";
    File file = MifosResourceUtil.getClassPathResourceAsResource("org/mifos/platform/accounting/tally/2010-08-10 to 2010-08-10").getFile();
    String expected = FileUtils.readFileToString(MifosResourceUtil.getClassPathResourceAsResource("org/mifos/platform/accounting/tally/" + fileName).getFile());
    List<AccountingDto> accountingData = cacheManager.accountingDataFromCache(file);
    String tallyOutput = TallyXMLGenerator.getTallyXML(accountingData, fileName);
    Assert.assertEquals(expected, tallyOutput);
}
Also used : AccountingDto(org.mifos.platform.accounting.AccountingDto) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with AccountingDto

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

the class TallyMessageBuilderTest method testTallyMessageBuilder.

@Test
public void testTallyMessageBuilder() throws TallyMessageBuilderException {
    AccountingDto voucherEntry = new AccountingDto("branch", "2010-04-20", "Payment", "4365", "GL CODE NAME", "4", "6");
    new TallyMessageBuilder(VoucherType.JOURNAL, "branch").withVoucherDate(new Date()).addDebitEntry(voucherEntry).addCreditEntry(voucherEntry).build();
}
Also used : AccountingDto(org.mifos.platform.accounting.AccountingDto) Date(java.util.Date) Test(org.junit.Test)

Aggregations

AccountingDto (org.mifos.platform.accounting.AccountingDto)12 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 LocalDate (org.joda.time.LocalDate)4 Date (java.util.Date)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 Ignore (org.junit.Ignore)2 AccountingRuntimeException (org.mifos.platform.accounting.AccountingRuntimeException)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 StringTokenizer (java.util.StringTokenizer)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)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