Search in sources :

Example 6 with A21IndirectCostRecoveryAccount

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

the class CuSubAccountPreRules method copyICRFromAccount.

@SuppressWarnings("deprecation")
protected void copyICRFromAccount(MaintenanceDocument document) {
    Person user = GlobalVariables.getUserSession().getPerson();
    // get a new instance of MaintenanceDocumentAuthorizations for this context
    MaintenanceDocumentRestrictions auths = SpringContext.getBean(BusinessObjectAuthorizationService.class).getMaintenanceDocumentRestrictions(document, user);
    // don't need to copy if the user does not have the authority to edit the fields
    if (!auths.getFieldRestriction("a21SubAccount.financialIcrSeriesIdentifier").isReadOnly()) {
        // only need to do this of the account sub type is EX
        A21SubAccount a21SubAccount = newSubAccount.getA21SubAccount();
        Account account = newSubAccount.getAccount();
        if (KFSConstants.SubAccountType.EXPENSE.equals(a21SubAccount.getSubAccountTypeCode())) {
            if (ObjectUtils.isNull(account) || StringUtils.isBlank(account.getAccountNumber())) {
                account = getAccountService().getByPrimaryId(newSubAccount.getChartOfAccountsCode(), newSubAccount.getAccountNumber());
            }
            if (ObjectUtils.isNotNull(account)) {
                if (a21SubAccount.getA21ActiveIndirectCostRecoveryAccounts().isEmpty()) {
                    for (IndirectCostRecoveryAccount icrAccount : account.getActiveIndirectCostRecoveryAccounts()) {
                        A21IndirectCostRecoveryAccount copyAccount = A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount);
                        copyAccount.setNewCollectionRecord(true);
                        a21SubAccount.getA21IndirectCostRecoveryAccounts().add(copyAccount);
                    }
                }
                if (StringUtils.isBlank(a21SubAccount.getFinancialIcrSeriesIdentifier())) {
                    a21SubAccount.setFinancialIcrSeriesIdentifier(account.getFinancialIcrSeriesIdentifier());
                }
                if (StringUtils.isBlank(a21SubAccount.getIndirectCostRecoveryTypeCode())) {
                    a21SubAccount.setIndirectCostRecoveryTypeCode(account.getAcctIndirectCostRcvyTypeCd());
                }
            }
        }
    }
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) MaintenanceDocumentRestrictions(org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) Account(org.kuali.kfs.coa.businessobject.Account) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) BusinessObjectAuthorizationService(org.kuali.kfs.kns.service.BusinessObjectAuthorizationService) Person(org.kuali.rice.kim.api.identity.Person) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 7 with A21IndirectCostRecoveryAccount

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

the class SubAccountGlobalRule method checkCgRules.

/**
 * Checks to make sure that if cgAuthorized is false it succeeds immediately, otherwise it checks that all the information
 * for CG is correctly entered and identified including:
 * <ul>
 * <li>If the {@link SubFundGroup} isn't for Contracts and Grants then check to make sure that the cost share and ICR fields are
 * not empty</li>
 * <li>If it isn't a child of CG, then the SubAccount must be of type ICR</li>
 * </ul>
 *
 * @param document
 * @return true if the user is not authorized to change CG fields, otherwise it checks the above conditions
 */
protected boolean checkCgRules(SubAccountGlobal newSubAccountGlobal, SubAccountGlobalDetail subAccountGlobalDetail) {
    boolean success = true;
    // short circuit if the parent account is NOT part of a CG fund group
    boolean a21SubAccountRefreshed = false;
    subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
    if (ObjectUtils.isNotNull(subAccountGlobalDetail.getAccount())) {
        Account account = subAccountGlobalDetail.getAccount();
        account.refreshReferenceObject(KFSPropertyConstants.SUB_FUND_GROUP);
        if (ObjectUtils.isNotNull(account.getSubFundGroup())) {
            // compare them, exit if the account isn't for contracts and grants
            if (!getSubFundGroupService().isForContractsAndGrants(account.getSubFundGroup())) {
                if (checkCgCostSharingIsEmpty(subAccountGlobalDetail) == false) {
                    putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_CS_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
                    success = false;
                }
                if (checkCgIcrIsEmpty() == false) {
                    putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.INDIRECT_COST_RECOVERY_TYPE_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_ICR_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
                    success = false;
                }
                if (newSubAccountGlobal.getIndirectCostRecoveryAccounts().isEmpty() == false) {
                    putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_NON_FUNDED_ACCT_ICR_INVALID, new String[] { getSubFundGroupService().getContractsAndGrantsDenotingAttributeLabel(), getSubFundGroupService().getContractsAndGrantsDenotingValueForMessage() });
                    success = false;
                }
                return success;
            }
        }
    }
    subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
    if (ObjectUtils.isNull(subAccountGlobalDetail.getSubAccount())) {
        return success;
    }
    SubAccount subAccount = subAccountGlobalDetail.getSubAccount();
    subAccount.refreshReferenceObject(KFSPropertyConstants.A21_SUB_ACCOUNT);
    A21SubAccount a21 = subAccount.getA21SubAccount();
    // short circuit if there is no A21SubAccount object at all (ie, null)
    if (ObjectUtils.isNull(a21)) {
        return success;
    }
    if (!a21SubAccountRefreshed) {
        // preserve the ICRAccounts before refresh to prevent the list from dropping
        List<A21IndirectCostRecoveryAccount> icrAccounts = a21.getA21IndirectCostRecoveryAccounts();
        a21.refresh();
        a21.setA21IndirectCostRecoveryAccounts(icrAccounts);
    }
    // get a convenience reference to this code
    String cgA21TypeCode = a21.getSubAccountTypeCode();
    // if this is a Cost Sharing SubAccount, run the Cost Sharing rules
    if (KFSConstants.SubAccountType.COST_SHARE.trim().equalsIgnoreCase(StringUtils.trim(cgA21TypeCode))) {
        success &= checkCgCostSharingRules(cgA21TypeCode);
    }
    // if this is an ICR subaccount, run the ICR rules
    if (KFSConstants.SubAccountType.EXPENSE.trim().equals(StringUtils.trim(cgA21TypeCode))) {
        success &= checkCgIcrRules(cgA21TypeCode, subAccountGlobalDetail);
    }
    return success;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) Account(org.kuali.kfs.coa.businessobject.Account) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 8 with A21IndirectCostRecoveryAccount

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

the class SubAccountGlobal method updateGlobalDetailICRAccountCollection.

@Override
public void updateGlobalDetailICRAccountCollection(GlobalBusinessObjectDetailBase globalDetail, List<IndirectCostRecoveryAccount> updatedIcrAccounts) {
    SubAccountGlobalDetail subAccountGlobalDetail = (SubAccountGlobalDetail) globalDetail;
    List<A21IndirectCostRecoveryAccount> updatedA21IcrAccounts = new ArrayList<A21IndirectCostRecoveryAccount>();
    for (IndirectCostRecoveryAccount icrAccount : updatedIcrAccounts) {
        updatedA21IcrAccounts.add(A21IndirectCostRecoveryAccount.copyICRAccount(icrAccount));
    }
    subAccountGlobalDetail.getSubAccount().getA21SubAccount().setA21IndirectCostRecoveryAccounts(updatedA21IcrAccounts);
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList)

Example 9 with A21IndirectCostRecoveryAccount

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

the class SubAccountGlobal method getGlobalObjectDetailsAndIcrAccountsMap.

@Override
public Map<GlobalBusinessObjectDetailBase, List<IndirectCostRecoveryAccount>> getGlobalObjectDetailsAndIcrAccountsMap() {
    Map<GlobalBusinessObjectDetailBase, List<IndirectCostRecoveryAccount>> globalObjectDetailsAndIcrAccountsMap = new HashMap<GlobalBusinessObjectDetailBase, List<IndirectCostRecoveryAccount>>();
    List<SubAccountGlobalDetail> subAccountGlobalDetails = getSubAccountGlobalDetails();
    if (ObjectUtils.isNotNull(subAccountGlobalDetails) && !subAccountGlobalDetails.isEmpty()) {
        for (GlobalBusinessObjectDetailBase globalDetail : subAccountGlobalDetails) {
            List<IndirectCostRecoveryAccount> existingIcrAccounts = new ArrayList<IndirectCostRecoveryAccount>();
            SubAccountGlobalDetail subAccountGlobalDetail = (SubAccountGlobalDetail) globalDetail;
            subAccountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.SUB_ACCOUNT);
            List<A21IndirectCostRecoveryAccount> a21IcrAccounts = subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts();
            for (A21IndirectCostRecoveryAccount a21ICRAccount : a21IcrAccounts) {
                IndirectCostRecoveryAccount icrAcct = new IndirectCostRecoveryAccount();
                icrAcct.setChartOfAccountsCode(a21ICRAccount.getChartOfAccountsCode());
                icrAcct.setAccountNumber(a21ICRAccount.getAccountNumber());
                icrAcct.setIndirectCostRecoveryAccountNumber(a21ICRAccount.getIndirectCostRecoveryAccountNumber());
                icrAcct.setIndirectCostRecoveryFinCoaCode(a21ICRAccount.getIndirectCostRecoveryFinCoaCode());
                icrAcct.setAccountLinePercent(a21ICRAccount.getAccountLinePercent());
                icrAcct.setActive(a21ICRAccount.isActive());
                existingIcrAccounts.add(icrAcct);
            }
            globalObjectDetailsAndIcrAccountsMap.put(globalDetail, existingIcrAccounts);
        }
    }
    return globalObjectDetailsAndIcrAccountsMap;
}
Also used : A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) HashMap(java.util.HashMap) A21IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GlobalBusinessObjectDetailBase(org.kuali.kfs.krad.bo.GlobalBusinessObjectDetailBase)

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