improvements
This commit is contained in:
@@ -22,24 +22,26 @@ class Supplier
|
||||
|
||||
after_create :add_section_on_create
|
||||
|
||||
def active_orders
|
||||
return @active_orders if @active_orders
|
||||
@active_orders = Order.active_for_supplier(id)
|
||||
def active_orders(options = {})
|
||||
return @active_orders if @active_orders && @active_orders_options == options
|
||||
@active_orders_options = options
|
||||
@active_orders = options[:section_id] ? Order.active_for_supplier_and_section(self, options[:section_id]) : Order.active_for_supplier(id)
|
||||
@active_orders.include_relation(list: {table: :section}, product_orders: :order)
|
||||
@active_orders
|
||||
end
|
||||
|
||||
def active_lists
|
||||
def active_lists(options = {})
|
||||
return @active_lists if @active_lists
|
||||
@tables ||= active_tables
|
||||
@tables ||= active_tables(options)
|
||||
@tables.include_relation(:lists)
|
||||
@active_lists = @tables.map(&:lists).flatten.select(&:active?)
|
||||
@active_lists.include_relations(table: :section, orders: {product_orders: :product})
|
||||
end
|
||||
|
||||
|
||||
def active_tables
|
||||
tables
|
||||
# Return the currently active tables for the supplier
|
||||
def active_tables(options = {})
|
||||
options[:section_id].present? ? tables.select{|t| t.section_id == options[:section_id]} : tables
|
||||
end
|
||||
|
||||
def non_placed_tables
|
||||
|
||||
Reference in New Issue
Block a user