Search in sources :

Example 1 with InvoiceAccountDetail

use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail 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 2 with InvoiceAccountDetail

use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentServiceImpl method findPurchaseOrderNumberForInvoiceOptionAccount.

protected String findPurchaseOrderNumberForInvoiceOptionAccount(ContractsGrantsInvoiceDocument document) {
    String purchaseOrderNumber = StringUtils.EMPTY;
    List<InvoiceAccountDetail> invoiceAccountDetails = document.getAccountDetails();
    if (CollectionUtils.isNotEmpty(invoiceAccountDetails)) {
        Account invoiceAccount = invoiceAccountDetails.get(0).getAccount();
        AwardAccountExtendedAttribute awardAccountExtension = findAwardAccountExtendedAttribute(invoiceAccountDetails.get(0).getProposalNumber(), invoiceAccount.getChartOfAccountsCode(), invoiceAccount.getAccountNumber());
        if (ObjectUtils.isNotNull(awardAccountExtension)) {
            purchaseOrderNumber = awardAccountExtension.getAccountPurchaseOrderNumber();
        }
    }
    return purchaseOrderNumber;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail) AwardAccountExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardAccountExtendedAttribute)

Example 3 with InvoiceAccountDetail

use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentServiceImpl method findPurchaseOrderNumberForInvoiceOptionContractControlAndScheduled.

protected String findPurchaseOrderNumberForInvoiceOptionContractControlAndScheduled(ContractsGrantsInvoiceDocument document) {
    String purchaseOrderNumber = StringUtils.EMPTY;
    List<InvoiceAccountDetail> invoiceAccountDetails = document.getAccountDetails();
    if (CollectionUtils.isNotEmpty(invoiceAccountDetails)) {
        Account contractControlAccount = determineContractControlAccount(invoiceAccountDetails.get(0));
        if (ObjectUtils.isNotNull(contractControlAccount)) {
            AwardAccountExtendedAttribute awardAccountExtension = findAwardAccountExtendedAttribute(invoiceAccountDetails.get(0).getProposalNumber(), contractControlAccount.getChartOfAccountsCode(), contractControlAccount.getAccountNumber());
            if (ObjectUtils.isNotNull(awardAccountExtension)) {
                purchaseOrderNumber = awardAccountExtension.getAccountPurchaseOrderNumber();
            }
        }
    }
    return purchaseOrderNumber;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail) AwardAccountExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardAccountExtendedAttribute)

Example 4 with InvoiceAccountDetail

use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceDocumentServiceImpl method assignCurrentExpenditureToNonExistingAccountObjectCode.

protected void assignCurrentExpenditureToNonExistingAccountObjectCode(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument, ContractsGrantsInvoiceDetail invoiceDetail) {
    String categoryCode = invoiceDetail.getCategoryCode();
    if (StringUtils.isBlank(categoryCode)) {
        throw new IllegalArgumentException("Category Code can not be null during recalculation of account object code for Contracts & Grants Invoice Document.");
    }
    // get the category that matches this category code.
    final CostCategory category = businessObjectService.findBySinglePrimaryKey(CostCategory.class, categoryCode);
    // got the category now.
    if (!ObjectUtils.isNull(category)) {
        final KualiDecimal oneCent = new KualiDecimal(0.01);
        int size = contractsGrantsInvoiceDocument.getAccountDetails().size();
        KualiDecimal amount = new KualiDecimal(invoiceDetail.getInvoiceAmount().bigDecimalValue().divide(new BigDecimal(size), 2, RoundingMode.HALF_UP));
        KualiDecimal remainder = invoiceDetail.getInvoiceAmount().subtract(amount.multiply(new KualiDecimal(size)));
        for (InvoiceAccountDetail invoiceAccountDetail : contractsGrantsInvoiceDocument.getAccountDetails()) {
            InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode = new InvoiceDetailAccountObjectCode();
            invoiceDetailAccountObjectCode.setDocumentNumber(contractsGrantsInvoiceDocument.getDocumentNumber());
            invoiceDetailAccountObjectCode.setProposalNumber(contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getProposalNumber());
            invoiceDetailAccountObjectCode.setCategoryCode(categoryCode);
            invoiceDetailAccountObjectCode.setAccountNumber(invoiceAccountDetail.getAccountNumber());
            invoiceDetailAccountObjectCode.setChartOfAccountsCode(invoiceAccountDetail.getChartOfAccountsCode());
            // it's 0.00 that's why we are in this section to begin with.
            invoiceDetailAccountObjectCode.setCumulativeExpenditures(KualiDecimal.ZERO);
            // this is also 0.00 because it has never been billed before
            invoiceDetailAccountObjectCode.setTotalBilled(KualiDecimal.ZERO);
            final ObjectCodeCurrent objectCode = getCostCategoryService().findObjectCodeForChartAndCategory(invoiceAccountDetail.getChartOfAccountsCode(), categoryCode);
            if (!ObjectUtils.isNull(objectCode)) {
                invoiceDetailAccountObjectCode.setFinancialObjectCode(objectCode.getFinancialObjectCode());
            }
            // tack on or remove one penny until the remainder is 0 - take a penny, leave a penny!
            if (remainder.isGreaterThan(KualiDecimal.ZERO)) {
                amount = amount.add(oneCent);
                remainder = remainder.subtract(oneCent);
            } else if (remainder.isLessThan(KualiDecimal.ZERO)) {
                amount = amount.subtract(oneCent);
                remainder = remainder.add(oneCent);
            }
            invoiceDetailAccountObjectCode.setCurrentExpenditures(amount);
            List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodes = contractsGrantsInvoiceDocument.getInvoiceDetailAccountObjectCodes();
            if (invoiceDetailAccountObjectCodes.contains(invoiceDetailAccountObjectCode)) {
                // update existing code
                InvoiceDetailAccountObjectCode original = invoiceDetailAccountObjectCodes.get(invoiceDetailAccountObjectCodes.indexOf(invoiceDetailAccountObjectCode));
                original.setCurrentExpenditures(amount);
                original.setCategoryCode(categoryCode);
            } else {
                // add this single account object code item to the list in the Map
                contractsGrantsInvoiceDocument.getInvoiceDetailAccountObjectCodes().add(invoiceDetailAccountObjectCode);
            }
        }
    } else {
        LOG.error("Category Code cannot be found from the category list during recalculation of account object " + "code for Contracts & Grants Invoice Document.");
    }
}
Also used : 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) ObjectCodeCurrent(org.kuali.kfs.coa.businessobject.ObjectCodeCurrent) CostCategory(org.kuali.kfs.module.ar.businessobject.CostCategory) BigDecimal(java.math.BigDecimal) InvoiceDetailAccountObjectCode(org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)

Example 5 with InvoiceAccountDetail

use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail 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)

Aggregations

InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)18 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)9 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)7 HashMap (java.util.HashMap)5 Account (org.kuali.kfs.coa.businessobject.Account)5 InvoiceDetailAccountObjectCode (org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)5 ContractsAndGrantsBillingAwardAccount (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount)4 ArrayList (java.util.ArrayList)3 SubFundGroup (org.kuali.kfs.coa.businessobject.SubFundGroup)3 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)3 AwardAccountExtendedAttribute (edu.cornell.kfs.module.cg.businessobject.AwardAccountExtendedAttribute)2 List (java.util.List)2 ContractsGrantsInvoiceDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail)2 ContractsGrantsLetterOfCreditReviewDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsLetterOfCreditReviewDetail)2 CustomerInvoiceDetail (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail)2 InvoiceAddressDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAddressDetail)2 InvoiceGeneralDetail (org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail)2 InvoiceMilestone (org.kuali.kfs.module.ar.businessobject.InvoiceMilestone)2 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)2 BigDecimal (java.math.BigDecimal)1