mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make ensure_correct_adjustment a public method because we call it in OFN
This commit is contained in:
@@ -241,6 +241,25 @@ module Spree
|
||||
inventory_units.create(variant_id: variant.id, state: state, order_id: order.id)
|
||||
end
|
||||
|
||||
def ensure_correct_adjustment
|
||||
if adjustment
|
||||
adjustment.originator = shipping_method
|
||||
adjustment.label = shipping_method.adjustment_label
|
||||
adjustment.amount = selected_shipping_rate.cost if adjustment.open?
|
||||
adjustment.save!
|
||||
adjustment.reload
|
||||
elsif selected_shipping_rate_id
|
||||
shipping_method.create_adjustment(shipping_method.adjustment_label,
|
||||
order,
|
||||
self,
|
||||
true,
|
||||
"open")
|
||||
reload # ensure adjustment is present on later saves
|
||||
end
|
||||
|
||||
update_adjustment_included_tax if adjustment
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def manifest_unstock(item)
|
||||
@@ -285,25 +304,6 @@ module Spree
|
||||
ShipmentMailer.shipped_email(id).deliver
|
||||
end
|
||||
|
||||
def ensure_correct_adjustment
|
||||
if adjustment
|
||||
adjustment.originator = shipping_method
|
||||
adjustment.label = shipping_method.adjustment_label
|
||||
adjustment.amount = selected_shipping_rate.cost if adjustment.open?
|
||||
adjustment.save!
|
||||
adjustment.reload
|
||||
elsif selected_shipping_rate_id
|
||||
shipping_method.create_adjustment(shipping_method.adjustment_label,
|
||||
order,
|
||||
self,
|
||||
true,
|
||||
"open")
|
||||
reload # ensure adjustment is present on later saves
|
||||
end
|
||||
|
||||
update_adjustment_included_tax if adjustment
|
||||
end
|
||||
|
||||
def update_adjustment_included_tax
|
||||
if Config.shipment_inc_vat && (order.distributor.nil? || order.distributor.charges_sales_tax)
|
||||
adjustment.set_included_tax! Config.shipping_tax_rate
|
||||
|
||||
Reference in New Issue
Block a user