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));
}
}
}
}
Aggregations