Respect rubocop Metrics/AbcSize by extracting a method

This commit is contained in:
Jean-Baptiste Bellet
2022-10-25 10:16:59 +02:00
parent 23b5e73c97
commit ede38a417f

View File

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