module Billing
  class InvoiceMailer < ApplicationMailer
    def invoice_pdf
      @invoice = params[:invoice]
      @club = @invoice.club

      attachments["fattura-#{@invoice.number.parameterize}.pdf"] = {
        mime_type: "application/pdf",
        content: @invoice.pdf.download
      }

      mail(
        to: @club.billing_email,
        subject: "Fattura #{@invoice.display_number} — Match Live TV"
      )
    end
  end
end
