mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove #to_package calls on shipment calculations
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user