mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-27 21:06:49 +00:00
Updating line items through admin controller causes enterprise fees to be recalculated
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
Spree::Admin::LineItemsController.class_eval do
|
||||
prepend_before_filter :load_order, except: :index
|
||||
around_filter :apply_enterprise_fees_with_lock, only: :update
|
||||
|
||||
respond_to :json
|
||||
|
||||
# TODO make updating line items faster by creating a bulk update method
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
@@ -16,8 +19,16 @@ Spree::Admin::LineItemsController.class_eval do
|
||||
|
||||
private
|
||||
|
||||
def load_order
|
||||
@order = Spree::Order.find_by_number!(params[:order_id])
|
||||
authorize! :update, @order
|
||||
def load_order
|
||||
@order = Spree::Order.find_by_number!(params[:order_id])
|
||||
authorize! :update, @order
|
||||
end
|
||||
|
||||
def apply_enterprise_fees_with_lock
|
||||
authorize! :read, @order
|
||||
@order.with_lock do
|
||||
yield
|
||||
@order.update_distribution_charge!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user