Merge branch 'quick_service' of bitbucket.org:code2lab/sxrestaurant into split_bill
This commit is contained in:
@@ -9,7 +9,10 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
end
|
||||
|
||||
def detail
|
||||
@menu = MenuCategory.all.active
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
@@ -44,6 +47,18 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = Menu.find_by_id(params[:id])
|
||||
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
Menu.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_sub_category ()
|
||||
id = params[:id]
|
||||
@@ -102,9 +117,13 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
@@ -115,22 +134,32 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking && @order.source == 'quick_service'
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
result = {:status=> @status, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
# limit visa_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@@ -49,9 +49,16 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
def add_customer
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
end
|
||||
|
||||
else
|
||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||
@booking = Booking.find(@booking_order.booking_id)
|
||||
|
||||
64
app/controllers/origami/dashboard_controller.rb
Normal file
64
app/controllers/origami/dashboard_controller.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
# @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
# @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
|
||||
# @top_products = Sale.top_products(today).sum('i.qty')
|
||||
# @bottom_products = Sale.bottom_products(today).sum('i.qty')
|
||||
# @hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
# @employee_sales = Sale.employee_sales(today)
|
||||
# .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
# @inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today)
|
||||
@total_count = Sale.total_count(today)
|
||||
@total_card = Sale.total_card_sale(today)
|
||||
@total_credit = Sale.credit_payment(today)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today)
|
||||
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
pay = Sale.payment_sale('card', today)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today)
|
||||
@total_customer = Sale.total_customer(today)
|
||||
@total_dinein = Sale.total_dinein(today)
|
||||
@total_takeaway = Sale.total_takeaway(today)
|
||||
@total_other_customer = Sale.total_other_customer(today)
|
||||
@total_membership = Sale.total_membership(today)
|
||||
|
||||
@total_order = Sale.total_order(today)
|
||||
@total_accounts = Sale.total_account(today)
|
||||
@account_data = Array.new
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today)
|
||||
@total_foc_items = Sale.total_foc_items(today)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
end
|
||||
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -4,9 +4,14 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#discount page show from origami index with selected order
|
||||
def index
|
||||
sale_id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@@ -22,8 +27,15 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table = nil
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
@@ -33,7 +45,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
puts origin_sale_item.to_json
|
||||
sale_item = SaleItem.new
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
@@ -54,6 +65,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_id, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
end
|
||||
@@ -62,13 +74,26 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# Re-calc All Amount in Sale
|
||||
if overall_discount.to_f > 0
|
||||
action_by = current_user.id
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
if table.nil?
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- no Table "
|
||||
else
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
if !table.nil?
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Success" }
|
||||
end
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
if !table.nil?
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -80,9 +105,15 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
sale = Sale.find(sale_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
@@ -91,7 +122,11 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
if table.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEITEMDISCOUNT" )
|
||||
|
||||
sale_item.destroy
|
||||
@@ -102,9 +137,19 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
@@ -116,9 +161,16 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
dining = DiningFacility.find(table_id)
|
||||
table_type = dining.type
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
table_type = table.type
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
table_type = nil
|
||||
end
|
||||
|
||||
discount_items = []
|
||||
#destroy all discount sale item
|
||||
@@ -137,14 +189,28 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale.sale_items.destroy(discount_items)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{dining.name} "
|
||||
if table.nil?
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
|
||||
else
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => dining.name, :table_type => table_type }
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => dining.name, :table_type => table_type }
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
|
||||
@@ -2,7 +2,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
|
||||
@@ -2,7 +2,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit master_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Origami::MpuController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit mpu_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
|
||||
@@ -3,9 +3,15 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,8 +22,14 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
@@ -44,7 +56,12 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
if table.nil?
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->"
|
||||
else
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ADDOTHERCHARGES" )
|
||||
|
||||
end
|
||||
@@ -53,9 +70,11 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
if !table.nil?
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -2,6 +2,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@membership_rebate_balance = 0
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
@payment_method_setting = PaymentMethodSetting.all
|
||||
|
||||
@rebate = MembershipSetting.find_by_rebate(1)
|
||||
|
||||
@@ -12,15 +12,21 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# Print for First Bill to Customer
|
||||
@@ -66,8 +72,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
member_info = nil
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
@@ -96,15 +102,21 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
# For Print
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
@@ -142,12 +154,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data,survey)
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,booking.dining_facility_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
@@ -164,6 +184,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@balance = 0.00
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
|
||||
@@ -213,10 +234,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#end customer amount
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
break
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
@sale_data.sale_payments.each do |spay|
|
||||
@@ -251,15 +279,21 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
@@ -321,15 +355,21 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
|
||||
|
||||
# Re-call Sale Data
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
redeem_amount = params[:redeem_amount]
|
||||
membership_id = params[:membership_id]
|
||||
payment_method = "paypar"
|
||||
|
||||
26
app/controllers/origami/pending_order_controller.rb
Normal file
26
app/controllers/origami/pending_order_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class Origami::PendingOrderController < BaseOrigamiController
|
||||
def index
|
||||
# @dining= DiningFacility.where("status = 'occupied'")
|
||||
# @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@sale = Sale.pending_order
|
||||
end
|
||||
def show
|
||||
@sales = Sale.pending_order
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
puts "sssssssssss"
|
||||
puts @booking
|
||||
if Booking.find(@booking).dining_facility_id.to_i > 0
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
221
app/controllers/origami/quick_service_controller.rb
Normal file
221
app/controllers/origami/quick_service_controller.rb
Normal file
@@ -0,0 +1,221 @@
|
||||
class Origami::QuickServiceController < ApplicationController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@zone = Zone.all
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
# @tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
# @rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
# @all_table = Table.all.active.order('status desc')
|
||||
# @all_room = Room.all.active.order('status desc')
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def modify_order
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
if(params[:id][0,3] == "BKI")
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
else
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
if i["parent_order_item_id"]
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
if @status && @booking && @order.source == 'quick_service'
|
||||
if params[:sale_id]
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
if @order.table_id.to_i > 0
|
||||
@table_id = @order.table_id
|
||||
else
|
||||
@table_id = nil
|
||||
end
|
||||
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
|
||||
end
|
||||
|
||||
result = {:status=> true, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_menu_sub_category ()
|
||||
id = params[:id]
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,6 +2,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
|
||||
@@ -2,9 +2,15 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
authorize_resource class: false
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
@table_id = params[:table_id]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
sale_id = params[:sale_id]
|
||||
if params[:table_id]
|
||||
@table_id = params[:table_id]
|
||||
else
|
||||
@table_id = nil
|
||||
end
|
||||
|
||||
@cashier_type = params[:type]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
end
|
||||
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
|
||||
@@ -7,8 +7,13 @@ class Origami::SalesController < BaseOrigamiController
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
if Booking.find(@booking).dining_facility_id.to_i>0
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
def add_to_existing_invoice
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
class Origami::SurveysController < BaseOrigamiController
|
||||
def new
|
||||
@survey = Survey.new()
|
||||
@id = params[:id]
|
||||
|
||||
@survey = Survey.new
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@receipt_no = @sale.receipt_no
|
||||
@grand_total = @sale.grand_total
|
||||
@booking = Booking.find_by_sale_id(@id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
else
|
||||
@dining_facility = nil
|
||||
@table_type = nil
|
||||
end
|
||||
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@@ -25,10 +35,25 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def create
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
@type = params[:cashier_type]
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
if params[:table_id].to_i>0
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
|
||||
if @type == "quick_service"
|
||||
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
||||
else
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
end
|
||||
|
||||
|
||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||
@survey = Survey.new(survey_params)
|
||||
@@ -61,15 +86,34 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
|
||||
def create_survey
|
||||
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
@type = params[:cashier_type]
|
||||
@sale_id = params[:sale_id]
|
||||
sale = Sale.find(@sale_id)
|
||||
|
||||
if @type != "quick_service"
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
cashier_zone = cashier_zone.cashier_terminal_id
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_zone = shift.cashier_terminal_id
|
||||
end
|
||||
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_terminal_id,nil)
|
||||
|
||||
if @type != "quick_service"
|
||||
survey = Survey.find_by_dining_name(dining_facility.name)
|
||||
else
|
||||
survey = nil
|
||||
end
|
||||
|
||||
survey = Survey.find_by_dining_name(dining_facility.name)
|
||||
|
||||
if survey.nil?
|
||||
survey = Survey.new
|
||||
survey.dining_name = dining_facility.name
|
||||
if @type != "quick_service"
|
||||
survey.dining_name = dining_facility.name
|
||||
end
|
||||
|
||||
survey.receipt_no = params[:receipt_no]
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.created_by = current_user.name
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Origami::UnionpayController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit unionpay_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
@@ -23,8 +23,6 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
puts "unionpaycount"
|
||||
puts @unionpaycount
|
||||
@can_unionpay = total - @unionpaycount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Origami::VisaController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit visa_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
|
||||
@@ -41,33 +41,41 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.id
|
||||
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
if table.nil?
|
||||
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table -> nil"
|
||||
else
|
||||
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
||||
|
||||
# For Print
|
||||
@@ -80,13 +88,21 @@ class Origami::VoidController < BaseOrigamiController
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
|
||||
Reference in New Issue
Block a user