order item split bill process

This commit is contained in:
phyusin
2018-02-06 09:46:30 +06:30
parent 3dc6f42bd5
commit 991bc48505
10 changed files with 309 additions and 505 deletions

View File

@@ -88,6 +88,12 @@ class Origami::HomeController < BaseOrigamiController
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
#for split bill
lookup_spit_bill = Lookup.collection_of('split_bill')
@spit_bill = 0
if !lookup_spit_bill[0].nil?
@spit_bill = lookup_spit_bill[0][1]
end
end
private

View File

@@ -1,4 +1,5 @@
class Origami::SplitBillController < BaseOrigamiController
authorize_resource :class => false
def index
dining_id = params[:dining_id]
@@ -18,4 +19,54 @@ class Origami::SplitBillController < BaseOrigamiController
@booking = nil
end
end
def create
order_items = JSON.parse(params[:order_items])
# byebug
status = false
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
#create Bill by Booking ID
table = 0
if !params[:booking_id].empty?
booking = Booking.find(params[:booking_id])
# for Multiple Cashier by Zone
table = DiningFacility.find(booking.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, get_cashier_by_terminal)
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
sale_id = booking.sale_id
sale_data = Sale.find_by_sale_id(sale_id)
end
end
else
puts "new booking"
puts "new order"
puts "update order_id in order"
puts "do process"
end
# Bind shift sale id to sale
sale_data.shift_sale_id = shift_by_terminal.id
sale_data.save
Promotion.promo_activate(sale)
BillBroadcastJob.perform_later(table)
render :json => { status: status }
else
render :json => { status: false, error_message: 'No Current Open Shift!'}
end
end
end