Search in sources :

Example 11 with A21SubAccount

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

the class CuLaborBenefitsCalculationServiceImpl method getBenefitRateCategoryCode.

@Override
public String getBenefitRateCategoryCode(String chartOfAccountsCode, String accountNumber, String subAccountNumber) {
    this.setCostSharingSourceAccountNumber(null);
    this.setCostSharingSourceAccountChartOfAccountsCode(null);
    this.setCostSharingSourceSubAccountNumber(null);
    // make sure the sub accout number is filled in
    if (subAccountNumber != null) {
        LOG.info("Sub Account Number was filled in. Checking to see if it is a Cost Sharing Sub Account.");
        // make sure the system parameter exists
        if (SpringContext.getBean(ParameterService.class).parameterExists(KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class, "USE_COST_SHARE_SOURCE_ACCOUNT_BENEFIT_RATE_IND")) {
            // parameter exists, determine the value of the parameter
            String sysParam2 = SpringContext.getBean(ParameterService.class).getParameterValueAsString(KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class, "USE_COST_SHARE_SOURCE_ACCOUNT_BENEFIT_RATE_IND");
            LOG.debug("sysParam2: " + sysParam2);
            // if sysParam2 == Y then check to see if it's a cost sharing sub account
            if (sysParam2.equalsIgnoreCase("Y")) {
                // lookup the A21SubAccount to get the cost sharing source account
                Map<String, Object> subFieldValues = new HashMap<String, Object>();
                subFieldValues.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartOfAccountsCode);
                subFieldValues.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, subAccountNumber);
                subFieldValues.put(KFSPropertyConstants.SUB_ACCOUNT_TYPE_CODE, "CS");
                subFieldValues.put(KFSPropertyConstants.ACCOUNT_NUMBER, accountNumber);
                LOG.info("Looking for a cost sharing sub account for sub account number " + subAccountNumber);
                if (ObjectUtils.isNull(businessObjectService)) {
                    this.businessObjectService = SpringContext.getBean(BusinessObjectService.class);
                }
                // perform the lookup
                List<A21SubAccount> subAccountList = (List<A21SubAccount>) businessObjectService.findMatching(A21SubAccount.class, subFieldValues);
                // check to see if the lookup returns an empty list
                if (subAccountList.size() > 0) {
                    LOG.info("Found A21 Sub Account. Retrieving source account number for cost sharing.");
                    accountNumber = subAccountList.get(0).getCostShareSourceAccountNumber();
                    LOG.debug("Cost Sharing Source Account Number : " + accountNumber);
                    this.setCostSharingSourceAccountNumber(accountNumber);
                    this.setCostSharingSourceAccountChartOfAccountsCode(subAccountList.get(0).getCostShareChartOfAccountCode());
                    this.setCostSharingSourceSubAccountNumber(subAccountList.get(0).getCostShareSourceSubAccountNumber());
                } else {
                    LOG.info(subAccountNumber + " is not a cost sharing account.  Using the Labor Benefit Rate Category from the account number.");
                }
            } else {
                LOG.info("Using the Grant Account to determine the labor benefit rate category code.");
            }
        }
    }
    LOG.info("Looking up Account {" + chartOfAccountsCode + "," + accountNumber + "}");
    // lookup the account from the db based off the account code and the account number
    Account account = this.getAccountService().getByPrimaryId(chartOfAccountsCode, accountNumber);
    String laborBenefitRateCategoryCode = null;
    if (account == null) {
        LOG.info("The Account {" + chartOfAccountsCode + "," + accountNumber + "} could not be found.");
    } else {
        laborBenefitRateCategoryCode = account.getLaborBenefitRateCategoryCode();
    }
    // make sure the laborBenefitRateCategoryCode is not null or blank
    if (StringUtils.isBlank(laborBenefitRateCategoryCode)) {
        LOG.info("The Account did not have a Labor Benefit Rate Category Code. Will use the system parameter default.");
        // The system parameter does not exist. Using a blank Labor Benefit Rate Category Code
        laborBenefitRateCategoryCode = StringUtils.defaultString(SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, LaborConstants.BenefitCalculation.DEFAULT_BENEFIT_RATE_CATEGORY_CODE_PARAMETER));
    } else {
        LOG.debug("Labor Benefit Rate Category Code for Account " + accountNumber + " is " + laborBenefitRateCategoryCode);
    }
    return laborBenefitRateCategoryCode;
}
Also used : A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) Account(org.kuali.kfs.coa.businessobject.Account) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) HashMap(java.util.HashMap) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) List(java.util.List) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 12 with A21SubAccount

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

the class CuScrubberProcessImpl method setupEntryWithPotentialContinuation.

/**
 * Helper method for configuring the chart, account and sub-account on the cost-share-source-account entry,
 * using the cost share account's continuation account or descendant (up to a depth of 10) in the
 * event of a closed cost share account.
 *
 * @param costShareSourceAccountEntry The origin entry to configure.
 * @param scrubbedEntryA21SubAccount The A21 sub-account from the original scrubbed origin entry.
 * @return A ScrubberProcessTransactionError if a valid cost share or continuation account could not be found, null otherwise.
 */
protected ScrubberProcessTransactionError setupEntryWithPotentialContinuation(OriginEntryFull costShareSourceAccountEntry, A21SubAccount scrubbedEntryA21SubAccount) {
    Account costShareAccount = accountingCycleCachingService.getAccount(scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber());
    if (ObjectUtils.isNotNull(costShareAccount) && costShareAccount.isClosed()) {
        // Cost share source account is closed; check for a valid continuation account.
        Account continuationAccount = costShareAccount;
        for (int i = 0; i < CONTINUATION_ACCOUNT_DEPTH_LIMIT && ObjectUtils.isNotNull(continuationAccount) && continuationAccount.isClosed(); i++) {
            continuationAccount = accountingCycleCachingService.getAccount(continuationAccount.getContinuationFinChrtOfAcctCd(), continuationAccount.getContinuationAccountNumber());
        }
        if (ObjectUtils.isNull(continuationAccount) || costShareAccount == continuationAccount || continuationAccount.isClosed()) {
            // Could not find a valid Cost Share continuation account; return an error.
            return new ScrubberProcessTransactionError(costShareSourceAccountEntry, new Message(MessageFormat.format(configurationService.getPropertyValueAsString(CUKFSKeyConstants.ERROR_CSACCOUNT_CONTINUATION_ACCOUNT_CLOSED), scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber()), Message.TYPE_FATAL));
        } else {
            // Found a valid Cost Share continuation account, so use it.
            LOG.warn(MessageFormat.format(configurationService.getPropertyValueAsString(CUKFSKeyConstants.WARNING_CSACCOUNT_CONTINUATION_ACCOUNT_USED), scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode(), scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber(), continuationAccount.getChartOfAccountsCode(), continuationAccount.getAccountNumber()));
            costShareSourceAccountEntry.setChartOfAccountsCode(continuationAccount.getChartOfAccountsCode());
            costShareSourceAccountEntry.setAccountNumber(continuationAccount.getAccountNumber());
            costShareSourceAccountEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
        }
    } else {
        // Cost Share source account is still open, so use it.
        costShareSourceAccountEntry.setChartOfAccountsCode(scrubbedEntryA21SubAccount.getCostShareChartOfAccountCode());
        costShareSourceAccountEntry.setAccountNumber(scrubbedEntryA21SubAccount.getCostShareSourceAccountNumber());
        costShareSourceAccountEntry.setSubAccountNumber(scrubbedEntryA21SubAccount.getCostShareSourceSubAccountNumber());
    }
    return null;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount) Message(org.kuali.kfs.sys.Message) ScrubberProcessTransactionError(org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError)

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