Search in sources :

Example 11 with CustomerInvoiceDetail

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

the class ContractsGrantsInvoiceDocumentServiceImpl method recalculateSourceAccountingLineTotals.

/**
 * If the document has only one CustomerInvoiceDetail, update the amount with the total expenditures from the
 * cost categories; otherwise, split the amounts by account.
 */
@Override
public void recalculateSourceAccountingLineTotals(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
    if (!CollectionUtils.isEmpty(contractsGrantsInvoiceDocument.getSourceAccountingLines())) {
        if (contractsGrantsInvoiceDocument.getSourceAccountingLines().size() == 1) {
            final CustomerInvoiceDetail customerInvoiceDetail = (CustomerInvoiceDetail) contractsGrantsInvoiceDocument.getSourceAccountingLine(0);
            customerInvoiceDetail.setAmount(getTotalAmountForInvoice(contractsGrantsInvoiceDocument));
        } else {
            final Map<String, KualiDecimal> accountExpenditureAmounts = getCategoryExpenditureAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
            for (Object al : contractsGrantsInvoiceDocument.getSourceAccountingLines()) {
                final CustomerInvoiceDetail customerInvoiceDetail = (CustomerInvoiceDetail) al;
                final String accountKey = StringUtils.join(new String[] { customerInvoiceDetail.getChartOfAccountsCode(), customerInvoiceDetail.getAccountNumber() }, "-");
                customerInvoiceDetail.setAmount(accountExpenditureAmounts.getOrDefault(accountKey, KualiDecimal.ZERO));
            }
        }
    }
}
Also used : 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)

Aggregations

CustomerInvoiceDetail (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail)11 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 AccountsReceivableCustomerInvoiceDetail (org.kuali.kfs.integration.ar.AccountsReceivableCustomerInvoiceDetail)4 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)3 List (java.util.List)2 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)2 BigDecimal (java.math.BigDecimal)1 SubFundGroup (org.kuali.kfs.coa.businessobject.SubFundGroup)1 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)1 ContractsGrantsInvoiceObjectCode (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceObjectCode)1 CustomerInvoiceItemCode (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceItemCode)1 OrganizationAccountingDefault (org.kuali.kfs.module.ar.businessobject.OrganizationAccountingDefault)1 SystemInformation (org.kuali.kfs.module.ar.businessobject.SystemInformation)1 AttributedRouteDocumentEvent (org.kuali.kfs.sys.document.validation.event.AttributedRouteDocumentEvent)1