diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 65c6a893..2a87d180 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -40,15 +40,15 @@ class Api::CheckInProcessController < Api::ApiController lookup_checkout_time = Lookup.collection_of("checkout_alert_time") if !lookup_checkout_time.empty? - now = Time.current - lookup_checkout_time.each do |checkout_time| - arr_time = checkout_time[0].split("-") - start_time = Time.zone.parse(arr_time[0].strip).utc.strftime("%H:%M%p") - end_time = Time.zone.parse(arr_time[1].strip).utc.strftime("%H:%M%p") - if start_time <= now && now <= end_time - alert_time_min = checkout_time[1].to_i - end - end + now = Time.now.utc + lookup_checkout_time.each do |checkout_time| + arr_time = checkout_time[0].split("-") + start_time = Time.zone.parse(arr_time[0].strip).utc.strftime("%H:%M%p") + end_time = Time.zone.parse(arr_time[1].strip).utc.strftime("%H:%M%p") + if start_time <= now && now <= end_time + alert_time_min = checkout_time[1].to_i + end + end render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } else render :json => { :status => true } diff --git a/app/controllers/api/shifts_controller.rb b/app/controllers/api/shifts_controller.rb index c6e41df3..1b3288f4 100644 --- a/app/controllers/api/shifts_controller.rb +++ b/app/controllers/api/shifts_controller.rb @@ -35,7 +35,7 @@ class Api::ShiftsController < Api::ApiController @shift = ShiftSale.find_by_id(shift_id) if !@shift.nil? if @shift.shift_closed_at.nil? - @shift.shift_closed_at = DateTime.now.utc + @shift.shift_closed_at = Time.current @shift.closing_balance = closing_balance.to_f @shift.save diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index a5e5a4ed..c2720a87 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -33,7 +33,6 @@ class BaseReportController < ActionController::Base if params[:from].present? && params[:to].present? from = Time.zone.parse(params[:from]) to = Time.zone.parse(params[:to]) - else case period.to_i when PERIOD["today"] diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 2ea0f6c7..9c3b6980 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -5,9 +5,9 @@ class Crm::DiningQueuesController < BaseCrmController # GET /crm/dining_queues # GET /crm/dining_queues.json def index - today = DateTime.now.strftime('%Y-%m-%d') - @dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") - @complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") + today = Time.current.strftime('%Y-%m-%d') + @dining_queues = DiningQueue.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") + @complete_queue = DiningQueue.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") if params[:term] @customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%") diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index c91637be..9799859f 100755 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -1,12 +1,12 @@ class Crm::HomeController < BaseCrmController def index - + @booking = Booking.all @customer = Customer.all from = Time.current.beginning_of_day to = Time.current.end_of_day @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') - redirect_to crm_customers_path + redirect_to crm_customers_path # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) end @@ -16,12 +16,12 @@ class Crm::HomeController < BaseCrmController #print for crm def print_order - + @booking = Booking.find(params[:id]) @total_amount = 0.00 @total_tax = 0.00 - + if @booking.booking_orders order_items = [] @booking.booking_orders.each do |bo| @@ -32,14 +32,14 @@ class Crm::HomeController < BaseCrmController end end - + # unique_code="CrmOrderPdf" # print_settings = PrintSetting.find_by_unique_code(unique_code) # printer = Printer::ReceiptPrinter.new(print_settings) - # printer.print_crm_order(@booking,order_items,print_settings) + # printer.print_crm_order(@booking,order_items,print_settings) end @@ -53,8 +53,7 @@ class Crm::HomeController < BaseCrmController # else # render json: JSON.generate({:status => false, :error_message => "Record not found"}) - # end + # end # end - -end +end diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 240777a0..109bb9bc 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -21,7 +21,7 @@ class Foodcourt::FoodCourtController < ApplicationController @tables = Table.active.order('status desc') @rooms = Room.active.order('status desc') - today = DateTime.now + today = Time.current day = Date.today.wday @menus = [] @menu = [] diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb index 1888b808..48cdb24f 100755 --- a/app/controllers/foodcourt/home_controller.rb +++ b/app/controllers/foodcourt/home_controller.rb @@ -7,7 +7,7 @@ class Foodcourt::HomeController < BaseFoodcourtController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @occupied_table = DiningFacility.where("status='occupied'").count @@ -22,7 +22,7 @@ class Foodcourt::HomeController < BaseFoodcourtController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @shift = ShiftSale.current_open_shift(current_user) @@ -33,8 +33,8 @@ class Foodcourt::HomeController < BaseFoodcourtController @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") - #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") + @dining_booking = @dining.bookings.active.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.today.prev_day}' ") + @order_items = Array.new @dining_booking.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 2a1b5185..d5d55a77 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -7,8 +7,8 @@ class Foodcourt::OrdersController < BaseFoodcourtController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') - @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @complete = Sale.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and sale_status != 'new'",Time.not.utc.strftime('%Y-%m-%d')) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) booking = Booking.select('bookings.booking_id, bookings.dining_facility_id') .joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id") @@ -100,7 +100,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController @rooms = Room.active.order('status desc') @cashier_type = "food_court" - today = DateTime.now + today = Time.current day = Date.today.wday @menus = [] @@ -214,7 +214,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController in_duties.each do |in_duty| induty = InDuty.find(in_duty.id) induty.sale_id = sale_data.sale_id - induty.out_time = Time.now.utc + induty.out_time = Time.now induty.save end end diff --git a/app/controllers/foodcourt/sales_controller.rb b/app/controllers/foodcourt/sales_controller.rb index cbc34cbe..fe37d0d7 100755 --- a/app/controllers/foodcourt/sales_controller.rb +++ b/app/controllers/foodcourt/sales_controller.rb @@ -8,7 +8,7 @@ class Foodcourt::SalesController < BaseFoodcourtController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @sale = Sale.find(params[:sale_id]) @order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id @@ -29,7 +29,7 @@ class Foodcourt::SalesController < BaseFoodcourtController sale_data = [] table = DiningFacility.find(dining) existing_booking = Booking.find_by_sale_id(sale_id) - table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking| + table.bookings.active.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking| if booking.sale_id.nil? order_array = [] booking.booking_orders.each do |booking_order| diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb index 52235ef3..40419091 100755 --- a/app/controllers/foodcourt/shifts_controller.rb +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -46,7 +46,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController shift_id = params[:shift_id] @shift = ShiftSale.find_by_id(shift_id) if @shift - @shift.shift_closed_at = DateTime.now.utc + @shift.shift_closed_at = Time.now @shift.closing_balance = closing_balance.to_f @shift.save diff --git a/app/controllers/induties/assign_in_duties_controller.rb b/app/controllers/induties/assign_in_duties_controller.rb index 84ce9038..2296eebd 100644 --- a/app/controllers/induties/assign_in_duties_controller.rb +++ b/app/controllers/induties/assign_in_duties_controller.rb @@ -4,15 +4,15 @@ class Induties::AssignInDutiesController < ApplicationController @commiss=Commissioner.active.all.order(created_at: :desc) @commiss.each do|commissioner| check_in_count =InDuty.where('commissioner_ids =? and out_time is null', commissioner.id.to_json).count; - @commissioners.push({ "id"=>commissioner.id, + @commissioners.push({ "id"=>commissioner.id, "name"=>commissioner.name, "image_path"=>commissioner.image_path.url, "check_in_count"=>check_in_count }) - + end @booking_id = params[:booking_id] - + end def get_all_occupied_dining @@ -32,10 +32,10 @@ class Induties::AssignInDutiesController < ApplicationController induty.booking_id = booking_id induty.commissioner_ids = commissioner_ids induty.by_name = params[:by_name] - induty.in_time = Time.current + induty.in_time = Time.now if induty.save dinning = DiningFacility.find(induty.dinning_id) - @induty= {"id"=>induty.id, + @induty= {"id"=>induty.id, "dinning_id"=>induty.dinning_id, "in_time"=>induty.in_time, "out_time"=>induty.out_time, diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index b4807889..20a4b140 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -249,7 +249,7 @@ class Oqs::HomeController < BaseOqsController # left join booking_orders as bo on bo.order_id = assigned_order_items.order_id # left join bookings as bk on bk.booking_id = bo.booking_id # left join dining_facilities as df on df.id = bk.dining_facility_id") - # .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ") + # .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.current.beginning_of_day.utc}' ") # query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) # .group("oqs.id") diff --git a/app/controllers/origami/bank_integration_controller.rb b/app/controllers/origami/bank_integration_controller.rb index c27d77d9..49564f89 100644 --- a/app/controllers/origami/bank_integration_controller.rb +++ b/app/controllers/origami/bank_integration_controller.rb @@ -3,8 +3,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon def settle_trans if(params[:type] == 'request') card_settle_trans = CardSettleTran.new() - card_settle_trans.req_date = Time.current.strftime("%Y-%m-%d") - card_settle_trans.req_time = Time.current + card_settle_trans.req_date = Date.today + card_settle_trans.req_time = Time.now card_settle_trans.req_cmd = params[:data][:cmd_type] card_settle_trans.req_type = params[:data][:payment_type] card_settle_trans.save() @@ -13,8 +13,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon response = {status: 'success', card_settle_trans_id: card_settle_trans_id} else card_settle_trans = CardSettleTran.find(params[:card_settle_trans_id]) - card_settle_trans.res_date = Time.current.strftime("%Y-%m-%d") - card_settle_trans.res_time = Time.current + card_settle_trans.res_date = Date.today + card_settle_trans.res_time = Time.now card_settle_trans.res_cmd = params[:data][:CMD] card_settle_trans.res_type = params[:data][:TYPE] card_settle_trans.status = params[:data][:STATUS] @@ -42,8 +42,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon if(params[:type] == 'request') card_sale_trans = CardSaleTran.new() card_sale_trans.sale_id = params[:data][:sale_id] - card_sale_trans.req_date = Time.current.strftime("%Y-%m-%d") - card_sale_trans.req_time = Time.current + card_sale_trans.req_date = Date.today + card_sale_trans.req_time = Time.now card_sale_trans.req_amt = params[:data][:amt] card_sale_trans.req_inv_no = params[:data][:inv_no] card_sale_trans.req_cmd = params[:data][:cmd_type] diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 92589ed7..e8fe214d 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -14,7 +14,7 @@ class Origami::CheckInProcessController < BaseOrigamiController checkout_at = checkout_at + (checkout_time[1]).to_i.minutes end end - + if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") @dining_facility = DiningFacility.find(params[:dining_id]) @@ -23,9 +23,9 @@ class Origami::CheckInProcessController < BaseOrigamiController # else # type = "RoomBooking" # end - + @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", - :checkin_by=>current_login_employee.name,:checkin_at => Time.current,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + :checkin_by=>current_login_employee.name, :checkin_at => Time.current, :checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) cashier_terminal = CashierTerminal.find_by_id(@dining_facility.zone_id) @@ -40,13 +40,13 @@ class Origami::CheckInProcessController < BaseOrigamiController booking = Booking.find_by_booking_id(@booking.booking_id) table = DiningFacility.find(params[:dining_id]) - # print when complete click + # print when complete click order_queue_printer = Printer::OrderQueuePrinter.new(printer) if !printer.nil? order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table) end - end + end end end diff --git a/app/controllers/origami/credit_sales_controller.rb b/app/controllers/origami/credit_sales_controller.rb index 587b22dd..9f781d6f 100644 --- a/app/controllers/origami/credit_sales_controller.rb +++ b/app/controllers/origami/credit_sales_controller.rb @@ -8,8 +8,8 @@ class Origami::CreditSalesController < BaseOrigamiController @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') - @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @complete = Sale.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and sale_status != 'new'",Time.current.strftime('%Y-%m-%d')) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @sale = Sale.find_by_sale_id(params[:sale_id]) diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb index a3fa48d4..33b90a7a 100644 --- a/app/controllers/origami/food_court_controller.rb +++ b/app/controllers/origami/food_court_controller.rb @@ -8,7 +8,7 @@ class Origami::FoodCourtController < ApplicationController end def index - today = DateTime.now + today = Time.current day = Date.current.wday # if params[:menu] == "true" @menus = [] @@ -47,7 +47,7 @@ class Origami::FoodCourtController < ApplicationController def modify_order @cashier_type = "food_court" - today = DateTime.now + today = Time.current day = Date.current.wday # if params[:menu] == "true" @menus = [] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 0ca69f3a..a40485b7 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -7,7 +7,7 @@ class Origami::HomeController < BaseOrigamiController @tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc') @rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @@ -24,7 +24,7 @@ class Origami::HomeController < BaseOrigamiController @tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc') @rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @shift = ShiftSale.current_open_shift(current_user) diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index 98054893..32ab34c0 100755 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -1,20 +1,20 @@ class Origami::MoveroomController < BaseOrigamiController - + authorize_resource :class => false - + def move_dining @webview = check_mobile - + @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @complete = Sale.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and sale_status != 'new'",Time.current.strftime('%Y-%m-%d')) + @orders = Order.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed'",Time.current.strftime('%Y-%m-%d')).order('date desc') @status_order = "" @status_sale = "" @sale_array = Array.new @dining = DiningFacility.find(params[:dining_id]) - @dining_room = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ") + @dining_room = @dining.bookings.active.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.current.prev_day}' ") @dining_room.each do |booking| if booking.sale_id.nil? @order_items = Array.new diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 283807d1..eee9270d 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -7,15 +7,15 @@ class Origami::MovetableController < BaseOrigamiController @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') - @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @complete = Sale.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and sale_status != 'new'",Time.current.strftime('%Y-%m-%d')) + @orders = Order.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed'",Time.current.strftime('%Y-%m-%d')).order('date desc') @dining = DiningFacility.find(params[:dining_id]) @status_order = "" @status_sale = "" @sale_array = Array.new - @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ") + @dining_booking = @dining.bookings.active.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.current.prev_day}' ") @dining_booking.each do |booking| if booking.sale_id.nil? @@ -32,7 +32,7 @@ class Origami::MovetableController < BaseOrigamiController @order_items.push(item) end end - + accounts = @customer.tax_profiles @account_arr =[] accounts.each do |acc| @@ -69,11 +69,11 @@ class Origami::MovetableController < BaseOrigamiController def moving change_to = params[:change_to] #new - change_from = params[:change_from] #original + change_from = params[:change_from] #original # bookings = Booking.where('dining_facility_id=?',change_from) - bookings = Booking.where("((DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}')) AND dining_facility_id='#{change_from}'") + bookings = Booking.where("((DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.current.prev_day}')) AND dining_facility_id='#{change_from}'") booking_array = Array.new order_items = Array.new @@ -85,13 +85,13 @@ class Origami::MovetableController < BaseOrigamiController booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) - if order.status == 'new' + if order.status == 'new' oqs = OrderQueueStation.new oqs.process_order(order, change_from, order.source, 'move',change_to,current_user.name) # order.order_items.each do |order_item| # order_items.push(order_item) # end - end + end end end end @@ -104,9 +104,9 @@ class Origami::MovetableController < BaseOrigamiController # @to = (DiningFacility.find(change_to)).name # @type = (DiningFacility.find(change_to)).type # @moved_by = @current_user.name - # @date = DateTime.now + # @date = Time.current # @shop = @shop - # unique_code = "MoveTablePdf" + # unique_code = "MoveTablePdf" # pdf_no = PrintSetting.where(:unique_code => unique_code).count # #print_settings = PrintSetting.find_by_unique_code(unique_code) # printer_array = [] @@ -115,15 +115,15 @@ class Origami::MovetableController < BaseOrigamiController # for i in 0..pdf_no # if i != pdf_no # print_settings = printer_array[i] - # printer = Printer::ReceiptPrinter.new(print_settings) + # printer = Printer::ReceiptPrinter.new(print_settings) # printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items) - # end - # end + # end + # end # end type = 'move' from = getCloudDomain #get sub domain in cloud mode - ActionCable.server.broadcast "order_channel",table: change_from,type:type,from:from ,change_to:change_to + ActionCable.server.broadcast "order_channel",table: change_from,type:type,from:from ,change_to:change_to end #get cloud domain diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 2a7c9aa3..f3556e7d 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -2,13 +2,13 @@ class Origami::OrdersController < BaseOrigamiController def show @webview = false if check_mobile - @webview = true + @webview = true end - + @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') - @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @complete = Sale.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and sale_status != 'new'",Time.current.strftime('%Y-%m-%d')) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) booking = Booking.select('bookings.booking_id, bookings.dining_facility_id') .joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id") @@ -22,7 +22,7 @@ class Origami::OrdersController < BaseOrigamiController else @booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil}) end - + end @customers = Customer.pluck("customer_id, name") #for split bill @@ -39,7 +39,7 @@ class Origami::OrdersController < BaseOrigamiController @sale_status = sale.sale_status end end - + @order.order_items.each_with_index do |item, order_item_index| if !item.set_menu_items.nil? instance_item_sets = JSON.parse(item.set_menu_items) @@ -52,7 +52,7 @@ class Origami::OrdersController < BaseOrigamiController @order.order_items[order_item_index].set_menu_items = arr_instance_item_sets end end - + # bookings = Booking.all # if !bookings.today.nil? # @order_items_count = Hash.new @@ -85,5 +85,5 @@ class Origami::OrdersController < BaseOrigamiController # end # end end - + end diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index aad9f792..f790da34 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -1,7 +1,7 @@ class Origami::PendingOrderController < BaseOrigamiController def index # @dining= DiningFacility.where("status = 'occupied'") - # @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d')) + # @order = Order.where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",Time.current.strftime('%Y-%m-%d')) @cashier_type = params[:type] @sale = Sale.pending_sale(@cashier_type) @order = Sale.pending_order(@cashier_type) diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index cb00e4ab..7285cc1a 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -8,7 +8,7 @@ class Origami::QuickServiceController < ApplicationController end def index - today = DateTime.now + today = Time.current day = Date.current.wday @menus = [] @@ -46,7 +46,7 @@ class Origami::QuickServiceController < ApplicationController def modify_order @cashier_type = "quick_service" - today = DateTime.now + today = Time.current day = Date.current.wday # if params[:menu] == "true" @menus = [] diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 7b6448d3..8fd847f5 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -4,7 +4,7 @@ class Origami::RoomsController < BaseOrigamiController @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @shift = ShiftSale.current_open_shift(current_user) @webview = false if check_mobile @@ -22,7 +22,7 @@ class Origami::RoomsController < BaseOrigamiController @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @room = DiningFacility.find(params[:room_id]) @shift = ShiftSale.current_open_shift(current_user) @@ -33,8 +33,8 @@ class Origami::RoomsController < BaseOrigamiController @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - - @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ") + + @dining_room = @room.bookings.active.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Time.current.strftime('%Y-%m-%d')}' OR DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = '#{Date.current.prev_day}' ") @order_items = Array.new @dining_room.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index 7a771cc3..424384a2 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -9,7 +9,7 @@ class Origami::SalesController < BaseOrigamiController @tables = Table.unscope(:order).all.active.order('status desc') @rooms = Room.unscope(:order).all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(CONVERT_TZ(date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",Time.current.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @sale = Sale.find(params[:sale_id]) @order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id @@ -31,7 +31,7 @@ class Origami::SalesController < BaseOrigamiController Sale.transaction do table = DiningFacility.find(dining) booking = table.current_checkin_booking - + sale = Sale.find(sale_id) existing = sale.booking diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index d11e781e..fd07a176 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -46,7 +46,7 @@ class Origami::ShiftsController < BaseOrigamiController shift_id = params[:shift_id] @shift = ShiftSale.find_by_id(shift_id) if @shift - @shift.shift_closed_at = DateTime.now.utc + @shift.shift_closed_at = Time.current.utc @shift.closing_balance = closing_balance.to_f @shift.save diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index 3ff4ef7b..5abc600d 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -3,8 +3,8 @@ class Reports::StockCheckController < BaseReportController def index - # from_date = DateTime.now.beginning_of_day - # to_date = DateTime.now.end_of_day + # from_date = Time.current.beginning_of_day + # to_date = Time.current.end_of_day # unless params[:daterange].blank? # from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day # to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day diff --git a/app/controllers/settings/out_of_stock_controller.rb b/app/controllers/settings/out_of_stock_controller.rb index 867d5ba0..7711297b 100644 --- a/app/controllers/settings/out_of_stock_controller.rb +++ b/app/controllers/settings/out_of_stock_controller.rb @@ -20,7 +20,7 @@ class Settings::OutOfStockController < ApplicationController } item_instance = MenuItemInstance.where(item_instance_code: [items_arr]) - date = DateTime.now + date = Time.current unless item_instance.nil? if !item_instance.first.is_out_of_stock? diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 42ede2d4..b07373dc 100755 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -17,8 +17,8 @@ class Settings::PromotionsController < ApplicationController # GET /promotions/new def new @promotion = Promotion.new - @promotion.promo_start_date = DateTime.now - @promotion.promo_end_date = DateTime.now + @promotion.promo_start_date = Time.current + @promotion.promo_end_date = Time.current end # GET /promotions/1/edit diff --git a/app/controllers/transactions/card_settle_trans_controller.rb b/app/controllers/transactions/card_settle_trans_controller.rb index 7968eede..99619fd3 100644 --- a/app/controllers/transactions/card_settle_trans_controller.rb +++ b/app/controllers/transactions/card_settle_trans_controller.rb @@ -5,31 +5,31 @@ class Transactions::CardSettleTransController < ApplicationController # GET /transactions/sales.json def index @status = [["All Status",''], ["Approved","Approved"], ["Declined","Declined"]] - @payment_method = [["All Payments",''],["MPU Payment","mpu"], ["Visa & Master Payment","vmj"], - ["JCB Payment","jcb"],["UnionPay Payment","cup"], + @payment_method = [["All Payments",''],["MPU Payment","mpu"], ["Visa & Master Payment","vmj"], + ["JCB Payment","jcb"],["UnionPay Payment","cup"], ["Alipay Payment","alipay"]] @sales = Sale.all payment_type = params[:payment_type] cashier_name = params[:cashier_name] status_type = params[:status_type] - + from, to = get_date_range_from_params if cashier_name.nil? && from.nil? && to.nil? && payment_method.nil? && status_type.nil? - + @cardSettles = CardSettleTran.order("sale_id desc") - + @cardSettles = Kaminari.paginate_array(@cardSettles).page(params[:page]).per(20) else cardSettle = CardSettleTran.search(cashier_name,from,to,payment_type,status_type) if cardSettle.count > 0 - @cardSettles = cardSettle + @cardSettles = cardSettle @cardSettles = Kaminari.paginate_array(@cardSettles).page(params[:page]).per(20) else @cardSettles = 0 - end + end end end @@ -49,51 +49,51 @@ class Transactions::CardSettleTransController < ApplicationController } def get_date_range_from_params - period_type = params[:period_type] - period = params[:period] - - if params[:from].present? && params[:to].present? - from = Time.zone.parse(params[:from]) - to = Time.zone.parse(params[:to]) - else - case period.to_i - when PERIOD["today"] - from = Time.current - to = Time.current - when PERIOD["yesterday"] - from = 1.day.ago - to = 1.day.ago - when PERIOD["this_week"] - from = Time.current.beginning_of_week - to = Time.current - when PERIOD["last_week"] - from = 1.week.ago.beginning_of_week - to = 1.week.ago.end_of_week - when PERIOD["last_7"] - from = 7.day.ago - to = Time.current - when PERIOD["this_month"] - from = Time.current.beginning_of_month - to = Time.current - when PERIOD["last_month"] - from = 1.month.ago.beginning_of_month - to = 1.month.ago.end_of_month - when PERIOD["last_30"] - from = 30.day.ago - to = Time.current - when PERIOD["this_year"] - from = Time.current.beginning_of_year - to = Time.current - when PERIOD["last_year"] - from = 1.year.ago.beginning_of_year - to = 1.year.ago.end_of_year - end + period_type = params[:period_type] + period = params[:period] + + if params[:from].present? && params[:to].present? + from = Time.zone.parse(params[:from]) + to = Time.zone.parse(params[:to]) + else + case period.to_i + when PERIOD["today"] + from = Time.current + to = Time.current + when PERIOD["yesterday"] + from = 1.day.ago + to = 1.day.ago + when PERIOD["this_week"] + from = Time.current.beginning_of_week + to = Time.current + when PERIOD["last_week"] + from = 1.week.ago.beginning_of_week + to = 1.week.ago.end_of_week + when PERIOD["last_7"] + from = 7.day.ago + to = Time.current + when PERIOD["this_month"] + from = Time.current.beginning_of_month + to = Time.current + when PERIOD["last_month"] + from = 1.month.ago.beginning_of_month + to = 1.month.ago.end_of_month + when PERIOD["last_30"] + from = 30.day.ago + to = Time.current + when PERIOD["this_year"] + from = Time.current.beginning_of_year + to = Time.current + when PERIOD["last_year"] + from = 1.year.ago.beginning_of_year + to = 1.year.ago.end_of_year end + end - from = from.beginning_of_day - to = to.end_of_day + from = from.beginning_of_day + to = to.end_of_day - return from, to + return from, to end end diff --git a/app/models/card_sale_tran.rb b/app/models/card_sale_tran.rb index fdd0f501..95f8e640 100644 --- a/app/models/card_sale_tran.rb +++ b/app/models/card_sale_tran.rb @@ -23,7 +23,7 @@ class CardSaleTran < ApplicationRecord if from.present? && to.present? - # cardSale = CardSaleTran.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status IS NULL ", from,to) + # cardSale = CardSaleTran.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status IS NULL ", from,to) from_date = from.strftime("%Y-%m-%d") to_date = to.strftime("%Y-%m-%d") query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+ @@ -48,7 +48,7 @@ class CardSaleTran < ApplicationRecord query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+ " JOIN customers c ON c.customer_id = s.customer_id") - cardSale = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status = 'Approved'",from,to) + cardSale = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status = 'Approved'",from,to) if shift.present? query1 = cardSale.where("s.shift_sale_id in (?)", shift.to_a) @@ -63,8 +63,8 @@ class CardSaleTran < ApplicationRecord end def self.get_by_shift_sale_by_card(from,to,status) - query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, - shift_closed_at As closing_date,") + query = ShiftSale.select("shift_sales.id ,shift_started_at, + shift_closed_at,") .order("shift_sales.id DESC") return query = query.where("shift_sales.shift_started_at >= ?" , from) end diff --git a/app/models/card_settle_tran.rb b/app/models/card_settle_tran.rb index 2829c9df..ac64f42a 100644 --- a/app/models/card_settle_tran.rb +++ b/app/models/card_settle_tran.rb @@ -25,7 +25,7 @@ class CardSettleTran < ApplicationRecord query = CardSettleTran.joins("Join shift_sales ss ON ss.id = card_settle_trans.shift_sale_id"+ " JOIN employees e ON e.id = ss.employee_id") - cardSettle = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ?",from,to) + cardSettle = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ?",from,to) query1 = cardSettle.where(keyword) query2 = query1.where(payment) query3 = query2.where(status) @@ -45,14 +45,14 @@ class CardSettleTran < ApplicationRecord query = CardSettleTran.joins("Join shift_sales ss ON ss.id = card_settle_trans.shift_sale_id"+ " JOIN employees e ON e.id = ss.employee_id") - cardSettle = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status = 'Approved'",from,to) + cardSettle = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status = 'Approved'",from,to) if shift.present? query1 = cardSettle.where("ss.id in (?)", shift.to_a) elsif shift_sale_range.present? query1 = cardSettle.where("ss.id in (?)",shift_sale_range.to_a) else - query1 = cardSettle.where("DATE_FORMAT(req_date,'%Y-%m-%d') between ? and ?",from,to) + query1 = cardSettle.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') between ? and ?",from,to) end query2 = query1.where(payment) @@ -60,8 +60,8 @@ class CardSettleTran < ApplicationRecord end def self.get_by_shift_sale_by_card(from,to,status) - query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, - shift_closed_at As closing_date,") + query = ShiftSale.select("shift_sales.id ,shift_started_at, + shift_closed_at,") .order("shift_sales.id DESC") return query = query.where("shift_sales.shift_started_at >= ?" , from) end diff --git a/app/models/customer.rb b/app/models/customer.rb index a88929a1..9fe33041 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -24,7 +24,7 @@ class Customer < ApplicationRecord self.contact_no = params[:phone_number] self.email = pin.to_s + "@gmail.com" self.pin_code = pin.to_s - self.pin_sent_at = Time.now + self.pin_sent_at = Time.current tax_profiles=TaxProfile.where(group_type: "online_order") tax_ids =[] tax_profiles.each {|tax| tax_ids << "#{tax.id}"} @@ -33,7 +33,7 @@ class Customer < ApplicationRecord return self else cus.pin_code = pin - cus.pin_sent_at = Time.now + cus.pin_sent_at = Time.current cus.save return cus end @@ -389,7 +389,7 @@ class Customer < ApplicationRecord def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("name LIKE ? OR customer_type LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(date_of_birth,'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%") + where("name LIKE ? OR customer_type LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(CONVERT_TZ(date_of_birth,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%") else find(:all) end diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb index d710d67f..d39a2c0f 100755 --- a/app/models/dining_queue.rb +++ b/app/models/dining_queue.rb @@ -1,8 +1,8 @@ class DiningQueue < ApplicationRecord belongs_to :dining_facility, :optional => true def self.generate_queue_no - today = DateTime.now.strftime('%Y-%m-%d') - dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no desc") + today = Time.current.strftime('%Y-%m-%d') + dining_queues = DiningQueue.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? ", today).order("queue_no desc") queue_no = dining_queues.count + 1 return queue_no end diff --git a/app/models/employee.rb b/app/models/employee.rb index 93e38e0d..e366d5dc 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -36,8 +36,8 @@ class Employee < ApplicationRecord #user.authenticate(password) if (user.authenticate(password)) user.generate_token - user.session_expiry = DateTime.now.utc + expiry_time.minutes - user.session_last_login = DateTime.now.utc + user.session_expiry = Time.now + expiry_time.minutes + user.session_last_login = Time.now user.save return user end @@ -50,7 +50,7 @@ class Employee < ApplicationRecord user = Employee.find_by_token_session(session_token) expiry_time = login_expiry_time - if user && user.session_expiry && user.session_expiry.utc > DateTime.now.utc + if user && user.session_expiry && user.session_expiry.utc > Time.current.utc #Extend the login time each time authenticatation take place user.session_expiry = user.session_expiry.utc + expiry_time.minutes user.save diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb index 523a7fc5..0ccfd350 100644 --- a/app/models/kbz_pay.rb +++ b/app/models/kbz_pay.rb @@ -7,7 +7,7 @@ class KbzPay prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" - datetime = DateTime.now.strftime("%d%m%Y%H%M") + datetime = Time.current.strftime("%d%m%Y%H%M") kbz_app_id = app_id kbz_merch_code = code kbz_api_key = key @@ -66,7 +66,7 @@ class KbzPay prefix = shop.shop_code receipt_no = "#{prefix}#{receipt_no}" amount = 0 - datetime = DateTime.now.strftime("%d%m%Y%H%M") + datetime = Time.current.strftime("%d%m%Y%H%M") kbz_app_id = app_id kbz_merch_code = code kbz_api_key = key diff --git a/app/models/menu.rb b/app/models/menu.rb index a59480a6..e32283d2 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -10,7 +10,7 @@ class Menu < ApplicationRecord scope :active, -> {where("is_active = true")} def self.current_menu - today = DateTime.now + today = Time.current day_of_week = today.wday menus = Menu.where("is_active = true and '#{today.strftime("%H:%M")}' between TIME(valid_time_from) and TIME(valid_time_to)") current_menu = nil diff --git a/app/models/order.rb b/app/models/order.rb index c813a5a8..fbdb7cdc 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -13,7 +13,7 @@ class Order < ApplicationRecord #internal references attributes for business logic control attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time - scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } + scope :active, -> { where("date BETWEEN '#{Time.current.utc.end_of_day}' AND '#{Time.current.utc.beginning_of_day}'") } #Main Controller method to create new order - validate all inputs and generate new order # order_item : { # order_item_code : "", diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 4a9f545f..8d340e8a 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -20,7 +20,8 @@ class OrderItem < ApplicationRecord # after_save :add_to_journal, if: Proc.new { !self.id_changed? } # after_save :update_stock_journal, if: Proc.new { self.id_changed? } - + alias_attribute :order_at, :created_at + alias_attribute :order_by, :item_order_by #This Method - handle how items is added into order # order_item : { diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b1257425..c7f70872 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -182,7 +182,7 @@ class OrderQueueStation < ApplicationRecord @to = (DiningFacility.find(change_to)).name @type = (DiningFacility.find(change_to)).type @moved_by = current_user - @date = DateTime.now + @date = Time.current @shop = Shop.current_shop unique_code = "MoveTablePdf" diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 183242a3..0dd769f6 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -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 diff --git a/app/models/payment_journal.rb b/app/models/payment_journal.rb index 1b195329..e7faa713 100755 --- a/app/models/payment_journal.rb +++ b/app/models/payment_journal.rb @@ -22,7 +22,7 @@ class PaymentJournal < ApplicationRecord # def self.today_cash_in(current_user) # credit = 0.0 - # today_date = DateTime.now.strftime("%Y-%m-%d") + # today_date = Time.current.strftime("%Y-%m-%d") # pj_credit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) # pj_credit.each do |obj| # credit += obj.credit_amount @@ -32,7 +32,7 @@ class PaymentJournal < ApplicationRecord # # def self.today_cash_out(current_user) # debit = 0.0 - # today_date = DateTime.now.strftime("%Y-%m-%d") + # today_date = Time.current.strftime("%Y-%m-%d") # pj_debit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user) # pj_debit.each do |obj| # debit += obj.debit_amount diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index 660c88ed..9a268e74 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -1,7 +1,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker def print_open_cashier(receipt_no) - time = DateTime.now + time = Time.current #Use CUPS service #Generate PDF @@ -17,7 +17,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # def print_close_cashier(receipt_no) # #Use CUPS service # #Generate PDF - # time = DateTime.now + # time = Time.current # #Print # pdf = CashierStationClosing.new # pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf" diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index c3e5838b..365955b3 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -150,7 +150,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) if type == "order_item" - OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -160,7 +160,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .where("order_items.order_items_id = '#{ id }'") .group("order_items.item_code") elsif type == "order_summary" - OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id @@ -171,7 +171,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker .group("order_items.order_items_id") else # order summary for booking - OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id diff --git a/app/models/promotion.rb b/app/models/promotion.rb index f02d468a..74aed210 100755 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -31,7 +31,7 @@ class Promotion < ApplicationRecord end def self.is_between_promo_datetime(current_day,current_time) #database is not local time - promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time) + promoList = Promotion.where("(Date_Format(CONVERT_TZ(promo_start_date, '+00:00', Time.zone.formatted_offset), '%Y-%m-%d') <=? AND Date_Format(CONVERT_TZ(promo_start_date, '+00:00', Time.zone.formatted_offset), '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time) return promoList end diff --git a/app/models/reservation.rb b/app/models/reservation.rb index 4e5ff37a..38c8caa7 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -6,7 +6,7 @@ class Reservation < ApplicationRecord has_many :reservation_items - 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.utc.beginning_of_day}' AND '#{Time.current.utc.end_of_day}'") } private def generate_custom_id diff --git a/app/models/sale.rb b/app/models/sale.rb index 7f933175..6dcb28bb 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -29,8 +29,8 @@ class Sale < ApplicationRecord before_save :round_to_precision after_update :update_stock_journal - scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } - scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") } + scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{Time.current.utc.end_of_day}' AND '#{Time.current.utc.beginning_of_day}'") } + scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{Time.current.utc.beginning_of_day}' AND '#{Time.current.utc.end_of_day}'") } scope :paid, -> { where(payment_status: 'paid')} scope :completed, -> { where(sale_status: 'completed') } @@ -202,7 +202,7 @@ class Sale < ApplicationRecord def generate_invoice_by_items (items, requested_by) taxable = true self.requested_by = requested_by - self.requested_at = DateTime.now + self.requested_at = Time.current items.each do |item| add_item(item) @@ -658,7 +658,7 @@ class Sale < ApplicationRecord # SaleOrder.create(:sale_id => self.id, :order_id => order_id) # end #dosomrting here - #puts Time.now.format(":short") + #puts Time.current.format(":short") end def adjust_rounding @@ -707,7 +707,7 @@ class Sale < ApplicationRecord shop_details = Shop.current_shop #Date-Shift- if self.receipt_no.nil? - prefix = DateTime.now().utc + prefix = Time.current().utc #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s new_receipt_no = SeedGenerator.new_receipt_no().to_s @@ -897,8 +897,8 @@ def self.get_by_shiftsales(from,to,shift) end def self.get_by_shift_sale(from,to,status) - query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, - shift_closed_at As closing_date," + + query = ShiftSale.select("shift_sales.id ,shift_started_at, + shift_closed_at," + " grand_total AS grand_total, cash_sales AS cash," + "total_taxes AS total_tax,total_discounts As total_discount") .order("shift_sales.id DESC") @@ -906,8 +906,8 @@ def self.get_by_shift_sale(from,to,status) end def self.get_by_shift_sale_by_item(from,to,status) - query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, - shift_closed_at As closing_date," + + query = ShiftSale.select("shift_sales.id ,shift_started_at, + shift_closed_at," + " grand_total AS grand_total, cash_sales AS cash," + "total_taxes AS total_tax,total_discounts As total_discount") .order("shift_sales.id DESC") diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 74e8a397..09022fb8 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -35,7 +35,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALEVOID" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = void_by sale_audit.approved_by = approved_by sale_audit.remark = reason @@ -47,7 +47,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALECOMPLETE" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = Sale.find(sale_id).cashier_id sale_audit.remark = remark sale_audit.approved_by = action_by @@ -59,7 +59,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = type - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = discount_by sale_audit.approved_by = approved_by sale_audit.remark = reason @@ -72,7 +72,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALEFOC" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = cashier_id sale_audit.approved_by = approved_by sale_audit.remark = reason @@ -84,7 +84,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = type - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = cashier_id sale_audit.approved_by = approved_by sale_audit.remark = reason @@ -95,7 +95,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALEPAYMENT" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = action_by sale_audit.remark = remark sale_audit.approved_by = action_by @@ -106,7 +106,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "PAYMAL" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = Sale.find(sale_id).cashier_id sale_audit.remark = remark sale_audit.approved_by = action_by @@ -117,7 +117,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = type - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = action_by sale_audit.remark = remark sale_audit.approved_by = action_by @@ -128,7 +128,7 @@ class SaleAudit < ApplicationRecord sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "CHANGE_TAX" - sale_audit.action_at = DateTime.now.utc + sale_audit.action_at = Time.current.utc sale_audit.action_by = action_by sale_audit.remark = remark sale_audit.approved_by = action_by diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 30add9ec..d930580e 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -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 diff --git a/app/views/layouts/_foodcourt_left_sidebar.html.erb b/app/views/layouts/_foodcourt_left_sidebar.html.erb index 278b7dd0..51922b8e 100644 --- a/app/views/layouts/_foodcourt_left_sidebar.html.erb +++ b/app/views/layouts/_foodcourt_left_sidebar.html.erb @@ -46,7 +46,7 @@