shop code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user