fix
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
|
||||
|
||||
include MultiTenancy
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
include ActionView::Rendering
|
||||
include Customers
|
||||
|
||||
before_action :core_allow
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class Api::AuthenticateController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
# before_action :find_shop
|
||||
|
||||
def create
|
||||
emp_id = params[:emp_id]
|
||||
@@ -67,8 +66,5 @@ class Api::AuthenticateController < Api::ApiController
|
||||
params.permit(:emp_id, :password, :session_token)
|
||||
end
|
||||
|
||||
private
|
||||
def find_shop
|
||||
@shop = Shop.find_by_shop_code(params[:shop_code])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Api::BillController < Api::ApiController
|
||||
if !ShiftSale.current_shift.nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking.booking_orders.count > 0
|
||||
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
||||
@@ -52,13 +52,6 @@ class Api::BillController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||
end
|
||||
# elsif (params[:order_id])
|
||||
# order = Order.find(params[:order_id])
|
||||
# @status, @sale_id = Sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
||||
#
|
||||
# # for Job
|
||||
# booking = Booking.find_by_sale_id(@sale_id)
|
||||
# table = DiningFacility.find(booking.dining_facility_id)
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@@ -148,7 +141,7 @@ class Api::BillController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = "cashier"
|
||||
@order.order_type = "Takeaway"
|
||||
@order.customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
@order.customer_id = takeaway.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
|
||||
@@ -26,7 +26,7 @@ class Api::CallWaitersController < ActionController::API
|
||||
unique_code = "CallWaiterPdf"
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
printer.print_call_waiter(print_settings,@table,@time,current_shop)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Api::CheckInProcessController < Api::ApiController
|
||||
# before_action :authenticate
|
||||
def check_in_time
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if params[:booking_id]
|
||||
data = Booking.where("dining_facility_id = #{params[:dining_id]} AND booking_id = '#{params[:booking_id]}'")
|
||||
if data.count > 0
|
||||
@@ -10,7 +10,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
else
|
||||
booking = nil
|
||||
end
|
||||
else
|
||||
else
|
||||
booking = dining_facility.get_current_booking
|
||||
end
|
||||
if !booking.nil?
|
||||
@@ -21,7 +21,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
#Send to background job for processing
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
|
||||
@@ -37,7 +37,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
end
|
||||
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
|
||||
|
||||
if !lookup_checkout_time.empty?
|
||||
now = Time.now.utc
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
@@ -52,16 +52,18 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
else
|
||||
render :json => { :status => false, :error_message => "No current booking!" }
|
||||
end
|
||||
else
|
||||
render :json => { :status => false }
|
||||
end
|
||||
end
|
||||
|
||||
def check_in_process
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.is_active && dining_facility.status == "available"
|
||||
if params[:checkin_time]
|
||||
checkin_at = nil
|
||||
@@ -75,7 +77,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
if dining_facility.check_time(checkin_at, "checkin")
|
||||
booking = dining_facility.get_current_booking
|
||||
if booking.nil?
|
||||
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => checkin_at,:checkout_at =>nil, :booking_status => "assign", :reserved_at => nil, :reserved_by => nil })
|
||||
if booking.save!
|
||||
@@ -95,10 +97,10 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
||||
end
|
||||
else
|
||||
booking = dining_facility.get_current_checkout_booking
|
||||
booking = dining_facility.current_checkout_booking
|
||||
if booking.nil?
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
|
||||
|
||||
if !lookup_checkout_time.empty?
|
||||
today = Time.now.utc.getlocal
|
||||
checkout_at = Time.now.utc.getlocal
|
||||
@@ -118,7 +120,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
# else
|
||||
# type = "RoomBooking"
|
||||
# end
|
||||
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
|
||||
: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 })
|
||||
if booking.save!
|
||||
@@ -133,13 +135,13 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
unique_code = "CheckInOutPdf"
|
||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# 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, dining_facility)
|
||||
end
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :booking_id => booking.booking_id, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
render :json => { :status => true }
|
||||
@@ -176,7 +178,7 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||
elsif !params[:booking_id].nil? && params[:time].nil?
|
||||
error_message = "time is required!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
elsif params[:booking_id].nil? && !params[:time].nil?
|
||||
|
||||
@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
|
||||
|
||||
if !order_reservation_id.nil? && flag
|
||||
shop = @shop
|
||||
shop = current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
|
||||
@@ -51,7 +51,7 @@ class Api::OrdersController < Api::ApiController
|
||||
# end
|
||||
|
||||
#
|
||||
return @shop.to_json
|
||||
return current_shop.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -66,24 +66,19 @@ class Api::OrdersController < Api::ApiController
|
||||
def create
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
@shop = Shop.find_by_shop_code(params[:shop_code])
|
||||
|
||||
current_shift = ShiftSale.current_shift
|
||||
if current_shift.nil?
|
||||
@status = false
|
||||
@message = "No Current Open Shift for This Employee"
|
||||
else
|
||||
current_user =Employee.find(current_shift.employee_id)
|
||||
current_user = Employee.find(current_shift.employee_id)
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
|
||||
if params[:booking_id].present?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
end
|
||||
if params[:table_id].present?
|
||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||
table = DiningFacility.find(params[:table_id])
|
||||
booking = table.get_current_booking
|
||||
end
|
||||
end
|
||||
table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
|
||||
|
||||
booking = table.current_checkin_booking if table
|
||||
booking ||= Booking.find(params[:booking_id]) if params[:booking_id].present?
|
||||
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
@@ -106,14 +101,14 @@ class Api::OrdersController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.shop_code = @shop.shop_code
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@@ -126,8 +121,9 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if params[:order_source] != "app"
|
||||
@order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
|
||||
if @status && @booking
|
||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||
end
|
||||
if @order.table_id.to_i > 0
|
||||
table = DiningFacility.find(@booking.dining_facility_id)
|
||||
@@ -135,11 +131,12 @@ class Api::OrdersController < Api::ApiController
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
end
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_user)
|
||||
end
|
||||
end
|
||||
# # for parallel order
|
||||
# remoteIP = ""
|
||||
# begin
|
||||
# @status, @booking = @order.generate
|
||||
# remoteIP = request.remote_ip
|
||||
# end while request.remote_ip != remoteIP
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
@@ -202,7 +199,7 @@ class Api::OrdersController < Api::ApiController
|
||||
#checked checkin and checkout time
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
if !booking_id.nil?
|
||||
if booking_id.present?
|
||||
if booking = Booking.find(booking_id)
|
||||
if booking.checkout_at.present?
|
||||
if booking.checkout_at.utc <= Time.now.utc
|
||||
|
||||
@@ -10,7 +10,7 @@ class Api::Payment::CallbackController < Api::ApiController
|
||||
if trade_status == "PAY_SUCCESS"
|
||||
merch_order_id = params[:Request][:merch_order_id]
|
||||
|
||||
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, 'kbzpay', merch_order_id)
|
||||
status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, current_shop, current_user, 'kbzpay', merch_order_id)
|
||||
render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
|
||||
shop_detail = @shop
|
||||
shop_detail = current_shop
|
||||
|
||||
# rounding adjustment
|
||||
if !path.include? ("credit_payment")
|
||||
|
||||
@@ -171,9 +171,9 @@ class Api::PaymentsController < Api::ApiController
|
||||
action_by = current_login_employee.name
|
||||
@status = true
|
||||
@message = ""
|
||||
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",sale.shop_code)
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
|
||||
@@ -8,8 +8,8 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
param_checksum = params[:checksum]
|
||||
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
|
||||
|
||||
shop_code = params[:shop_code]
|
||||
all_menu = Menu.where('shop_code=?',shop_code).active.all
|
||||
all_menu = Menu.includes(:menu_categories => [:children, :menu_items => [:menu_item_instances => :menu_instance_item_sets, :item_sets => :menu_item_instances]]).active.all
|
||||
|
||||
@request_url = ''
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
@request_url = request.base_url
|
||||
@@ -17,10 +17,7 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
# to hash
|
||||
menu_array = []
|
||||
all_menu.each do |m|
|
||||
menu_array.push(m.to_json(:include => {:menu_categories =>
|
||||
{ :include => { :menu_items =>
|
||||
{ :include => [:menu_item_sets, :menu_item_instances =>
|
||||
{ :include => :menu_instance_item_sets}]} } }}))
|
||||
menu_array.push(m.to_json(:include => { :menu_categories => { :include => { :menu_items => { :include => [ :item_sets, :menu_item_instances => { :include => :menu_instance_item_sets } ] } } } } ))
|
||||
end
|
||||
|
||||
#export Checksum file generate by md5
|
||||
@@ -29,6 +26,10 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
if menu_checksum != param_checksum
|
||||
response.headers['CHECKSUM'] = menu_checksum
|
||||
@menus = all_menu
|
||||
@item_attributes = MenuItemAttribute.all.load
|
||||
@item_options = MenuItemOption.all.load
|
||||
else
|
||||
render :json => nil
|
||||
end
|
||||
# @current_menu = Menu.current_menu
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ class Api::Restaurant::ZonesController < Api::ApiController
|
||||
|
||||
def index
|
||||
if (params[:filter] && params[:filter] = "all" )
|
||||
@all_tables = Table.active
|
||||
@all_rooms = Room.active
|
||||
@all_tables = Table.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||
@all_rooms = Room.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||
else
|
||||
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
|
||||
|
||||
#sound effect / alarm api for doemal side calling
|
||||
def sound_effect
|
||||
shop = @shop
|
||||
shop = current_shop
|
||||
if !shop.nil?
|
||||
shop_code = shop.shop_code
|
||||
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||
|
||||
Reference in New Issue
Block a user