Make ensure_correct_adjustment a public method because we call it in OFN

This commit is contained in:
Luis Ramos
2020-07-01 20:55:58 +01:00
parent 46cf106047
commit 8e116dd58a

View File

@@ -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