mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Change the basis of line_item grouping for Bulk Co-op and Order Cycle reports from User to Order
This commit is contained in:
@@ -99,7 +99,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |lis| lis.first.variant.product.supplier.name },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| "UNIT SIZE" },
|
||||
proc { |lis| lis.first.variant.product.group_buy_unit_size },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
@@ -111,7 +111,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
sort_by: proc { |product| product.name },
|
||||
summary_columns: [ proc { |lis| lis.first.variant.product.supplier.name },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| "UNIT SIZE" },
|
||||
proc { |lis| lis.first.variant.product.group_buy_unit_size },
|
||||
proc { |lis| "" },
|
||||
proc { |lis| "" },
|
||||
proc { |lis| lis.sum { |li| li.quantity * li.variant.weight || 0 } },
|
||||
@@ -125,7 +125,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| "UNIT SIZE" },
|
||||
proc { |lis| lis.first.variant.product.group_buy_unit_size },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
@@ -135,8 +135,8 @@ Spree::Admin::ReportsController.class_eval do
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } },
|
||||
{ group_by: proc { |li| li.order.user },
|
||||
sort_by: proc { |user| user.to_s } } ]
|
||||
{ group_by: proc { |li| li.order },
|
||||
sort_by: proc { |order| order.to_s } } ]
|
||||
|
||||
when "bulk_coop_packing_sheets"
|
||||
|
||||
@@ -151,22 +151,20 @@ Spree::Admin::ReportsController.class_eval do
|
||||
sort_by: proc { |product| product.name } },
|
||||
{ group_by: proc { |li| li.variant },
|
||||
sort_by: proc { |variant| variant.options_text } },
|
||||
{ group_by: proc { |li| li.order.user },
|
||||
sort_by: proc { |user| user.to_s } } ]
|
||||
{ group_by: proc { |li| li.order },
|
||||
sort_by: proc { |order| order.to_s } } ]
|
||||
|
||||
when "bulk_coop_customer_payments"
|
||||
|
||||
header = ["Customer", "Date of Order", "Total Cost", "Amount Owing", "Amount Paid"]
|
||||
|
||||
columns = [ proc { |lis| lis.first.order.bill_address.firstname + " " + lis.first.order.bill_address.lastname },
|
||||
proc { |lis| lis.first.order.created_at.to_s },
|
||||
proc { |lis| lis.first.order.completed_at.to_s },
|
||||
proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.total } },
|
||||
proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.outstanding_balance } },
|
||||
proc { |lis| lis.map { |li| li.order }.uniq.sum { |o| o.payment_total } } ]
|
||||
|
||||
rules = [ { group_by: proc { |li| li.order.user },
|
||||
sort_by: proc { |user| user.to_s } },
|
||||
{ group_by: proc { |li| li.order },
|
||||
rules = [ { group_by: proc { |li| li.order },
|
||||
sort_by: proc { |order| order.created_at } } ]
|
||||
|
||||
else # List all line items
|
||||
@@ -175,7 +173,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
columns = [ proc { |lis| lis.first.variant.product.supplier.name },
|
||||
proc { |lis| lis.first.variant.product.name },
|
||||
proc { |lis| "UNIT SIZE" },
|
||||
proc { |lis| lis.first.variant.product.group_buy_unit_size },
|
||||
proc { |lis| lis.first.variant.options_text },
|
||||
proc { |lis| lis.first.variant.weight || 0 },
|
||||
proc { |lis| lis.sum { |li| li.quantity } },
|
||||
@@ -415,11 +413,12 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
when "order_cycle_customer_totals"
|
||||
table_items = line_items
|
||||
@include_blank = false
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Customer", "Email", "Phone", "Product", "Variant", "Amount", "Total Cost", "Paid?", "Packed?", "Shipped?"]
|
||||
header = ["Distributor", "Customer", "Email", "Phone", "Product", "Variant", "Amount", "Total Cost", "Paid?", "Packed?", "Shipped?"]
|
||||
|
||||
columns = [ proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
columns = [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
proc { |line_items| line_items.first.order.email },
|
||||
proc { |line_items| line_items.first.order.bill_address.phone },
|
||||
proc { |line_items| line_items.first.variant.product.name },
|
||||
@@ -430,16 +429,19 @@ Spree::Admin::ReportsController.class_eval do
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" } ]
|
||||
|
||||
rules = [ { group_by: proc { |line_item| line_item.order.user },
|
||||
sort_by: proc { |user| user.to_s },
|
||||
summary_columns: [ proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
rules = [ { group_by: proc { |line_item| line_item.order.distributor },
|
||||
sort_by: proc { |distributor| distributor.name } },
|
||||
{ group_by: proc { |line_item| line_item.order },
|
||||
sort_by: proc { |order| order.completed_at },
|
||||
summary_columns: [ proc { |line_items| line_items.first.order.distributor.name },
|
||||
proc { |line_items| line_items.first.order.bill_address.firstname + " " + line_items.first.order.bill_address.lastname },
|
||||
proc { |line_items| line_items.first.order.email },
|
||||
proc { |line_items| line_items.first.order.bill_address.phone },
|
||||
proc { |line_items| "TOTAL" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| line_items.sum { |li| li.quantity * li.variant.price } },
|
||||
proc { |line_items| "work out whether paid or not" },
|
||||
proc { |line_items| line_items.map { |li| li.order.paid? }.all? { |paid| paid == true } ? "Yes" : "No" },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| "" } ] },
|
||||
{ group_by: proc { |line_item| line_item.variant.product },
|
||||
@@ -449,6 +451,7 @@ Spree::Admin::ReportsController.class_eval do
|
||||
|
||||
else
|
||||
table_items = line_items
|
||||
@include_blank = 'All'
|
||||
|
||||
header = ["Supplier", "Product", "Variant", "Amount", "Cost per Unit", "Total Cost", "Status", "Incoming Transport"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user