order controller update
This commit is contained in:
@@ -33,27 +33,22 @@ class Api::OrdersController < Api::ApiController
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id]
|
||||
@order.new_booking = true
|
||||
#@order.employee_name = "Emenu"
|
||||
@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]
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed"
|
||||
@order.new_booking = true
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
# rescue Exception => error
|
||||
# @status = false
|
||||
# @error_messages = "Exception has occurs on System"
|
||||
#
|
||||
# logger.fatal("Exception Raise - " + error.message)
|
||||
# end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Description
|
||||
|
||||
@@ -25,7 +25,7 @@ class Order < ApplicationRecord
|
||||
booking = nil
|
||||
|
||||
if self.new_booking
|
||||
puts "a"
|
||||
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
|
||||
@@ -12,7 +12,8 @@ class Sale < ApplicationRecord
|
||||
has_many :sale_taxes
|
||||
has_many :sale_payments
|
||||
has_many :sale_orders
|
||||
|
||||
has_many :bookings
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by)
|
||||
|
||||
Reference in New Issue
Block a user