Packing Report: Adds new subreport "Pack by product"

This commit is contained in:
Sebastian Castro
2022-04-06 11:06:55 +02:00
committed by Jean-Baptiste Bellet
parent eeb525aedb
commit b259f59d1e
3 changed files with 54 additions and 1 deletions

View File

@@ -1272,6 +1272,7 @@ en:
tax_rates: Tax Rates
pack_by_customer: Pack By Customer
pack_by_supplier: Pack By Supplier
pack_by_product: Pack By Product
orders_and_distributors:
name: Orders And Distributors
description: Orders with distributor details

View File

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

View 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