update order and request bill

This commit is contained in:
Thein Lin Kyaw
2019-12-11 17:56:39 +06:30
parent 26edf23b46
commit 58117d0f48
28 changed files with 336 additions and 448 deletions

View File

@@ -1,12 +1,14 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
has_many :in_juties
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_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, -> { assign.within_time_limit.where(checkout_at: 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', 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"
has_one :current_reserved_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
TABLE_TYPE = "Table"