mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Respect rubocop Metrics/AbcSize by extracting a method
This commit is contained in:
@@ -62,20 +62,19 @@ describe Api::V0::ReportsController, type: :controller do
|
||||
results
|
||||
end
|
||||
|
||||
def distributor_report_row(line_item) # rubocop:disable Metrics/AbcSize
|
||||
def distributor_report_row(line_item)
|
||||
{
|
||||
"hub" => line_item.order.distributor.name,
|
||||
"customer_code" => line_item.order.customer&.code,
|
||||
"first_name" => line_item.order.bill_address.firstname,
|
||||
"last_name" => line_item.order.bill_address.lastname,
|
||||
"supplier" => line_item.product.supplier.name,
|
||||
"product" => line_item.product.name,
|
||||
"variant" => line_item.full_name,
|
||||
"quantity" => line_item.quantity,
|
||||
"price" => (line_item.quantity * line_item.price).to_s,
|
||||
"phone" => line_item.order.bill_address.phone,
|
||||
"temp_controlled" => line_item.product.shipping_category&.temperature_controlled
|
||||
}.merge(dimensions(line_item))
|
||||
}.
|
||||
merge(dimensions(line_item)).
|
||||
merge(contacts(line_item.order.bill_address))
|
||||
end
|
||||
|
||||
def supplier_report_row(line_item)
|
||||
@@ -103,6 +102,14 @@ describe Api::V0::ReportsController, type: :controller do
|
||||
}
|
||||
end
|
||||
|
||||
def contacts(bill_address)
|
||||
{
|
||||
"first_name" => bill_address.firstname,
|
||||
"last_name" => bill_address.lastname,
|
||||
"phone" => bill_address.phone,
|
||||
}
|
||||
end
|
||||
|
||||
def i18n_scope
|
||||
"admin.reports"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user