use of org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method refresh.
public void refresh(String refreshCaller, Map fieldValues, org.kuali.kfs.kns.document.MaintenanceDocument document) {
super.refresh(refreshCaller, fieldValues, document);
String maintAction = super.getMaintenanceAction();
if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) {
SubAccount subAccount = (SubAccount) super.getBusinessObject();
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
if (ObjectUtils.isNotNull(newSubAccount) && ObjectUtils.isNotNull(newSubAccount.getA21IndirectCostRecoveryAccounts()) && newSubAccount.getA21IndirectCostRecoveryAccounts().size() > 0) {
for (A21IndirectCostRecoveryAccount recoveryAccount : newSubAccount.getA21IndirectCostRecoveryAccounts()) {
// set the newCollectionRecord indicator to true so that the entries can be deleted
recoveryAccount.setNewCollectionRecord(true);
}
}
}
}
use of org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method hasIcrSectionChanged.
// KFSUPGRADE-765 : Route edits to indirect cost to CG Resp ID
private boolean hasIcrSectionChanged() {
String maintAction = super.getMaintenanceAction();
boolean retval = false;
if ((maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_NEW_ACTION)) || (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_COPY_ACTION))) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
if (subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.EXPENSE)) {
// We need to route only when the ICR data the user is submitting does NOT match the ICR data on the account
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
// "existing" data that would have pre-populated
Account account = this.getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber());
if (ObjectUtils.isNotNull(account) && ObjectUtils.isNotNull(newSubAccount)) {
List<IndirectCostRecoveryAccount> acctIcr = account.getIndirectCostRecoveryAccounts();
List<A21IndirectCostRecoveryAccount> subAcctIcr = newSubAccount.getA21ActiveIndirectCostRecoveryAccounts();
if (CollectionUtils.isEmpty(subAcctIcr)) {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = false;
} else {
retval = true;
}
} else {
if (CollectionUtils.isEmpty(acctIcr)) {
retval = true;
} else {
/*
* the ICR accounts on the sub account needs to match the active ICR accounts on the parent account.
*/
int activeAcctIcrCount = 0;
for (IndirectCostRecoveryAccount acct : acctIcr) {
if (acct.isActive()) {
activeAcctIcrCount++;
}
}
if (subAcctIcr.size() == activeAcctIcrCount) {
retval = isIcrSectionDataChanged(subAcctIcr, acctIcr);
} else {
retval = true;
}
}
}
}
}
} else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
// need "new" bo for data comparisons
SubAccount subAccount = (SubAccount) super.getBusinessObject();
// "new" subAccount for data comparisons
A21SubAccount newSubAccount = subAccount.getA21SubAccount();
if (ObjectUtils.isNotNull(newSubAccount)) {
try {
MaintenanceDocument oldMaintDoc = (MaintenanceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(getDocumentNumber());
A21SubAccount oldSubAccount = (A21SubAccount) ((SubAccount) oldMaintDoc.getOldMaintainableObject().getDataObject()).getA21SubAccount();
retval = isIcrSectionChanged(newSubAccount, oldSubAccount);
} catch (Exception e) {
LOG.error("caught exception while getting subaccount old maintainable -> documentService.getByDocumentHeaderId(" + getDocumentNumber() + "). ", e);
}
}
}
return retval;
}
use of org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method processAfterCopy.
/**
* After a copy is done set specific fields on {@link SubAccount} to default values
*
* @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#processAfterCopy(MaintenanceDocument, Map)
*/
@Override
public void processAfterCopy(org.kuali.kfs.kns.document.MaintenanceDocument document, Map<String, String[]> parameters) {
super.processAfterCopy(document, parameters);
SubAccount subAccount = (SubAccount) this.getBusinessObject();
List<A21IndirectCostRecoveryAccount> copyIndirectCostRecoveryAccounts = new ArrayList<A21IndirectCostRecoveryAccount>();
for (A21IndirectCostRecoveryAccount indirectAccount : subAccount.getA21SubAccount().getA21ActiveIndirectCostRecoveryAccounts()) {
indirectAccount.setA21IndirectCostRecoveryAccountGeneratedIdentifier(null);
indirectAccount.setNewCollectionRecord(true);
copyIndirectCostRecoveryAccounts.add(indirectAccount);
}
subAccount.getA21SubAccount().setA21IndirectCostRecoveryAccounts(copyIndirectCostRecoveryAccounts);
}
use of org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class CuSubAccountMaintainableImpl method getSections.
/**
* Overridden to force the old maintenance object to include the relevant A21 sub-account and ICR account sections
* if the new object has them. This is necessary to work around a section size mismatch issue, which can occur
* when the old sub-account has a type of "CS" but the new one has a type of "EX" and possibly under other circumstances.
*
* @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument, Maintainable)
*/
@SuppressWarnings("rawtypes")
@Override
public List getSections(org.kuali.kfs.kns.document.MaintenanceDocument document, Maintainable oldMaintainable) {
// The special handling only applies to the old maintainable.
if (this == document.getOldMaintainableObject()) {
SubAccount oldAccount = (SubAccount) getDataObject();
SubAccount newAccount = (SubAccount) document.getNewMaintainableObject().getDataObject();
if (hasA21SubAccount(newAccount) && (doesNotHaveA21SubAccount(oldAccount) || (isCostShareSubAccount(oldAccount) && isExpenseSubAccount(newAccount)) || oldAccountHasFewerIndirectCostRecoveryAccounts(oldAccount, newAccount))) {
// If necessary, set up an A21 sub-account with sufficient ICR accounts on the old maintainable before generating the sections.
List sections;
A21SubAccount oldA21Account = oldAccount.getA21SubAccount();
A21SubAccount tempA21Account = ObjectUtils.isNull(oldA21Account) ? new A21SubAccount() : (A21SubAccount) ObjectUtils.deepCopy(oldA21Account);
for (int i = newAccount.getA21SubAccount().getA21IndirectCostRecoveryAccounts().size() - tempA21Account.getA21IndirectCostRecoveryAccounts().size() - 1; i >= 0; i--) {
tempA21Account.getA21IndirectCostRecoveryAccounts().add(new A21IndirectCostRecoveryAccount());
}
// Temporarily override the old A21 account as needed when generating the sections.
oldAccount.setA21SubAccount(tempA21Account);
sections = super.getSections(document, oldMaintainable);
oldAccount.setA21SubAccount(oldA21Account);
return sections;
}
}
return super.getSections(document, oldMaintainable);
}
use of org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount in project cu-kfs by CU-CommunityApps.
the class SubAccountGlobal method createIndirectCostRecoveryAccountFromChange.
@Override
public IndirectCostRecoveryAccount createIndirectCostRecoveryAccountFromChange(GlobalBusinessObjectDetailBase globalDetail, IndirectCostRecoveryAccountChange newICR) {
SubAccountGlobalDetail subAccountGlobalDetail = (SubAccountGlobalDetail) globalDetail;
String chart = subAccountGlobalDetail.getChartOfAccountsCode();
String account = subAccountGlobalDetail.getAccountNumber();
A21IndirectCostRecoveryAccount icrAccount = new A21IndirectCostRecoveryAccount();
icrAccount.setAccountNumber(account);
icrAccount.setChartOfAccountsCode(chart);
icrAccount.setIndirectCostRecoveryAccountNumber(newICR.getIndirectCostRecoveryAccountNumber());
icrAccount.setIndirectCostRecoveryFinCoaCode(newICR.getIndirectCostRecoveryFinCoaCode());
icrAccount.setActive(newICR.isActive());
icrAccount.setAccountLinePercent(newICR.getAccountLinePercent());
return icrAccount;
}
Aggregations