mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
[bug] close period reminder is sent too early
This commit is contained in:
parent
3945b760b5
commit
83d3fd83b3
@ -6,6 +6,7 @@
|
||||
- Fix a bug: (spanish) some translations are not loaded correctly
|
||||
- Fix a bug: some users may not appear in the admin's general listing
|
||||
- Fix a bug: Availabilities export report an erroneous number of reservations for machine availabilities (#131)
|
||||
- Fix a bug: close period reminder is sent before the first invoice's first anniversary
|
||||
- Improved translations syntax according to YML specifications
|
||||
- Refactored some Ruby code to match style guide
|
||||
- [TODO DEPLOY] `rake fablab:fix:users_group_ids`
|
||||
|
@ -2,8 +2,12 @@ class ClosePeriodReminderWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
return if Invoice.count.zero?
|
||||
|
||||
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))
|
||||
first_invoice = Invoice.order(created_at: :asc).limit(1).last
|
||||
return if !last_period && first_invoice.created_at > (Time.current - 1.year)
|
||||
return if last_period && last_period.end_at > (Time.current - 1.year)
|
||||
|
||||
NotificationCenter.call type: 'notify_admin_close_period_reminder',
|
||||
receiver: User.admins,
|
||||
|
@ -30,8 +30,8 @@ namespace :fablab do
|
||||
|
||||
if AccountingPeriod.count.positive?
|
||||
last_period = AccountingPeriod.order(start_at: 'DESC').first
|
||||
InvoiceItem.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
puts "Regenerating from #{last_period.end_at}..."
|
||||
InvoiceItem.where('created_at > ?', last_period.end_at).order(:id).each(&:chain_record)
|
||||
else
|
||||
puts '(Re)generating all footprint...'
|
||||
InvoiceItem.order(:id).all.each(&:chain_record)
|
||||
|
Loading…
x
Reference in New Issue
Block a user