Extract relevant adjustments to comment-method

This commit is contained in:
Matt-Yorkley
2021-02-24 12:34:45 +00:00
parent d517e5adf6
commit 02b3636377

View File

@@ -8,11 +8,7 @@ class PaypalItemsBuilder
def call
items = order.line_items.map(&method(:line_item_data))
shipping_and_tax_adjustments = order.all_adjustments.shipping + order.all_adjustments.tax
order.all_adjustments.eligible.each do |adjustment|
next if shipping_and_tax_adjustments.include?(adjustment)
relevant_adjustments.each do |adjustment|
items << adjustment_data(adjustment)
end
@@ -30,6 +26,11 @@ class PaypalItemsBuilder
attr_reader :order
def relevant_adjustments
# Tax total and shipping costs are added separately, so they're not included here.
order.all_adjustments.eligible - order.all_adjustments.tax - order.all_adjustments.shipping
end
def line_item_data(item)
{
Name: item.product.name,