Module: Pay::Receipts

Defined in:
lib/pay/receipts.rb

Instance Method Summary collapse

Instance Method Details

#filenameObject



3
4
5
# File 'lib/pay/receipts.rb', line 3

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

#line_itemsObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pay/receipts.rb', line 29

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

#productObject



7
8
9
# File 'lib/pay/receipts.rb', line 7

def product
  Pay.application_name
end

#receiptObject

Must return a file object



12
13
14
# File 'lib/pay/receipts.rb', line 12

def receipt
  receipt_pdf.render
end

#receipt_pdfObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pay/receipts.rb', line 16

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