module ContabilidadeHelper
	def enviar_email_pagamento_confirmado pagamento_id
		if Configuracao.last.permite_envio_de_email
			pdf = WickedPdf.new.pdf_from_string(
				render_to_string(
					template: "contabilidade/pagamentos/enviar_email_pagamento_confirmado.pdf.slim",
					orientation: 'Portrait',
					disable_smart_shrinking: true,
					
					dpi: '96',
					header: {
						html: {
							template: 'layouts/_cabecalho_pdf.html.slim',
							locals: { titulo1: 'AVISO DE PAGAMENTO REALIZADO', titulo2: "" }
						},
						spacing: 5
					}
				)
			)

			PrincipalMailer.pagamento_confirmado( pdf, pagamento_id ).deliver_now unless Rails.env.development? || Rails.env.test?
		end
	end
end
