Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fees wrongly removed when an order is modified after products have been removed from the order cycle #13100

Open
nicolasVr opened this issue Jan 27, 2025 · 6 comments
Assignees
Labels
bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround.

Comments

@nicolasVr
Copy link

nicolasVr commented Jan 27, 2025

Description

It happens that hubs or shops remove some products from the order cycle (OC) during the OC. It succeeds for instance if the producer needs to stop orders before the OC finish.
In that case, If the hub/shop admin change an order, for instance deleting a product that was not available, the commission and fees are calculated again. But if there are products previously removed from the OC in the order those products remain (expected behaviour), but their fees are deleted. The result is that the credit owed is not only the price of deleted product, but also includes the fees wrongly removed.
In practice, we have a Hub in France that has just realized it had made numerous excessive reimbursements.
(while writing this issue I have acknowledged that it happens also when customer modify its own order)

Expected Behavior

When products are removed from an order cycle, modifying the order should not change the fees associated with the products included in order that were removed of the order cycle after they were bought.

Actual Behaviour

The fees are deleted, which leads to wrong and too high credit owed information.

Steps to Reproduce

  1. As a shop owner I remove 2 products from an order cycle. Those products were previously ordered by a customer :

Image

  1. Edit an order. In this example, I will delete "Yourts Coulis de fruits... ". I expect the credit owe should be product price (2,20) + associated fee (0,24) = 2,44

Image

  1. As you can see here not only product fee associated with the product removed from order are cancelled but also the product fee linked to Yaourts nature. Consequently the credit owed is 2.66 € instead of 2.44 €

Image

Please note that in this example the product modified in order was removed from order cycle, but it is not relevant.

Here is another example where this is the customer who modify its own order :
1 - Order issued by customer :

Image

2 - The hub admin removes "Yourts coulis de fruits par 4*125g - Yaourt coulis abricot par 4 " from order cycle

3 - The customer decides to delete 1 product from its order. The new price should be 13,32 €, but it is 13,08 €

Image

Workaround

Re-introducing products in the order cycle before modifying orders is a workaround, but not possible if the customer modify its own order.

Severity

bug-s1: a critical feature is broken: checkout, payments, signup, login
This bug causes errors in the order amounts. It is a function in which users should have complete trust.

Your Environment

Examples on Coopcircuits.fr

@github-project-automation github-project-automation bot moved this to All the things 💤 in OFN Delivery board Jan 27, 2025
@github-project-automation github-project-automation bot moved this from All the things 💤 to Done in OFN Delivery board Jan 27, 2025
@chahmedejaz chahmedejaz reopened this Jan 28, 2025
@github-project-automation github-project-automation bot moved this from Done to Dev ready 👋 in OFN Delivery board Jan 28, 2025
@RachL RachL added the bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. label Jan 28, 2025
@filipefurtad0
Copy link
Contributor

Thank you for the detailed description @nicolasVr . I was able to reproduce this, indeed removing an item from an order cycle and having any action on an order which triggers totals re-calculation surfaces the issue.

In the example below, from the placed order (left pic), I've removed a product from the order cycle and simply clicked the button Update and recalculate fees (right pic):

Image

This removes the enterprise fee, associated with the line item (although the line item is still in the order).

This week's release (v5.0.12) has not yet been deployed, so it might relate to v5.0.11 or a previous release.

@tschumilas
Copy link

I think this has been like this for a long time - and I thought there was an issue for it. But now I can't find it. So I don't think it was a recent release.

@rioug rioug moved this from Dev ready 👋 to In Progress ⚙ in OFN Delivery board Feb 4, 2025
@rioug rioug self-assigned this Feb 4, 2025
@rioug
Copy link
Collaborator

rioug commented Feb 5, 2025

So just to explain what is happening here, the removed fees are Enterprise Fees linked to the Order Cycle. To calculate fees we look at the items in the order, and via the product we can find the Order Cycle and figure out if there are enterprise fees to be applied. If you remove a product from the Order Cycle then we loose this information. So when the order gets updated, we delete all existing fee and create new ones, so that's why the fee "disappear". So I think it's fair to say it's an expected scenario. As far as I can tell it's been like this since 2021, and probably longer than that.

My understanding is that shop/hubs remove product from an Order Cycle so that a product can no longer be ordered. My suggestion would be to set the variants stock to 0. I believe you could also do that via the inventory if you want to avoid changing the producer own stock level. Can some confirm that ?

We can't really fix the issue, what we could potentially do is, add a warning if someone is trying to remove a product from an Order Cycle and this product is part of at least one order.

@RachL @tschumilas What do you think ?

@RachL
Copy link
Contributor

RachL commented Feb 5, 2025

@rioug I understand the problem of having OC fees linked to products. Could they be linked to line items instead?

Otherwise, can we display the message only if there are fees linked? I'm afraid this case of removing product happens a lot, and it could be annoying for people who are not using fees to handle an additional step.

@tschumilas
Copy link

If fees could be linked to line items it would be ideal. It would solve the flower farm use case (see below). But could several different fees be attached to the same product? For example: a supplier sells in OC 1 and OC 2. The OCs are open at the same time. OC 1 adds 10% enterprise fee to this supplier's product. OC 2 adds a -20% discount to this supplier's products. So if these fees were at the product level, the product would have to be attached to multiple fees. Maybe thats not a problem - i don't know the tech - just raising the use case. (And thinking we might need to adjust the fees in reports? not sure just flagging the issue.)

here, when a supplier has to remove items from an OC early, they usually just use a product import to re-set the stock to O. So this is not an issue for our food hubs. The use case in flower hubs is a bit different because suppliers sell to different hubs with order cycles open at the same time. And I have been coaching people away from inventory. It happens that, while the OCs are still open, a supplier decides to sell their remaining stock in one hub, but not the other hub. (Its because the supplier has a 'preferred' hub local to them, and if product is limited, they rationalize its allocation) So right now the supplier leaves their stock set above 0, keeps selling it in hub 1, and removes the product from hub B's order cycle. And they tell the hub this, and the hub keeps a list so the hub manager knows if they need to remove that item from a customer's order, they need to first put the item back into the order cycle (temporarily) while they edit the order. So here, OC managers routinely re- add all items to a closed order cycle before they do the order editing.

I think the question for me is - how much additional cost to link fees to the product? Its a nice solution - but maybe too expensive considering the need, given there are good workarounds. We have much bigger issues that impact more users, with more cumbersome workarounds I think. A warning sounds cheap and easy to me. And lets target the warning: appears only if the product being removed has (1) an order associated and (2) a per item enterprise fee associated? (I think this issue does NOT happen with per order fees.)

Last random thought - what if we could edit fees on an order? Would this be a direction to go instead of the above?

@nicolasVr
Copy link
Author

I am not sure we can consider we have a good workaround : as explained in the issue if a customer modify its own order he can have the fees deleted and there is no workaround for the admin. For the same reason, the warning message is not completely satisfactory.
I am afraid we have a responsibility issue : the hub could ask us to refund the money he has lost because of this issue.
The only easy answer I see is not allowing to delete a product from an order cycle when it has been ordered. But as previously emphasized it is widely used, so it is a problem. Inventory is not an easy workaround and probably won't fit all users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround.
Projects
Status: In Progress ⚙
Development

No branches or pull requests

6 participants