Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
535 B
2
Indexable
Never
# frozen_string_literal: true

module Fixers
  module BookingInternalNotes
    class DeleteForObsoletedBills
      def perform
        deleted_bookings_ids = BookingInternalNote.pluck(:booking_id) - Booking.ids
        obsoleted_order_calculations = OrderCalculation.with_status(:obsoleted)
        obsoleted_bookings_ids = ObsoletedBooking.where(order_calculation: obsoleted_order_calculations).ids
        BookingInternalNote.where(booking_id: [*deleted_bookings_ids, *obsoleted_bookings_ids]).delete_all
      end
    end
  end
end