From 9ae65e135b782033032fb5fdabcc9dd3e2acf426 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 3 May 2023 10:42:00 +1000 Subject: [PATCH] Rails/Pick Prefer pick("sum(amount)") over pluck("sum(amount)").first --- .../enterprise_fees_with_tax_report_by_producer.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb index dc073d4ef3..1690677828 100644 --- a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb +++ b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb @@ -254,8 +254,7 @@ module Reporting .where(included: true) .where(adjustable_type: 'Spree::Adjustment') .where(adjustable_id: enterprise_fee_adjustment_ids_for_orders(order_ids)) - .pluck("sum(amount)") - .first || 0 + .pick("sum(amount)") || 0 end def tax_for_order_ids(order_ids) @@ -263,8 +262,7 @@ module Reporting .where(order: order_ids) .where(adjustable_type: 'Spree::Adjustment') .where(adjustable_id: enterprise_fee_adjustment_ids_for_orders(order_ids)) - .pluck("sum(amount)") - .first || 0 + .pick("sum(amount)") || 0 end def enterprise_fee_adjustment_ids_for_orders(order_ids) @@ -272,7 +270,7 @@ module Reporting end def enterprise_fees_amount_for_orders(order_ids) - enterprise_fees_for_orders(order_ids).pluck("sum(amount)").first || 0 + enterprise_fees_for_orders(order_ids).pick("sum(amount)") || 0 end def enterprise_fees_for_orders(order_ids) @@ -294,7 +292,7 @@ module Reporting end def producer_tax_status(query_result_row) - Enterprise.where(id: supplier_id(query_result_row)).pluck(:charges_sales_tax).first + Enterprise.where(id: supplier_id(query_result_row)).pick(:charges_sales_tax) end def order_cycle(query_result_row) @@ -331,8 +329,7 @@ module Reporting amount = Spree::Adjustment.enterprise_fee .where(order_id: order_ids) .where(originator_id: enterprise_fee_id) - .pluck("sum(amount)") - .first + .pick("sum(amount)") amount - tax(query_result_row, all: true, included: true) end