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

Update line items enterprise fee instead of deleting and recreating #13144

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rioug
Copy link
Collaborator

@rioug rioug commented Feb 12, 2025

What? Why?

Currently when an order gets updated all enterprise fees are deleted and recreated to ensure it's up to date. This is an issue when a product has been removed from an Order Cycle, any subsequent update to the order will remove fees associated with said product. To prevent this, we now create or update per item enterprise fees, per order fee are still deleted and recreated.

An easier way to fix the issue is to assume any product in the order are from the Order Cycle linked to the order, so we could keep the delete and recreate solution. However, currently Order Cycle are not mandatory on the Order, and there is no check to ensure a product is the Order Cycle when adding/updating an order.

What should we test?

In general we want to test that enterprise fee per item are working as before
As an enterprise manager :

  • Create an order cycle with per item fee on incoming variants and another fee on outgoing variant

TODO simple order cycle add scenario

As a customer

  • place an order with a couple of different product.

As an enterprise manager:

  • Search for the just placed order and open the edit page

  • ensure both fees were applied

  • remove on outgoing variant

  • on the order edit page, Click on "update and recalculate fees!"

  • check the outgoing fee is still present

  • remove the incoming variant

  • on the order edit page, Click on "update and recalculate fees!"

  • check the incoming fee is still present

  • remove fee from the Order Cycle, stay there

  • add a new fee -> gets added to product even removed onec

  • delete fee -> fee still there

  • update removed product quantity -> fee gets updated

  • customer edit order -> fee don't disappear

Release notes

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

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

Renamed to clear_order_adjustments, it doesn't clear line item
adjustment
We now update or create line item fees instead of deleting them and
recreating them. This is to cover the case when a product has been
removed from an Order Cycle but we want to keep the fee already applied
on existing order. This was an issue only if the existing order got
updated after the product was removed.
Spree::Order just delegate Orders::HandleFeesService so there is no
point testing fees in the order spec
@rioug rioug self-assigned this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress ⚙
Development

Successfully merging this pull request may close these issues.

Fees wrongly removed when an order is modified after products have been removed from the order cycle
1 participant