use of org.mifos.platform.accounting.AccountingDto in project head by mifos.
the class AccountingDataCacheManager method parseLine.
private AccountingDto parseLine(String line) {
StringTokenizer st = new StringTokenizer(line, ";");
String branchname = st.nextToken().trim();
String voucherdate = st.nextToken().trim();
String vouchertype = st.nextToken().trim();
String glcode = st.nextToken().trim();
String glname = st.nextToken().trim();
String debit = parseNumber(st.nextToken().trim());
String credit = parseNumber(st.nextToken().trim());
return new AccountingDto(branchname, voucherdate, vouchertype, glcode, glname, debit, credit);
}
use of org.mifos.platform.accounting.AccountingDto in project head by mifos.
the class AccountingDataCacheManager method writeAccountingDataToCache.
public final void writeAccountingDataToCache(List<AccountingDto> accountingData, String cacheFileName) {
File file = new File(getAccoutingDataCachePath() + cacheFileName);
PrintWriter out = null;
try {
out = new PrintWriter(file);
} catch (FileNotFoundException e) {
LOGGER.error(file.toString(), e);
throw new AccountingRuntimeException(file.toString(), e);
}
out.println("branchname;voucherdate;vouchertype;glcode;glname;debit;credit");
for (AccountingDto instance : accountingData) {
out.println(instance.toString());
}
out.flush();
out.close();
}
use of org.mifos.platform.accounting.AccountingDto in project head by mifos.
the class AccountingDataCacheManagerTest method testAccoutingDataFromCache.
@Test
public void testAccoutingDataFromCache() throws Exception {
List<AccountingDto> data = new ArrayList<AccountingDto>();
data.add(new AccountingDto("branch", "2010-10-12", "RECEIPT", "234324", "GLCODE NAME", "5", "546"));
data.add(new AccountingDto("branch", "2010-10-12", "RECEIPT", "234324", "GLCODE NAME", "5", "546"));
LocalDate date = new LocalDate(2010, 10, 12);
String cacheFileName = cacheManager.getCacheFileName(date, date);
cacheManager.writeAccountingDataToCache(data, cacheFileName);
List<AccountingDto> accountingData = cacheManager.getExportDetails(cacheFileName);
Assert.assertEquals(2, accountingData.size());
DecimalFormat df = new DecimalFormat("#.0", new DecimalFormatSymbols(Locale.ENGLISH));
for (AccountingDto dto : accountingData) {
Assert.assertEquals("branch;2010-10-12;RECEIPT;234324;GLCODE NAME;" + df.format(5.0) + ";" + df.format(546.0), dto.toString());
Assert.assertEquals("GLCODE NAME", dto.getGlCodeName());
}
}
use of org.mifos.platform.accounting.AccountingDto in project head by mifos.
the class AccountingServiceTest method shouldGetTallyOutputFromCache.
@Test
public void shouldGetTallyOutputFromCache() throws Exception {
when(cacheManager.getTallyOutputFileName(any(LocalDate.class), any(LocalDate.class))).thenReturn("DummyFileName");
List<AccountingDto> dataFromCache = new ArrayList<AccountingDto>();
dataFromCache.add(new AccountingDto("branch", "2010-10-12", "RECEIPT", "234324", "GLCODE NAME", "5", "546"));
dataFromCache.add(new AccountingDto("branch", "2010-10-12", "RECEIPT", "15249", "GLCODE NAME", "6", "544"));
when(cacheManager.isAccountingDataAlreadyInCache(any(String.class))).thenReturn(true);
when(accountingDao.getAccountingDataByDate(any(LocalDate.class), any(LocalDate.class))).thenReturn(dataFromCache);
when(cacheManager.getExportDetails(any(String.class))).thenReturn(dataFromCache);
String output = accountingService.getExportOutput(new LocalDate(2010, 8, 10), new LocalDate(2010, 8, 10));
Assert.assertTrue("Should be receipt type", output.contains("VCHTYPE=\"Receipt\""));
Assert.assertTrue("Date should be set to 20101012", output.contains("<DATE>20101012</DATE>"));
}
use of org.mifos.platform.accounting.AccountingDto in project head by mifos.
the class TallyMessageBuilderTest method testTallyMessageBuilderNegativeAmountCredit.
@Test(expected = TallyMessageBuilderException.class)
public void testTallyMessageBuilderNegativeAmountCredit() 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()).addCreditEntry(voucherEntry).build();
}
Aggregations