mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #2260 from coopdevs/improve-report
Improve order_and_distributor report's readability
This commit is contained in:
@@ -32,15 +32,43 @@ module OpenFoodNetwork
|
||||
|
||||
@orders.each do |order|
|
||||
order.line_items.each do |line_item|
|
||||
order_and_distributor_details << [order.created_at, order.id,
|
||||
order.bill_address.full_name, order.email, order.bill_address.phone, order.bill_address.city,
|
||||
line_item.product.sku, line_item.product.name, line_item.options_text, line_item.quantity, line_item.max_quantity, line_item.price * line_item.quantity, line_item.distribution_fee,
|
||||
order.payments.first.andand.payment_method.andand.name,
|
||||
order.distributor.andand.name, order.distributor.address.address1, order.distributor.address.city, order.distributor.address.zipcode, order.special_instructions ]
|
||||
order_and_distributor_details << row_for(line_item, order)
|
||||
end
|
||||
end
|
||||
|
||||
order_and_distributor_details
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns a row with the data to display for the specified line_item and
|
||||
# its order
|
||||
#
|
||||
# @param line_item [Spree::LineItem]
|
||||
# @param order [Spree::Order]
|
||||
# @return [Array]
|
||||
def row_for(line_item, order)
|
||||
[
|
||||
order.created_at,
|
||||
order.id,
|
||||
order.bill_address.full_name,
|
||||
order.email,
|
||||
order.bill_address.phone,
|
||||
order.bill_address.city,
|
||||
line_item.product.sku,
|
||||
line_item.product.name,
|
||||
line_item.options_text,
|
||||
line_item.quantity,
|
||||
line_item.max_quantity,
|
||||
line_item.price * line_item.quantity,
|
||||
line_item.distribution_fee,
|
||||
order.payments.first.andand.payment_method.andand.name,
|
||||
order.distributor.andand.name,
|
||||
order.distributor.address.address1,
|
||||
order.distributor.address.city,
|
||||
order.distributor.address.zipcode,
|
||||
order.special_instructions
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user