Class: EventDispatchers::UnreviewedPayrollTransactionEventDispatcher
- Inherits:
-
BaseEventDispatcher
- Object
- BaseEventDispatcher
- EventDispatchers::UnreviewedPayrollTransactionEventDispatcher
- Defined in:
- app/notifications/event_dispatchers/unreviewed_payroll_transaction_event_dispatcher.rb
Instance Attribute Summary
Attributes inherited from BaseEventDispatcher
Instance Method Summary collapse
Methods inherited from BaseEventDispatcher
Constructor Details
This class inherits a constructor from EventDispatchers::BaseEventDispatcher
Instance Method Details
#dispatch ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/notifications/event_dispatchers/unreviewed_payroll_transaction_event_dispatcher.rb', line 5 def dispatch PayrollTransactionHeader.where(company_id: company_id).find_each do |transaction_header| next if transaction_header.sent_for_approval? next unless transaction_header.payroll_period next if transaction_header.payroll_period.run_payroll_deadline_passed? ReferenceEvent.find_or_create_by!( slug: ReferenceEvent::Slugs::UNREVIEWED_PAYROLL_TRANSACTION, level: ReferenceEvent::Levels::ERROR, company_id: company_id, reference: transaction_header, end_at: nil ).tap do |reference_event| reference_event.update!( last_verified_at: Time.current ) end end end |