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;
}
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;
}
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);
}
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);
}
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();
}
Aggregations