Page 1 of 1

ac_Orders.TotalPayment not being updated

Posted: Tue Jan 12, 2010 2:33 pm
by Jusedawg
Hey guys,

Anyone had or seen the strange problem of the ac_Orders.TotalPayment not being updated and still 0 even though the order completed successfully?

The payment, transaction, order tables and everything all have the correct payment amounts, except the TotalPayments field in ac_Orders.

I cannot reproduce it locally in order to debug and the problem is on a production server.

Since the code that updates that field is in a compiled CommerceBuilder.DLL and the problem is on a production server I am not entirely sure how to go about debugging the problem.

Any ideas would be great.

AbleCommerce 7.0.2 build 11659

This seem to start happening once we upgraded to 7.0.2. The TotalPayments not being updated also does not appear to affect the normal operation of the store either. I only noticed it because we export our orders to an accounting system and was doing a check to make sure TotalPayments = TotalCharges before they get exported.

Re: ac_Orders.TotalPayment not being updated

Posted: Wed Jan 13, 2010 5:28 am
by mazhar
Can you have a look at your ac_Payments table and then check PaymentStatusId for payments made for order under observation. Does any of the payments have PaymentStatusId 2,5 or 11. In fact TotalPayments for order are calculated for those payments that have status of Captured, Completed and Authorized.

Re: ac_Orders.TotalPayment not being updated

Posted: Wed Jan 13, 2010 10:55 am
by Jusedawg
Yep, as I said, all payments are marked correctly related to the payments table. : )

I ended up adding some debugging info to the CommerceBuilder.dll for the update methods that update and recalculate the totals.

Basically, what is happening is the Recalculate Totals function is being called 4 or more times and sometimes the last call was updating the TotalPayments to 0

DEBUG 2010-01-13 02:04:06,750 6503250ms Object DoLog - Function: RecalculatePaymentStatus - productSubtotal:79.9700 totalCharges:107.0000 totalPayments:0
DEBUG 2010-01-13 02:04:10,046 6506546ms Object DoLog - Function: RecalculatePaymentStatus - productSubtotal:79.9700 totalCharges:107.0000 totalPayments:0
DEBUG 2010-01-13 02:04:10,187 6506687ms Object DoLog - Function: RecalculatePaymentStatus - productSubtotal:79.9700 totalCharges:107.0000 totalPayments:107.00
DEBUG 2010-01-13 02:04:10,187 6506687ms Object DoLog - Function: UpdateCalculatedTotals - productSubtotal:79.9700 totalCharges:107.0000 totalPayments:107.00
DEBUG 2010-01-13 02:04:10,218 6506718ms Object DoLog - Function: RecalculatePaymentStatus - productSubtotal:79.9700 totalCharges:107.0000 totalPayments:0
DEBUG 2010-01-13 02:04:10,218 6506718ms Object DoLog - Function: UpdateCalculatedTotals - productSubtotal:79.9700 totalCharges:0

If you look at the log, you can see there was no reason for the UpdateCalculatedTotals to be called a second time.

I added some code to stop the second UpdateCalculatedTotals from running once the totalcharges = totalpayments to correct the problem.

Maybe that will help other people if they run across the same issue.