71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
class Api::OrdersController < ActionController::API
|
|
#before :authenticate_token
|
|
|
|
#Description
|
|
# This API show current order details
|
|
# Input Params - order_id
|
|
def show
|
|
order = Order.find(params[:order_id])
|
|
order.order_items
|
|
end
|
|
|
|
|
|
# Description
|
|
# This API allow new order creation
|
|
# Input Params
|
|
# order_source [* default - emenu] | table_id | booking_id [table_booking_id & Room_booking_id] (*require for Dine-In) | order_type [* Default - Dine-in]
|
|
# | guest_info (optional) | customer_id (* Default assigned to WALK-IN)
|
|
# order_items {[item_code, item_instance_code , qty, option, variants]}
|
|
# Output Params
|
|
# Status [Success | Error | System Error] , order_id, error_message (*)
|
|
def create
|
|
Rails.logger.debug "Order Source - " + params[:order_source]
|
|
Rails.logger.debug "Table ID - " + params[:table_id]
|
|
|
|
# begin
|
|
@order = Order.new
|
|
@order.source = params[:order_source]
|
|
@order.order_type = params[:order_type]
|
|
@order.customer_id = params[:customer_id]
|
|
@order.items = params[:order_items]
|
|
@order.guest = params[:guest_info]
|
|
@order.table_id = params[:table_id]
|
|
@order.new_booking = true
|
|
@order.employee_name = current_login_employee.name
|
|
|
|
|
|
#Create Table Booking or Room Booking
|
|
if !params["booking_id"].nil?
|
|
@order.new_booking = false
|
|
@order.booking_id = params[:booking_id]
|
|
end
|
|
|
|
@status = @order.generate
|
|
|
|
# rescue Exception => error
|
|
# @status = false
|
|
# @error_messages = "Exception has occurs on System"
|
|
#
|
|
# logger.fatal("Exception Raise - " + error.message)
|
|
# end
|
|
|
|
|
|
|
|
end
|
|
|
|
# Description
|
|
# This API - allow order to add new items to existing orders, does not allow you to remove confirm items
|
|
# Update customer info, Guest Info
|
|
# Input Params
|
|
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
|
def update
|
|
|
|
end
|
|
|
|
def order_params
|
|
params.permits(:order_source, :booking_id,:order_type,
|
|
:customer_id,:guest_info, :table_id, :room_id,
|
|
order_items: [:item_code, :qty, :option, :remark])
|
|
end
|
|
end
|