update dine-in pay bill

This commit is contained in:
Thein Lin Kyaw
2019-12-03 10:02:49 +06:30
parent 1607cb70d3
commit 108415ed3f
2 changed files with 9 additions and 22 deletions

View File

@@ -176,14 +176,14 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone
# 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)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
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_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)

View File

@@ -87,7 +87,7 @@ class SalePayment < ApplicationRecord
amount_due = amount_due - payment.payment_amount
end
end
if (amount_due >= 0)
if (amount_due > 0)
payment_status = false
membership_data = nil
#route to payment type
@@ -780,27 +780,14 @@ class SalePayment < ApplicationRecord
def table_update_status(sale_obj)
status = true
sale_count = 0
booking = Booking.find_by_sale_id(sale_obj.id)
if booking
if booking = sale_obj.bookings[0]
if booking.dining_facility_id.to_i > 0
table = DiningFacility.find(booking.dining_facility_id)
bookings = table.bookings
bookings.each do |tablebooking|
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
table = booking.dining_facility
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?
status = false
end
if status && sale_count == 0
if status
table.update_attributes(status: "available")
# table.status = "available"
# table.save