mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Refactor methods for updating closed adjustments
This commit is contained in:
@@ -106,8 +106,8 @@ module Spree
|
||||
# more than on line items at once via accepted_nested_attributes the order
|
||||
# object on the association would be in a old state and therefore the
|
||||
# adjustment calculations would not performed on proper values
|
||||
def update!(calculable = nil)
|
||||
return if immutable?
|
||||
def update!(calculable = nil, force: false)
|
||||
return if immutable? && !force
|
||||
|
||||
# Fix for Spree issue #3381
|
||||
# If we attempt to call 'source' before the reload, then source is currently
|
||||
|
||||
@@ -857,11 +857,8 @@ module Spree
|
||||
def update_adjustment!(adjustment)
|
||||
return if adjustment.finalized?
|
||||
|
||||
state = adjustment.state
|
||||
adjustment.state = 'open'
|
||||
adjustment.update!
|
||||
adjustment.update!(force: true)
|
||||
update!
|
||||
adjustment.state = state
|
||||
end
|
||||
|
||||
# object_params sets the payment amount to the order total, but it does this
|
||||
|
||||
Reference in New Issue
Block a user