openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.09k stars 708 forks source link

[Enterprise fees w/ Tax Report by Producer] Can't trace origin from enterprise fees #11529

Open filipefurtad0 opened 9 months ago

filipefurtad0 commented 9 months ago

Description

Follow-up from #11013.

Currently, our data model makes it impossible to generate a correct Enterprise fees w/ Tax Report by Producer report: if an enterprise fee is not linked to the order cycle, then it will not show up in this report. Enterprise fees linked to orders cannot be traced to their origin, there's no way to know the source of that enterprise fee.

See also this comment.

Expected Behavior

It should be possible to trace the origin of an enterprise fee, at the order level. This should allow querying orders and making the Enterprise fees w/ Tax Report by Producer report accurate - currently, it is not.

Actual Behaviour

It is not possible to trace the origin of an enterprise fee, at the order level. The Enterprise fees w/ Tax Report by Producer report relies on querying order cycles, which may change, thus rendering incorrect reports.

Steps to Reproduce

  1. Set up an order cycle, with a supplier fee.
  2. Place an order, making sure that supplier fee is charged.
  3. Run the report: the enterprise fee should be visible for that supplier.
  4. Edit the order cycle and remove the supplier fee, from the incoming exchange
  5. Run the report again: notice the enterprise fee is not appearing on the report
  6. Check the order: see that the order still contains the adjustment related to the supplier fee (Bonus point 7. Click Update and recalculate fees: notice the order was updated and the fee removed -> this point goes to show that orders can be paid/shipped/cancelled when not in sync with order cycles. I'd say this is something to note, but out of scope here)

Animated Gif/Screenshot

-

Workaround

-

Severity

bug-s3: a feature is broken but there is a workaround (there is no workaround, but this report has been marked as deprecated)

Your Environment

Possible Fix

See: https://github.com/openfoodfoundation/openfoodnetwork/pull/11013#issuecomment-1697187001

mkllnk commented 8 months ago

This is not completely accurate. We do have the data already stored in AdjustmentMetadata. We need to use it for this report though:

abdulazizali77 commented 5 days ago

@RachL @sigmundpetersen id like to work on this. I will post followup questions after triaging