mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Packing Report: Adds new subreport "Pack by product"
This commit is contained in:
committed by
Jean-Baptiste Bellet
parent
eeb525aedb
commit
b259f59d1e
@@ -76,7 +76,8 @@ module Reporting
|
||||
def packing_report_types
|
||||
[
|
||||
[i18n_translate("pack_by_customer"), :customer],
|
||||
[i18n_translate("pack_by_supplier"), :supplier]
|
||||
[i18n_translate("pack_by_supplier"), :supplier],
|
||||
[i18n_translate("pack_by_product"), :product]
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
51
lib/reporting/reports/packing/product.rb
Normal file
51
lib/reporting/reports/packing/product.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Reporting
|
||||
module Reports
|
||||
module Packing
|
||||
class Product < Base
|
||||
def columns
|
||||
# Reorder default columns
|
||||
super.slice(:hub, :supplier, :product, :variant,
|
||||
:customer_code, :last_name, :first_name, :phone,
|
||||
:quantity, :price, :temp_controlled)
|
||||
end
|
||||
|
||||
def rules
|
||||
[
|
||||
{
|
||||
group_by: :hub,
|
||||
header: true,
|
||||
header_class: "h1 with-background text-center",
|
||||
},
|
||||
{
|
||||
group_by: :supplier,
|
||||
header: true,
|
||||
header_class: "h1",
|
||||
},
|
||||
{
|
||||
group_by: proc { |_item, row| "#{row.product} - #{row.variant}" },
|
||||
header: true,
|
||||
fields_used_in_header: [:product, :variant],
|
||||
summary_row: summary_row,
|
||||
header_class: "h3",
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
def ordering_fields
|
||||
lambda do
|
||||
[
|
||||
distributor_alias[:name],
|
||||
Arel.sql("supplier"),
|
||||
Arel.sql("product"),
|
||||
Arel.sql("variant"),
|
||||
bill_address_alias[:lastname],
|
||||
order_table[:id],
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user