diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 71ad42c8..39858c65 100644 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -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') } diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 1f1afbe4..9dd9e741 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -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') } diff --git a/app/models/menu_item_instance.rb b/app/models/menu_item_instance.rb index f39c29a2..ab4c806d 100644 --- a/app/models/menu_item_instance.rb +++ b/app/models/menu_item_instance.rb @@ -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 diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index c9a05561..b7ce7299 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -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