Fix bugs and improvements

fix payment outstanding with amount <= 0
fix payment outstanding with other payments
This commit is contained in:
Thein Lin Kyaw
2019-12-18 15:41:18 +06:30
parent e6392c3bd4
commit 92e467d512
11 changed files with 122 additions and 217 deletions

View File

@@ -4,11 +4,11 @@ class DiningFacility < ApplicationRecord
has_one :dining_charge
has_one :cashier_terminal_by_zone, foreign_key: "zone_id", primary_key: "zone_id"
has_one :cashier_terminal, through: :cashier_terminal_by_zone
has_one :current_shift, through: :cashier_terminal
has_many :order_queue_process_by_zones, foreign_key: "zone_id", primary_key: "zone_id"
has_many :order_queue_stations, -> { where(is_active: true) }, through: :order_queue_process_by_zones
has_many :bookings
has_many :current_bookings, -> { left_joins(:sale).assign.within_time_limit.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.within_time_limit.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"