Customer Balance Discrepancy - Ruby openfoodnetwork

Description

A shoppers balance appears to be incorrect in many places.

The affected user id is 200213.

Expected Behavior

A consistent customer balance in /accounts, admin/customers, admin/orders of £35.86.

From the hubs records the balance should be £35.86.

Actual Behaviour

From the shopper perspective /accounts shows a balance of £73.70 From admin/orders the account has a small credit of 97p

Steps to Reproduce

  1. Sum the /admin/orders totals for this user and find the balance of 97p
  2. Check the users accounting software and find a balance of £35.86
  3. Look on OFN and find a balance of £73.70
  4. These balances all need to be the same

Animated Gif/Screenshot

Workaround

No workaround.

Severity

Technically S2. I hope that @sauloperez will look at this at part of the Customer Balances work if its not finished.

Your Environment

  • Version used: 3.5.12
  • Browser name and version:
  • Operating System and version (desktop or mobile):

Possible Fix

Asked Oct 06 '21 02:10
avatar lin-d-hop
lin-d-hop

5 Answer:

Both pages look at Spree::Order#outstanding_balance which is total - payment_total.

  • The customer-facing page is adding these amounts up in Javascript and shows: "Balance due: £73.57".
  • The admin/orders page doesn't show a total of the account balance to me, just for each individual order.
  • I can look at the customers page which shows me a total of £-73.57. So these amounts match.

@lin-d-hop Where do you see the non-matching amount? Can you share a screenshot?

1
Answered Mar 15 '21 at 23:56
avatar  of mkllnk
mkllnk

I edited the issue adding the user id which enables all core devs to find the user without sharing the email address publicly.

Even if we don't know how to get into this situation, I think that it can be useful to include the steps of how to observe this situation in How to reproduce.

1
Answered Mar 15 '21 at 23:59
avatar  of mkllnk
mkllnk

The non-matching amount comes from two places:

  • On manually totally the order totals in /admin/order with a calculator
  • The accounting software of the user. The user did this exercise with 6 staff members and found one with this discrepancy. They wish to change to paperless systems and require customer balances to be accurate in order to do this.

What I will do is go to the user and ask for a running balance of the users orders according to their accounting software and reconcile against the shopper accounts.

1
Answered Mar 16 '21 at 07:20
avatar  of lin-d-hop
lin-d-hop

Looking at admin/orders and /accounts I see there are only two orders for this customer with balance owing: R685780682 placed on 07/03/21 owing £35.73 (admin) £35.73 (accounts) R627200625 placed on 11/12/17 owing £37.84 (admin) £37.84 (accounts) This makes the balance due overall = £73.57 (which is the total seen when I enter the customer's account and look under /transactions)

The name of the customer in R627200625 is not R* F* but a different name. I think this might be the difference we are looking for.

Searching /admin/orders by the customer's name (first four letters of first name and initial of surname) and not their account email address brings up orders related to not only the @tam* email address but another email address. It also misses out order R627200625 Search /admin/orders by name gives outstanding payments on orders R685780682 placed on 07/03/21 owing £35.73 R406025453 placed on 11/12/16 owing £26.55 R344617085 placed on 05/11/16 owing £9.12

1
Answered Mar 17 '21 at 13:03
avatar  of lbwright22
lbwright22

This is excellent sleuthing! Please share with Sara and once she confirms we can all celebrate that balances are working!!

Tamar tested with their whole staff team so this inspires huge confidence in a part of the system that has always been tricky.

Thanks @lbwright22 and huge thanks to @sauloperez for driving this work!!!

1
Answered Mar 17 '21 at 13:18
avatar  of lin-d-hop
lin-d-hop