add channel for checkin process

This commit is contained in:
phyusin
2017-12-13 15:58:44 +06:30
parent 5ba010c1e6
commit 211db16311
8 changed files with 81 additions and 4 deletions

View File

@@ -96,4 +96,26 @@ class DiningFacility < ApplicationRecord
end
end
end
def self.get_checkin_booking
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
arr_booking = Array.new
if bookings
bookings.each do |booking|
now = Time.now.utc.getlocal
hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil?
checkout_at = booking.checkout_at.utc.getlocal
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
checkout_at_min -= min
if (checkout_at_hr <= hr) && (checkout_at_min <= 15)
arr_booking.push({'table_id' => booking.dining_facility_id})
end
end
end
end
return arr_booking
end
end

View File

@@ -979,11 +979,11 @@ end
def self.hourly_sales(today)
query= Sale.select("grand_total")
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.group("date_format(receipt_date, '%I %p')")
.group("date_format(convert_tz(receipt_date,'+00:00','+06:30'), '%I:%p')")
end
def self.employee_sales(today)
query = Sale.select("e.name as employee_name,grand_total")
query = Sale.select("e.name as employee_name,(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE sp.payment_amount END) as total_amount")
.where('sales.payment_status="paid" and sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.joins("join employees e on e.id=sales.cashier_id")
.joins("join sale_payments sp on sp.sale_id=sales.sale_id")
@@ -1102,7 +1102,7 @@ end
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.group("a.product_code")
.order("SUM(a.price) DESC")
.order("SUM(a.qty) DESC")
.first()
end