From 2f9796d137e1d7a673be70c00991bf58cc0d569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Semp=C3=A9?= Date: Wed, 28 Aug 2024 15:15:03 +0200 Subject: [PATCH] feat(dunning): Generate PDF files for payment request invoices --- app/mailers/payment_request_mailer.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/mailers/payment_request_mailer.rb b/app/mailers/payment_request_mailer.rb index 9ac55033fa4..125008d9401 100644 --- a/app/mailers/payment_request_mailer.rb +++ b/app/mailers/payment_request_mailer.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class PaymentRequestMailer < ApplicationMailer + before_action :ensure_invoices_pdf + def requested @payment_request = params[:payment_request] @organization = @payment_request.organization @@ -19,4 +21,12 @@ def requested ) end end + + private + + def ensure_invoices_pdf + params[:payment_request].invoices.each do |invoice| + Invoices::GeneratePdfService.new(invoice:).call + end + end end