Skip to content

Show orders with credit as paid in customer account#14367

Open
nicolasVr wants to merge 1 commit into
openfoodfoundation:masterfrom
nicolasVr:issue-14197-credit-owed-shown-as-paid
Open

Show orders with credit as paid in customer account#14367
nicolasVr wants to merge 1 commit into
openfoodfoundation:masterfrom
nicolasVr:issue-14197-credit-owed-shown-as-paid

Conversation

@nicolasVr

@nicolasVr nicolasVr commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What? Why?

When a customer overpays an order (e.g. a product is removed after payment), the order gets a payment_state of credit_owed. In the customer account's Past Orders table, such orders were displayed as not paid ("No" in the Paid? column), which is misleading — the customer has actually paid more than required.

The Order#paid? method already handles this correctly, returning true for both paid and credit_owed states. The bug was in the frontend: the Past Orders template was comparing payment_state directly against 'paid', missing the credit_owed case.

Fix: Add a paid boolean attribute to Api::OrderSerializer that delegates to Order#paid?, and use order.paid in the template instead of the raw payment_state comparison. This keeps the logic in one place (the model) and avoids the frontend duplicating payment state knowledge.

Before — order with credit shows "No":
See Order # R367266433 at state "Credit owed"
before_fix_s

After — order with credit correctly shows "Yes":
after_fix_s

What should we test?

  1. Create an order for a customer and mark it as paid (payment total = order total).
  2. Remove a product from the order or reduce a quantity, so the customer has paid more than the new total.
  3. Go to the customer's account page (/account) → Past Orders.
  4. Verify the order shows Yes in the "Paid?" column (previously showed "No").

Also check that a genuinely unpaid order (balance due) still shows No.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

In the past orders table, orders with payment_state 'credit_owed'
were shown as not paid. The customer had overpaid (e.g. after a
product was removed from a paid order) but the UI labelled the
order as unpaid.

The Order model's paid? method already treats both 'paid' and
'credit_owed' as paid, but the frontend was checking payment_state
directly against 'paid'.

Add a paid attribute to Api::OrderSerializer that delegates to
Order#paid?, and use order.paid in the template instead of
comparing payment_state directly.

Fixes openfoodfoundation#14197
@github-project-automation github-project-automation Bot moved this to All the things 💤 in OFN Delivery board Jun 3, 2026
@nicolasVr nicolasVr marked this pull request as draft June 3, 2026 20:39
@nicolasVr nicolasVr marked this pull request as ready for review June 3, 2026 20:51
@sigmundpetersen sigmundpetersen moved this from All the things 💤 to Code review 🔎 in OFN Delivery board Jun 3, 2026
@rioug rioug added the user facing changes Thes pull requests affect the user experience label Jun 5, 2026

@rioug rioug left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good ! Thanks for your help @nicolasVr 🙏

@mkllnk mkllnk moved this from Code review 🔎 to Test Ready 🧪 in OFN Delivery board Jun 5, 2026
@ValVerCH ValVerCH self-assigned this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

user facing changes Thes pull requests affect the user experience

Projects

Status: Test Ready 🧪

Development

Successfully merging this pull request may close these issues.

When a customer has a credit it is tagged as non paid in customer account

5 participants