Fix bugs and improvements
fix payment outstanding with amount <= 0 fix payment outstanding with other payments
This commit is contained in:
@@ -7,10 +7,10 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@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')
|
||||
@tables = Table.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.active.order('status desc')
|
||||
@all_room = Room.active.order('status desc')
|
||||
end
|
||||
|
||||
def detail
|
||||
|
||||
@@ -13,13 +13,13 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
booking = sale_data.booking
|
||||
|
||||
if current_user.role == 'cashier'
|
||||
cashier_terminal = shift.cashier_terminal
|
||||
elsif booking.dining_facility_id
|
||||
cashier_terminal = booking.dining_facility.cashier_terminal
|
||||
else
|
||||
cashier_terminal = sale_data.shift_sale.cashier_terminal
|
||||
cashier_terminal = current_user.cashier_terminal
|
||||
elsif booking.dining_facility
|
||||
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||
end
|
||||
|
||||
cashier_terminal ||= sale_data.cashier_terminal_by_shift_sale
|
||||
|
||||
customer = sale_data.customer
|
||||
|
||||
#record for sale audit
|
||||
@@ -90,11 +90,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
latest_order_no = nil
|
||||
is_kbz = params[:is_kbz]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
if saleObj = Sale.find(sale_id)
|
||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
if is_kbz == 'false'
|
||||
Rails.logger.info '################ CASH PAYMENT #################'
|
||||
sale_payment = SalePayment.new
|
||||
@@ -104,6 +102,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
end
|
||||
else
|
||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||
end
|
||||
|
||||
@@ -112,24 +111,23 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
# For Cashier by Zone
|
||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
bookings = saleObj.booking
|
||||
booking = saleObj.booking
|
||||
|
||||
shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !shift.nil?
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
else
|
||||
if bookings.dining_facility_id.to_i > 0
|
||||
table = bookings.dining_facility
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if current_user.role == 'cashier'
|
||||
cashier_terminal = current_user.cashier_terminal
|
||||
elsif booking.dining_facility
|
||||
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||
end
|
||||
|
||||
type = 'payment'
|
||||
from = getCloudDomain #get sub domain in cloud mode
|
||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||
else
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
cashier_terminal ||= saleObj.cashier_terminal_by_shift_sale
|
||||
|
||||
if booking.dining_facility
|
||||
ActionCable.server.broadcast(
|
||||
"order_channel",
|
||||
table: booking.dining_facility,
|
||||
type: 'payment',
|
||||
from: getCloudDomain
|
||||
)
|
||||
end
|
||||
|
||||
# For Print
|
||||
@@ -157,8 +155,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
#orders print out
|
||||
if type == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
if booking.dining_facility_id.present?
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
@@ -712,7 +709,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
|
||||
@@ -10,39 +10,23 @@ class Origami::QuickServiceController < ApplicationController
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
# if params[:menu] == "true"
|
||||
|
||||
@menus = []
|
||||
@menu = []
|
||||
# else
|
||||
# @menus = Menu.all
|
||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
# end
|
||||
@zone = Zone.all
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = Table.active.order('status desc')
|
||||
@rooms = Room.active.order('status desc')
|
||||
@cashier_type = "quick_service"
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
if !display_type.nil? && display_type.value.to_i == 2
|
||||
@display_type = display_type.value
|
||||
else
|
||||
@display_type = nil
|
||||
end
|
||||
|
||||
#checked quick_service only
|
||||
@quick_service_only = false
|
||||
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||
puts 'lookup_dine_in!!!!'
|
||||
puts lookup_dine_in
|
||||
if !lookup_dine_in.empty?
|
||||
lookup_dine_in.each do |dine_in|
|
||||
if dine_in[0].downcase == "quickserviceaddorder"
|
||||
if dine_in[1] == '1'
|
||||
@quick_service_only = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@quick_service_only = Lookup.collection_of('quickservice_add_order').any? { |x| x == ["quickserviceaddorder", "1"] }
|
||||
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
@@ -121,7 +105,7 @@ class Origami::QuickServiceController < ApplicationController
|
||||
order.table_id = params[:table_id] # this is dining facilities's id
|
||||
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
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
else
|
||||
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||
|
||||
if booking.sale.nil?
|
||||
if booking.sale_id.nil?
|
||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||
# in-duty update
|
||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||
@@ -47,13 +47,11 @@ class Origami::RequestBillsController < ApplicationController
|
||||
from = ""
|
||||
end
|
||||
|
||||
if order.source == "cashier" || order.source == "quick_service"
|
||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
||||
if ["quick_service", "cashier"].include? order.source
|
||||
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
||||
end
|
||||
if order.source == "quick_service" || order.source == "food_court"
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
else
|
||||
|
||||
unless ["quick_service", "food_court"].include? order.source
|
||||
#check checkInOut pdf print
|
||||
checkout_time = Lookup.collection_of('checkout_time')
|
||||
if !booking.dining_facility_id.nil?
|
||||
@@ -74,15 +72,24 @@ class Origami::RequestBillsController < ApplicationController
|
||||
end
|
||||
end
|
||||
@status = true
|
||||
sale_id = sale_data.sale_id
|
||||
else
|
||||
@status = false
|
||||
sale_id = nil
|
||||
end
|
||||
else
|
||||
@status = true
|
||||
sale_id = booking.sale_id
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
end
|
||||
if ["quick_service", "food_court"].include? order.source
|
||||
result = {:status=> @status, :data => sale_data.sale_id }
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -105,7 +105,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
booking.orders << new_order
|
||||
end
|
||||
|
||||
puts split_orders
|
||||
if split_orders.present?
|
||||
BookingOrder.where(order_id: split_orders).update_all(booking_id: booking.booking_id)
|
||||
end
|
||||
@@ -122,7 +121,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
from = ""
|
||||
end
|
||||
|
||||
ActionCable.server.broadcast "bill_channel",table: table,from:from
|
||||
ActionCable.server.broadcast "bill_channel", table: table, from:from
|
||||
|
||||
render :json => { status: true }
|
||||
end
|
||||
@@ -131,61 +130,6 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def create_order(params,order_type,items_count,current_user)
|
||||
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 = 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!
|
||||
|
||||
return order
|
||||
end
|
||||
|
||||
def update_order_item(order_id, order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
set_menu_items_obj = Array.new
|
||||
if !orderItem.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(orderItem.set_menu_items)
|
||||
instance_item_sets.each_with_index do |instance_item, instance_index|
|
||||
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
|
||||
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
|
||||
end
|
||||
orderItem.set_menu_items = instance_item_sets.to_json
|
||||
end
|
||||
|
||||
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.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
set_menu_items_obj.to_json,
|
||||
order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
else
|
||||
same_order.qty = same_order.qty.to_f + order_item['qty'].to_f
|
||||
same_order.set_menu_items = set_menu_items_obj.to_json
|
||||
same_order.save
|
||||
end
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order_id
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
def update_sale
|
||||
sale = Sale.find(params[:sale_id])
|
||||
sale.equal_persons = params[:total_customer].to_i
|
||||
|
||||
Reference in New Issue
Block a user