Search in sources :

Example 6 with A21SubAccount

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

the class CuSubAccountMaintainableImpl method hasCgIcrDataChanged.

// KFSPTS-1740 added
/**
 * Answers true for the following conditions:
 * a) New or Copy of SubAccount with data existing in any field on the Edit CG ICR tab of the Sub-Account
 *      maintenance document will enforce the route the Award split-node.
 * b) Edit of the SubAccount where any data change is detected on the Edit CG ICR tab of the Sub-Account
 *      maintenance document will enforce the route the Award split-node.
 *
 * @return true when conditions are met; otherwise return false
 */
private boolean hasCgIcrDataChanged() {
    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)) {
                // compare each field in question
                boolean hasIcrIdChanged = !areFieldValuesTheSame(account.getFinancialIcrSeriesIdentifier(), newSubAccount.getFinancialIcrSeriesIdentifier());
                boolean hasIcrTypeCodeChanged = !areFieldValuesTheSame(account.getAcctIndirectCostRcvyTypeCd(), newSubAccount.getIndirectCostRecoveryTypeCode());
                boolean hasOffCampusIndChanged = newSubAccount.getOffCampusCode() != account.isAccountOffCampusIndicator();
                if (hasIcrIdChanged || hasIcrTypeCodeChanged || hasOffCampusIndChanged) {
                    // retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId
                    // is not a sub-account attribute and we must populate the account attribute on sub-account
                    subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
                    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();
        // "old" subAccount for data comparisons
        A21SubAccount oldSubAccount = this.getA21SubAccountService().getByPrimaryKey(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber(), subAccount.getSubAccountNumber());
        // compare each field in question
        boolean hasIcrIdChanged = isFieldValueChanged(newSubAccount.getFinancialIcrSeriesIdentifier(), oldSubAccount.getFinancialIcrSeriesIdentifier());
        boolean hasIcrTypeCodeChanged = isFieldValueChanged(newSubAccount.getIndirectCostRecoveryTypeCode(), oldSubAccount.getIndirectCostRecoveryTypeCode());
        boolean hasOffCampusIndChanged = newSubAccount.getOffCampusCode() != oldSubAccount.getOffCampusCode();
        if (hasIcrIdChanged || hasIcrTypeCodeChanged || hasOffCampusIndChanged) {
            // retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId is
            // not a sub-account attribute and we must populate the account attribute on sub-account
            subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
            retval = true;
        }
    }
    return retval;
}
Also used : 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) SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 7 with A21SubAccount

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

the class CuSubAccountMaintainableImpl method isSubAccountTypeCodeCostShare.

// KFSPTS-1740 added
/**
 * Answers true for the following conditions:
 * a) New or Copy of SubAccount with a CS SubAccount type enforce route to Award split-node.
 * b) Any Edit of an existing SubAccount type code to change it from-or-to a cost share enforces
 *  split-node route to Award (i.e. old=EX to new=CS OR old=CS to new=EX OR old=CS to new=CS).
 *
 * @return true when code is CS for old or new value; otherwise return false
 */
private boolean isSubAccountTypeCodeCostShare() {
    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.COST_SHARE)) {
            // retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId is
            // not a sub-account attribute and we must populate the account attribute on sub-account
            subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
            retval = true;
        }
    } else if (maintAction.equalsIgnoreCase(KRADConstants.MAINTENANCE_EDIT_ACTION)) {
        // need "new" bo for data comparisons
        SubAccount subAccount = (SubAccount) super.getBusinessObject();
        // need "old" bo for data comparisons
        A21SubAccount oldSubAccount = this.getA21SubAccountService().getByPrimaryKey(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber(), subAccount.getSubAccountNumber());
        if ((subAccount.getA21SubAccount().getSubAccountTypeCode().equals(KFSConstants.SubAccountType.COST_SHARE)) || (oldSubAccount.getSubAccountTypeCode().equals(KFSConstants.SubAccountType.COST_SHARE))) {
            // retrieve data we need for split-node route to work, contractsAndGrantsAccountResponsibilityId is
            // not a sub-account attribute and we must populate the account attribute on sub-account
            subAccount.setAccount(getAccountService().getByPrimaryIdWithCaching(subAccount.getChartOfAccountsCode(), subAccount.getAccountNumber()));
            retval = true;
        }
    }
    return retval;
}
Also used : SubAccount(org.kuali.kfs.coa.businessobject.SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 8 with A21SubAccount

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

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

the class CuSubAccountRule method checkCgIcrIsEmpty.

/**
 * This method tests if all fields in the ICR section are empty.
 *
 * @return true if the ICR values passed in are empty, otherwise false.
 */
@Override
protected boolean checkCgIcrIsEmpty() {
    boolean success = true;
    A21SubAccount newA21SubAccount = newSubAccount.getA21SubAccount();
    if (ObjectUtils.isNotNull(newA21SubAccount)) {
        success &= StringUtils.isEmpty(newA21SubAccount.getFinancialIcrSeriesIdentifier());
        success &= checkICRCollectionExist(false);
        success &= StringUtils.isEmpty(newA21SubAccount.getIndirectCostRecoveryTypeCode());
    }
    return success;
}
Also used : A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 10 with A21SubAccount

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

Aggregations

A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)12 A21IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.A21IndirectCostRecoveryAccount)6 Account (org.kuali.kfs.coa.businessobject.Account)6 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)6 List (java.util.List)3 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)3 HashMap (java.util.HashMap)2 ScrubberProcessTransactionError (org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError)2 Message (org.kuali.kfs.sys.Message)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ScrubberStep (org.kuali.kfs.gl.batch.ScrubberStep)1 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)1 Transaction (org.kuali.kfs.gl.businessobject.Transaction)1 MaintenanceDocumentRestrictions (org.kuali.kfs.kns.document.authorization.MaintenanceDocumentRestrictions)1 BusinessObjectAuthorizationService (org.kuali.kfs.kns.service.BusinessObjectAuthorizationService)1 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1