Search in sources :

Example 1 with InvoiceMilestone

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

the class ContractsGrantsInvoiceDocumentServiceImpl method correctContractsGrantsInvoiceDocument.

@Override
public void correctContractsGrantsInvoiceDocument(ContractsGrantsInvoiceDocument document) {
    // correct Direct Cost Invoice Details.
    for (ContractsGrantsInvoiceDetail id : document.getDirectCostInvoiceDetails()) {
        correctInvoiceDetail(id);
    }
    // correct Indirect Cost Invoice Details.
    for (ContractsGrantsInvoiceDetail id : document.getIndirectCostInvoiceDetails()) {
        correctInvoiceDetail(id);
    }
    // update correction to the InvoiceAccountDetail objects
    for (InvoiceAccountDetail id : document.getAccountDetails()) {
        correctInvoiceAccountDetail(id);
    }
    // correct invoiceDetailAccountObjectCode.
    for (InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode : document.getInvoiceDetailAccountObjectCodes()) {
        invoiceDetailAccountObjectCode.correctInvoiceDetailAccountObjectCodeExpenditureAmount();
    }
    // correct Bills
    KualiDecimal totalBillingAmount = KualiDecimal.ZERO;
    for (InvoiceBill bill : document.getInvoiceBills()) {
        bill.setEstimatedAmount(bill.getEstimatedAmount().negated());
        totalBillingAmount = totalBillingAmount.add(bill.getEstimatedAmount());
    }
    // correct Milestones
    KualiDecimal totalMilestonesAmount = KualiDecimal.ZERO;
    for (InvoiceMilestone milestone : document.getInvoiceMilestones()) {
        milestone.setMilestoneAmount(milestone.getMilestoneAmount().negated());
        totalMilestonesAmount = totalMilestonesAmount.add(milestone.getMilestoneAmount());
    }
    document.getInvoiceGeneralDetail().setTotalPreviouslyBilled(getAwardBilledToDateAmountExcludingDocument(document.getInvoiceGeneralDetail().getProposalNumber(), document.getDocumentNumber()));
    if (ArConstants.BillingFrequencyValues.isMilestone(document.getInvoiceGeneralDetail()) && CollectionUtils.isNotEmpty(document.getInvoiceMilestones())) {
        document.getInvoiceGeneralDetail().setTotalAmountBilledToDate(document.getInvoiceGeneralDetail().getTotalAmountBilledToDate().add(totalMilestonesAmount));
    } else if (ArConstants.BillingFrequencyValues.isPredeterminedBilling(document.getInvoiceGeneralDetail()) && CollectionUtils.isNotEmpty(document.getInvoiceBills())) {
        document.getInvoiceGeneralDetail().setTotalAmountBilledToDate(document.getInvoiceGeneralDetail().getTotalAmountBilledToDate().add(totalBillingAmount));
    } else {
        KualiDecimal newTotalBilled = document.getTotalCostInvoiceDetail().getInvoiceAmount().add(document.getInvoiceGeneralDetail().getTotalPreviouslyBilled());
        newTotalBilled = newTotalBilled.add(getOtherTotalBilledForAwardPeriod(document));
        document.getInvoiceGeneralDetail().setTotalAmountBilledToDate(newTotalBilled);
        calculatePreviouslyBilledAmounts(document);
    }
    for (InvoiceAddressDetail invoiceAddressDetail : document.getInvoiceAddressDetails()) {
        invoiceAddressDetail.setInitialTransmissionDate(null);
        invoiceAddressDetail.setTransmittedByPrincipalId("");
        invoiceAddressDetail.setTransmissionDate(null);
        invoiceAddressDetail.setTransmissionStatusCode("");
        invoiceAddressDetail.setTransmissionCount(0);
    }
}
Also used : ContractsGrantsInvoiceDetail(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail) InvoiceBill(org.kuali.kfs.module.ar.businessobject.InvoiceBill) 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) InvoiceMilestone(org.kuali.kfs.module.ar.businessobject.InvoiceMilestone) InvoiceAddressDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAddressDetail) InvoiceDetailAccountObjectCode(org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)

Aggregations

AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 ContractsGrantsInvoiceDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail)1 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)1 InvoiceAddressDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAddressDetail)1 InvoiceBill (org.kuali.kfs.module.ar.businessobject.InvoiceBill)1 InvoiceDetailAccountObjectCode (org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)1 InvoiceMilestone (org.kuali.kfs.module.ar.businessobject.InvoiceMilestone)1