This commit is contained in:
Myat Zin Wai Maw
2019-11-19 14:59:45 +06:30
parent 8b2da5e3da
commit 5a3f328789
16 changed files with 299 additions and 238 deletions

View File

@@ -16,6 +16,7 @@ class ShiftSale < ApplicationRecord
belongs_to :cashier_terminal
belongs_to :employee, :foreign_key => 'employee_id'
has_many :sales
belongs_to :shop
def self.current_shift
# today_date = DateTime.now.strftime("%Y-%m-%d")
@@ -23,12 +24,12 @@ class ShiftSale < ApplicationRecord
return shift
end
def self.current_open_shift(current_user)
def self.current_open_shift(current_user,shop)
#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("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
shift = shop.shift_sales.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
return shift
#end
end