use of edu.cornell.kfs.coa.businessobject.AccountReversionDetail in project cu-kfs by CU-CommunityApps.
the class AccountReversionMaintainableImpl method setBusinessObject.
/**
* pre-populate the static list of details with each category
*
* @see org.kuali.kfs.kns.maintenance.MaintainableImpl#setBusinessObject(org.kuali.kfs.kns.bo.BusinessObject)
*/
public void setBusinessObject(PersistableBusinessObject businessObject) {
AccountReversionService accountReversionService = SpringContext.getBean(AccountReversionService.class);
AccountReversion accountReversion = (AccountReversion) businessObject;
List<AccountReversionDetail> details = accountReversion.getAccountReversionDetails();
if (details == null) {
details = new ArrayList<AccountReversionDetail>();
accountReversion.setAccountReversionDetails(details);
}
if (details.size() == 0) {
Collection<ReversionCategory> categories = accountReversionService.getCategoryList();
for (ReversionCategory category : categories) {
if (category.isActive()) {
AccountReversionDetail detail = new AccountReversionDetail();
detail.setAccountReversionCategoryCode(category.getReversionCategoryCode());
detail.setReversionCategory(category);
details.add(detail);
}
}
Collections.sort(details, new categoryComparator());
}
super.setBusinessObject(businessObject);
}
use of edu.cornell.kfs.coa.businessobject.AccountReversionDetail in project cu-kfs by CU-CommunityApps.
the class AccountReversionDetailTrickleDownInactivationServiceImpl method trickleDownActiveAccountReversionDetails.
/**
* @see org.kuali.kfs.coa.service.AccountReversionDetailTrickleDownInactivationService#trickleDownActiveAccountReversionDetails(org.kuali.kfs.coa.businessobject.ReversionCategory, java.lang.String)
*/
public void trickleDownActiveAccountReversionDetails(ReversionCategory reversionCategory, String documentNumber) {
Map<String, Object> fieldValues = new HashMap<String, Object>();
fieldValues.put("reversionCategoryCode", reversionCategory.getReversionCategoryCode());
Collection acctReversionDetails = businessObjectService.findMatching(AccountReversionDetail.class, fieldValues);
List<AccountReversionDetail> acctReversionDetailList = new ArrayList<AccountReversionDetail>();
for (Object acctRevDetailAsObject : acctReversionDetails) {
acctReversionDetailList.add((AccountReversionDetail) acctRevDetailAsObject);
}
trickleDownActivations(acctReversionDetailList, documentNumber);
}
use of edu.cornell.kfs.coa.businessobject.AccountReversionDetail in project cu-kfs by CU-CommunityApps.
the class AccountReversionImportServiceImpl method importAccountReversions.
/* (non-Javadoc)
* @see edu.cornell.kfs.coa.service.AccountReversionImportService#importAccountReversions()
*/
public void importAccountReversions(File f) {
// KFSPTS-2174 : Repurposed this batch job to append the loaded values to the existing table, rather than delete all current values and reload the tables from scratch
// arid.destroyAccountReversionsAndDetails();
int count = 0;
String objectCode = parameterService.getParameterValueAsString("KFS-COA", "Reversion", "CASH_REVERSION_OBJECT_CODE");
Integer fiscalYear = Integer.parseInt(parameterService.getParameterValueAsString("KFS-COA", "Reversion", "ACCOUNT_REVERSION_FISCAL_YEAR"));
try {
CSVReader reader = new CSVReader(new FileReader(f));
List<String[]> lines = reader.readAll();
Object[] array = lines.toArray();
LOG.info("Read: " + lines.toArray().length + " records");
for (int i = 0; i < array.length; i++) {
String[] line = (String[]) array[i];
String fromChart = line[0];
String fromAcct = line[1];
String toChart = line[2];
String toAcct = line[3];
LOG.info("Creating Reversion for: from account: " + fromAcct + ": to account " + toAcct);
if (StringUtils.isNotBlank(fromChart) && StringUtils.isNotBlank(fromAcct) && StringUtils.isNotBlank(toChart) && StringUtils.isNotBlank(toAcct)) {
AccountReversion exists = null;
Map<String, String> pks = new HashMap<String, String>();
pks.put("UNIV_FISCAL_YR", String.valueOf(fiscalYear));
pks.put("FIN_COA_CD", fromChart);
pks.put("ACCT_NBR", fromAcct);
exists = (AccountReversion) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(AccountReversion.class, pks);
if (ObjectUtils.isNotNull(exists)) {
LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
continue;
}
// Validate from account; cannot add account reversion if account does not exist
Account fromAcctExists = null;
fromAcctExists = SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
if (ObjectUtils.isNull(fromAcctExists)) {
LOG.info("From account (" + fromAcct + ") does not exist.");
LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
continue;
}
// Validate to account; cannot add account reversion if account does not exist
Account toAcctExists = null;
toAcctExists = SpringContext.getBean(AccountService.class).getByPrimaryId(fromChart, fromAcct);
if (ObjectUtils.isNull(toAcctExists)) {
LOG.info("To account (" + toAcct + ") does not exist.");
LOG.info("Account Reversion already exists for this fiscal year (" + fiscalYear + "): from account: " + fromAcct + ": to account " + toAcct);
continue;
}
AccountReversion accountReversion = new AccountReversion();
accountReversion.setUniversityFiscalYear(fiscalYear);
accountReversion.setChartOfAccountsCode(fromChart);
accountReversion.setAccountNumber(fromAcct);
accountReversion.setBudgetReversionChartOfAccountsCode(toChart);
accountReversion.setBudgetReversionAccountNumber(toAcct);
accountReversion.setCashReversionFinancialChartOfAccountsCode(toChart);
accountReversion.setCashReversionAccountNumber(toAcct);
accountReversion.setCarryForwardByObjectCodeIndicator(false);
accountReversion.setActive(true);
AccountReversionDetail accountReversionDetail = new AccountReversionDetail();
accountReversionDetail.setUniversityFiscalYear(fiscalYear);
accountReversionDetail.setChartOfAccountsCode(fromChart);
accountReversionDetail.setAccountNumber(fromAcct);
accountReversionDetail.setAccountReversionCategoryCode("A1");
accountReversionDetail.setAccountReversionCode("CA");
accountReversionDetail.setAccountReversionObjectCode(objectCode);
accountReversionDetail.setActive(true);
accountReversion.addAccountReversionDetail(accountReversionDetail);
boService.save(accountReversion);
count++;
}
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
LOG.info("Wrote: " + count + " records");
}
}
use of edu.cornell.kfs.coa.businessobject.AccountReversionDetail in project cu-kfs by CU-CommunityApps.
the class AccountReversionMaintainableImpl method processAfterNew.
@Override
public void processAfterNew(MaintenanceDocument document, Map<String, String[]> requestParameters) {
super.processAfterNew(document, requestParameters);
AccountReversion accountReversion = (AccountReversion) getBusinessObject();
List<AccountReversionDetail> details = accountReversion.getAccountReversionDetails();
if (details == null) {
details = new ArrayList<AccountReversionDetail>();
accountReversion.setAccountReversionDetails(details);
}
if (details.size() == 0) {
Collection<ReversionCategory> categories = SpringContext.getBean(AccountReversionService.class).getCategoryList();
for (ReversionCategory category : categories) {
if (category.isActive()) {
AccountReversionDetail detail = new AccountReversionDetail();
detail.setAccountReversionCategoryCode(category.getReversionCategoryCode());
detail.setReversionCategory(category);
details.add(detail);
}
}
Collections.sort(details, new categoryComparator());
}
}
use of edu.cornell.kfs.coa.businessobject.AccountReversionDetail in project cu-kfs by CU-CommunityApps.
the class AccountReversionDetailTrickleDownInactivationServiceImpl method trickleDownInactivations.
/**
* The method which actually does the work of inactivating the details
* @param organizationReversionDetails the details to inactivate
* @param documentNumber the document number which has the inactivations as part of it
* @return an inactivation status object which will help us save notes
*/
protected void trickleDownInactivations(List<AccountReversionDetail> accountReversionDetails, String documentNumber) {
TrickleDownStatus status = new TrickleDownStatus(CUKFSKeyConstants.ACCOUNT_REVERSION_DETAIL_TRICKLE_DOWN_INACTIVATION, CUKFSKeyConstants.ACCOUNT_REVERSION_DETAIL_TRICKLE_DOWN_INACTIVATION_ERROR_DURING_PERSISTENCE);
if (!ObjectUtils.isNull(accountReversionDetails) && !accountReversionDetails.isEmpty()) {
for (AccountReversionDetail detail : accountReversionDetails) {
if (detail.isActive()) {
detail.setActive(false);
try {
businessObjectService.save(detail);
status.addAccountReversionDetail(detail);
} catch (RuntimeException re) {
LOG.error("Unable to trickle-down inactivate sub-account " + detail.toString(), re);
status.addErrorPersistingAccountReversionDetail(detail);
}
}
}
}
status.saveSuccesfullyChangedNotes(documentNumber);
status.saveErrorNotes(documentNumber);
}
Aggregations