Remove #to_package calls on shipment calculations

This commit is contained in:
Matt-Yorkley
2021-02-19 16:28:30 +00:00
parent db07a73bd7
commit 7d3288ca53

View File

@@ -27,18 +27,12 @@ module Spree
# calculator as applied to the given calculable (Order, LineItems[], Shipment, etc.)
# By default the adjustment will not be considered mandatory
def create_adjustment(label, target, calculable, mandatory = false, state = "closed")
# Adjustment calculations done on Spree::Shipment objects MUST
# be done on their to_package'd variants instead
# It's only the package that contains the correct information.
# See https://github.com/spree/spree_active_shipping/pull/96 et. al
old_calculable = calculable
calculable = calculable.to_package if calculable.is_a?(Spree::Shipment)
amount = compute_amount(calculable)
return if amount.zero? && !mandatory
adjustment_attributes = {
amount: amount,
source: old_calculable,
source: calculable,
originator: self,
order: order_object_for(target),
label: label,