Skip to content

Fix order cycle mail Report grouping by product and price.#14422

Open
lufafajoshua wants to merge 3 commits into
openfoodfoundation:masterfrom
lufafajoshua:solution_issue_13413
Open

Fix order cycle mail Report grouping by product and price.#14422
lufafajoshua wants to merge 3 commits into
openfoodfoundation:masterfrom
lufafajoshua:solution_issue_13413

Conversation

@lufafajoshua

Copy link
Copy Markdown

What? Why?

In the Producer Order Cycle Mail Report, products from different orders were grouped solely by product name. As a result, when the same product appeared in multiple orders at different unit prices, the quantity multiplied by unit price did not match the displayed total price because the price differences were not reflected.
This solution groups line items by both product name and unit price. In the report, same products with identical prices continue to be integrated into a single row, while products with different prices are displayed in separate rows, ensuring that unit prices and totals are reported accurately.

What should we test?

  1. Open an order cycle
  2. Make an order with product A
  3. Modify price of product A
  4. Make another order with product A
  5. Wait for end of cycle and check mail received by producer

Release notes

  • User facing changes

@github-project-automation github-project-automation Bot moved this to All the things 💤 in OFN Delivery board Jun 16, 2026
@rioug rioug moved this from All the things 💤 to Code review 🔎 in OFN Delivery board Jun 16, 2026
@rioug rioug self-requested a review June 17, 2026 01:06
@rioug rioug added the user facing changes Thes pull requests affect the user experience label Jun 17, 2026
Comment thread spec/mailers/producer_mailer_spec.rb
@github-project-automation github-project-automation Bot moved this from Code review 🔎 to In Progress ⚙ in OFN Delivery board Jun 17, 2026
…price, added tests to check whether the quantity multiplied by the unit price is equivalent to the subtotal for each line_item row in the table order-summary.
@lufafajoshua lufafajoshua force-pushed the solution_issue_13413 branch from 0733c63 to f83144d Compare June 17, 2026 16:48
@sigmundpetersen

Copy link
Copy Markdown
Contributor

Hi @lufafajoshua there's a linter error that maybe you could have a look at?

@sigmundpetersen sigmundpetersen moved this from In Progress ⚙ to Code review 🔎 in OFN Delivery board Jun 17, 2026
@sigmundpetersen sigmundpetersen requested a review from rioug June 17, 2026 16:55
@lufafajoshua

Copy link
Copy Markdown
Author

I think i forgot to run rubocop, let me update and push again.

@lufafajoshua

Copy link
Copy Markdown
Author

I personally think failing tests in ./spec/system/admin/order_cycles/simple_spec.rb are not caused by changes in this PR, though i will continue to investigate.

@sigmundpetersen

Copy link
Copy Markdown
Contributor

You are right @lufafajoshua it's a flaky spec. Trying to get Copilot fix it in #14435 🙂

@sigmundpetersen

Copy link
Copy Markdown
Contributor

Copilot did not manage to fix it 😄 We can move on with this PR, there will be someone reviewing it.
I'll try rebuilding to get it green.

@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 🙏

@dacook dacook left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work, thank you very much!
Awaiting a manual test before it will be merged and included in a release.

@dacook dacook moved this from Code review 🔎 to Test Ready 🧪 in OFN Delivery board Jul 7, 2026
@AMEA-LYON AMEA-LYON self-assigned this Jul 8, 2026
@AMEA-LYON AMEA-LYON added the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 8, 2026
@AMEA-LYON

Copy link
Copy Markdown

Hi all, it's ok, products are correctly grouped by price... 🎉
14422_products_prices

@AMEA-LYON AMEA-LYON removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 8, 2026
@AMEA-LYON AMEA-LYON moved this from Test Ready 🧪 to Ready to go 🚀 in OFN Delivery board Jul 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: Ready to go 🚀

Development

Successfully merging this pull request may close these issues.

Display error in mail reports when product price change during order cycle

5 participants