svn commit: r544051 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

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

svn commit: r544051 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

jacopoc
Author: jacopoc
Date: Sun Jun  3 22:00:20 2007
New Revision: 544051

URL: http://svn.apache.org/viewvc?view=rev&rev=544051
Log:
Fixed an approximation issues happening under some special situations when a billing account + another payment method were selected.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java?view=diff&rev=544051&r1=544050&r2=544051
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentGatewayServices.java Sun Jun  3 22:00:20 2007
@@ -998,6 +998,7 @@
         String billingAccountId = (String) context.get("billingAccountId");
         Double captureAmount = (Double) context.get("captureAmount");
         BigDecimal amountToCapture = new BigDecimal(captureAmount.doubleValue());
+        amountToCapture = amountToCapture.setScale(2, BigDecimal.ROUND_HALF_UP);
 
         // get the order header and payment preferences
         GenericValue orderHeader = null;
@@ -1385,6 +1386,7 @@
         String billingAccountId = (String) context.get("billingAccountId");
         Double captureAmountDbl = (Double) context.get("captureAmount");
         BigDecimal captureAmount = new BigDecimal(captureAmountDbl.doubleValue());
+        captureAmount = captureAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
         String orderId = (String) context.get("orderId");
         BigDecimal capturedAmount = BigDecimal.ZERO;
         
@@ -1412,6 +1414,7 @@
                     // TODO: check the statusId of the payment
                     BigDecimal paymentApplicationAmount = paymentApplication.getBigDecimal("amountApplied");
                     BigDecimal amountToCapture = paymentApplicationAmount.min(captureAmount.subtract(capturedAmount));
+                    amountToCapture = amountToCapture.setScale(2, BigDecimal.ROUND_HALF_UP);
                     if (amountToCapture.compareTo(paymentApplicationAmount) == 0) {
                         // apply the whole payment application to the invoice
                         paymentApplication.set("invoiceId", invoiceId);
@@ -1434,6 +1437,7 @@
         } catch (GenericEntityException ex) {
             return ServiceUtil.returnError(ex.getMessage());
         }
+        capturedAmount = capturedAmount.setScale(2, BigDecimal.ROUND_HALF_UP);
         Map results = ServiceUtil.returnSuccess();
         results.put("captureAmount", new Double(capturedAmount.doubleValue()));
         return results;