Apply cosmetics and fix specs

This commit is contained in:
François Turbelin
2025-10-09 17:59:07 +02:00
committed by Maikel Linke
parent 245f0caedb
commit 71dd398131
7 changed files with 10 additions and 10 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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