openfoodfoundation / openfoodnetwork

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

[Order Cycles] Incoming exchange accepts supplier fees with order-based calculators #11326

Closed filipefurtad0 closed 3 months ago

filipefurtad0 commented 1 year ago

Description

In the scope of #11013, we've discussed the case of OC coordinators adding supplier fees, which are applied over the order. While we've mentioned this might be an edge case, it would be good to:

A PR to close this issue would focus on filtering the options on the incoming exchange, to display only line-item based calculators.

Expected Behavior

Incoming exchanges only display supplier fees with line-item-based calculators

Actual Behaviour

Incoming exchanges accepts supplier fees, with all calculator types (line item and order based)

Steps to Reproduce

Create a coordinator and a supplier enterprise; having granted the required permissions:

  1. As the supplier, create an enterprise fee, with a calculator which operates at the order level, for example, flat-rate per order.
  2. As a coordinator, create an order cycle
  3. In the incoming exchange, add the previously mentioned supplier
  4. Notice you can add the supplier order-based calculator fee

Animated Gif/Screenshot

-

Workaround

Incoming exchange: Add line-items calculators instead; leave your order based calculators for the outgoing exchage

Severity

bug-s3: a feature is broken but there is a workaround

Your Environment

Possible Fix

abdulazizali77 commented 5 months ago

@RachL @sigmundpetersen id like to work on this Just to clarify in this screenshot below, we only want to display PerItem Enterprise Fees correct? image

Could either do this by filtering on the Coffeescript side app\assets\javascripts\admin\order_cycles\services\enterprise_fee.js.coffee with a new function which should be quite quick to do, or pass a :per_item param to the EnterpriseFeesController controller. What do you guys think?

RachL commented 5 months ago

This is my understanding as well, but pinging @filipefurtad0 in case there is something I'm missing :+1:

filipefurtad0 commented 5 months ago

we only want to display PerItem Enterprise Fees correct?

Yes, that's it @abdulazizali77 :-)

In OFN, we have different calculator types, some have effect over the order, some apply fees over line items.

In the scope of this issue, the only allowed fee calculator should be:

The other calculators should not be allowed, on step 2. Incoming products: