shop code

This commit is contained in:
Myat Zin Wai Maw
2019-11-22 18:24:02 +06:30
parent 5a3f328789
commit d1ab2c194d
106 changed files with 834 additions and 895 deletions

View File

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