1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/workers/close_period_reminder_worker.rb

13 lines
471 B
Ruby
Raw Normal View History

class ClosePeriodReminderWorker
include Sidekiq::Worker
def perform
last_period = AccountingPeriod.order(closed_at: :desc).limit(1).last
return if Invoice.count == 0 || (last_period && last_period.end_at > (Time.current - 1.year))
NotificationCenter.call type: 'notify_admin_close_period_reminder',
receiver: User.admins,
attached_object: last_period || Invoice.order(:created_at).first
end
end