mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Simplify helper with extracted method
This commit is contained in:
@@ -7,17 +7,23 @@ module Admin
|
||||
# We exclude shipping method adjustments because they are displayed in a
|
||||
# separate table together with the order line items.
|
||||
def order_adjustments_for_display(order)
|
||||
adjustments_for_display = order.adjustments + order.all_adjustments.payment_fee.eligible
|
||||
order.adjustments +
|
||||
voucher_included_tax_representations(order) +
|
||||
order.all_adjustments.payment_fee.eligible
|
||||
end
|
||||
|
||||
if VoucherAdjustmentsService.new(order).voucher_included_tax.negative?
|
||||
adjustment = order.voucher_adjustments.first
|
||||
adjustments_for_display << Spree::Adjustment.new(
|
||||
label: I18n.t("admin.orders.edit.voucher_tax_included_in_price", label: adjustment.label),
|
||||
def voucher_included_tax_representations(order)
|
||||
return [] unless VoucherAdjustmentsService.new(order).voucher_included_tax.negative?
|
||||
|
||||
adjustment = order.voucher_adjustments.first
|
||||
|
||||
[
|
||||
Spree::Adjustment.new(
|
||||
label: I18n.t("admin.orders.edit.voucher_tax_included_in_price",
|
||||
label: adjustment.label),
|
||||
amount: adjustment.included_tax
|
||||
)
|
||||
end
|
||||
|
||||
adjustments_for_display
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user