use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CashControlDocument method recalculateTotals.
public void recalculateTotals() {
KualiDecimal total = KualiDecimal.ZERO;
for (CashControlDetail cashControlDetail : getCashControlDetails()) {
total = total.add(cashControlDetail.getFinancialDocumentLineAmount());
}
cashControlTotalAmount = total;
getFinancialSystemDocumentHeader().setFinancialDocumentTotalAmount(total);
// from 'A' to 'N' and GLPEs won't be correctly processed into G/L entries / cleared.
if (getDocumentHeader().getWorkflowDocument().isInitiated() || getDocumentHeader().getWorkflowDocument().isSaved() || getDocumentHeader().getWorkflowDocument().isEnroute() || getDocumentHeader().getWorkflowDocument().isException()) {
recalculateGeneralLedgerPendingEntries();
}
// end of FINP-7340
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method buildAwardFieldsMap.
private Map<String, Object> buildAwardFieldsMap(ContractsAndGrantsBillingAward award) {
Map<String, Object> awardFieldsMap = new HashMap<>();
KualiDecimal billing = getAwardBilledToDateAmount(award.getProposalNumber());
KualiDecimal payments = calculateTotalPaymentsToDateByAward(award);
KualiDecimal receivable = billing.subtract(payments);
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.BILLINGS, billing);
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.PAYMENTS, payments);
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.RECEIVABLES, receivable);
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.PROPOSAL_NUMBER, award.getProposalNumber());
if (ObjectUtils.isNotNull(award.getAwardBeginningDate())) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_BEGINNING_DATE, award.getAwardBeginningDate());
}
if (ObjectUtils.isNotNull(award.getAwardEndingDate())) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_ENDING_DATE, award.getAwardEndingDate());
}
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_TOTAL_AMOUNT, award.getAwardTotalAmount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_ADDENDUM_NUMBER, award.getAwardAddendumNumber());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_ALLOCATED_UNIVERSITY_COMPUTING_SERVICES_AMOUNT, award.getAwardAllocatedUniversityComputingServicesAmount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.FEDERAL_PASS_THROUGH_FUNDED_AMOUNT, award.getFederalPassThroughFundedAmount());
if (ObjectUtils.isNotNull(award.getAwardEntryDate())) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_ENTRY_DATE, award.getAwardEntryDate());
}
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AGENCY_FUTURE_1_AMOUNT, award.getAgencyFuture1Amount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AGENCY_FUTURE_2_AMOUNT, award.getAgencyFuture2Amount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AGENCY_FUTURE_3_AMOUNT, award.getAgencyFuture3Amount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_DOCUMENT_NUMBER, award.getAwardDocumentNumber());
if (ObjectUtils.isNotNull(award.getAwardLastUpdateDate())) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_LAST_UPDATE_DATE, award.getAwardLastUpdateDate());
}
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.FEDERAL_PASS_THROUGH_INDICATOR, award.getFederalPassThroughIndicator());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_DIRECT_COST_AMOUNT, award.getAwardDirectCostAmount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_INDIRECT_COST_AMOUNT, award.getAwardIndirectCostAmount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.GRANT_DESCRIPTION_CODE, award.getGrantDescriptionCode());
final ContractAndGrantsProposal proposal = award.getProposal();
if (ObjectUtils.isNotNull(proposal)) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.GRANT_NUMBER, proposal.getGrantNumber());
}
awardFieldsMap.put(KFSPropertyConstants.AGENCY_NUMBER, award.getAgencyNumber());
awardFieldsMap.put(KFSPropertyConstants.AGENCY + "." + KFSPropertyConstants.FULL_NAME, award.getAgency().getFullName());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.FEDERAL_PASS_THROUGH_AGENCY_NUMBER, award.getFederalPassThroughAgencyNumber());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AGENCY_ANALYST_NAME, award.getAgencyAnalystName());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.ANALYST_TELEPHONE_NUMBER, award.getAnalystTelephoneNumber());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.BILLING_FREQUENCY_CODE, award.getBillingFrequencyCode());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.AWARD_PROJECT_TITLE, award.getAwardProjectTitle());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AWARD_PURPOSE_CODE, award.getAwardPurposeCode());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + KFSPropertyConstants.ACTIVE, award.isActive());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.EXCLUDED_FROM_INVOICING, award.isExcludedFromInvoicing());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.ADDITIONAL_FORMS_REQUIRED, award.isAdditionalFormsRequiredIndicator());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.ADDITIONAL_FORMS_DESCRIPTION, award.getAdditionalFormsDescription());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.INSTRUMENT_TYPE_CODE, award.getInstrumentTypeCode());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.MIN_INVOICE_AMOUNT, award.getMinInvoiceAmount());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.AUTO_APPROVE, award.getAutoApproveIndicator());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.FUNDING_EXPIRATION_DATE, award.getFundingExpirationDate());
if (ObjectUtils.isNotNull(award.getAwardPrimaryProjectDirector())) {
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArConstants.AWARD_PROJECT_DIRECTOR + "." + KFSPropertyConstants.NAME, award.getAwardPrimaryProjectDirector().getProjectDirector().getName());
}
if (ObjectUtils.isNotNull(award.getAwardPrimaryFundManager())) {
final Person fundManager = award.getAwardPrimaryFundManager().getFundManager();
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.PRIMARY_FUND_MANAGER + "." + KFSPropertyConstants.NAME, fundManager.getName());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.PRIMARY_FUND_MANAGER + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.EMAIL, fundManager.getEmailAddress());
awardFieldsMap.put(KFSPropertyConstants.AWARD + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.PRIMARY_FUND_MANAGER + "." + ArPropertyConstants.ContractsAndGrantsBillingAwardFields.PHONE, fundManager.getPhoneNumber());
}
return awardFieldsMap;
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method getAwardBilledToDateAmountExcludingDocument.
@Override
public KualiDecimal getAwardBilledToDateAmountExcludingDocument(String proposalNumber, String documentNumber) {
Map<String, String> fieldValues = new HashMap<>();
fieldValues.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentFields.PROPOSAL_NUMBER, proposalNumber);
fieldValues.put(KFSPropertyConstants.DOCUMENT_HEADER + "." + KFSPropertyConstants.WORKFLOW_DOCUMENT_STATUS_CODE, StringUtils.join(financialSystemDocumentService.getSuccessfulDocumentStatuses(), "|"));
fieldValues.put(KFSPropertyConstants.DOCUMENT_NUMBER, SearchOperator.NOT + documentNumber);
Collection<ContractsGrantsInvoiceDocument> invoiceDocuments = retrieveAllCGInvoicesByCriteria(fieldValues);
final KualiDecimal milestoneTotal = getMilestonesBilledToDateAmount(proposalNumber);
final KualiDecimal billTotal = getPredeterminedBillingBilledToDateAmount(proposalNumber);
final KualiDecimal nonScheduledTotal = calculateTotalInvoiceAmount(invoiceDocuments);
return milestoneTotal.add(billTotal).add(nonScheduledTotal);
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method adjustObjectCodeAmountsIfChanged.
/**
* If any of the current expenditures for the cost categories on the Contracts & Grants Invoice Document have
* changed, recalculate the Object Code amounts.
*
* @param contractsGrantsInvoiceDocument document containing cost categories to review
* @return true if expenditure value changed, false otherwise
*/
protected boolean adjustObjectCodeAmountsIfChanged(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
boolean isExpenditureValueChanged = false;
// put the invoiceDetailAccountObjectCode into a map based on category
List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodes = contractsGrantsInvoiceDocument.getInvoiceDetailAccountObjectCodes();
Map<String, List<InvoiceDetailAccountObjectCode>> invoiceDetailAccountObjectCodeMap = new HashMap<>();
for (InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode : invoiceDetailAccountObjectCodes) {
String categoryCode = invoiceDetailAccountObjectCode.getCategoryCode();
List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodeList = invoiceDetailAccountObjectCodeMap.get(categoryCode);
// if new category, create new list to put into map
if (invoiceDetailAccountObjectCodeList == null) {
List<InvoiceDetailAccountObjectCode> newInvoiceDetailAccountObjectCodeList = new ArrayList<>();
newInvoiceDetailAccountObjectCodeList.add(invoiceDetailAccountObjectCode);
invoiceDetailAccountObjectCodeMap.put(categoryCode, newInvoiceDetailAccountObjectCodeList);
} else {
// else, if list is found, add it to existing list
invoiceDetailAccountObjectCodeMap.get(categoryCode).add(invoiceDetailAccountObjectCode);
}
}
// invoiceDetailObjectCode and update account details
for (ContractsGrantsInvoiceDetail invoiceDetail : contractsGrantsInvoiceDocument.getInvoiceDetails()) {
KualiDecimal total = getSumOfExpendituresOfCategory(invoiceDetailAccountObjectCodeMap.get(invoiceDetail.getCategoryCode()));
// To set expenditures to zero if its blank - to avoid exceptions.
if (ObjectUtils.isNull(invoiceDetail.getInvoiceAmount())) {
invoiceDetail.setInvoiceAmount(KualiDecimal.ZERO);
}
if (invoiceDetail.getInvoiceAmount().compareTo(total) != 0) {
recalculateObjectCodeByCategory(contractsGrantsInvoiceDocument, invoiceDetail, total, invoiceDetailAccountObjectCodeMap.get(invoiceDetail.getCategoryCode()));
isExpenditureValueChanged = true;
}
}
return isExpenditureValueChanged;
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method calculateTotalPaymentsToDateByAward.
@Override
public KualiDecimal calculateTotalPaymentsToDateByAward(ContractsAndGrantsBillingAward award) {
KualiDecimal totalPayments = KualiDecimal.ZERO;
Map<String, Object> criteria = new HashMap<>();
criteria.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentFields.PROPOSAL_NUMBER, award.getProposalNumber());
Collection<ContractsGrantsInvoiceDocument> cgInvoiceDocs = businessObjectService.findMatching(ContractsGrantsInvoiceDocument.class, criteria);
for (ContractsGrantsInvoiceDocument cgInvoiceDoc : cgInvoiceDocs) {
totalPayments = totalPayments.add(getCustomerInvoiceDocumentService().calculateAppliedPaymentAmount(cgInvoiceDoc));
}
return totalPayments;
}
Aggregations