From 7e2b4593f5282223b5d22721a7d02d82eecff638 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 2 Nov 2023 13:49:54 +0100 Subject: [PATCH] adds a rake task to regenerate invoices by ids (see maintenance.rake) --- CHANGELOG.md | 1 + lib/tasks/fablab/maintenance.rake | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95ceec115..ffe4a55c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - decreases sidekiq concurrency from 25 to 5, 25 is too much and consumes memory for nothing - do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true - Fix a bug: api/products/index bug when sorting by amount +- adds a rake task to regenerate invoices by ids (see maintenance.rake) ## v6.2.0 2023 October 13 diff --git a/lib/tasks/fablab/maintenance.rake b/lib/tasks/fablab/maintenance.rake index 3402555fa..0a1359152 100644 --- a/lib/tasks/fablab/maintenance.rake +++ b/lib/tasks/fablab/maintenance.rake @@ -14,6 +14,15 @@ namespace :fablab do puts '-> Done' end + desc 'Regenerate the invoices (invoices & avoirs) PDF by ids' + # example: rails fablab:maintenance:regenerate_invoices_by_ids[1,2,3,4] + task regenerate_invoices_by_ids: :environment do |_task, args| + puts "-> Start regenerate the invoices PDF" + invoices = Invoice.where(id: args.extras) + invoices.each(&:regenerate_invoice_pdf) + puts '-> Done' + end + task :regenerate_schedules, %i[year month end] => :environment do |_task, args| start_date, end_date = dates_from_args(args) puts "-> Start regenerate the payment schedules PDF between #{I18n.l start_date, format: :long} and " \