Merge pull request #9575 from apricot12/9487-Dimensions-Packing-Reports

Added HEIGHT, WEIGHT, WIDTH, DEPTH columns to packing reports by customer.
This commit is contained in:
Filipe
2022-11-10 09:55:26 +00:00
committed by GitHub
8 changed files with 62 additions and 7 deletions

View File

@@ -66,16 +66,15 @@ describe Api::V0::ReportsController, type: :controller do
{
"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(contacts(line_item.order.bill_address))
end
def supplier_report_row(line_item)
@@ -91,6 +90,23 @@ describe Api::V0::ReportsController, type: :controller do
"quantity" => line_item.quantity,
"price" => (line_item.quantity * line_item.price).to_s,
"temp_controlled" => line_item.product.shipping_category&.temperature_controlled
}.merge(dimensions(line_item))
end
def dimensions(line_item)
{
"weight" => line_item.weight.to_s,
"height" => line_item.height.to_s,
"width" => line_item.width.to_s,
"depth" => line_item.depth.to_s
}
end
def contacts(bill_address)
{
"first_name" => bill_address.firstname,
"last_name" => bill_address.lastname,
"phone" => bill_address.phone,
}
end