sync records
This commit is contained in:
@@ -7,6 +7,25 @@ class AssignedOrderItem < ApplicationRecord
|
||||
belongs_to :order
|
||||
belongs_to :order_queue_station
|
||||
|
||||
def self.sync_assigned_order_item_records(assigned_order_items)
|
||||
if !assigned_order_items.nil?
|
||||
assigned_order_items.each do |items|
|
||||
unless AssignedOrderItem.exists?(items['assigned_order_item_id'])
|
||||
order_item = AssignedOrderItem.new
|
||||
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
||||
order_item.item_code = item['item_code']
|
||||
order_item.instance_code = item['instance_code']
|
||||
order_item.order_queue_station_id = item['order_queue_station_id']
|
||||
order_item.order_id = item['order_id']
|
||||
order_item.print_status = item['print_status']
|
||||
order_item.delivery_status = item['delivery_status']
|
||||
order_item.save
|
||||
puts '....... Assigned Order Item has been created .......'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
|
||||
assigned_order_item = AssignedOrderItem.new()
|
||||
assigned_order_item.order = order
|
||||
|
||||
@@ -11,6 +11,29 @@ class Booking < ApplicationRecord
|
||||
scope :active, -> {where("booking_status != 'moved'")}
|
||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||
|
||||
def self.sync_booking_records(bookings)
|
||||
if !bookings.nil?
|
||||
bookings.each do |b|
|
||||
unless Booking.exists?(b['booking_id'])
|
||||
booking = Booking.new
|
||||
booking.booking_id = b['booking_id']
|
||||
booking.dining_facility_id = b['dining_facility_id']
|
||||
booking.checkin_at = b['checkin_at']
|
||||
booking.checkin_by = b['checkin_by']
|
||||
booking.checkout_at = b['checkout_at']
|
||||
booking.checkout_by = b['checkout_by']
|
||||
booking.reserved_at = b['reserved_at']
|
||||
booking.reserved_by = b['reserved_by']
|
||||
booking.booking_status = b['booking_status']
|
||||
booking.sale_id = b['sale_id']
|
||||
booking.customer_id = b['customer_id']
|
||||
booking.save
|
||||
puts '....... Booking has been created ......'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_dining_facility(booking_arr, newd, old)
|
||||
table = DiningFacility.find(newd)
|
||||
exist = table.get_booking
|
||||
@@ -69,6 +92,12 @@ class Booking < ApplicationRecord
|
||||
.joins('left join sale_orders on sale_orders.order_id = order_items.order_id')
|
||||
.where('sale_orders.sale_id=?', sale_id)
|
||||
|
||||
@assigned_order_items = AssignedOrderItem.select('assigned_order_items.*')
|
||||
.joins('left join sale_orders on sale_orders.order_id=assigned_order_items.order_id')
|
||||
.where('sale_orders.sale_id=?', sale_id)
|
||||
|
||||
@bookings = Booking.where('sale_id=?', sale_id)
|
||||
|
||||
@sales = Sale.where("sale_id=?", sale_id)
|
||||
|
||||
@sale_items = SaleItem.where("sale_id=?", sale_id)
|
||||
@@ -85,7 +114,7 @@ class Booking < ApplicationRecord
|
||||
.joins('left join sales on sales.shift_sale_id = shift_sales.id')
|
||||
.where('sales.sale_id=?', sale_id)
|
||||
|
||||
return @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @shift_sales
|
||||
return @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user