Move adjustment filtering from view to helper

This commit is contained in:
Maikel Linke
2019-04-02 17:25:33 +11:00
parent 11c12787f6
commit 2a6236823f
2 changed files with 12 additions and 6 deletions

View File

@@ -1,7 +1,14 @@
module Admin
module OrdersHelper
def order_adjustments(order)
order.adjustments.eligible
order.adjustments.eligible.select do |adjustment|
type = adjustment.originator_type
is_shipping_method_fee = (type == 'Spree::ShippingMethod')
is_zero_tax_rate = (type == 'Spree::TaxRate' && adjustment.amount.zero?)
!is_shipping_method_fee && !is_zero_tax_rate
end
end
end
end

View File

@@ -8,8 +8,7 @@
%th= Spree.t('amount')
%tbody.with-border
- adjustments.each do |adjustment|
- if (adjustment.originator_type != 'Spree::ShippingMethod') && !(adjustment.originator_type == 'Spree::TaxRate' && adjustment.amount == 0)
%tr.total
%td.strong= adjustment.label + ":"
%td.total.align-center
%span= Spree::Money.new(adjustment.amount)
%tr.total
%td.strong= adjustment.label + ":"
%td.total.align-center
%span= Spree::Money.new(adjustment.amount)