update split bill
This commit is contained in:
@@ -6,10 +6,13 @@ class DiningFacility < ApplicationRecord
|
||||
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, -> { 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"
|
||||
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"
|
||||
|
||||
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign.within_time_limit) }, through: :bookings, class_name: "Sale", source: "sale"
|
||||
|
||||
TABLE_TYPE = "Table"
|
||||
ROOM_TYPE = "Room"
|
||||
|
||||
@@ -31,16 +31,18 @@ class MenuItem < ApplicationRecord
|
||||
|
||||
# Work with item_code = item_instance_code
|
||||
def self.search_by_item_code(item_code)
|
||||
MenuItem.joins(:menu_item_instances)
|
||||
MenuItem.left_joins(:menu_item_instances => :menu_instance_item_sets)
|
||||
.where(menu_item_instances: {item_instance_code: item_code})
|
||||
.pluck(:type, :account_id, :item_code, :item_instance_code, :name, :alt_name, "menu_item_instances.item_instance_name AS item_instance_name", :price, :promotion_price, :is_on_promotion, "menu_item_instances.is_available", :taxable)
|
||||
.map { |type, account_id, item_code, item_instance_code, item_name, item_alt_name, item_instance_name, price, promotion_price, is_on_promotion, is_available, taxable|
|
||||
.pluck(:type, :account_id, :item_code, :item_instance_code, :name, :alt_name, :item_instance_name, :price, :promotion_price, :is_on_promotion, "menu_item_instances.is_available", :taxable, :item_set_id)
|
||||
.map { |type, account_id, item_code, item_instance_code, item_name, item_alt_name, item_instance_name, price, promotion_price, is_on_promotion, is_available, taxable, item_set_id|
|
||||
name = item_instance_name if item_set_id
|
||||
name ||= "#{item_name}#{' - ' + item_instance_name if item_instance_name.present?}"
|
||||
{
|
||||
type: type,
|
||||
account_id: account_id,
|
||||
item_code: item_code,
|
||||
item_instance_code: item_instance_code,
|
||||
name: "#{item_name}#{' - ' + item_instance_name if item_instance_name.present?}",
|
||||
name: "#{name}",
|
||||
alt_name: "#{item_alt_name}",
|
||||
price: price,
|
||||
promotion_price: promotion_price,
|
||||
|
||||
Reference in New Issue
Block a user