fix timezone
This commit is contained in:
@@ -7,7 +7,7 @@ class OrderReservation < ApplicationRecord
|
||||
has_many :order_reservation_items
|
||||
has_one :delivery
|
||||
|
||||
scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
scope :active, -> { where("created_at BETWEEN '#{Time.current.beginning_of_day.utc}' AND '#{Time.current.end_of_day.utc}'") }
|
||||
scope :latest_order, -> { order("order_reservation_id desc, created_at desc") }
|
||||
|
||||
SEND_TO_KITCHEN = "send_to_kitchen"
|
||||
@@ -158,7 +158,7 @@ class OrderReservation < ApplicationRecord
|
||||
if(Sale.exists?(order.sale_id))
|
||||
saleObj = Sale.find(order.sale_id)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -311,18 +311,18 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
|
||||
if status == "accepted"
|
||||
action_times = {"accepted_time" => DateTime.now.utc, "kitchen_time" => "", "ready_time" => ""}
|
||||
action_times = {"accepted_time" => Time.now.utc, "kitchen_time" => "", "ready_time" => ""}
|
||||
order_reservation.action_times = action_times.to_json
|
||||
elsif status == SEND_TO_KITCHEN
|
||||
if !order_reservation.action_times.nil?
|
||||
action_data = JSON.parse(order_reservation.action_times)
|
||||
action_data["kitchen_time"] = DateTime.now.utc
|
||||
action_data["kitchen_time"] = Time.now.utc
|
||||
order_reservation.action_times = action_data.to_json
|
||||
end
|
||||
elsif status == READY_TO_DELIVERY
|
||||
if !order_reservation.action_times.nil?
|
||||
action_data = JSON.parse(order_reservation.action_times)
|
||||
action_data["ready_time"] = DateTime.now.utc
|
||||
action_data["ready_time"] = Time.now.utc
|
||||
order_reservation.action_times = action_data.to_json
|
||||
end
|
||||
end
|
||||
@@ -391,7 +391,7 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
def self.get_count_on_completed
|
||||
order_reservation = OrderReservation.select("COUNT(order_reservation_id) as count")
|
||||
.where("created_at BETWEEN '#{DateTime.now.beginning_of_day}' AND '#{DateTime.now.end_of_day}' AND status = 'delivered'").first()
|
||||
.where("created_at BETWEEN '#{Time.current.beginning_of_day.utc}' AND '#{Time.current.end_of_day.utc}' AND status = 'delivered'").first()
|
||||
end
|
||||
|
||||
def self.get_pending_orders
|
||||
@@ -426,7 +426,7 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
shop_code = ''
|
||||
end
|
||||
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.current.utc}'")
|
||||
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'")
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
@@ -444,7 +444,7 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
shop_code = ''
|
||||
end
|
||||
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.current.utc}'")
|
||||
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'")
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
|
||||
Reference in New Issue
Block a user