mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Use OrderContents in LineItemsController and move enterprise fee updating logic
This commit is contained in:
@@ -81,7 +81,6 @@ module Api
|
||||
quantity = params[:quantity].to_i
|
||||
|
||||
@order.contents.remove(variant, quantity, @shipment)
|
||||
@order.recreate_all_fees!
|
||||
@shipment.reload if @shipment.persisted?
|
||||
|
||||
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok
|
||||
|
||||
@@ -39,12 +39,9 @@ class LineItemsController < BaseController
|
||||
def destroy_with_lock(item)
|
||||
order = item.order
|
||||
order.with_lock do
|
||||
item.destroy
|
||||
order.contents.remove(item.variant)
|
||||
order.update_shipping_fees!
|
||||
order.update_payment_fees!
|
||||
order.update_order_fees!
|
||||
order.update_order!
|
||||
order.create_tax_charge!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ module Spree
|
||||
def remove(variant, quantity = nil, shipment = nil)
|
||||
line_item = remove_from_line_item(variant, quantity, shipment)
|
||||
update_shipment(shipment)
|
||||
order.update_order_fees! if order.completed?
|
||||
update_order
|
||||
line_item
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user