diff --git a/lib/reporting/report_query_template.rb b/lib/reporting/report_query_template.rb index 4ab64b130f..422e71e90c 100644 --- a/lib/reporting/report_query_template.rb +++ b/lib/reporting/report_query_template.rb @@ -15,7 +15,7 @@ module Reporting # Here the query_result is already the expected result, so we just create # a fake columns method to copy the sql result into the row result def columns - report_data.columns.map { |field| [field.to_sym, proc { |data| data[field] }] }.to_h + report_data.columns.to_h{ |field| [field.to_sym, proc { |data| data[field] }] } end def search diff --git a/lib/reporting/report_row_builder.rb b/lib/reporting/report_row_builder.rb index 0ae1704dbf..3835f8c422 100644 --- a/lib/reporting/report_row_builder.rb +++ b/lib/reporting/report_row_builder.rb @@ -30,7 +30,7 @@ module Reporting result = row.to_h.select { |k, _v| k.in?(report.fields_to_show) } unless report.unformatted_render? - result = result.map { |k, v| [k, format_cell(v, k)] }.to_h + result = result.to_h { |k, v| [k, format_cell(v, k)] } end OpenStruct.new(result) end diff --git a/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb b/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb index 08447fdb85..d4495f7a4a 100644 --- a/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb +++ b/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb @@ -46,9 +46,9 @@ module Reporting # This report calculate data in a different way, so we just encapsulate the result # in the columns method def columns - data_attributes.map { |field| + data_attributes.to_h { |field| [field.to_sym, proc { |data| data.public_send(field) }] - }.to_h + } end private diff --git a/lib/reporting/reports/payments/itemised_payment_totals.rb b/lib/reporting/reports/payments/itemised_payment_totals.rb index 6e05dd5ea0..fae956543d 100644 --- a/lib/reporting/reports/payments/itemised_payment_totals.rb +++ b/lib/reporting/reports/payments/itemised_payment_totals.rb @@ -11,8 +11,8 @@ module Reporting product_total_price: proc { |orders| orders.map(&:item_total).sum(&:to_f) }, shipping_total_price: proc { |orders| orders.map(&:ship_total).sum(&:to_f) }, outstanding_balance_price: proc do |orders| - orders.map { |order| order.outstanding_balance } - end.sum(&:to_f), + orders.map(&:outstanding_balance).sum(&:to_f) + end, total_price: proc { |orders| orders.map(&:total).sum(&:to_f) } } end diff --git a/lib/reporting/reports/payments/payment_totals.rb b/lib/reporting/reports/payments/payment_totals.rb index 8903387bef..28ccde0cef 100644 --- a/lib/reporting/reports/payments/payment_totals.rb +++ b/lib/reporting/reports/payments/payment_totals.rb @@ -14,8 +14,8 @@ module Reporting eft_price: proc { |orders| total_by_payment_method(orders, "EFT") }, paypal_price: proc { |orders| total_by_payment_method(orders, "PayPal") }, outstanding_balance_price: proc { |orders| - orders.map{ |order| order.outstanding_balance } - }.sum(&:to_f) + orders.map(&:outstanding_balance).sum(&:to_f) + } } end diff --git a/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb b/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb index 1141b5f714..58b8c2706f 100644 --- a/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb +++ b/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb @@ -136,7 +136,7 @@ module Reporting .where(originator_id: tax_rate_id(query_result_row)) .map(&:amount) .sum(&:to_f) - end.sum(&:to_f) + end&.sum(&:to_f) end def total_incl_tax(query_result_row) diff --git a/lib/reporting/reports/xero_invoices/base.rb b/lib/reporting/reports/xero_invoices/base.rb index 573d3d88bf..8cc666b767 100644 --- a/lib/reporting/reports/xero_invoices/base.rb +++ b/lib/reporting/reports/xero_invoices/base.rb @@ -233,7 +233,7 @@ module Reporting def tax_on_shipping_s(order) tax_on_shipping = order.shipments - .map{ |shipment | shipment.additional_tax_total + shipment.included_tax_total } + .map{ |shipment| shipment.additional_tax_total + shipment.included_tax_total } .sum(&:to_f) .positive? if tax_on_shipping