GithubHelp home page GithubHelp logo

excid3 / receipts Goto Github PK

View Code? Open in Web Editor NEW
581.0 9.0 76.0 450 KB

Easy receipts and invoices for your Ruby on Rails applications

License: MIT License

Ruby 100.00%
receipt ruby pdf pdf-receipt rails-application

receipts's Introduction

Tests

Receipts Gem

Receipts, Invoices, and Statements for your Rails application that works with any payment provider. Receipts uses Prawn to generate the PDFs.

Check out the example PDFs.

Installation

Add this line to your application's Gemfile:

gem 'receipts'

And then execute:

$ bundle

Or install it yourself as:

$ gem install receipts

Usage

To generate a Receipt, Invoice, or Statement, create an instance and provide content to render:

r = Receipts::Receipt.new(
  # title: "Receipt",
  details: [
    ["Receipt Number", "123"],
    ["Date paid", Date.today],
    ["Payment method", "ACH super long super long super long super long super long"]
  ],
  company: {
    name: "Example, LLC",
    address: "123 Fake Street\nNew York City, NY 10012",
    email: "[email protected]",
    logo: File.expand_path("./examples/images/logo.png")
  },
  recipient: [
    "Customer",
    "Their Address",
    "City, State Zipcode",
    nil,
    "[email protected]"
  ],
  line_items: [
    ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
    ["Subscription", "$19.00", "1", "$19.00"],
    [nil, nil, "Subtotal", "$19.00"],
    [nil, nil, "Tax", "$1.12"],
    [nil, nil, "Total", "$20.12"],
    [nil, nil, "<b>Amount paid</b>", "$20.12"],
    [nil, nil, "Refunded on #{Date.today}", "$5.00"]
  ],
  footer: "Thanks for your business. Please contact us if you have any questions."
)

# Returns a string of the raw PDF
r.render

# Writes the PDF to disk
r.render_file "examples/receipt.pdf"

Configuration

You can specify the default font for all PDFs by defining the following in an initializer:

Receipts.default_font = {
  bold: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic-Bold.ttf'),
  normal: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic.ttf'),
}

Options

You can pass the following options to generate a PDF:

  • recipient - Array of customer details to include. Typically, this is name, address, email, VAT ID, etc.

  • company - Hash of your company details

    • name - Company name

    • address - Company address

    • email - Company support email address

    • phone - Company phone number - Optional

    • logo - Logo to be displayed on the receipt - Optional This can be either a Path, File, StringIO, or URL. Here are a few examples:

      logo: Rails.root.join("app/assets/images/logo.png")
      logo: File.expand_path("./logo.png")
      logo: File.open("app/assets/images/logo.png", "rb")
      logo: "https://www.ruby-lang.org/images/[email protected]" # Downloaded with OpenURI
    • display: [] - Customize the company details rendered. By default, renders [:address, :phone, :email] under the company name. Items in the array should be Symbols matching keys in the company hash to be displayed.

  • details - Array of details about the Receipt, Invoice, Statement. Typically, this is receipt numbers, issue date, due date, status, etc.

  • line_items - Array of line items to be displayed in table format.

  • footer - String for a message at the bottom of the PDF.

  • font - Hash of paths to font files - Optional

    font: {
      bold: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic-Bold.ttf'),
      normal: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic.ttf'),
    }
  • logo_height - An integer value of how tall the logo should be. Defaults to 16

Here's an example of where each option is displayed.

options

Line Items Table - Column Widths

You may set an option to configure the line items table's columns width in order to accommodate shortcomings of Prawn's width guessing ability to render header and content reasonably sized. The configuration depends on your line item column count and follows the prawn/table configuration as documented here:

This will size the second column to 400 and the fourth column to 50.

column_widths: {1 => 400,3 => 50 }

This will set all column widths, considering your table has 4 columns.

column_widths: [100, 200, 240]

If not set, it will fall back to Prawn's default behavior.

Formatting

details and line_items allow inline formatting with Prawn. This allows you to use HTML tags to format text: <b> <i> <u> <strikethrough> <sub> <sup> <font> <color> <link>

See the Prawn docs for more information.

Page Size

You can specify a different page size by passing in the page_size keyword argument:

receipt = Receipts::Receipt.new page_size: "A4"

Internationalization (I18n)

You can use I18n.t when rendering your receipts to internationalize them.

line_items: [
  [I18n.t("receipts.date"),           created_at.to_s],
  [I18n.t("receipts.product"), "GoRails"],
  [I18n.t("receipts.transaction"), uuid]
]

Custom PDF Content

You can change the entire PDF content by instantiating an Receipts object without any options.

receipt = Receipts::Receipt.new # creates an empty PDF

Each Receipts object inherits from Prawn::Document. This allows you to choose what is rendered and include any custom Prawn content you like.

receipt.text("hello world")

You can also use the Receipts helpers in your custom PDFs at the current cursor position.

receipt.text("Custom header")
receipt.render_line_items([
  ["my line items"]
])
receipt.render_footer("This is a custom footer using the Receipts helper")

Rendering PDFs

To render a PDF in memory, use render. This is recommended for serving PDFs in your Rails controllers.

receipt.render

To render a PDF to disk, use render_file:

receipt.render_file "receipt.pdf"

Rendering PDFs in Rails controller actions

Here's an example Rails controller action you can use for serving PDFs. We'll first look up the database record for the Charge we want to render a receipt for.

The Charge model has a receipt method that returns a Receipts::Receipt instance with all the receipt data filled out.

Then we can render to generate the PDF in memory. This produces a String with the raw PDF data in it.

Using send_data from Rails, we can send the PDF contents and provide the browser with a recommended filename, content type and disposition.

class ChargesController < ApplicationController
  before_action :authenticate_user!
  before_action :set_charge

  def show
    respond_to do |format|
      format.pdf { send_pdf }
    end
  end

  private

    def set_charge
      @charge = current_user.charges.find(params[:id])
    end

    def send_pdf
      # Render the PDF in memory and send as the response
      send_data @charge.receipt.render,
        filename: "#{@charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
        type: "application/pdf",
        disposition: :inline # or :attachment to download
    end
end

Then, just link_to to your charge with the format of pdf. For example:

# config/routes.rb
resources :charges
<%= link_to "View Receipt", charge_path(@charge, format: :pdf) %>

Invoices

Invoices follow the exact same set of steps as above. You'll simply want to modify the details to include other information for the Invoice such as the Issue Date, Due Date, etc.

Receipts::Invoice.new(
  # title: "Invoice",
  details: [
    ["Invoice Number", "123"],
    ["Issue Date", Date.today.strftime("%B %d, %Y")],
    ["Due Date", Date.today.strftime("%B %d, %Y")],
    ["Status", "<b><color rgb='#5eba7d'>PAID</color></b>"]
  ],
  recipient: [
    "<b>Bill To</b>",
    "Customer",
    "Address",
    "City, State Zipcode",
    "[email protected]"
  ],
  company: {
    name: "Example, LLC",
    address: "123 Fake Street\nNew York City, NY 10012",
    phone: "(555) 867-5309",
    email: "[email protected]",
    logo: File.expand_path("./examples/images/logo.png")
  },
  line_items: [
    ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
    ["Subscription", "$19.00", "1", "$19.00"],
    [nil, nil, "Subtotal", "$19.00"],
    [nil, nil, "Tax Rate", "0%"],
    [nil, nil, "Amount Due", "$19.00"]
  ]
)

Statements

Statements follow the exact same set of steps as above. You'll simply want to modify the details to include other information for the Invoice such as the Issue Date, Start and End Dates, etc.

Receipts::Statement.new(
  # title: "Statement",
  details: [
    ["Statement Number", "123"],
    ["Issue Date", Date.today.strftime("%B %d, %Y")],
    ["Period", "#{(Date.today - 30).strftime("%B %d, %Y")} - #{Date.today.strftime("%B %d, %Y")}"]
  ],
  recipient: [
    "<b>Bill To</b>",
    "Customer",
    "Address",
    "City, State Zipcode",
    "[email protected]"
  ],
  company: {
    name: "Example, LLC",
    address: "123 Fake Street\nNew York City, NY 10012",
    email: "[email protected]",
    phone: "(555) 867-5309",
    logo: File.expand_path("./examples/images/logo.png")
  },
  line_items: [
    ["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
    ["Subscription", "$19.00", "1", "$19.00"],
    [nil, nil, "Subtotal", "$19.00"],
    [nil, nil, "Tax Rate", "0%"],
    [nil, nil, "Total", "$19.00"]
  ]
)

Contributing

  1. Fork it https://github.com/excid3/receipts/fork
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

receipts's People

Contributors

anquinn avatar davidvii avatar enderahmetyurt avatar excid3 avatar macfanatic avatar mikevic avatar ocarreterom avatar petergoldstein avatar sublimecoder avatar sujaysudheenda avatar uurcank avatar weavermedia avatar whysthatso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

receipts's Issues

How to customize the layout for a receipt printer?

Hi,

Thanks for the great gem!

How can you customize the layout of the pdf to use smaller margins and smaller fonts for printing on small thermal paper? Also, how could you add a logo and update the message on the header of the receipt?

Thank you!

Logo showing extremely small on invoice

Using latest Receipts gem version 2.1.0, and for some reason the logo always appears too small, unlike the one shown at Readme. I tried to trace the code, and if I understand correctly, the height is set to 16 by default? Sorry if I'm mistaken.

How can I specify a larger logo size?

How to customise RECEIPT FOR CHARGE line

Hi,

Thank you for really nice gem, I'm using it and I really like it.

How can I customise the message on the header RECEIPT FOR CHARGE # ?
I'm creating receipts in foreign language and would like to customise this message

Thank you

Issues with prawn's automatic column_width decision making

render_line_items is giving me headaches, because it cannot be coerced into rendering different use cases (which i cannot even replicate sensibly) of amounts of columns, and content width or title width.

so i tried to figure out how to extend the parameters of render_line_items and came up with a PR for that feature. it's optional, so if not needed, users can ignore it.

Getting Prawn::Errors::IncompatibleStringEncoding

It does not encode non-alphabet characters.

Your document includes text that's not compatible with the Windows-1252 character set.
If you need full UTF-8 support, use external fonts instead of PDF's built-in fonts.

According to this (see: jessedoyle/prawn-icon#44), the prawn-table needs to be pointed as below:

# in Gemfile
gem 'prawn-table', git: 'https://github.com/prawnpdf/prawn-table.git'  

The Gemfile in my app is already pointed as above, but it still does not work.

Maybe you need to update your Gemfile?

How do I contribute to this gem translation?

Hi,

I'm using this gem inside my current project it was awesome. I really like it!

I'm thinking to translate this gem to Malay language since I'm Malaysian and I'm native Malay speaker.

Please show me clear 'how to' step-by-step guide to contribute to this gem and translate the strings to Malay?

Thanks!

How to use picture in line items?

In the case:
Company has 6 products. Customer has 10 usages for each product. Total 60 line items required.
I want to use a divider line that includes product icon and the name to make visual separation between the different product's line items.
I need a guide to archive this.

Upgrade `prawn` to make it compatible with Ruby 3.1.0

Prawn 2.4.0 seems to be incompatible with Ruby 3.1.0.

I think it works in development, but problems arise in production. This issue disappeared when I removed the receipts gem from my project.

Here's a release log from Heroku.

 !     Could not detect rake tasks
 !     ensure you can run `$ bundle exec rake -P` against your app
 !     and using the production group of your Gemfile.
 !     rake aborted!
 !     LoadError: cannot load such file -- matrix
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `<main>'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `<main>'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/receipts-1.1.2/lib/receipts.rb:3:in `<main>'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:60:in `block (2 levels) in require'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:55:in `each'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:55:in `block in require'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:44:in `each'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:44:in `require'
 !     /tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler.rb:176:in `require'
 !     /tmp/build_92530fb1/config/application.rb:7:in `<main>'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
 !     /tmp/build_92530fb1/Rakefile:4:in `<main>'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load_rakefile'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:710:in `raw_load_rakefile'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:104:in `block in load_rakefile'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:103:in `load_rakefile'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:82:in `block in run'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
 !     /tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
 !     /tmp/build_92530fb1/bin/rake:4:in `<main>'
 !
/tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/helpers/rake_runner.rb:100:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
rake aborted!
LoadError: cannot load such file -- matrix
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `<main>'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `<main>'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/receipts-1.1.2/lib/receipts.rb:3:in `<main>'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:60:in `block (2 levels) in require'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:55:in `each'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:55:in `block in require'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:44:in `each'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler/runtime.rb:44:in `require'
/tmp/build_92530fb1/vendor/ruby-3.1.0/lib/ruby/3.1.0/bundler.rb:176:in `require'
/tmp/build_92530fb1/config/application.rb:7:in `<main>'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
/tmp/build_92530fb1/Rakefile:4:in `<main>'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load_rakefile'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:710:in `raw_load_rakefile'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:104:in `block in load_rakefile'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:103:in `load_rakefile'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:82:in `block in run'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/tmp/build_92530fb1/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/tmp/build_92530fb1/bin/rake:4:in `<main>'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:967:in `rake'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:69:in `block in run_assets_precompile_rake_task'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:175:in `log'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:63:in `run_assets_precompile_rake_task'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:103:in `block in compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:988:in `allow_git'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:96:in `compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails2.rb:55:in `compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails3.rb:37:in `compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:30:in `compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails6.rb:17:in `compile'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:19:in `block in <main>'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:175:in `log'
	from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:18:in `<main>'
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

Issues with update to Prawn

After installing this gem file, when trying to run "rails s", I get this error:

/.rvm/gems/ruby-2.2.0/gems/receipts-0.1.0/lib/receipts/receipt.rb:2:in <module:Receipts>': uninitialized constant Receipts::Prawn (NameError) /.rvm/gems/ruby-2.2.0/gems/receipts-0.1.0/lib/receipts/receipt.rb:1:in<top (required)>'

Not sure if this is related to the recent update with Prawn?

Prawn::Errors::IncompatibleStringEncoding: Your document includes text that's not compatible with the Windows-1252 character set. If you need full UTF-8 support, use external fonts instead of PDF's built-in fonts.

Hey there,

I have a customer that signed up a Twitter app of mine, paid for it with the pay gem, and when I try to send them a receipt I get this error.

Prawn::Errors::IncompatibleStringEncoding: Your document includes text that's not compatible with the Windows-1252 character set. If you need full UTF-8 support, use external fonts instead of PDF's built-in fonts.

I'm pretty sure it's because I pull their username from twitter (as their "name"), and their username has random characters used for stylistic purposes.

Is there a good way to override this behavior somehow?

Thanks

  • Pete

Pass open file to company logo option

Hey Chris,

It would be really awesome if you could pass an ActiveStorage attachment or other open stream/tempfile to the invoice's company logo. Is this a feature you'd consider implementing? Thanks!

receipts/base.rb:47:in `header': no implicit conversion of Symbol into Integer (TypeError)

I'm using version 2.2.0 of the gemfile, and was trying to generate a PDF with the following:

      receipt = Receipts::Receipt.new(
        page_size: "A4",
        logo_height: 60,
        title: I18n.t('receipts.receipt'),
        details: [
          [ I18n.t('receipts.payment_number'), "PMT20240126-10000" ],
          [ I18n.t('receipts.issue_date'), Time.now.strftime("%a %d-%b-%Y") ]
        ],
        company: [
          name: company_name,
          address: address,
          phone: phone,
          email: support_email,
          logo: File.expand_path('app/assets/images/logo_for_pdfs.png')
        ],
        recipient: [
        ],
        line_items: [
        ],
        footer: "Footer info..."
      )

However I get:

receipts/base.rb:47:in header: no implicit conversion of Symbol into Integer (TypeError)

Any suggestions for where I am going wrong would be greatly appreciated.

Thank you!

make page_size configurable

Thanks for this gem of a gem, it makes using prawn so much more reasonable.

is there a way to add page_size as a configurable?

as it is in the initialize function, i'm not sure how to override or configure it best. if you could give me some hints, i might be able to come up with a pr.

Matrix gem dependency requires users to add matrix gem in Gemfile when using receipts.

Looks like this gem depends on prawn which depends on matrix, which was removed from the standard library in 3.1, and caused an error for me on deploy. The error went away once I declared the matrix gem explicitly in my Gemfile. I believe this may be fixed upstream by prawn at some point but in the interim, it may prove beneficial to add matrix as a dependency in the gemspec for this gem. Let me know if you'd like a pr.

Document title not translatable

The document titles "Receipt", "Invoice", "Statement" are inherited from the class name, which makes them non-translatable.

Even if you start empty, there is not an option to set a custom title. Am I missing anything?

It may be better to remove this dependency and just use the class name as fallback when no title option present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.