Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into osaka

This commit is contained in:
Yan
2017-07-12 17:37:26 +06:30
4 changed files with 8 additions and 7 deletions

View File

@@ -1,12 +1,12 @@
class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code
# before_create :generate_menu_category_code
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
has_many :menu_items
validates_presence_of :name, :menu, :order_by
validates_presence_of :name, :menu, :code, :order_by
default_scope { order('order_by asc') }

View File

@@ -1,6 +1,6 @@
class MenuItem < ApplicationRecord
before_create :generate_menu_item_code
# before_create :generate_menu_item_code
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
@@ -8,7 +8,7 @@ class MenuItem < ApplicationRecord
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
validates_presence_of :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
default_scope { order('item_code asc') }

View File

@@ -1,6 +1,6 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
before_create :generate_menu_item_instance_code
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id

View File

@@ -18,15 +18,16 @@ class ShiftSale < ApplicationRecord
def self.current_shift
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null",today_date).take
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null").take
return shift
end
def self.current_open_shift(current_user)
#if current_user
#find open shift where is open today and is not closed and login by current cashier
#DATE(shift_started_at)=? and
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
return shift
#end
end