end of day commit

This commit is contained in:
2012-08-29 17:42:04 +02:00
parent 89700f36e9
commit 8213bae2c6
57 changed files with 1109 additions and 128 deletions
+18
View File
@@ -8,6 +8,7 @@ class List
has_many :orders, dependent: :destroy
belongs_to :table
belongs_to :supplier
belongs_to :section
has_and_belongs_to_many :users, storing_keys: true
validates :table_id, presence: true
@@ -15,6 +16,16 @@ class List
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
def self.from_table table, user
return if user.has_active_list?
list = new table: table, supplier_id: table.supplier_id, section_id: table.section_id
list.add_user user
list.save
user.active_list_id = list.id
user.save
list
end
def close!
orders.map(&:close!)
self.state = 'closed'
@@ -48,6 +59,13 @@ class List
@order
end
def move_to_table to_table
TableMove.create list: self, from_table_id: table_id, to_table: to_table
self.table = to_table
self.section_id = to_table.section_id
save
end
def as_json
super.merge(table_number: table_number)
end