Don't generate packing reports unnecessarily when displaying the report form

This commit is contained in:
Matt-Yorkley
2024-03-23 02:11:23 +00:00
parent 26f3b5603d
commit fc1b686938
5 changed files with 30 additions and 10 deletions

View File

@@ -11,13 +11,13 @@ module Reporting
def table_headers
filter = proc { |key| key.to_sym.in?(fields_to_show) }
report.columns.keys.filter { |key| filter.call(key) }.map do |key|
report.table_columns.keys.filter { |key| filter.call(key) }.map do |key|
translate_header(key)
end
end
def available_headers
report.columns.keys.map { |key| [translate_header(key), key] }
report.table_columns.keys.map { |key| [translate_header(key), key] }
end
def fields_to_hide

View File

@@ -54,6 +54,10 @@ module Reporting
raise NotImplementedError
end
def table_columns
columns
end
# Exple { total_price: :currency }
def columns_format
{}

View File

@@ -4,11 +4,16 @@ module Reporting
module Reports
module Packing
class Customer < Base
def table_columns
Struct.new(:keys).new(
[:hub, :customer_code, :first_name, :last_name, :phone, :supplier, :product,
:variant, :weight, :height, :width, :depth, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :customer_code, :first_name, :last_name, :phone,
:supplier, :product, :variant, :weight, :height, :width, :depth, :quantity,
:price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules

View File

@@ -4,11 +4,16 @@ module Reporting
module Reports
module Packing
class Product < Base
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :product, :variant, :customer_code, :first_name,
:last_name, :phone, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :supplier, :product, :variant,
:customer_code, :first_name, :last_name, :phone,
:quantity, :price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules

View File

@@ -4,10 +4,16 @@ module Reporting
module Reports
module Packing
class Supplier < Base
def table_columns
Struct.new(:keys).new(
[:hub, :supplier, :customer_code, :first_name, :last_name, :phone,
:product, :variant, :quantity, :price, :temp_controlled]
)
end
def columns
# Reorder default columns
super.slice(:hub, :supplier, :customer_code, :first_name, :last_name, :phone,
:product, :variant, :quantity, :price, :temp_controlled)
super.slice(*table_columns.keys)
end
def rules