update pull split bill
This commit is contained in:
@@ -185,4 +185,9 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
# @dining = DiningFacility.find(params[:id])
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,4 +95,10 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
|
||||
end
|
||||
render json: response
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,4 +24,9 @@ class Origami::CardPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,4 +14,10 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
shift.cash_in = shift.cash_in + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,4 +7,10 @@ class Origami::CashMgmtController < ApplicationController
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,4 +12,10 @@ class Origami::CashOutsController < BaseOrigamiController
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,4 +35,10 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
||||
format.json { render json: respond }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,4 +47,10 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -132,5 +132,9 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -290,5 +290,9 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# redirect_to origami_path(sale_id)
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,6 +114,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
|
||||
@@ -122,4 +128,9 @@ def set_dining
|
||||
@dining = DiningFacility.find(params[:dining_id])
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,4 +81,9 @@ class Origami::HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -168,4 +168,10 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
def in_duty_params
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,4 +58,9 @@ class Origami::JcbController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,4 +57,9 @@ class Origami::MasterController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,4 +36,10 @@ class Origami::MoveroomController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -70,4 +70,10 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
|
||||
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,4 +57,9 @@ class Origami::MpuController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,4 +39,10 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,4 +58,10 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -37,4 +37,9 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -376,4 +376,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -28,4 +28,10 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -136,4 +136,10 @@ class Origami::ProductCommissionsController < BaseOrigamiController
|
||||
def product_commission_params
|
||||
params.fetch(:product_commission, {})
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,4 +68,10 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,4 +55,10 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,4 +37,9 @@ class Origami::RoomInvoicesController < BaseOrigamiController
|
||||
@customer = @sale.customer
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,7 +117,17 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
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
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -161,4 +161,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,5 +51,9 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,4 +108,9 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
215
app/controllers/origami/split_bill_controller.rb
Normal file
215
app/controllers/origami/split_bill_controller.rb
Normal file
@@ -0,0 +1,215 @@
|
||||
class Origami::SplitBillController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
dining_id = params[:dining_id]
|
||||
@table = DiningFacility.find(dining_id)
|
||||
@booking = @table.get_booking
|
||||
@orders = Array.new
|
||||
@order_items = Array.new
|
||||
@sale_data = Array.new
|
||||
|
||||
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
|
||||
if !table_bookings.nil?
|
||||
table_bookings.each do |table_booking|
|
||||
@sale_data.push(table_booking.sale)
|
||||
end
|
||||
end
|
||||
|
||||
if @booking
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@orders.push(@order)
|
||||
|
||||
@order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
order_ids = params[:order_ids]
|
||||
orders = nil
|
||||
if !params[:orders].empty?
|
||||
orders = JSON.parse(params[:orders])
|
||||
end
|
||||
order_items = nil
|
||||
if !params[:order_items].empty?
|
||||
order_items = JSON.parse(params[:order_items])
|
||||
end
|
||||
|
||||
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
|
||||
if params[:type] == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
||||
:booking_status => "assign" })
|
||||
|
||||
if !orders.nil?
|
||||
orders.each do |order|
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
|
||||
end
|
||||
elsif !order_items.nil?
|
||||
order_item_count = 0
|
||||
order_id_count = 0
|
||||
order_id = nil
|
||||
|
||||
order_items.each do |order_item|
|
||||
order_item_count = 0
|
||||
order = Order.find(order_item["order_id"])
|
||||
if order.order_items.count == 1
|
||||
order_id = order.id
|
||||
order_id_count += 1
|
||||
else
|
||||
order_item_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
if !order_id.nil?
|
||||
if order_id_count > 1
|
||||
updated_order_id = Array.new
|
||||
order_ids.each do |odr_id|
|
||||
odr = Order.find(odr_id)
|
||||
if odr.order_items.count > 1
|
||||
updated_order_id.push(odr_id)
|
||||
end
|
||||
end
|
||||
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
|
||||
order_items.each do |order_item|
|
||||
if updated_order_id.include?(order_item["order_id"])
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order_id
|
||||
orderItem.save!
|
||||
end
|
||||
end
|
||||
else
|
||||
order_ids.each do |odr_id|
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
else
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order_id
|
||||
orderItem.save!
|
||||
end
|
||||
end
|
||||
else
|
||||
if order_ids.count == 1 && order_item_count == 1
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
else
|
||||
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.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!
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order.order_id
|
||||
orderItem.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, get_cashier_by_terminal)
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
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
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -44,4 +44,10 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
def survey_params
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,4 +61,9 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
@customer = @sale.customer
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,4 +56,10 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,4 +57,9 @@ class Origami::VisaController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -112,4 +112,10 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -78,4 +78,9 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user