From 465055aacb098c4647d48dc09d2d57cc1e8acc72 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 12 Jul 2017 10:20:43 +0630 Subject: [PATCH 1/3] re-add validate for menu item and cat --- app/models/menu_category.rb | 2 +- app/models/menu_item.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 71ad42c8..9e8e808d 100644 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -6,7 +6,7 @@ class MenuCategory < ApplicationRecord 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..9ab8822e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -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') } From c88248281cc683fc9a00eaa15f3ad27dce0e3701 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 12 Jul 2017 10:27:45 +0630 Subject: [PATCH 2/3] remove date filter in shift --- app/models/shift_sale.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 From 762db6bff9982e7f0c00bd4f1464b8e26d095d4f Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 12 Jul 2017 10:39:23 +0630 Subject: [PATCH 3/3] remove auto gen for menu --- app/models/menu_category.rb | 2 +- app/models/menu_item.rb | 2 +- app/models/menu_item_instance.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 9e8e808d..39858c65 100644 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -1,5 +1,5 @@ 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" diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 9ab8822e..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 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