Files
openfoodnetwork/app/helpers/admin/orders_helper.rb
Maikel Linke f83e78a5b8 Clarify adjustment data only for display
We are not creating a new adjustment here.
2023-10-12 15:16:38 +11:00

32 lines
910 B
Ruby

# frozen_string_literal: true
module Admin
module OrdersHelper
AdjustmentData = Struct.new(:label, :amount)
# Adjustments to display under "Order adjustments".
#
# 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)
order.adjustments +
voucher_included_tax_representations(order) +
order.all_adjustments.payment_fee.eligible
end
def voucher_included_tax_representations(order)
return [] unless VoucherAdjustmentsService.new(order).voucher_included_tax.negative?
adjustment = order.voucher_adjustments.first
[
AdjustmentData.new(
I18n.t("admin.orders.edit.voucher_tax_included_in_price",
label: adjustment.label),
adjustment.included_tax
)
]
end
end
end