fix timezone

This commit is contained in:
Thein Lin Kyaw
2023-02-09 14:55:43 +06:30
parent c580cc731a
commit 944f7a7259
52 changed files with 238 additions and 236 deletions

View File

@@ -17,8 +17,11 @@ class ShiftSale < ApplicationRecord
belongs_to :employee, :foreign_key => 'employee_id'
has_many :sales
alias_attribute :opening_date, :shift_started_at
alias_attribute :closing_date, :shift_closed_at
def self.current_shift
# today_date = DateTime.now.strftime("%Y-%m-%d")
# today_date = Time.current.strftime("%Y-%m-%d")
shift = ShiftSale.where.not(shift_started_at: nil).where(shift_closed_at: nil).first
return shift
end
@@ -27,7 +30,7 @@ class ShiftSale < ApplicationRecord
#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")
today_date = Time.current.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
return shift
#end
@@ -80,7 +83,7 @@ class ShiftSale < ApplicationRecord
def create(opening_balance,cashier_terminal, current_user)
self.cashier_terminal_id = cashier_terminal
self.shift_started_at = DateTime.now
self.shift_started_at = Time.current
self.employee_id = current_user.id
self.opening_balance = opening_balance
self.other_sales = 0