Skip to content

Exclude cancelled orders from bulk co-op reports#14415

Open
karlafalk wants to merge 8 commits into
openfoodfoundation:masterfrom
karlafalk:10159-exclude-cancelled-orders-from-coop-reports
Open

Exclude cancelled orders from bulk co-op reports#14415
karlafalk wants to merge 8 commits into
openfoodfoundation:masterfrom
karlafalk:10159-exclude-cancelled-orders-from-coop-reports

Conversation

@karlafalk

@karlafalk karlafalk commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What? Why?

Closes #10159

Cancelled orders were appearing in all bulk co-op reports. BulkCoop::Base#report_line_items was passing CompleteVisibleOrdersQuery.new(order_permissions).call as an explicit orders_relation to Reporting::LineItems. This bypassed the default relation in LineItems#initialize, which already excludes cancelled orders via .not_state(:canceled).

Fix: Remove the explicit orders_relation argument so LineItems uses its default, which correctly excludes cancelled orders.

What should we test?

  • Create an order, complete it, then cancel it
  • Visit any bulk co-op report (Allocation, Supplier, Packing Sheets, Customer Payments)
  • Confirm the cancelled order does not appear in the results
  • Confirm completed (non-cancelled) orders still appear as expected

Release notes

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

  • User facing changes

Note: The n8n workflow docs and GOAT agent files appearing in this diff are pre-existing commits on the my fork unrelated to this fix. Only lib/reporting/reports/bulk_coop/base.rb and spec/lib/reports/bulk_coop_report_spec.rb are part of this change. I wasn't sure how to remove these unrelated files without doing a force-push.

Ron Tozer and others added 8 commits May 29, 2026 13:03
Base was explicitly passing CompleteVisibleOrdersQuery without the
.not_state(:canceled) filter, overriding LineItems' default which
already excludes cancelled orders. Removing the explicit argument
lets the default apply, fixing the bug with a one-line change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: All the things 💤

Development

Successfully merging this pull request may close these issues.

[Reports] Bulk co-op reports showing products from cancelled orders

1 participant