before sync

This commit is contained in:
Zoey
2019-06-21 10:04:35 +06:30
parent 60a3655dc3
commit f21d144111
17 changed files with 229 additions and 161 deletions

View File

@@ -14,24 +14,26 @@ class Booking < ApplicationRecord
def self.sync_booking_records(bookings)
if !bookings.nil?
bookings.each do |b|
unless TableBooking.exists?(b['booking_id'])
booking = TableBooking.find_by_booking_id(b['booking_id'])
# unless TableBooking.exists?(b['booking_id'])
if booking.nil?
booking = TableBooking.new
booking.booking_id = b['booking_id']
booking.dining_facility_id = b['dining_facility_id']
# booking.type = b['type']
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
booking.booking_id = b['booking_id']
booking.dining_facility_id = b['dining_facility_id']
# booking.type = b['type']
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
end
puts '....... Booking sync completed ......'
end
end