use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method getOtherTotalBilledForAwardPeriod.
@Override
public KualiDecimal getOtherTotalBilledForAwardPeriod(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
KualiDecimal newTotalBilled = KualiDecimal.ZERO;
Map<String, String> fieldValuesForInvoice = new HashMap<>();
fieldValuesForInvoice.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentFields.PROPOSAL_NUMBER, contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getProposalNumber());
fieldValuesForInvoice.put(ArPropertyConstants.INVOICE_GENERAL_DETAIL + "." + ArPropertyConstants.BILLING_PERIOD, contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getBillingPeriod());
String docNumberCriteriaString = SearchOperator.NOT + contractsGrantsInvoiceDocument.getDocumentNumber();
if (ObjectUtils.isNotNull(contractsGrantsInvoiceDocument.getFinancialSystemDocumentHeader()) && StringUtils.isNotBlank(contractsGrantsInvoiceDocument.getFinancialSystemDocumentHeader().getFinancialDocumentInErrorNumber())) {
docNumberCriteriaString += SearchOperator.NOT + contractsGrantsInvoiceDocument.getFinancialSystemDocumentHeader().getFinancialDocumentInErrorNumber();
}
fieldValuesForInvoice.put(KFSPropertyConstants.DOCUMENT_NUMBER, docNumberCriteriaString);
fieldValuesForInvoice.put(ArPropertyConstants.DOCUMENT_STATUS_CODE, SearchOperator.NOT + KFSConstants.DocumentStatusCodes.PROCESSED + SearchOperator.NOT + KFSConstants.DocumentStatusCodes.APPROVED);
Collection<ContractsGrantsInvoiceDocument> cgInvoiceDocuments = retrieveAllCGInvoicesByCriteria(fieldValuesForInvoice);
for (ContractsGrantsInvoiceDocument cgInvoiceDocument : cgInvoiceDocuments) {
for (InvoiceAccountDetail invAcctD : cgInvoiceDocument.getAccountDetails()) {
newTotalBilled = newTotalBilled.add(invAcctD.getInvoiceAmount());
}
}
return newTotalBilled;
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method recalculateAccountDetails.
public void recalculateAccountDetails(List<InvoiceAccountDetail> invoiceAccountDetails, List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodes) {
Map<String, KualiDecimal> currentExpenditureByAccountNumberMap = new HashMap<>();
for (InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode : invoiceDetailAccountObjectCodes) {
String accountNumber = invoiceDetailAccountObjectCode.getAccountNumber();
KualiDecimal expenditureSum = currentExpenditureByAccountNumberMap.get(accountNumber);
// if account number not found in map, then create new total, 0
if (expenditureSum == null) {
expenditureSum = KualiDecimal.ZERO;
}
expenditureSum = expenditureSum.add(invoiceDetailAccountObjectCode.getCurrentExpenditures());
currentExpenditureByAccountNumberMap.put(accountNumber, expenditureSum);
}
for (InvoiceAccountDetail invoiceAccountDetail : invoiceAccountDetails) {
final KualiDecimal expenditureAmount = ObjectUtils.isNull(currentExpenditureByAccountNumberMap.get(invoiceAccountDetail.getAccountNumber())) ? KualiDecimal.ZERO : currentExpenditureByAccountNumberMap.get(invoiceAccountDetail.getAccountNumber());
invoiceAccountDetail.setInvoiceAmount(expenditureAmount);
}
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method updateLastBilledDate.
@Override
public void updateLastBilledDate(ContractsGrantsInvoiceDocument document) {
boolean isFinalBill = document.getInvoiceGeneralDetail().isFinalBillIndicator();
for (InvoiceAccountDetail id : document.getAccountDetails()) {
if (isFinalBill) {
setAwardAccountFinalBilledValueAndLastBilledDate(id, true, document.getInvoiceGeneralDetail().getProposalNumber(), document.isInvoiceReversal(), document.getInvoiceGeneralDetail().getLastBilledDate());
} else {
calculateAwardAccountLastBilledDate(id, document.isInvoiceReversal(), document.getInvoiceGeneralDetail().getLastBilledDate(), document.getInvoiceGeneralDetail().getProposalNumber());
}
}
// 2. Set last Billed to Award = least of last billed date of award account.
String proposalNumber = document.getInvoiceGeneralDetail().getProposalNumber();
Map<String, Object> map = new HashMap<>();
map.put(KFSPropertyConstants.PROPOSAL_NUMBER, proposalNumber);
ContractsAndGrantsBillingAward award = kualiModuleService.getResponsibleModuleService(ContractsAndGrantsBillingAward.class).getExternalizableBusinessObject(ContractsAndGrantsBillingAward.class, map);
if (CollectionUtils.isNotEmpty(award.getActiveAwardAccounts())) {
// To set last billed Date to award.
contractsAndGrantsModuleBillingService.setLastBilledDateToAward(proposalNumber, getLastBilledDate(award));
}
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method updateUnfinalizationToAwardAccount.
@Override
public void updateUnfinalizationToAwardAccount(List<InvoiceAccountDetail> accountDetails, String proposalNumber) {
for (Object entry : accountDetails) {
InvoiceAccountDetail id = (InvoiceAccountDetail) entry;
setAwardAccountFinalBilledValue(id, false, proposalNumber);
}
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method calculatePreviouslyBilledAmounts.
@Override
public void calculatePreviouslyBilledAmounts(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
KualiDecimal previouslyBilledAmount = KualiDecimal.ZERO;
final String proposalNumber = contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getProposalNumber();
for (InvoiceAccountDetail invoiceAccountDetail : contractsGrantsInvoiceDocument.getAccountDetails()) {
String chartOfAccountsCode = invoiceAccountDetail.getChartOfAccountsCode();
String accountNumber = invoiceAccountDetail.getAccountNumber();
previouslyBilledAmount = previouslyBilledAmount.add(getPredeterminedBillingBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
previouslyBilledAmount = previouslyBilledAmount.add(getMilestonesBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
}
contractsGrantsInvoiceDocument.setPreviouslyBilledTotal(previouslyBilledAmount);
KualiDecimal previouslyBilledInvoiceAmount;
if (contractsGrantsInvoiceDocument.isCorrectionDocument()) {
previouslyBilledInvoiceAmount = previouslyBilledAmount.negated();
} else {
final KualiDecimal totalPreviouslyBilled = contractsGrantsInvoiceDocument.getTotalCostInvoiceDetail().getTotalPreviouslyBilled();
previouslyBilledInvoiceAmount = previouslyBilledAmount.subtract(totalPreviouslyBilled);
if (previouslyBilledInvoiceAmount.isLessThan(KualiDecimal.ZERO)) {
previouslyBilledInvoiceAmount = KualiDecimal.ZERO;
}
}
final KualiDecimal invoiceAmount = contractsGrantsInvoiceDocument.getTotalCostInvoiceDetail().getInvoiceAmount();
contractsGrantsInvoiceDocument.setPreviouslyBilledInvoiceAmount(previouslyBilledInvoiceAmount);
contractsGrantsInvoiceDocument.setTotalInvoiceInvoiceAmount(invoiceAmount.subtract(previouslyBilledInvoiceAmount));
}
Aggregations