Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into quick_service

This commit is contained in:
Aung Myo
2018-02-08 11:09:21 +06:30
33 changed files with 303 additions and 127 deletions

View File

@@ -46,7 +46,8 @@ class Api::BillController < Api::ApiController
Promotion.promo_activate(@sale)
BillBroadcastJob.perform_later(table)
#BillBroadcastJob.perform_later(table)
ActionCable.server.broadcast "bill_channel",table: table
else
@status = false
@error_message = "No Current Open Shift"

View File

@@ -5,7 +5,8 @@ class Api::CallWaitersController < ActionController::API
@table_id = params[:dining_id]
@time = params[:time]
@table = DiningFacility.find(@table_id)
CallWaiterJob.perform_later(@table,@time)
# CallWaiterJob.perform_later(@table,@time)
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time
# get printer info
@shop = Shop::ShopDetail

View File

@@ -25,9 +25,10 @@ class Api::CheckInProcessController < Api::ApiController
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 }
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 => false, :error_message => "No current booking!" }
end
@@ -41,31 +42,36 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_time")
if !lookup_checkout_time.empty?
checkout_at = Time.now.utc
today = Time.now.utc.getlocal
checkout_at = Time.now.utc.getlocal
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= checkout_at && checkout_at <= end_time
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end
dining_facility.status = "occupied"
dining_facility.save!
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
dining_facility.status = "occupied"
dining_facility.save!
if dining_facility.type == "Table"
type = "TableBooking"
if dining_facility.type == "Table"
type = "TableBooking"
else
type = "RoomBooking"
end
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
booking.save!
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
else
type = "RoomBooking"
render :json => { :status => true }
end
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
booking.save!
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
else
render :json => { :status => true }
end

View File

@@ -184,9 +184,9 @@ class Api::OrdersController < Api::ApiController
#checked checkin and checkout time
def checkin_checkout_time(booking_id)
status = true
if !params[:booking_id].nil?
if !booking_id.nil?
today = Time.now.utc
booking = Booking.find(params[:booking_id])
booking = Booking.find(booking_id)
if !booking.nil?
if !booking.checkout_at.nil?
checkout_time = booking.checkout_at.utc

View File

@@ -10,7 +10,9 @@ class Oqs::EditController < BaseOqsController
qty_weight = params[:qty_weight]
remarks = params[:remarks]
order_item = OrderItem.find(order_items_id);
order_item = OrderItem.find(order_items_id)
before_updated_qty = order_item.qty
order_item.item_order_by = current_user.name
order_item.qty = qty_weight
order_item.remark = remarks
@@ -45,7 +47,7 @@ class Oqs::EditController < BaseOqsController
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end
end

View File

@@ -1,7 +1,7 @@
class Oqs::HomeController < BaseOqsController
def index
@queue_stations = OrderQueueStation.all
# Query for OQS with delivery status false
# @queue_items_details = queue_items_query(false)
@@ -11,26 +11,28 @@ class Oqs::HomeController < BaseOqsController
@filter = params[:filter]
@queue_stations = OrderQueueStation.all
@queue_completed_item = completed_order(@filter)
if !@queue_completed_item.empty?
@queue_completed_item.each do |queue_item|
if !queue_item.set_menu_items.nil?
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
end
queue_item.set_menu_items = arr_instance_item_sets
end
end
end
# if !@queue_completed_item.empty?
# @queue_completed_item.each do |queue_item|
# if !queue_item.set_menu_items.nil?
# instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
# arr_instance_item_sets = Array.new
# instance_item_sets.each do |instance_item|
# item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
# arr_instance_item_sets.push(item_instance_name)
# end
# queue_item.set_menu_items = arr_instance_item_sets
# end
# end
# end
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
@count.each do |count|
#@count.each do |count|
end
#end
end
# @queue_stations_items=Array.new
@@ -99,7 +101,6 @@ class Oqs::HomeController < BaseOqsController
end
end
end
render :json => items.to_json
end
@@ -194,18 +195,35 @@ class Oqs::HomeController < BaseOqsController
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
# def queue_items_count_query(status,filter)
# query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
# .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
# left join orders as od ON od.order_id = assigned_order_items.order_id
# left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
# left join customers as cus ON cus.customer_id = od.customer_id
# 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}' ")
# 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")
# end
def queue_items_count_query(status,filter)
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
# query = OrderQueueStation.all
query = OrderQueueStation.select("order_queue_stations.id as station_id,
(case when (count(odt.item_code)>0) then count(odt.item_code) else 0 end) as total")
.joins(" left join assigned_order_items as aoi on aoi.order_queue_station_id= order_queue_stations.id
left join orders as od ON od.order_id = aoi.order_id
left join order_items as odt ON odt.item_instance_code = aoi.instance_code AND odt.order_id = aoi.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join booking_orders as bo on bo.order_id = aoi.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("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.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")
.group("order_queue_stations.id")
end

View File

@@ -38,7 +38,7 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
# update print status for completed same order items
assigned_items.each do |ai|

View File

@@ -2,31 +2,34 @@ class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process
lookup_checkout_time = Lookup.collection_of("checkout_time")
checkout_at = Time.now.utc
today = Time.now.utc.getlocal
checkout_at = Time.now.utc.getlocal
if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= checkout_at && checkout_at <= end_time
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end
end
@dining_facility = DiningFacility.find(params[:dining_id])
@dining_facility.status = "occupied"
@dining_facility.save!
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])
@dining_facility.status = "occupied"
@dining_facility.save!
if @dining_facility.type == "Table"
type = "TableBooking"
else
type = "RoomBooking"
if @dining_facility.type == "Table"
type = "TableBooking"
else
type = "RoomBooking"
end
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
@booking.save!
end
end
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
@booking.save!
respond = {:status => 'ok'}
respond_to do |format|
format.json { render json: respond }

View File

@@ -6,7 +6,7 @@ class Origami::HomeController < 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.all.order('date desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@shop = Shop::ShopDetail
# @shift = ShiftSale.current_open_shift(current_user.id)
@@ -17,7 +17,7 @@ class Origami::HomeController < 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.all.order('date desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@status_order = ""
@status_sale = ""
@@ -84,7 +84,10 @@ class Origami::HomeController < BaseOrigamiController
end
end
end
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
end
private

View File

@@ -3,7 +3,7 @@ class Origami::OrdersController < 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.all.order('status desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@order = Order.find(params[:order_id])
sale_order = SaleOrder.find_by_order_id(@order.order_id)
if sale_order

View File

@@ -45,8 +45,8 @@ class Origami::PaymentsController < BaseOrigamiController
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
current_balance = SaleAudit.paymal_search(sale_id)
# current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)

View File

@@ -3,7 +3,7 @@ class Origami::RoomsController < 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.all.order('date desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -11,7 +11,7 @@ class Origami::RoomsController < 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.all.order('date desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@room = DiningFacility.find(params[:room_id])

View File

@@ -3,7 +3,7 @@ class Origami::SalesController < 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.all.order('date desc')
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@sale = Sale.find(params[:sale_id])
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id

View File

@@ -4,6 +4,12 @@ class Origami::ShiftsController < BaseOrigamiController
def show
@shift = ShiftSale.current_open_shift(current_user.id)
#for bank integration
bank_integration = Lookup.collection_of('bank_integration')
@bank_integration = 0
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def new

View File

@@ -1,6 +1,7 @@
class Origami::TableInvoicesController < BaseOrigamiController
def index
@table = DiningFacility.find(params[:table_id])
shop = Shop::ShopDetail
puts "table bookig lenght"
@sale_array = Array.new
@table.bookings.each do |booking|
@@ -9,7 +10,18 @@ class Origami::TableInvoicesController < BaseOrigamiController
if booking.sale_id.nil?
else
sale = Sale.find(booking.sale_id)
# rounding adjustment
if shop.is_rounding_adj
a = sale.grand_total % 25 # Modulus
b = sale.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale.grand_total)
sale.rounding_adjustment = new_total-sale.grand_total
end
end
#end rounding adjustment
if sale.sale_status != "completed"
@sale_array.push(sale)
end
@@ -19,12 +31,24 @@ class Origami::TableInvoicesController < BaseOrigamiController
def show
@table = DiningFacility.find(params[:table_id])
shop = Shop::ShopDetail
@sale_array = Array.new
@table.bookings.each do |booking|
if booking.sale_id.nil?
else
sale = Sale.find(booking.sale_id)
sale = Sale.find(booking.sale_id)
# rounding adjustment
if shop.is_rounding_adj
a = sale.grand_total % 25 # Modulus
b = sale.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale.grand_total)
sale.rounding_adjustment = new_total-sale.grand_total
end
end
#end rounding adjustment
if sale.sale_status != "completed" && sale.sale_status != 'void'
@sale_array.push(sale)
end

View File

@@ -87,7 +87,7 @@ class Origami::VoidController < BaseOrigamiController
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end