mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Log cronjob
This commit is contained in:
parent
f4ba4d4238
commit
c7e02373fa
1 changed files with 5 additions and 1 deletions
|
@ -114,12 +114,16 @@ class Invoice < ActiveRecord::Base
|
|||
|
||||
class << self
|
||||
def cancel_overdue_invoices
|
||||
STDOUT << "#{Time.zone.now.utc} - Cancelling overdue invoices\n"
|
||||
|
||||
cr_at = Time.zone.now - Setting.days_to_keep_overdue_invoices_active.days
|
||||
invoices = Invoice.unbinded.where(
|
||||
'due_date < ? AND created_at < ? AND cancelled_at IS NULL', Time.zone.now, cr_at
|
||||
)
|
||||
|
||||
invoices.update_all(cancelled_at: Time.zone.now)
|
||||
count = invoices.update_all(cancelled_at: Time.zone.now)
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue