update complete tab and other issuse

This commit is contained in:
Aung Myo
2018-05-03 09:52:53 +06:30
parent bf00eceba0
commit 28dc5faada
10 changed files with 981 additions and 623 deletions

View File

@@ -45,16 +45,21 @@ class MenuCategory < ApplicationRecord
from_t = Time.parse(menu.valid_time_from.strftime("%H:%M:%S"))
to_t = Time.parse(menu.valid_time_to.strftime("%H:%M:%S"))
current_t = Time.parse(Time.now.utc.getlocal.strftime("%H:%M:%S"))
from = from_t.hour * 3600 + from_t.min*60 + from_t.sec
to = to_t.hour * 3600 + to_t.min* 60 + to_t.sec
current = current_t.hour * 3600 + current_t.min*60+current_t.sec
if from > to
h = to_t.hour
if h < 12 # before noon
if h == 0
to = 24
to = to * 3600 + to_t.min* 60 + to_t.sec
else
h += 24
to = h*3600 + to_t.min* 60 + to_t.sec
end
else # (after) noon
if h > 12
@@ -64,13 +69,9 @@ class MenuCategory < ApplicationRecord
end
end
# from = from.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
# to = to.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
# current = current.split(':').map { |a| a.to_i }.inject(0) { |a, b| a * 60 + b}
day = Date.today.wday
dayresult = menu.valid_days.include?(day.to_s)
if current.between?(from, to) && menu.valid_days.include?(day.to_s)
return true
else

View File

@@ -2604,6 +2604,13 @@ end
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","quick_service")
.group("bookings.booking_id")
end
def self.completed_sale
query = Sale.all
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service")
.group("sales.sale_id")
end
def self.all_receipts
query = Sale.select("sale_payments.created_at as receipt_close_time,