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