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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Adam Heath-2
[hidden email] 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.