diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index e9698da6..3fa36f7d 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -58,6 +58,39 @@ class Origami::SplitBillController < BaseOrigamiController booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, :checkin_at => Time.now.utc, :checkin_by => current_user.name, :booking_status => "assign" }) + + customer = Customer.find(params[:customer_id]) + order_type = "dine_in" + if !customer.nil? + if customer.customer_type == "Takeaway" + order_type = "takeaway" + elsif customer.customer_type == "Delivery" + order_type = "delivery" + end + end + # begin + order = Order.new + order.date = Time.now.utc + order.source = "cashier" + order.order_type = order_type + order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + order.item_count = order_items.count + order.status = "new" + order.table_id = params[:dining_id] # this is dining facilities's id + order.waiters = current_user.name + order.employee_name = current_user.name + order.guest_info = nil + order.save + + order_items.each do |order_item| + orderItem = OrderItem.find(order_item.order_items_id) + orderItem.order_id = order.order_id + orderItem.save + end + + 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) end # Bind shift sale id to sale diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index e776dacf..6057077e 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -170,6 +170,7 @@ function splitBillProcess(cnt_items){ var dining_id = $("#table_id").text(); var type = $("#table_type").text(); + var customer_id = $("#customer_id").text(); var order_items = get_selected_order_items();// Selected Order Items var json_booking = JSON.parse('<%= @booking.to_json.html_safe %>'); var booking_id = ""; @@ -182,7 +183,7 @@ function splitBillProcess(cnt_items){ type: "POST", url: ajax_url, dataType: 'JSON', - data: {'dining_id' : dining_id, 'type': type, 'booking_id' : booking_id, 'order_items' : JSON.stringify(order_items)}, + data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_items' : JSON.stringify(order_items)}, success: function (result) { if (!result.status) { swal("Information!", result.error_message);