6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rawbotz/routes/stock.rb', line 6
def self.registered(app)
show_stock = lambda do
@suppliers = Supplier.where.not(id: settings.supplier.id).order(:name).all
begin
@stock_products = Rawbotz::Models::StockProductFactory.create @suppliers
rescue Exception => e
@stock_products = []
add_flash :error, "Error: #{e.message}"
end
haml "stock/index".to_sym
end
show_stock_alerts = lambda do
@suppliers = Supplier.where.not(id: settings.supplier.id).order(:name).all
begin
@stock_products = Rawbotz::Models::StockProductFactory.create @suppliers
rescue Exception => e
@stock_products = []
add_flash :error, "Error: #{e.message}"
end
mis_stocked_product_ids = RawgentoDB::Query.wrongly_not_in_stock
@wrongly_out_of_stocks = LocalProduct.where(product_id: mis_stocked_product_ids)
haml "stock/index".to_sym
end
show_stock_warnings = lambda do
@suppliers = Supplier.where.not(id: settings.supplier.id).order(:name).all
begin
@stock_products = Rawbotz::Models::StockProductFactory.create @suppliers
rescue Exception => e
@stock_products = []
add_flash :error, "Error: #{e.message}"
end
@stock_products.delete_if {|s| s.expected_stock_lifetime > 10 }
haml "stock/index".to_sym
end
app.get '/stock', &show_stock
app.get '/stock/alerts', &show_stock_alerts
app.get '/stock/warnings', &show_stock_warnings
end
|