Search in sources :

Example 1 with A21IndirectCostRecoveryAccount

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);
            }
        }
    }
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 2 with A21IndirectCostRecoveryAccount

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;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) DocumentService(org.kuali.kfs.krad.service.DocumentService) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 3 with A21IndirectCostRecoveryAccount

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);
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) ArrayList(java.util.ArrayList)

Example 4 with A21IndirectCostRecoveryAccount

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);
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) ArrayList(java.util.ArrayList) List(java.util.List) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 5 with A21IndirectCostRecoveryAccount

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;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)

Aggregations

A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)9 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)6 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)5 ArrayList (java.util.ArrayList)4 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)4 Account (org.kuali.kfs.coa.businessobject.Account)3 List (java.util.List)2 HashMap (java.util.HashMap)1 MaintenanceDocumentRestrictions (org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions)1 BusinessObjectAuthorizationService (org.kuali.kfs.kns.service.BusinessObjectAuthorizationService)1 GlobalBusinessObjectDetailBase (org.kuali.kfs.krad.bo.GlobalBusinessObjectDetailBase)1 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 Person (org.kuali.rice.kim.api.identity.Person)1