use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.
the class AccountReversionMaintainableImpl method retrieveExistingAccountReversion.
/**
* Grabs the old version of this org reversion from the database
* @return the old version of this organization reversion
*/
protected AccountReversion retrieveExistingAccountReversion() {
final AccountReversion acctRev = (AccountReversion) getBusinessObject();
final AccountReversion oldAcctRev = SpringContext.getBean(AccountReversionService.class).getByPrimaryId(acctRev.getUniversityFiscalYear(), acctRev.getChartOfAccountsCode(), acctRev.getAccountNumber());
return oldAcctRev;
}
use of edu.cornell.kfs.coa.businessobject.AccountReversion 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.AccountReversion in project cu-kfs by CU-CommunityApps.
the class AccountReversionPreRules method doCustomPreRules.
/**
* This calls the {@link AccountReversionPreRules#copyKeyAttributesToDetail(OrganizationReversion)}
* @see org.kuali.kfs.coa.document.validation.impl.MaintenancePreRulesBase#doCustomPreRules(org.kuali.kfs.kns.document.MaintenanceDocument)
*/
@Override
protected boolean doCustomPreRules(MaintenanceDocument document) {
AccountReversion acctRev = (AccountReversion) document.getNewMaintainableObject().getBusinessObject();
// copy year and chart to detail records
copyKeyAttributesToDetail(acctRev);
return true;
}
use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.
the class AccountReversionTrickleDownInactivationServiceImpl method addMaintenanceLockedNotes.
/**
* Adds notes about any maintence locks on Account Reversions.
*
* @param documentNumber
* @param lockedAccountReversions
* @param messageKey
* @param noteParent
* @param noteTemplate
*/
protected void addMaintenanceLockedNotes(String documentNumber, Map<AccountReversion, String> lockedAccountReversions, String messageKey, PersistableBusinessObject noteParent, Note noteTemplate) {
for (Map.Entry<AccountReversion, String> entry : lockedAccountReversions.entrySet()) {
try {
AccountReversion accountReversion = entry.getKey();
String accountReversionString = accountReversion.getUniversityFiscalYear() + " - " + accountReversion.getChartOfAccountsCode() + " - " + accountReversion.getAccountNumber();
if (StringUtils.isNotBlank(accountReversionString)) {
String noteTextTemplate = kualiConfigurationService.getPropertyValueAsString(messageKey);
String noteText = MessageFormat.format(noteTextTemplate, accountReversionString, entry.getValue());
Note note = noteService.createNote(noteTemplate, noteParent, GlobalVariables.getUserSession().getPrincipalId());
note.setNoteText(noteText);
noteService.save(note);
}
} catch (Exception e) {
LOG.error("Unable to create/save notes for document " + documentNumber, e);
throw new RuntimeException("Unable to create/save notes for document " + documentNumber, e);
}
}
}
use of edu.cornell.kfs.coa.businessobject.AccountReversion in project cu-kfs by CU-CommunityApps.
the class AccountReversionTrickleDownInactivationServiceImpl method trickleDownInactivateAccountReversions.
/**
* Inactivates all related AccountReversion rules.
*
* @see edu.cornell.kfs.coa.service.AccountReversionTrickleDownInactivationService#trickleDownInactivateAccountReversions(org.kuali.kfs.coa.businessobject.Account, java.lang.String)
*/
public void trickleDownInactivateAccountReversions(Account inactivatedAccount, String documentNumber) {
List<AccountReversion> inactivatedAccountReversions = new ArrayList<AccountReversion>();
Map<AccountReversion, String> alreadyLockedAccountReversions = new HashMap<AccountReversion, String>();
List<AccountReversion> errorPersistingAccountReversions = new ArrayList<AccountReversion>();
Maintainable accountReversionMaintainable;
try {
accountReversionMaintainable = (Maintainable) maintenanceDocumentDictionaryService.getMaintainableClass(AccountReversion.class.getName()).newInstance();
accountReversionMaintainable.setBoClass(AccountReversion.class);
accountReversionMaintainable.setDocumentNumber(documentNumber);
} catch (Exception e) {
LOG.error("Unable to instantiate accountReversionMaintainable Maintainable", e);
throw new RuntimeException("Unable to instantiate accountReversionMaintainable Maintainable", e);
}
Integer universityFiscalYear = universityDateService.getCurrentFiscalYear() - 1;
List<AccountReversion> accountReversionRules = new ArrayList<AccountReversion>();
List<AccountReversion> matchingAccountReversionRules = accountReversionService.getAccountReversionsByChartAndAccount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
if (ObjectUtils.isNotNull(matchingAccountReversionRules) && CollectionUtils.isNotEmpty(matchingAccountReversionRules)) {
accountReversionRules.addAll(matchingAccountReversionRules);
}
List<AccountReversion> cashAccountReversionRules = accountReversionService.getAccountReversionsByCashReversionAcount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
if (ObjectUtils.isNotNull(cashAccountReversionRules) && cashAccountReversionRules.size() > 0) {
accountReversionRules.addAll(cashAccountReversionRules);
}
List<AccountReversion> budgetAccountReversionRules = accountReversionService.getAccountReversionsByBudgetReversionAcount(inactivatedAccount.getChartOfAccountsCode(), inactivatedAccount.getAccountNumber());
if (ObjectUtils.isNotNull(budgetAccountReversionRules) && budgetAccountReversionRules.size() > 0) {
accountReversionRules.addAll(budgetAccountReversionRules);
}
if (ObjectUtils.isNotNull(accountReversionRules) && !accountReversionRules.isEmpty()) {
for (AccountReversion accountReversion : accountReversionRules) {
if (accountReversion.isActive()) {
accountReversionMaintainable.setBusinessObject(accountReversion);
List<MaintenanceLock> accountReversionLocks = accountReversionMaintainable.generateMaintenanceLocks();
MaintenanceLock failedLock = verifyAllLocksFromThisDocument(accountReversionLocks, documentNumber);
if (failedLock != null) {
// another document has locked this AccountReversion, so we don't try to inactivate the account
alreadyLockedAccountReversions.put(accountReversion, failedLock.getDocumentNumber());
} else {
// no locks other than our own (but there may have been no locks at all), just go ahead and try to update
accountReversion.setActive(false);
try {
accountReversionMaintainable.saveBusinessObject();
inactivatedAccountReversions.add(accountReversion);
} catch (RuntimeException e) {
LOG.error("Unable to trickle-down inactivate accountReversion " + accountReversion.toString(), e);
errorPersistingAccountReversions.add(accountReversion);
}
}
}
}
addNotesToDocument(documentNumber, inactivatedAccountReversions, alreadyLockedAccountReversions, errorPersistingAccountReversions);
}
}
Aggregations