[OFBiz] SVN: r6905 - trunk/applications/accounting/script/org/ofbiz/accounting/payment

sichen@svn.ofbiz.org sichen at svn.ofbiz.org
Fri Mar 3 11:59:59 CST 2006


Author: sichen
Date: 2006-03-03 11:59:56 -0600 (Fri, 03 Mar 2006)
New Revision: 6905

Modified:
   trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
Log:
Now when payment applications are created with reference to an invoice, it will see if the amount to apply will go over the outstanding amount in the invoice. If so, it will apply only enough to satisfy the outstanding amount, leaving the rest unapplied. A warning will be logged.

Modified: trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
===================================================================
--- trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml	2006-03-03 17:11:54 UTC (rev 6904)
+++ trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml	2006-03-03 17:59:56 UTC (rev 6905)
@@ -115,11 +115,21 @@
         <make-value entity-name="PaymentApplication" value-name="paymentAppl"/>
         <set-nonpk-fields map-name="parameters" value-name="paymentAppl"/>
 
+        <!-- get the invoice and do some further validation against it -->
         <if-not-empty field-name="parameters.invoiceId">
             <entity-one entity-name="Invoice" value-name="invoice"/>
             <if-not-empty field-name="invoice.billingAccountId">
                 <set from-field="invoice.billingAccountId" field="paymentAppl.billingAccountId"/>
             </if-not-empty>
+
+            <!-- get the amount that has not been applied yet for the invoice (outstanding amount) -->
+            <set field="notApplied" value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice).doubleValue()}"/>
+
+            <!-- if the amount to apply goes over the outstanding amount, then use the notApplied amount and log a warning -->
+            <if-compare-field field-name="paymentAppl.amountApplied" operator="greater" to-field-name="notApplied">
+                <log level="warn" message="Create Payment Application: Amount to apply [${paymentAppl.amountApplied}] is greater than the outstanding amount [${notApplied}] of the invoice [${invoice.invoiceId}]. Creating Payment Application for outstanding amount [${notApplied}] instead."/>
+                <set field="paymentAppl.amountApplied" from-field="notApplied"/>
+            </if-compare-field>
         </if-not-empty>
 
         <sequenced-id-to-env sequence-name="PaymentApplication" env-name="paymentAppl.paymentApplicationId"/>



More information about the Svn mailing list