Sha256: c04be80816e341d6778a3e2bed205b3db1085a41069f432e551381e38b578342

Contents?: true

Size: 1.02 KB

Versions: 20

Compression:

Stored size: 1.02 KB

Contents

module Pay
  module Receipts
    def filename
      "receipt-#{created_at.strftime("%Y-%m-%d")}.pdf"
    end

    def product
      Pay.application_name
    end

    # Must return a file object
    def receipt
      receipt_pdf.render
    end

    def receipt_pdf
      ::Receipts::Receipt.new(
        id: id,
        product: product,
        company: {
          name: Pay.business_name,
          address: Pay.business_address,
          email: Pay.support_email
        },
        line_items: line_items
      )
    end

    def line_items
      line_items = [
        [I18n.t("receipt.date"), created_at.to_s],
        [I18n.t("receipt.account_billed"), "#{owner.name} (#{owner.email})"],
        [I18n.t("receipt.product"), product],
        [I18n.t("receipt.amount"), ActionController::Base.helpers.number_to_currency(amount / 100.0)],
        [I18n.t("receipt.charged_to"), charged_to]
      ]
      line_items << [I18n.t("receipt.additional_info"), owner.extra_billing_info] if owner.extra_billing_info?
      line_items
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
pay-2.7.2 lib/pay/receipts.rb
pay-2.7.1 lib/pay/receipts.rb
pay-2.7.0 lib/pay/receipts.rb
pay-2.6.11 lib/pay/receipts.rb
pay-2.6.10 lib/pay/receipts.rb
pay-2.6.9 lib/pay/receipts.rb
pay-2.6.8 lib/pay/receipts.rb
pay-2.6.7 lib/pay/receipts.rb
pay-2.6.6 lib/pay/receipts.rb
pay-2.6.5 lib/pay/receipts.rb
pay-2.6.4 lib/pay/receipts.rb
pay-2.6.3 lib/pay/receipts.rb
pay-2.6.2 lib/pay/receipts.rb
pay-2.6.1 lib/pay/receipts.rb
pay-2.6.0 lib/pay/receipts.rb
pay-2.5.0 lib/pay/receipts.rb
pay-2.4.4 lib/pay/receipts.rb
pay-2.4.3 lib/pay/receipts.rb
pay-2.4.2 lib/pay/receipts.rb
pay-2.4.0 lib/pay/receipts.rb