fix first bill amount less than actual sales
This commit is contained in:
@@ -4,12 +4,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
@webview = true
|
||||
end
|
||||
|
||||
|
||||
dining_id = params[:dining_id]
|
||||
@cashier_type = params[:type]
|
||||
@table = DiningFacility.find(dining_id)
|
||||
@table = DiningFacility.find(dining_id)
|
||||
@booking = @table.get_booking
|
||||
@orders = Array.new
|
||||
@order_items = Array.new
|
||||
@@ -47,10 +47,10 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
arr_item = Hash.new
|
||||
if item.qty.to_i > 1
|
||||
i = 1
|
||||
while i <= item.qty.to_i do
|
||||
arr_item = {'order_items_id' => item.order_items_id,
|
||||
'order_id' => item.order_id,
|
||||
'order_item_status' => item.order_item_status,
|
||||
while i <= item.qty.to_i do
|
||||
arr_item = {'order_items_id' => item.order_items_id,
|
||||
'order_id' => item.order_id,
|
||||
'order_item_status' => item.order_item_status,
|
||||
'item_order_by' => item.item_order_by,
|
||||
'item_code' => item.item_code,
|
||||
'item_instance_code' => item.item_instance_code,
|
||||
@@ -91,7 +91,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
arr_order_ids = JSON.parse(params[:arr_order_ids])
|
||||
end
|
||||
orders = nil
|
||||
if !params[:orders].empty?
|
||||
if !params[:orders].empty?
|
||||
orders = JSON.parse(params[:orders])
|
||||
end
|
||||
order_items = nil
|
||||
@@ -102,31 +102,27 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
status = false
|
||||
if !ShiftSale.current_shift.nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if !params[:booking_id].empty?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
# for Multiple Cashier by Zone
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
else
|
||||
table = nil
|
||||
cashier_zone = nil
|
||||
end
|
||||
table = 0
|
||||
if !params[:booking_id].empty?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
# for Multiple Cashier by Zone
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
else
|
||||
table = nil
|
||||
cashier_zone = nil
|
||||
end
|
||||
|
||||
# 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, current_user, cashier_type,params[:current_checkin_induties_count])
|
||||
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
|
||||
if sale_data = booking.sale
|
||||
status = true
|
||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
else
|
||||
status = false
|
||||
end
|
||||
else
|
||||
if params[:type] == "Table"
|
||||
@@ -283,7 +279,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
else
|
||||
if order_ids.count == 1 && order_item_count == 1
|
||||
if order_id_count == 0
|
||||
if order_id_count == 0
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
@@ -332,18 +328,19 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
||||
end
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
||||
status = true
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
else
|
||||
from = ""
|
||||
end
|
||||
ActionCable.server.broadcast "bill_channel",table: table,from:from
|
||||
|
||||
|
||||
render :json => { status: status }
|
||||
else
|
||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||
@@ -381,17 +378,17 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
same_order = OrderItem.find_by_order_id(order_id)
|
||||
if same_order.nil?
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
orderItem.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
set_menu_items_obj.to_json,
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
set_menu_items_obj.to_json,
|
||||
order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
else
|
||||
same_order.qty = same_order.qty.to_f + order_item['qty'].to_f
|
||||
|
||||
Reference in New Issue
Block a user