Question on payment capture

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

Question on payment capture

Sandeep A
Hi,

I had a question regarding the capture process in the ofbiz...


Below is the code in
org.ofbiz.accounting.payment.PaymentGatewayServices.java
OrderReadHelper orh = new OrderReadHelper(orderHeader);
 BigDecimal orderGrandTotal = orh.getOrderGrandTotal();
 orderGrandTotal = orderGrandTotal.setScale(decimals, rounding);

//Here  getting total payments from payment entity
** BigDecimal totalPayments =
PaymentWorker.getPaymentsTotal(orh.getOrderPayments()); **//this is where
my question is
 totalPayments = totalPayments.setScale(decimals, rounding);
 BigDecimal remainingTotalBd = orderGrandTotal.subtract(totalPayments);

 // The amount to capture cannot be greater than the remaining total
 amountToCapture = amountToCapture.min(remainingTotalBd);

What i understood from the line
PaymentWorker.getPaymentsTotal(orh.getOrderPayments());
is we get all payments (i.e received or sent) and add their amounts.

Now my question is why are we not distinguishing between the status of
Payment while adding them up?
This question comes from
Assume we had order with $100 captured and $10 refunded... total payments
results in $110,
but the order grand total would reflect as $90.

Now if we perform a capture of $19 again i.e order total would be $90 +
$19=$109
the above mentioned condition was capturing $1, whereas it should have
captured $19

Any ideas of why this is being done?


--
Thanks and Regards,
A.SANDEEP.
Reply | Threaded
Open this post in threaded view
|

Re: Question on payment capture

BJ Freeman
What SVN version is you check out?

Sandeep A sent the following on 1/18/2012 10:46 AM:

> Hi,
>
> I had a question regarding the capture process in the ofbiz...
>
>
> Below is the code in
> org.ofbiz.accounting.payment.PaymentGatewayServices.java
> OrderReadHelper orh = new OrderReadHelper(orderHeader);
>  BigDecimal orderGrandTotal = orh.getOrderGrandTotal();
>  orderGrandTotal = orderGrandTotal.setScale(decimals, rounding);
>
> //Here  getting total payments from payment entity
> ** BigDecimal totalPayments =
> PaymentWorker.getPaymentsTotal(orh.getOrderPayments()); **//this is where
> my question is
>  totalPayments = totalPayments.setScale(decimals, rounding);
>  BigDecimal remainingTotalBd = orderGrandTotal.subtract(totalPayments);
>
>  // The amount to capture cannot be greater than the remaining total
>  amountToCapture = amountToCapture.min(remainingTotalBd);
>
> What i understood from the line
> PaymentWorker.getPaymentsTotal(orh.getOrderPayments());
> is we get all payments (i.e received or sent) and add their amounts.
>
> Now my question is why are we not distinguishing between the status of
> Payment while adding them up?
> This question comes from
> Assume we had order with $100 captured and $10 refunded... total payments
> results in $110,
> but the order grand total would reflect as $90.
>
> Now if we perform a capture of $19 again i.e order total would be $90 +
> $19=$109
> the above mentioned condition was capturing $1, whereas it should have
> captured $19
>
> Any ideas of why this is being done?
>
>