Search in sources :

Example 11 with InvoiceAccountDetail

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;
}
Also used : HashMap(java.util.HashMap) 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) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)

Example 12 with InvoiceAccountDetail

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);
    }
}
Also used : HashMap(java.util.HashMap) 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) InvoiceDetailAccountObjectCode(org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)

Example 13 with InvoiceAccountDetail

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));
    }
}
Also used : HashMap(java.util.HashMap) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 14 with InvoiceAccountDetail

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);
    }
}
Also used : InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 15 with InvoiceAccountDetail

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));
}
Also used : 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)

Aggregations

InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)18 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)9 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)7 HashMap (java.util.HashMap)5 Account (org.kuali.kfs.coa.businessobject.Account)5 InvoiceDetailAccountObjectCode (org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)5 ContractsAndGrantsBillingAwardAccount (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount)4 ArrayList (java.util.ArrayList)3 SubFundGroup (org.kuali.kfs.coa.businessobject.SubFundGroup)3 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)3 AwardAccountExtendedAttribute (edu.cornell.kfs.module.cg.businessobject.AwardAccountExtendedAttribute)2 List (java.util.List)2 ContractsGrantsInvoiceDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail)2 ContractsGrantsLetterOfCreditReviewDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsLetterOfCreditReviewDetail)2 CustomerInvoiceDetail (org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail)2 InvoiceAddressDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAddressDetail)2 InvoiceGeneralDetail (org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail)2 InvoiceMilestone (org.kuali.kfs.module.ar.businessobject.InvoiceMilestone)2 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)2 BigDecimal (java.math.BigDecimal)1