33 lines
840 B
Ruby
33 lines
840 B
Ruby
class Api::BillController < Api::ApiController
|
|
|
|
#Create invoice based on booking
|
|
#Output and invoice
|
|
def create
|
|
@status = false
|
|
@error_message = "Order ID or Booking ID is require to request for a bill."
|
|
|
|
#create Bill by Booking ID
|
|
if (params[:booking_id])
|
|
booking = Booking.find(params[:booking_id])
|
|
if booking
|
|
if booking.sale_id.nil?
|
|
@sale = Sale.new
|
|
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
|
|
else
|
|
@status = true
|
|
end
|
|
end
|
|
elsif (params[:order_id])
|
|
@sale = Sale.new
|
|
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)
|
|
|
|
end
|
|
end
|
|
|
|
|
|
private
|
|
def bill_params
|
|
params.permit(:booking_id, :order_id)
|
|
end
|
|
end
|