Merge branch 'master' into cloud

This commit is contained in:
Yan
2017-12-13 18:30:39 +06:30
11 changed files with 114 additions and 27 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

@@ -984,7 +984,7 @@ end
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")
@@ -1103,7 +1103,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