Search in sources :

Example 6 with InvoicePaidApplied

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

the class PaymentApplicationAction method generateAndValidateNewPaidApplied.

/**
 * Create an InvoicePaidApplied for a CustomerInvoiceDetail and validate it. If the validation succeeds the
 * paidApplied is returned. If the validation does succeed a null is returned.
 *
 * @param detailApplication
 * @param fieldName
 * @param document
 * @return
 */
protected InvoicePaidApplied generateAndValidateNewPaidApplied(PaymentApplicationInvoiceDetailApply detailApplication, String fieldName, PaymentApplicationDocument document) {
    // generate the paidApplied
    InvoicePaidApplied paidApplied = detailApplication.generatePaidApplied();
    // validate the paidApplied, but ignore any failures (other than the error message)
    LOG.debug("Validating the generated paidApplied " + paidApplied.getDocumentNumber());
    PaymentApplicationDocumentRuleUtil.validateInvoicePaidApplied(paidApplied, fieldName, document);
    // return the generated paidApplied
    return paidApplied;
}
Also used : InvoicePaidApplied(org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied)

Example 7 with InvoicePaidApplied

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

the class PaymentApplicationAction method quickApplyToInvoices.

protected List<InvoicePaidApplied> quickApplyToInvoices(PaymentApplicationForm paymentApplicationForm, List<InvoicePaidApplied> appliedToIndividualDetails) {
    PaymentApplicationDocument applicationDocument = (PaymentApplicationDocument) paymentApplicationForm.getDocument();
    List<InvoicePaidApplied> invoicePaidApplieds = new ArrayList<>();
    // go over the selected invoices and apply full amount to each of their details
    for (PaymentApplicationInvoiceApply invoiceApplication : paymentApplicationForm.getInvoiceApplications()) {
        String invoiceDocNumber = invoiceApplication.getDocumentNumber();
        // skip the line if its not set to quick apply
        if (!invoiceApplication.isQuickApply()) {
            // if it was just flipped from True to False
            if (invoiceApplication.isQuickApplyChanged()) {
                for (PaymentApplicationInvoiceDetailApply detailApplication : invoiceApplication.getDetailApplications()) {
                    // zero out all the details
                    detailApplication.setAmountApplied(KualiDecimal.ZERO);
                    detailApplication.setFullApply(false);
                    // remove any existing paidApplieds for this invoice
                    for (int i = appliedToIndividualDetails.size() - 1; i >= 0; i--) {
                        InvoicePaidApplied applied = appliedToIndividualDetails.get(i);
                        if (applied.getFinancialDocumentReferenceInvoiceNumber().equals(invoiceApplication.getDocumentNumber())) {
                            appliedToIndividualDetails.remove(i);
                        }
                    }
                }
            }
            continue;
        }
        // make sure none of the invoices selected have zero open amounts, complain if so
        if (invoiceApplication.getOpenAmount().isZero()) {
            addGlobalError(ArKeyConstants.PaymentApplicationDocumentErrors.CANNOT_QUICK_APPLY_ON_INVOICE_WITH_ZERO_OPEN_AMOUNT);
            return invoicePaidApplieds;
        }
        // remove any existing paidApplieds for this invoice
        for (int i = appliedToIndividualDetails.size() - 1; i >= 0; i--) {
            InvoicePaidApplied applied = appliedToIndividualDetails.get(i);
            if (applied.getFinancialDocumentReferenceInvoiceNumber().equals(invoiceApplication.getDocumentNumber())) {
                appliedToIndividualDetails.remove(i);
            }
        }
        // create and validate the paid applieds for each invoice detail
        String fieldName = "invoiceApplications[" + invoiceDocNumber + "].quickApply";
        for (PaymentApplicationInvoiceDetailApply detailApplication : invoiceApplication.getDetailApplications()) {
            detailApplication.setAmountApplied(detailApplication.getAmountOpen());
            detailApplication.setFullApply(true);
            InvoicePaidApplied paidApplied = generateAndValidateNewPaidApplied(detailApplication, fieldName, applicationDocument);
            if (paidApplied != null) {
                invoicePaidApplieds.add(paidApplied);
            }
        }
        // maintain the selected doc number
        if (invoiceDocNumber.equals(paymentApplicationForm.getEnteredInvoiceDocumentNumber())) {
            paymentApplicationForm.setSelectedInvoiceDocumentNumber(invoiceDocNumber);
        }
    }
    return invoicePaidApplieds;
}
Also used : InvoicePaidApplied(org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied) ArrayList(java.util.ArrayList) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument)

Example 8 with InvoicePaidApplied

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

the class PaymentApplicationAction method filterTempInvoicePaidApplieds.

protected List<InvoicePaidApplied> filterTempInvoicePaidApplieds(PaymentApplicationForm paymentApplicationForm) {
    PaymentApplicationDocument paymentApplicationDocument = paymentApplicationForm.getPaymentApplicationDocument();
    List<InvoicePaidApplied> invoicePaidApplieds = paymentApplicationDocument.getInvoicePaidApplieds();
    return new ArrayList<>(invoicePaidApplieds);
}
Also used : InvoicePaidApplied(org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied) ArrayList(java.util.ArrayList) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument)

Example 9 with InvoicePaidApplied

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

the class PaymentApplicationForm method getPaidAppliedForInvoiceDetail.

/**
 * For a given invoiceDocNumber and invoiceItemNumber, this method will return any paidApplieds that match those
 * two fields, if any exists. Otherwise it will return null.
 */
public InvoicePaidApplied getPaidAppliedForInvoiceDetail(String invoiceDocNumber, Integer invoiceItemNumber) {
    if (StringUtils.isBlank(invoiceDocNumber)) {
        throw new IllegalArgumentException("The parameter [invoiceDocNumber] passed in was blank or null.");
    }
    if (invoiceItemNumber == null || invoiceItemNumber < 1) {
        throw new IllegalArgumentException("The parameter [invoiceItemNumber] passed in was blank, zero or negative.");
    }
    PaymentApplicationDocument payAppDoc = getPaymentApplicationDocument();
    List<InvoicePaidApplied> paidApplieds = payAppDoc.getInvoicePaidApplieds();
    for (InvoicePaidApplied paidApplied : paidApplieds) {
        if (invoiceDocNumber.equalsIgnoreCase(paidApplied.getFinancialDocumentReferenceInvoiceNumber())) {
            if (invoiceItemNumber.equals(paidApplied.getInvoiceItemNumber())) {
                return paidApplied;
            }
        }
    }
    return null;
}
Also used : InvoicePaidApplied(org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument)

Aggregations

InvoicePaidApplied (org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied)9 PaymentApplicationDocument (org.kuali.kfs.module.ar.document.PaymentApplicationDocument)6 ArrayList (java.util.ArrayList)4 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)3 ParseException (java.text.ParseException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 Document (org.kuali.kfs.krad.document.Document)1 ContractsGrantsPaymentHistoryReport (org.kuali.kfs.module.ar.businessobject.ContractsGrantsPaymentHistoryReport)1 NonAppliedHolding (org.kuali.kfs.module.ar.businessobject.NonAppliedHolding)1 NonInvoiced (org.kuali.kfs.module.ar.businessobject.NonInvoiced)1 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)1 PaymentApplicationAdjustableDocument (org.kuali.kfs.module.ar.document.PaymentApplicationAdjustableDocument)1 FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)1