2020-11-13 14:34:53 +01:00
|
|
|
class Cron::OperationsSignatureJob < Cron::CronJob
|
2020-04-01 15:26:46 +02:00
|
|
|
self.schedule_expression = "every day at 6 am"
|
2019-06-04 10:37:05 +02:00
|
|
|
|
|
|
|
def perform(*args)
|
2024-04-18 11:18:53 +02:00
|
|
|
start_date = DossierOperationLog.where(bill_signature: nil).order(:executed_at).pick(:executed_at).beginning_of_day
|
2019-06-04 10:37:05 +02:00
|
|
|
last_midnight = Time.zone.today.beginning_of_day
|
2024-04-18 11:18:53 +02:00
|
|
|
|
|
|
|
while start_date < last_midnight
|
|
|
|
operations = DossierOperationLog
|
2024-04-18 11:19:51 +02:00
|
|
|
.select(:id, :digest)
|
2024-04-18 11:18:53 +02:00
|
|
|
.where(executed_at: start_date...start_date.tomorrow, bill_signature: nil)
|
|
|
|
|
|
|
|
BillSignatureService.sign_operations(operations, start_date) if operations.present?
|
|
|
|
|
|
|
|
start_date = start_date.tomorrow
|
2019-06-04 10:37:05 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|