Search in sources :

Example 1 with AccountingRuntimeException

use of org.mifos.platform.accounting.AccountingRuntimeException 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 2 with AccountingRuntimeException

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

the class AccountingDataCacheManager method accountingDataFromCache.

public List<AccountingDto> accountingDataFromCache(File file) {
    BufferedReader br;
    try {
        br = new BufferedReader(new FileReader(file));
    } catch (FileNotFoundException e) {
        LOGGER.error(file.toString(), e);
        throw new AccountingRuntimeException(file.toString(), e);
    }
    String line = null;
    // skip first line
    try {
        br.readLine();
    } catch (IOException e) {
        LOGGER.error("skipping header line", e);
        throw new AccountingRuntimeException("skipping header line", e);
    }
    List<AccountingDto> accountingData = new ArrayList<AccountingDto>();
    try {
        while ((line = br.readLine()) != null) {
            accountingData.add(parseLine(line));
        }
        br.close();
    } catch (IOException e) {
        throw new AccountingRuntimeException("reading line" + line, e);
    }
    return accountingData;
}
Also used : BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException) AccountingDto(org.mifos.platform.accounting.AccountingDto) AccountingRuntimeException(org.mifos.platform.accounting.AccountingRuntimeException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)2 AccountingDto (org.mifos.platform.accounting.AccountingDto)2 AccountingRuntimeException (org.mifos.platform.accounting.AccountingRuntimeException)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1