mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
rake task to regenerate payment schedules PDF files
This commit is contained in:
parent
a01eba3902
commit
8468a3c6de
@ -51,6 +51,12 @@ class PaymentSchedule < PaymentDocument
|
||||
invoicing_profile.user
|
||||
end
|
||||
|
||||
# for debug & used by rake task "fablab:maintenance:regenerate_schedules"
|
||||
def regenerate_pdf
|
||||
pdf = ::PDF::PaymentSchedule.new(self).render
|
||||
File.binwrite(file, pdf)
|
||||
end
|
||||
|
||||
def check_footprint
|
||||
payment_schedule_items.map(&:check_footprint).all? && footprint == compute_footprint
|
||||
end
|
||||
|
@ -17,6 +17,19 @@ namespace :fablab do
|
||||
puts '-> Done'
|
||||
end
|
||||
|
||||
task :regenerate_schedules, %i[year, month] => :environment do |_task, args|
|
||||
year = args.year || Time.current.year
|
||||
month = args.month || Time.current.month
|
||||
start_date = Time.zone.local(year.to_i, month.to_i, 1)
|
||||
end_date = start_date.next_month
|
||||
puts "-> Start regenerate the payment schedules PDF between #{I18n.l start_date, format: :long} and " \
|
||||
"#{I18n.l end_date - 1.minute, format: :long}"
|
||||
schedules = PaymentSchedule.where('created_at >= :start_date AND created_at < :end_date', start_date: start_date, end_date: end_date)
|
||||
.order(created_at: :asc)
|
||||
schedules.each(&:regenerate_pdf)
|
||||
puts '-> Done'
|
||||
end
|
||||
|
||||
desc 'recreate every versions of images'
|
||||
task build_images_versions: :environment do
|
||||
Project.find_each do |project|
|
||||
|
Loading…
x
Reference in New Issue
Block a user