You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2008/11/15 00:10:14 UTC

svn commit: r714185 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Author: sichen
Date: Fri Nov 14 15:10:13 2008
New Revision: 714185

URL: http://svn.apache.org/viewvc?rev=714185&view=rev
Log:
fix bug where payments are not applied to invoices generated by subsequent ship groups that are packed

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=714185&r1=714184&r2=714185&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Fri Nov 14 15:10:13 2008
@@ -774,19 +774,17 @@
                 currentPayments.addAll(payments);
             }
             if (currentPayments.size() > 0) {
-                // apply these payments to the invoice; only if they haven't already been applied
+                // apply these payments to the invoice if they have any remaining amount to apply
                 Iterator cpi = currentPayments.iterator();
                 while (cpi.hasNext()) {
                     GenericValue payment = (GenericValue) cpi.next();
-                    List currentApplications = null;
-                    currentApplications = payment.getRelated("PaymentApplication");
-                    if (currentApplications == null || currentApplications.size() == 0) {
-                        // no applications; okay to apply
+                    BigDecimal notApplied = PaymentWorker.getPaymentNotAppliedBd(payment);
+                    if (notApplied.signum() > 0) {
                         Map appl = new HashMap();
                         appl.put("paymentId", payment.get("paymentId"));
                         appl.put("invoiceId", invoiceId);
                         appl.put("billingAccountId", billingAccountId);
-                        appl.put("amountApplied", payment.get("amount"));
+                        appl.put("amountApplied", new Double(notApplied.doubleValue()));
                         appl.put("userLogin", userLogin);
                         Map createPayApplResult = dispatcher.runSync("createPaymentApplication", appl); 
                         if (ServiceUtil.isError(createPayApplResult)) {



Re: svn commit: r714185 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Posted by Adam Heath <do...@brainfood.com>.
sichen@apache.org wrote:
> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=714185&r1=714184&r2=714185&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
> +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Fri Nov 14 15:10:13 2008
> @@ -774,19 +774,17 @@
>                  currentPayments.addAll(payments);
>              }
>              if (currentPayments.size() > 0) {
> -                // apply these payments to the invoice; only if they haven't already been applied
> +                // apply these payments to the invoice if they have any remaining amount to apply
>                  Iterator cpi = currentPayments.iterator();
>                  while (cpi.hasNext()) {
>                      GenericValue payment = (GenericValue) cpi.next();
> -                    List currentApplications = null;
> -                    currentApplications = payment.getRelated("PaymentApplication");
> -                    if (currentApplications == null || currentApplications.size() == 0) {
> -                        // no applications; okay to apply
> +                    BigDecimal notApplied = PaymentWorker.getPaymentNotAppliedBd(payment);
> +                    if (notApplied.signum() > 0) {
>                          Map appl = new HashMap();
>                          appl.put("paymentId", payment.get("paymentId"));
>                          appl.put("invoiceId", invoiceId);
>                          appl.put("billingAccountId", billingAccountId);
> -                        appl.put("amountApplied", payment.get("amount"));
> +                        appl.put("amountApplied", new Double(notApplied.doubleValue()));

Haven't mentioned this 'til now, but let's not use new Number() going
foward; the pattern should be Number.valueOf.

Keeping the new HashMap for now is fine.  I'm just saying if new code is
added, use java 1.5 features for it.

ps: I have patches that fix new Number, convert all collections to
javolution, etc, just haven't applied them, while I wait for the product
generification to settle.