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;
}
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;
}
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);
}
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;
}
Aggregations