Search in sources :

Example 1 with NonInvoiced

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

the class PaymentApplicationAction method doApplicationOfFunds.

protected void doApplicationOfFunds(PaymentApplicationForm paymentApplicationForm) throws WorkflowException {
    PaymentApplicationDocument paymentApplicationDocument = paymentApplicationForm.getPaymentApplicationDocument();
    List<InvoicePaidApplied> invoicePaidApplieds = new ArrayList<>();
    // apply invoice detail entries
    invoicePaidApplieds.addAll(applyToIndividualCustomerInvoiceDetails(paymentApplicationForm));
    // quick-apply invoices
    invoicePaidApplieds.addAll(quickApplyToInvoices(paymentApplicationForm, invoicePaidApplieds));
    // re-number the paidApplieds internal sequence numbers
    int paidAppliedItemNumber = 1;
    for (InvoicePaidApplied i : invoicePaidApplieds) {
        i.setPaidAppliedItemNumber(paidAppliedItemNumber++);
    }
    // apply non-Invoiced
    NonInvoiced nonInvoiced = applyNonInvoiced(paymentApplicationForm);
    // apply non-applied holdings
    NonAppliedHolding nonAppliedHolding = applyUnapplied(paymentApplicationForm);
    // sum up the paid applieds
    KualiDecimal sumOfInvoicePaidApplieds = KualiDecimal.ZERO;
    for (InvoicePaidApplied invoicePaidApplied : invoicePaidApplieds) {
        KualiDecimal amount = invoicePaidApplied.getInvoiceItemAppliedAmount();
        if (null == amount) {
            amount = KualiDecimal.ZERO;
        }
        sumOfInvoicePaidApplieds = sumOfInvoicePaidApplieds.add(amount);
    }
    // sum up all applieds
    KualiDecimal appliedAmount = KualiDecimal.ZERO;
    appliedAmount = appliedAmount.add(sumOfInvoicePaidApplieds);
    if (null != nonInvoiced && null != nonInvoiced.getFinancialDocumentLineAmount()) {
        appliedAmount = appliedAmount.add(nonInvoiced.getFinancialDocumentLineAmount());
    }
    appliedAmount = appliedAmount.add(paymentApplicationDocument.getSumOfNonAppliedDistributions());
    appliedAmount = appliedAmount.add(paymentApplicationDocument.getSumOfNonInvoicedDistributions());
    appliedAmount = appliedAmount.add(paymentApplicationDocument.getSumOfNonInvoiceds());
    if (null != paymentApplicationDocument.getNonAppliedHoldingAmount()) {
        appliedAmount = appliedAmount.add(paymentApplicationDocument.getNonAppliedHoldingAmount());
    }
    // check that we haven't applied more than our control total
    KualiDecimal controlTotalAmount = paymentApplicationForm.getTotalFromControl();
    // if the person over-applies, we dont stop them, we just complain
    if (appliedAmount.isGreaterThan(controlTotalAmount)) {
        addGlobalError(ArKeyConstants.PaymentApplicationDocumentErrors.CANNOT_APPLY_MORE_THAN_CASH_CONTROL_TOTAL_AMOUNT);
    }
    // swap out the old paidApplieds with the newly generated
    paymentApplicationDocument.getInvoicePaidApplieds().clear();
    paymentApplicationDocument.getInvoicePaidApplieds().addAll(invoicePaidApplieds);
    // NonInvoiced list management
    if (null != nonInvoiced) {
        paymentApplicationDocument.getNonInvoiceds().add(nonInvoiced);
        // re-number the non-invoiced
        int nonInvoicedItemNumber = 1;
        for (NonInvoiced n : paymentApplicationDocument.getNonInvoiceds()) {
            n.setFinancialDocumentLineNumber(nonInvoicedItemNumber++);
            n.refreshReferenceObject("chartOfAccounts");
            n.refreshReferenceObject("account");
            n.refreshReferenceObject("subAccount");
            n.refreshReferenceObject("financialObject");
            n.refreshReferenceObject("financialSubObject");
            n.refreshReferenceObject("project");
        }
        // make an empty new one
        paymentApplicationForm.setNonInvoicedAddLine(new NonInvoiced());
    }
    // reset the allocations, so it gets re-calculated
    paymentApplicationForm.setNonAppliedControlAllocations(null);
    // Update the doc total if it is not a CashControl generated PayApp
    if (!paymentApplicationDocument.hasCashControlDetail()) {
        paymentApplicationDocument.getFinancialSystemDocumentHeader().setFinancialDocumentTotalAmount(appliedAmount);
    }
}
Also used : InvoicePaidApplied(org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument) NonAppliedHolding(org.kuali.kfs.module.ar.businessobject.NonAppliedHolding) NonInvoiced(org.kuali.kfs.module.ar.businessobject.NonInvoiced)

Example 2 with NonInvoiced

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

the class PaymentApplicationAction method applyNonInvoiced.

protected NonInvoiced applyNonInvoiced(PaymentApplicationForm payAppForm) throws WorkflowException {
    PaymentApplicationDocument applicationDocument = (PaymentApplicationDocument) payAppForm.getDocument();
    NonInvoiced nonInvoiced = payAppForm.getNonInvoicedAddLine();
    // amount entered is blank or zero.
    if (ObjectUtils.isNull(payAppForm.getNonInvoicedAddLine()) || nonInvoiced.getFinancialDocumentLineAmount() == null || nonInvoiced.getFinancialDocumentLineAmount().isZero()) {
        return null;
    }
    // If we got past the above conditional, wire it up for adding
    nonInvoiced.setFinancialDocumentPostingYear(applicationDocument.getPostingYear());
    nonInvoiced.setDocumentNumber(applicationDocument.getDocumentNumber());
    nonInvoiced.setFinancialDocumentLineNumber(payAppForm.getNextNonInvoicedLineNumber());
    if (StringUtils.isNotBlank(nonInvoiced.getChartOfAccountsCode())) {
        nonInvoiced.setChartOfAccountsCode(nonInvoiced.getChartOfAccountsCode().toUpperCase(Locale.US));
    }
    // run the validations
    boolean isValid = PaymentApplicationDocumentRuleUtil.validateNonInvoiced(nonInvoiced, applicationDocument, payAppForm.getTotalFromControl());
    // check the validation results and return null if there were any errors
    if (!isValid) {
        return null;
    }
    return nonInvoiced;
}
Also used : PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument) NonInvoiced(org.kuali.kfs.module.ar.businessobject.NonInvoiced)

Example 3 with NonInvoiced

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

the class PaymentApplicationAction method deleteNonArLine.

public ActionForward deleteNonArLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    PaymentApplicationForm paymentApplicationForm = (PaymentApplicationForm) form;
    PaymentApplicationDocument paymentApplicationDocument = paymentApplicationForm.getPaymentApplicationDocument();
    int deleteIndex = getLineToDelete(request);
    paymentApplicationDocument.getNonInvoiceds().remove(deleteIndex);
    int nonInvoicedItemNumber = 1;
    for (NonInvoiced n : paymentApplicationDocument.getNonInvoiceds()) {
        n.setFinancialDocumentLineNumber(nonInvoicedItemNumber++);
        n.refreshReferenceObject("chartOfAccounts");
        n.refreshReferenceObject("account");
        n.refreshReferenceObject("subAccount");
        n.refreshReferenceObject("financialObject");
        n.refreshReferenceObject("financialSubObject");
        n.refreshReferenceObject("project");
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument) PaymentApplicationForm(org.kuali.kfs.module.ar.document.web.struts.PaymentApplicationForm) NonInvoiced(org.kuali.kfs.module.ar.businessobject.NonInvoiced)

Aggregations

NonInvoiced (org.kuali.kfs.module.ar.businessobject.NonInvoiced)3 PaymentApplicationDocument (org.kuali.kfs.module.ar.document.PaymentApplicationDocument)3 ArrayList (java.util.ArrayList)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 InvoicePaidApplied (org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied)1 NonAppliedHolding (org.kuali.kfs.module.ar.businessobject.NonAppliedHolding)1 PaymentApplicationForm (org.kuali.kfs.module.ar.document.web.struts.PaymentApplicationForm)1