update dine-in pay bill
This commit is contained in:
@@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
bookings = Booking.find_by_sale_id(sale_id)
|
bookings = saleObj.bookings[0]
|
||||||
|
|
||||||
shift = ShiftSale.current_open_shift(current_user.id)
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
else
|
else
|
||||||
if bookings.dining_facility_id.to_i > 0
|
if bookings.dining_facility_id.to_i > 0
|
||||||
table = DiningFacility.find(bookings.dining_facility_id)
|
table = bookings.dining_facility
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class SalePayment < ApplicationRecord
|
|||||||
amount_due = amount_due - payment.payment_amount
|
amount_due = amount_due - payment.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (amount_due >= 0)
|
if (amount_due > 0)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
membership_data = nil
|
membership_data = nil
|
||||||
#route to payment type
|
#route to payment type
|
||||||
@@ -780,27 +780,14 @@ class SalePayment < ApplicationRecord
|
|||||||
def table_update_status(sale_obj)
|
def table_update_status(sale_obj)
|
||||||
status = true
|
status = true
|
||||||
sale_count = 0
|
sale_count = 0
|
||||||
booking = Booking.find_by_sale_id(sale_obj.id)
|
if booking = sale_obj.bookings[0]
|
||||||
if booking
|
|
||||||
if booking.dining_facility_id.to_i > 0
|
if booking.dining_facility_id.to_i > 0
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
table = booking.dining_facility
|
||||||
bookings = table.bookings
|
if Booking.left_joins(:sale).where(dining_facility_id: booking.dining_facility_id).where.not(booking_status: 'moved').where("sales.sale_status NOT IN ('completed', 'void', 'spoile', 'waste') OR sales.sale_status IS NULL").exists?
|
||||||
bookings.each do |tablebooking|
|
status = false
|
||||||
if tablebooking.booking_status != 'moved'
|
|
||||||
if tablebooking.sale_id
|
|
||||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste'
|
|
||||||
status = false
|
|
||||||
sale_count += 1
|
|
||||||
else
|
|
||||||
status = true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
status = false
|
|
||||||
sale_count += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if status && sale_count == 0
|
|
||||||
|
if status
|
||||||
table.update_attributes(status: "available")
|
table.update_attributes(status: "available")
|
||||||
# table.status = "available"
|
# table.status = "available"
|
||||||
# table.save
|
# table.save
|
||||||
|
|||||||
Reference in New Issue
Block a user