Search in sources :

Example 1 with SubAccount

use of org.kuali.kfs.coa.businessobject.SubAccount in project cu-kfs by CU-CommunityApps.

the class AwsAccountingXmlDocumentAccountingLineServiceImpl method validateSubAccountNumber.

private boolean validateSubAccountNumber(String chartCode, String accountNumber, String subAccountNumber) {
    if (StringUtils.isBlank(subAccountNumber)) {
        return true;
    }
    SubAccount subAccount = subAccountService.getByPrimaryId(chartCode, accountNumber, subAccountNumber);
    if (ObjectUtils.isNull(subAccount)) {
        String errorMessage = configurationService.getPropertyValueAsString(CuFPKeyConstants.ERROR_SUB_ACCOUNT_NOT_FOUND);
        LOG.error(String.format(errorMessage, chartCode, accountNumber, subAccountNumber));
        return false;
    }
    if (!subAccount.isActive()) {
        String errorMessage = configurationService.getPropertyValueAsString(CuFPKeyConstants.ERROR_SUB_ACCOUNT_INACTIVE);
        LOG.error(String.format(errorMessage, chartCode, accountNumber, subAccountNumber));
        return false;
    }
    return true;
}
Also used : SubAccount(org.kuali.kfs.coa.businessobject.SubAccount)

Example 2 with SubAccount

use of org.kuali.kfs.coa.businessobject.SubAccount 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 3 with SubAccount

use of org.kuali.kfs.coa.businessobject.SubAccount 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 4 with SubAccount

use of org.kuali.kfs.coa.businessobject.SubAccount 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 5 with SubAccount

use of org.kuali.kfs.coa.businessobject.SubAccount 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)

Aggregations

SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)22 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)7 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)7 ArrayList (java.util.ArrayList)4 Account (org.kuali.kfs.coa.businessobject.Account)4 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)3 SubAccountService (org.kuali.kfs.coa.service.SubAccountService)2 SubAccountGlobal (edu.cornell.kfs.coa.businessobject.SubAccountGlobal)1 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)1 ValidationResult (edu.cornell.kfs.concur.businessobjects.ValidationResult)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Maintainable (org.kuali.kfs.kns.maintenance.Maintainable)1 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)1 MaintenanceLock (org.kuali.kfs.krad.maintenance.MaintenanceLock)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1