calculator: Sometimes we are not called with a shipment
We can not always use adjustment as we are not called with an order all the time. Just give up on the idea of using reductions to the price.
This commit is contained in:
parent
cb6c6476a2
commit
b14af8cffd
|
@ -1,7 +1,5 @@
|
||||||
# AGPLv3 sysmocom s.f.m.c. GmbH
|
# AGPLv3 sysmocom s.f.m.c. GmbH
|
||||||
|
|
||||||
puts "Fooo"
|
|
||||||
|
|
||||||
module Spree
|
module Spree
|
||||||
class Calculator::SysmocomValueCalculator < Calculator
|
class Calculator::SysmocomValueCalculator < Calculator
|
||||||
|
|
||||||
|
@ -151,18 +149,8 @@ ZONE3 = {
|
||||||
|
|
||||||
|
|
||||||
def total_value_no_tax(o)
|
def total_value_no_tax(o)
|
||||||
value = o.line_items.inject(0) { |sum, item |
|
item_total = o.line_items.map(&:amount).sum
|
||||||
sum + (item.price * item.quantity)}
|
item_total
|
||||||
reductions = o.adjustments.eligible.inject(0) { |sum, adj|
|
|
||||||
if adj.originator_type == "Spree::ShippingMethod"
|
|
||||||
add = 0
|
|
||||||
elsif adj.originator_type == "Spree::TaxRate"
|
|
||||||
add = 0
|
|
||||||
else
|
|
||||||
add = adjustment.amount
|
|
||||||
end
|
|
||||||
sum + add}
|
|
||||||
value + reductions
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute(order)
|
def compute(order)
|
||||||
|
|
Loading…
Reference in New Issue