1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-05 16:24:21 +01:00
fab-manager/app/workers/payment_schedule_worker.rb
Sylvain e5439901d6 fix generate payment schedule pdf + send by mail
TODO: total amount does not match with sum of all lines
- generate invoices for each PS-item
- interface to access the payment schedules
2021-01-19 16:47:51 +01:00

22 lines
688 B
Ruby

# frozen_string_literal: true
# Generates the PDF Document associated with the provided payment schedule, and send it to the customer
# If this is the case
class PaymentScheduleWorker
include Sidekiq::Worker
def perform(payment_schedule_id)
# generate a payment schedule document
ps = PaymentSchedule.find(payment_schedule_id)
pdf = ::PDF::PaymentSchedule.new(ps).render
# save the file on the disk
File.binwrite(ps.file, pdf)
# notify user, send schedule document by email
NotificationCenter.call type: 'notify_user_when_payment_schedule_ready',
receiver: ps.user,
attached_object: ps
end
end