Show orders with credit as paid in customer account#14367
Open
nicolasVr wants to merge 1 commit into
Open
Conversation
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
rioug
approved these changes
Jun 5, 2026
rioug
left a comment
Collaborator
There was a problem hiding this comment.
Looks good ! Thanks for your help @nicolasVr 🙏
mkllnk
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What? Why?
When a customer overpays an order (e.g. a product is removed after payment), the order gets a
payment_stateofcredit_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, returningtruefor bothpaidandcredit_owedstates. The bug was in the frontend: the Past Orders template was comparingpayment_statedirectly against'paid', missing thecredit_owedcase.Fix: Add a
paidboolean attribute toApi::OrderSerializerthat delegates toOrder#paid?, and useorder.paidin the template instead of the rawpayment_statecomparison. 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"
After — order with credit correctly shows "Yes":

What should we test?
/account) → Past Orders.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):