Search in sources :

Example 6 with AccountingDto

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);
}
Also used : StringTokenizer(java.util.StringTokenizer) AccountingDto(org.mifos.platform.accounting.AccountingDto)

Example 7 with AccountingDto

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();
}
Also used : FileNotFoundException(java.io.FileNotFoundException) AccountingDto(org.mifos.platform.accounting.AccountingDto) File(java.io.File) AccountingRuntimeException(org.mifos.platform.accounting.AccountingRuntimeException) PrintWriter(java.io.PrintWriter)

Example 8 with AccountingDto

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());
    }
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) AccountingDto(org.mifos.platform.accounting.AccountingDto) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 9 with AccountingDto

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>"));
}
Also used : ArrayList(java.util.ArrayList) AccountingDto(org.mifos.platform.accounting.AccountingDto) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with AccountingDto

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