use of edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork in project cu-kfs by CU-CommunityApps.
the class AccountReversionProcessImpl method processBalances.
/**
* Given a list of balances, this method generates the origin entries for the organization reversion/carry forward process, and saves those
* to an initialized origin entry group
*
* @param balances an iterator of balances to process; each balance returned by the iterator will be processed by this method
*/
public void processBalances(Iterator<Balance> balances) {
boolean skipToNextUnitOfWork = false;
unitOfWork = new ReversionUnitOfWork();
unitOfWork.setCategories(categoryList);
int brokenCodeCount = 0;
Balance bal;
while (balances.hasNext()) {
bal = balances.next();
// we only want AC balance types so we will limit them here rather than in the query used for both Account Reversion and Organization Reversion.
if (!bal.getBalanceTypeCode().equals(KFSConstants.BALANCE_TYPE_ACTUAL)) {
continue;
}
String acctNumber = bal.getAccountNumber();
if (LOG.isDebugEnabled()) {
LOG.debug("BALANCE SELECTED: " + bal.getUniversityFiscalYear() + bal.getChartOfAccountsCode() + bal.getAccountNumber() + bal.getSubAccountNumber() + bal.getObjectCode() + bal.getSubObjectCode() + bal.getBalanceTypeCode() + bal.getObjectTypeCode() + " " + bal.getAccountLineAnnualBalanceAmount().add(bal.getBeginningBalanceLineAmount()));
}
try {
if (!unitOfWork.isInitialized()) {
unitOfWork.setFields(bal.getChartOfAccountsCode(), bal.getAccountNumber(), bal.getSubAccountNumber());
retrieveCurrentReversionAndAccount(bal);
} else // just gonna leave this broken code here....
if (!unitOfWork.wouldHold(bal)) {
if (!skipToNextUnitOfWork) {
calculateTotals();
List<OriginEntryFull> originEntriesToWrite = generateOutputOriginEntries();
summarizeOriginEntries(originEntriesToWrite);
if (holdGeneratedOriginEntries) {
generatedOriginEntries.addAll(originEntriesToWrite);
}
int recordsWritten = writeOriginEntries(originEntriesToWrite);
incrementCount("recordsWritten", recordsWritten);
getReversionUnitOfWorkService().save(unitOfWork);
}
unitOfWork.setFields(bal.getChartOfAccountsCode(), bal.getAccountNumber(), bal.getSubAccountNumber());
retrieveCurrentReversionAndAccount(bal);
brokenCodeCount++;
skipToNextUnitOfWork = false;
}
if (skipToNextUnitOfWork) {
// if there is no org reversion or an org reversion detail is missing or the balances are off for
continue;
// this unit of work,
// just skip all the balances until we change unit of work
}
calculateBucketAmounts(bal);
} catch (FatalErrorException fee) {
LOG.info(fee.getMessage());
skipToNextUnitOfWork = true;
}
}
System.out.println("Total broken code balances processed: " + brokenCodeCount);
// save the final unit of work
if (!skipToNextUnitOfWork && getBalancesSelected() > 0) {
try {
calculateTotals();
List<OriginEntryFull> originEntriesToWrite = generateOutputOriginEntries();
summarizeOriginEntries(originEntriesToWrite);
if (holdGeneratedOriginEntries) {
generatedOriginEntries.addAll(originEntriesToWrite);
}
int recordsWritten = writeOriginEntries(originEntriesToWrite);
incrementCount("recordsWritten", recordsWritten);
getReversionUnitOfWorkService().save(unitOfWork);
} catch (FatalErrorException fee) {
LOG.info(fee.getMessage());
}
}
}
use of edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork in project cu-kfs by CU-CommunityApps.
the class ReversionUnitOfWorkServiceImplTest method testLoadCategories.
public void testLoadCategories() {
ReversionUnitOfWork unitOfWork = new ReversionUnitOfWork("IT", "1003000", "-----");
if (!unitOfworkExists()) {
createUnitOfWork();
}
if (!categoryAmountExists()) {
createCategoryAmounts();
}
accountReversionUnitOfWorkService.loadCategories(unitOfWork);
assertEquals(true, unitOfWork.getCategoryAmounts().size() > 0);
}
Aggregations