added ribica rake task (item import, copying sections to menu etc.)

This commit is contained in:
Edin Dazdarevic
2015-04-07 00:29:14 +02:00
parent 76d5fd7599
commit 5464ec5770
5 changed files with 331 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ class Item < ActiveRecord::Base
belongs_to :sub_category
belongs_to :supplier
belongs_to :brand
belongs_to :delivery_time_estimation
has_and_belongs_to_many :item_groups, :join_table => 'item_item_groups'
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
@@ -12,13 +13,13 @@ class Item < ActiveRecord::Base
# todo build a front end in backoffice (rails)
def self.items_to_order
return Item.find_by_sql(%Q{
select s.name as supplier, i.name as item, sum(iic.count) amount, i.current_input_price
from carts c
join item_in_carts iic on iic.cart_id = c.id
join items i on i.id = iic.item_id
join suppliers s on i.supplier_id = s.id
where c.confirmed and not (c.packed or c.delivered)
group by s.name, i.name, i.current_input_price
select s.name as supplier, i.name as item, sum(iic.count) amount, i.current_input_price
from carts c
join item_in_carts iic on iic.cart_id = c.id
join items i on i.id = iic.item_id
join suppliers s on i.supplier_id = s.id
where c.confirmed and not (c.packed or c.delivered)
group by s.name, i.name, i.current_input_price
order by s.name, amount desc;
})
end