Search in sources :

Example 1 with SubFundGroup

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

the class SubAccountGlobalRule method accountIsForContractsAndGrants.

protected boolean accountIsForContractsAndGrants(Account account) {
    if (ObjectUtils.isNotNull(account)) {
        account.refreshReferenceObject(KFSPropertyConstants.SUB_FUND_GROUP);
        SubFundGroup subFundGroup = account.getSubFundGroup();
        if (ObjectUtils.isNotNull(subFundGroup)) {
            return getSubFundGroupService().isForContractsAndGrants(subFundGroup);
        }
    }
    return false;
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup)

Example 2 with SubFundGroup

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

the class CuContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByContractControlAccount.

/*
     * CUMod: KFSPTS-14929
     */
@Override
protected CustomerInvoiceDetail createSourceAccountingLinesByContractControlAccount(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
    String coaCode = null;
    String accountNumber = null;
    SubFundGroup subFundGroup = null;
    List<InvoiceAccountDetail> accountDetails = contractsGrantsInvoiceDocument.getAccountDetails();
    if (CollectionUtils.isNotEmpty(accountDetails)) {
        Account contractControlAccount = determineContractControlAccount(accountDetails.get(0));
        if (ObjectUtils.isNotNull(contractControlAccount)) {
            coaCode = contractControlAccount.getChartOfAccountsCode();
            accountNumber = contractControlAccount.getAccountNumber();
            subFundGroup = contractControlAccount.getSubFundGroup();
            if (ObjectUtils.isNull(subFundGroup)) {
                contractControlAccount.refreshReferenceObject(KFSPropertyConstants.SUB_FUND_GROUP);
                subFundGroup = contractControlAccount.getSubFundGroup();
            }
        }
    }
    return createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), coaCode, accountNumber, subFundGroup, getTotalAmountForInvoice(contractsGrantsInvoiceDocument), 1);
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) Account(org.kuali.kfs.coa.businessobject.Account) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 3 with SubFundGroup

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

the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByContractControlAccount.

/**
 * Creates source accounting lines using the contract control account to populate
 *
 * @param contractsGrantsInvoiceDocument the Contracts & Grants Invoice to add lines to
 */
protected CustomerInvoiceDetail createSourceAccountingLinesByContractControlAccount(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
    String coaCode = null;
    String accountNumber = null;
    SubFundGroup subFundGroup = null;
    List<InvoiceAccountDetail> accountDetails = contractsGrantsInvoiceDocument.getAccountDetails();
    if (CollectionUtils.isNotEmpty(accountDetails)) {
        InvoiceAccountDetail invoiceAccountDetail = accountDetails.get(0);
        Account account = invoiceAccountDetail.getAccount();
        if (ObjectUtils.isNull(account)) {
            invoiceAccountDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
            account = invoiceAccountDetail.getAccount();
        }
        if (ObjectUtils.isNotNull(account)) {
            Account contractControlAccount = account.getContractControlAccount();
            if (ObjectUtils.isNotNull(contractControlAccount)) {
                coaCode = contractControlAccount.getChartOfAccountsCode();
                accountNumber = contractControlAccount.getAccountNumber();
                subFundGroup = contractControlAccount.getSubFundGroup();
            }
        }
    }
    return createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), coaCode, accountNumber, subFundGroup, getTotalAmountForInvoice(contractsGrantsInvoiceDocument), 1);
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) ContractsAndGrantsBillingAwardAccount(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount) Account(org.kuali.kfs.coa.businessobject.Account) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 4 with SubFundGroup

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

the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByAward.

/**
 * Generates the source accounting lines for a Contracts & Grants Invoice from the award accounts associated with
 * an award (in the form of the pre-generated invoice account details)
 *
 * @param contractsGrantsInvoiceDocument the Contracts & Grants Invoice to create invoice details for
 * @return a List of generated accounting lines
 */
protected List<CustomerInvoiceDetail> createSourceAccountingLinesByAward(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
    List<CustomerInvoiceDetail> awardAccountingLines = new ArrayList<>();
    if (!CollectionUtils.isEmpty(contractsGrantsInvoiceDocument.getAccountDetails())) {
        final Map<String, KualiDecimal> accountExpenditureAmounts = getCategoryExpenditureAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
        final Map<String, KualiDecimal> accountTotalBilledAmounts = getCategoryTotalBilledAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
        for (InvoiceAccountDetail invAcctD : contractsGrantsInvoiceDocument.getAccountDetails()) {
            final String proposalNumber = invAcctD.getProposalNumber();
            final String chartOfAccountsCode = invAcctD.getChartOfAccountsCode();
            final String accountNumber = invAcctD.getAccountNumber();
            if (invAcctD.getAccount() == null) {
                invAcctD.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
            }
            final SubFundGroup subFundGroup = invAcctD.getAccount().getSubFundGroup();
            final Integer sequenceNumber = contractsGrantsInvoiceDocument.getAccountDetails().indexOf(invAcctD) + 1;
            final String accountKey = StringUtils.join(new String[] { chartOfAccountsCode, accountNumber }, "-");
            KualiDecimal totalAmount = accountExpenditureAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
            if (invAcctD.getTotalPreviouslyBilled().isZero()) {
                KualiDecimal previouslyBilledAmount = getPredeterminedBillingBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber);
                previouslyBilledAmount = previouslyBilledAmount.add(getMilestonesBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
                KualiDecimal totalBilledAmount = accountTotalBilledAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
                previouslyBilledAmount = previouslyBilledAmount.subtract(totalBilledAmount);
                if (previouslyBilledAmount.isGreaterThan(KualiDecimal.ZERO)) {
                    totalAmount = totalAmount.subtract(previouslyBilledAmount);
                }
            }
            CustomerInvoiceDetail cide = createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), chartOfAccountsCode, accountNumber, subFundGroup, totalAmount, sequenceNumber);
            awardAccountingLines.add(cide);
        }
    }
    return awardAccountingLines;
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) ArrayList(java.util.ArrayList) CustomerInvoiceDetail(org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail) AbstractKualiDecimal(org.kuali.kfs.core.api.util.type.AbstractKualiDecimal) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 5 with SubFundGroup

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

the class AccountGlobalPreRules method checkForDefaultSubFundGroupStatus.

protected void checkForDefaultSubFundGroupStatus() {
    String restrictedStatusCode = StringUtils.EMPTY;
    if (ObjectUtils.isNull(accountGlobal.getSubFundGroup()) || StringUtils.isBlank(accountGlobal.getSubFundGroupCode())) {
        return;
    }
    SubFundGroup subFundGroup = accountGlobal.getSubFundGroup();
    if (StringUtils.isNotBlank(subFundGroup.getAccountRestrictedStatusCode())) {
        restrictedStatusCode = subFundGroup.getAccountRestrictedStatusCode().trim();
        accountGlobal.setAccountRestrictedStatusCode(restrictedStatusCode);
    }
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup)

Aggregations

SubFundGroup (org.kuali.kfs.coa.businessobject.SubFundGroup)6 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)3 Account (org.kuali.kfs.coa.businessobject.Account)2 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 SubFundGroupService (org.kuali.kfs.coa.service.SubFundGroupService)1 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 ContractsAndGrantsBillingAwardAccount (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount)1 CustomerInvoiceDetail (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail)1