GithubHelp home page GithubHelp logo

spree-contrib / spree_print_invoice Goto Github PK

View Code? Open in Web Editor NEW
90.0 17.0 241.0 23.59 MB

Create a PDF invoice for Spree orders.

Home Page: http://guides.spreecommerce.org

License: BSD 3-Clause "New" or "Revised" License

Ruby 82.12% JavaScript 0.38% HTML 17.50%

spree_print_invoice's Introduction

Spree Print Invoice

Build Status Code Climate

This extension provides a model Spree::BookkeepingDocument, which generates PDFs from any Spree Object with the help of View objects that translate between different object structures and PDF templates. It stores a "number" string as well as first name, last name, email, and amount with each document for convenient searching in the backend.

The Gem contains an example implementation for Invoices for Spree::Orders. The basic structure looks like this:

Spree::BookkeepingDocument takes as constructor arguments a printable (polymorphic AR object) and a template (string). It then passes on all actual data generation to a ViewObject. You can find these objects in app/spree/printables/#{printable}/#{template}_view.rb. The object will be instantiated upon PDF generation (look at the Spree::BookkeepingDocument#pdf method to see how it's done).

Spree::Order is patched so that it generates both an invoice and a packaging_slip on completion.

In the Spree::Admin::OrdersController#edit view, you'll find an additional button Documents, where all printable documents will be listed. Additionally, you can find all available Documents in a "Documents" tab in the main menu.

Installation

Add to your Gemfile

gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: 'master'

Run

bundle && exec rails g spree_print_invoice:install

Enjoy! Now you can generate invoices and packaging slips with sequential numbers from arbitrary Spree objects.


Configuration

  1. Set the logo path preference to include your store / company logo.
Spree::PrintInvoice::Config.set(logo_path: '/path/to/public/images/company-logo.png')
  1. Add your own own footer texts to the locale. The current footer works with :footer_left1 , :footer_left2 and :footer_right1, :footer_right2 where the 1 version is on the left in bold, and the 2 version the "value" on the right.

  2. Override any of the partial templates.

  3. Many european countries requires numeric and sequential invoices numbers. To use invoices sequential number fill the specific field in "General Settings" or by setting:

Spree::PrintInvoice::Config.set(next_number: [1|'your current next invoice number'])

The next invoice number will be the one that you specified. You will able to increase it in any moment, for example, to re-sync invoices number if you are making invoices also in other programs for the same business name.

  1. Set page/document options with:
Spree::PrintInvoice::Config.set(prawn_options: { page_layout: :landscape, page_size: 'A4', margin: [50, 100, 150, 200] })
  1. Enable PDF storage feature

PDF files can be stored to disk. This is very handy if you want to send these files as email attachment.

Spree::PrintInvoice::Config.set(store_pdf: true) # Default: false
Spree::PrintInvoice::Config.set(storage_path: 'pdfs/orders') # Default: tmp/order_prints

Inside the storage_path a folder for each template will be created. Files will be saved with order number respectively invoice number as file name.

Customize templates

In order to customize the build in invoice and packaging slip templates you need to copy them into your app:

$ bundle exec rails g spree_print_invoice:templates

You can then customize them in the app/views/spree/printables directory.

Upgrading

From previous versions of spree_print_invoice, the syntax and location of the prawn templates has changed. Please copy new templates using rails g spree_print_invoice:templates and adapt according to your needs.

Adding templates for another model

In order to create a packaging slip for Spree::Shipments, do the following:

  1. Create a View object in app/models/printables/shipments/packagin_slip_view.rb:

    module Spree
      class Printables::Shipment::PackagingSlipView < Printables::BaseView
        def number
          @printable.number
        end
    
        # [ ... more code here, look at the BaseView to see what to implement ]
    
      end
    end
  2. Create a prawn template in app/views/spree/printables/shipment/packaging_slip.pdf.prawn. You can find orientation on the format and syntax of the template by looking at the packaging slip template for Spree::Orders in app/views/spree/printables/orders/invoice.pdf.prawn. Some familiarity with Rails templates will help a lot, as well as reading the prawn docs.

  3. Decorate the shipment model to generate a packaging slip at some point in its life cycle. You could go with a simple after_create Callback, or hook yourself into one of Spree's various state machines. Again, take the supplied app/models/order_decorator.rb as inspiration.

Using Prawn for templating

This Gem uses the prawn-rails to generate templates.

Usage

Name PDF view files like foo.pdf.prawn. Inside, use the pdf method to access a Prawn::Document object:

pdf.bounding_box [100, 600], width: 200 do
  pdf.text 'The rain in spain falls mainly on the plains ' * 5
  pdf.stroke do
    pdf.line pdf.bounds.top_left,    pdf.bounds.top_right
    pdf.line pdf.bounds.bottom_left, pdf.bounds.bottom_right
  end
end

Troubleshooting

When you customize templates and you get the message "You have reached the end of the graphics stack", any one of the objects you're trying to place on your template is too big for the surrounding bounding_box. A common source of this is a missing translation, so make sure your translations are up-to-date.


Contributing

See corresponding guidelines


License

Copyright (c) 2011-2015 Spree Commerce, and other contributors, released under the New BSD License

spree_print_invoice's People

Contributors

adhik-mehta avatar alepore avatar angileri avatar bbonislawski avatar binaryphile avatar damianlegawiec avatar dominiksteiner avatar dpritchett avatar futhr avatar hates avatar imgarylai avatar jdutil avatar jumph4x avatar kennyadsl avatar koprad avatar linrock avatar mamhoff avatar mauazua avatar mdavo6 avatar mtylty avatar peterberkenbosch avatar radar avatar romul avatar schof avatar smartacus avatar ssendev avatar tailic avatar tvdeyen avatar voleoo avatar zhiyao 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

Watchers

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

spree_print_invoice's Issues

Starting spree after installing spree_print_invoice - server fails to start

=> Booting WEBrick
=> Rails 3.1.4 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:203:in parse': (/Users/halcasteel/.rvm/gems/ruby-1.9.3-head/bundler/gems/spree_print_invoice-65639d46c311/config/locales/en.yml): found unknown escape character while parsing a quoted scalar at line 5 column 16 (Psych::SyntaxError) from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:203:inparse_stream'
from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:151:in parse' from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:127:inload'
from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:297:in block in load_file' from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:297:inopen'
from /Users/halcasteel/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/psych.rb:297:in load_file' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:171:inload_yml'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:157:in load_file' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:inblock in load_translations'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:in each' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:inload_translations'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/simple.rb:57:in init_translations' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/simple.rb:71:inlookup'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n/backend/base.rb:26:in translate' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n.rb:156:inblock in translate'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n.rb:152:in catch' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/i18n-0.6.0/lib/i18n.rb:152:intranslate'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.1.4/lib/active_record/railtie.rb:102:in block in <class:Railtie>' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/lazy_load_hooks.rb:34:incall'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/lazy_load_hooks.rb:34:in execute_hook' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/lazy_load_hooks.rb:43:inblock in run_load_hooks'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/lazy_load_hooks.rb:42:in each' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/lazy_load_hooks.rb:42:inrun_load_hooks'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/application/finisher.rb:56:in block in <module:Finisher>' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/initializable.rb:30:ininstance_exec'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/initializable.rb:30:in run' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/initializable.rb:55:inblock in run_initializers'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/initializable.rb:54:in each' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/initializable.rb:54:inrun_initializers'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/application.rb:96:in initialize!' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from /Users/halcasteel/Desktop/mystore/config/environment.rb:5:in <top (required)>' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:240:inrequire'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:240:in block in require' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:223:inblock in load_dependency'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:640:in new_constants_in' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:223:inload_dependency'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:240:in require' from /Users/halcasteel/Desktop/mystore/config.ru:4:inblock in

'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/builder.rb:51:in instance_eval' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/builder.rb:51:ininitialize'
from /Users/halcasteel/Desktop/mystore/config.ru:1:in new' from /Users/halcasteel/Desktop/mystore/config.ru:1:in'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/builder.rb:40:in eval' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/builder.rb:40:inparse_file'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/server.rb:200:in app' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/commands/server.rb:46:inapp'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/server.rb:301:in wrapped_app' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/rack-1.3.6/lib/rack/server.rb:252:instart'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/commands/server.rb:70:in start' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/commands.rb:54:inblock in <top (required)>'
from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/commands.rb:49:in tap' from /Users/halcasteel/.rvm/gems/ruby-1.9.3-head/gems/railties-3.1.4/lib/rails/commands.rb:49:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in'

prawn_options preference not defined (NoMethodError)

Following the readme of the current 3-0-stable branch I get an

preferable.rb:62:in `has_preference!': prawn_options preference not defined (NoMethodError)

error.

This is how my config looks like:

# config/initializers/spree.rb
Spree::PrintInvoice::Config.set(
  prawn_options: {
    page_layout: :portrait,
    page_size: 'A4'
  }
)

Maybe the readme is outdated?

Compatibilty with spree 3.2.0.rc1

When I try to bundle install I get the following error. There seems to be an issue with the compatibility.

Resolving dependencies...

Bundler could not find compatible versions for gem "spree_core":
In snapshot (Gemfile.lock):
spree_core (= 3.2.0.rc2)

In Gemfile:

spree (~> 3.2.0.rc1) was resolved to 3.2.0.rc2, which depends on
  spree_core (= 3.2.0.rc2)

spree (~> 3.2.0.rc1) was resolved to 3.2.0.rc2, which depends on
  spree_core (= 3.2.0.rc2)

spree (~> 3.2.0.rc1) was resolved to 3.2.0.rc2, which depends on
  spree_core (= 3.2.0.rc2)

spree (~> 3.2.0.rc1) was resolved to 3.2.0.rc2, which depends on
  spree_core (= 3.2.0.rc2)

spree (~> 3.2.0.rc1) was resolved to 3.2.0.rc2, which depends on
  spree_core (= 3.2.0.rc2)

spree_gateway (~> 3.2.0.beta) was resolved to 3.2.0.beta, which depends on
  spree_core (< 4.0, >= 3.1.0)

spree_gateway (~> 3.2.0.beta) was resolved to 3.2.0.beta, which depends on
  spree_core (< 4.0, >= 3.1.0)

spree_print_invoice was resolved to 3.0.0.beta, which depends on
  spree_core (~> 3.1.0.beta)

Running bundle update will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

This is how my gemfile looks:
gem 'spree', '> 3.2.0.rc1'
gem 'spree_auth_devise', '
> 3.2.0.beta'
gem 'spree_gateway', '~> 3.2.0.beta'
gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings'
gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: 'master'

Logo not found for logos in public folder.

The default spree admin_interface_logo is defaulted to logo/spree_50.png and resist in the app's public folder. This plugin takes the Spree::Config[:admin_interface_logo] as default value for it's logo_path. Nice!

But, unfortunately this is broken, because the pdf writer only finds files known to Rails asset pipeline from the assets folder.

This is easily fixed, with moving the print logo into the assets folder, sure, but it feels a bit strange, since the spree default logo breaks this behavior.

Show an example image

Could the README include an example image of what the PDF looks like? Or a link to a sample online somewhere?

Problem with invoice when the user changed his address

When an user made a checkout, the order gets the ship address and bill address of that user, on the admin you should be able to get the invoice of that order (orders->order->edit->invoice), but when the user changes his address, that order has the old address of him, so if you want to generate again that order invoice, it gets an error, because it has the old address id

Anyone knows a quick fix for it?

Module::DelegationError (Spree::Order#invoice_number delegated to invoice.number, but invoice is nil

Hi
I'm getting the following error each time I attempt to add an item to the cart; "Module::DelegationError (Spree::Order#invoice_number delegated to invoice.number, but invoice is nil", while running `ensure_cart'.

I have a clean install of spree 4.1. However I've imported order data from a spree 2.4 implementation, so possibly that is causing the issue. Within order I still have the invoice_number and invoice_date.

EDIT:
Error message solved
The error was caused by still having the invoice_number field on orders. I renamed the columns invoice_number and invoice date and the error went away.

Data migration still a problem
I tried to migrate the invoice numbers from the old 2.4 setup into the new spree 4.1 setup. I added the following migration;

`class RenameInvoiceNumberOnOrder < ActiveRecord::Migration[6.0]
def change
up_only {
Spree::Order.complete.where.not(invoice_number: nil).find_each do |order|
order.bookkeeping_documents.delete_all
order.invoice_for_order
order.invoice.update(number: order.invoice_number, created_at: order.completed_at.to_date)
order.packaging_slip.update(number: order.invoice_number, created_at: order.completed_at.to_date)
end
}
rename_column :spree_orders, :invoice_number, :old_invoice_number
rename_column :spree_orders, :invoice_date, :old_invoice_date
end

end
`

It recreated the invoices but the invoice numbers didn't set as the old numbers. The order numbers didn't set to the old number but a number a few thousand higher. Possibly it is taking the next invoice number and adding the old number to it?
Also attempting to set the number on the packaging_slip to the old invoice number had no effect and it kept the packaging slip number as the order number.

Graceful handling of missing shipping or billing address

My spree installation allows orders without a shipping address (i.e. digital downloaded products).

Therefore, @order.ship_address can be nil, which breaks the PDF template code that prints the shipping address.

You can imagine a similar scenario could manifest itself for a nil billing address (e.g. coupon code for free purchase may not require a billing address).

One simple solution is to detect a nil address in the invoice templates and display a message like "No shipping" (pulled from the locale files perhaps?).

Thoughts?

Pdf generation for Reimbursements ?

It's discussed here: #87 but there doesn't seem to be an implementation for generating a Document when a Reimbursement is issued.

Can anyone point me in the right direction or where to start with this ?

TypeError at /admin/orders/R837725288.pdf - "no implicit conversion of nil into String"

My Gemfile has the below version :

gem 'spree_print_invoice' , :git => 'git://github.com/spree/spree_print_invoice.git' , branch: '2-3-stable'

While, I am clicking the button -- print invoice, getting the error -

Started GET "/admin/orders/R837725288.pdf?template=invoice" for 127.0.0.1 at 2015-04-13 13:50:57 +0530
Processing by Spree::Admin::OrdersController#show as PDF
  Parameters: {"template"=>"invoice", "id"=>"R837725288"}
#.....
Rendered /Users/shreyas/.rvm/gems/ruby-2.1.2@collective/bundler/gems/spree_print_invoice-393bec83bfd6/app/views/spree/admin/orders/_print.pdf.prawn (20.2ms)
  Rendered /Users/shreyas/.rvm/gems/ruby-2.1.2@collective/bundler/gems/spree_print_invoice-393bec83bfd6/app/views/spree/admin/orders/invoice.pdf.prawn (27.7ms)
Completed 500 Internal Server Error in 47ms

TypeError - no implicit conversion of nil into String:
  prawn (1.0.0) lib/prawn/images.rb:144:in `verify_and_open_image'
  prawn (1.0.0) lib/prawn/images.rb:79:in `build_image_object'
  prawn (1.0.0) lib/prawn/images.rb:67:in `image'
   () Users/shreyas/.rvm/gems/ruby-2.1.2@collective/bundler/gems/spree_print_invoice-393bec83bfd6/lib/prawn_handler.rb:22:in `method_missing'
   () Users/shreyas/.rvm/gems/ruby-2.1.2@collective/bundler/gems/spree_print_invoice-393bec83bfd6/app/views/spree/admin/orders/_print.pdf.prawn:8:in `_411b913187c5f59f36c7bb34abf7ead6'
  actionview (4.1.4) lib/action_view/template.rb:145:in `block in render'
#...

Checkout fails

When going through the checkout process, a user (logged in or not, doesn't matter) gets an ArgumentError in Spree::CheckoutController#update:

ArgumentError (wrong number of arguments (given 3, expected 1)):
  $RBENV_ROOT/versions/2.3.1/lib/ruby/2.3.0/forwardable.rb:133:in `instance_delegate'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/content_item.rb:12:in `block in <class:ContentItem>'
  activesupport (4.2.7.1) lib/active_support/core_ext/object/with_options.rb:67:in `instance_eval'
  activesupport (4.2.7.1) lib/active_support/core_ext/object/with_options.rb:67:in `with_options'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/content_item.rb:11:in `<class:ContentItem>'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/content_item.rb:3:in `<module:Stock>'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/content_item.rb:2:in `<module:Spree>'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/content_item.rb:1:in `<top (required)>'
  activesupport (4.2.7.1) lib/active_support/dependencies.rb ...
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/package.rb:14:in `add'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/package.rb:18:in `block in add_multiple'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/package.rb:18:in `each'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/package.rb:18:in `add_multiple'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/packer.rb:29:in `block in default_package'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/packer.rb:22:in `each'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/packer.rb:22:in `default_package'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/packer.rb:16:in `packages'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/coordinator.rb:25:in `block in build_packages'
  activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:46:in `each'
  activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:46:in `each'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/coordinator.rb:24:in `build_packages'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/coordinator.rb:18:in `packages'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/stock/coordinator.rb:12:in `shipments'
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_core-3.1.1/app/models/spree/order.rb:492:in `create_proposed_shipments'
  state_machines (0.4.0) lib/state_machines/...
  $RBENV_ROOT/versions/2.3.1/gemsets/shop/gems/spree_frontend-3.1.1/app/controllers/spree/checkout_controller.rb:31:in `update'
  [...]

This Gist contains the full error log, Gemfile and Gemfile.lock. I'm using Ruby 2.3.1, Rails 4.2.7.1, Spree 3.1.1 and spree_print_invoice on master branch.

If I remove this gem (and undo the migrations), the user can step through the checkout process without an error.

What happened here and how can I fix this?

Assembled products don't display items

When using spree_product_assembly the invoice only shows the assembled product. Not what actually goes into the bundle.

I'm sure this can be corrected with some editing and I'm trying to figure it out on my own. But I figure maybe someone has figured this out. Also this would be handy to have built in. When/if I figure this out I'll post my solution. I hope someone else has the solution already to be honest!

Does not work with 2.1

The partial is never rendered in 2.1 as the following no longer exists...

:insert_top => "[data-hook='toolbar']>ul",

print_buttons preference not defined (NoMethodError)

Following readme of master and I get

/gems/ruby-2.3.1/gems/spree_core-3.1.0/app/models/spree/preferences/preferable.rb:62:in `has_preference!': print_buttons preference not defined (NoMethodError)

This is how my config looks like

Spree::PrintInvoice::Config.set(print_buttons: 'invoice')

ArgumentError Exception: wrong number of arguments

Hey,
after implementing gem spree_print_invoice I got error after trying make second order. (first order is OK)
Error appears after cart step.

SQL (2.8ms)  DELETE FROM "spree_adjustments" WHERE "spree_adjustments"."order_id" = ? AND "spree_adjustments"."adjustable_type" = ?  [["order_id", 9], ["adjustable_type", "Spree::Shipment"]]
  Spree::Shipment Load (0.2ms)  SELECT "spree_shipments".* FROM "spree_shipments" WHERE "spree_shipments"."order_id" = ?  [["order_id", 9]]
  Spree::Variant Load (0.1ms)  SELECT "spree_variants".* FROM "spree_variants" INNER JOIN "spree_assemblies_parts" ON "spree_variants"."id" = "spree_assemblies_parts"."part_id" INNER JOIN "spree_variants" "variants_including_masters_parts_join" ON "spree_assemblies_parts"."assembly_id" = "variants_including_masters_parts_join"."id" WHERE "spree_variants"."deleted_at" IS NULL AND "variants_including_masters_parts_join"."product_id" = ?  ORDER BY "spree_variants"."position" ASC  [["product_id", 1]]
  Spree::StockLocation Load (0.4ms)  SELECT "spree_stock_locations".* FROM "spree_stock_locations" INNER JOIN "spree_stock_items" ON "spree_stock_items"."stock_location_id" = "spree_stock_locations"."id" AND "spree_stock_items"."deleted_at" IS NULL WHERE "spree_stock_locations"."active" = ? AND "spree_stock_items"."variant_id" = 1  [["active", "t"]]
  Spree::StockItem Load (0.5ms)  SELECT  "spree_stock_items".* FROM "spree_stock_items" WHERE "spree_stock_items"."deleted_at" IS NULL AND "spree_stock_items"."stock_location_id" = ? AND "spree_stock_items"."variant_id" = 1  ORDER BY "spree_stock_items"."id" ASC LIMIT 1  [["stock_location_id", 1]]
  CACHE (0.0ms)  SELECT  "spree_stock_items".* FROM "spree_stock_items" WHERE "spree_stock_items"."deleted_at" IS NULL AND "spree_stock_items"."stock_location_id" = ? AND "spree_stock_items"."variant_id" = 1  ORDER BY "spree_stock_items"."id" ASC LIMIT 1  [["stock_location_id", 1]]
*** ArgumentError Exception: wrong number of arguments (3 for 1)

After restarting server I can make new order and everything is OK until next order.
spree 3.1
rails 4.2.6

Update 1:
After commenting out before_transition in model everything works fine excepted that invoices are not generated.

#spree_print_invoice/app/models/spree/oreder_decorator.rb
...
# state_machine.before_transition to: :complete, do: :invoice_for_order
...

Invoice is showing ALL adjustments

The invoice PDF is showing all adjustments, rather then just the adjustments relevant to that order.

spree 2.0.8
spree_print_invoice (2.0.0)
prawn (= 0.8.4)
spree_core (~> 2.0)

Break "create order" functionality in admin panel. Spree 3.0

Just try to open /admin/orders/new:

ActiveRecord::RecordNotFound (ActiveRecord::RecordNotFound):
  friendly_id (5.1.0) lib/friendly_id/finder_methods.rb:23:in `find'
  /Users/roman/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/spree-6d8721e0e19d/backend/app/controllers/spree/admin/orders_controller.rb:134:in `load_order'
  /Users/roman/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/spree_print_invoice-2b95eec699f8/app/controllers/spree/admin/orders_controller_decorator.rb:7:in `show'

TypeError in Spree::Admin::Orders#show -no implicit conversion of Sprockets::Asset into String

I'm using '3-0-stable of spree_print_invoice gem on a spreecommerce project (3.0.1).

My gem file contain the following line and I use ruby 2.2.2

gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: '3-0-stable'.

I run the generator, run those migrations and I can see the links in admin panel.
But when I click print invoice, I'm getting the following error.

Started GET "/admin/orders/R987654321.pdf?template=invoice" for 127.0.0.1 at 2015-07-16 06:41:21 +0530
Processing by Spree::Admin::OrdersController#show as PDF
  Parameters: {"template"=>"invoice", "id"=>"R987654321"}
  Spree::Preference Load (0.8ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/backend_configuration/locale"]]
  Spree::User Load (1.1ms)  SELECT  "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1  ORDER BY "spree_users"."id" ASC LIMIT 1  [["id", 1]]
   (1.0ms)  SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = $2  [["user_id", 1], ["name", "admin"]]
  Spree::Order Load (1.0ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."number" = $1  ORDER BY "spree_orders"."id" ASC LIMIT 1  [["number", "R987654321"]]
  Spree::Adjustment Load (1.0ms)  SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."adjustable_id" IN (2)  ORDER BY spree_adjustments.created_at ASC
  Spree::Preference Load (0.8ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/print_invoice_setting/next_number"]]
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/views/spree/admin/orders/invoice.pdf.prawn (164.1ms)
Completed 500 Internal Server Error in 351ms (ActiveRecord: 5.7ms)

ActionView::Template::Error (no implicit conversion of Sprockets::Asset into String):
     9: 
    10:   if im && File.exist?(im.pathname)
    11:     image im, vposition: :top, height: 40, scale: Spree::PrintInvoice::Config[:logo_scale]
    12:   end
    13: 
    14:   grid([0,3], [0,4]).bounding_box do
    15:     font @font_face, size: @font_size
  prawn (1.0.0) lib/prawn/images.rb:144:in `initialize'
  prawn (1.0.0) lib/prawn/images.rb:144:in `new'
  prawn (1.0.0) lib/prawn/images.rb:144:in `verify_and_open_image'
  prawn (1.0.0) lib/prawn/images.rb:79:in `build_image_object'
  prawn (1.0.0) lib/prawn/images.rb:67:in `image'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/lib/prawn_handler.rb:30:in `method_missing'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/views/spree/admin/orders/invoice.pdf.prawn:12:in `block in _9de645c5feda03bf902dcb753ec0eb61'
  pdf-core (0.2.5) lib/pdf/core/page.rb:62:in `stamp_stream'
  prawn (1.0.0) lib/prawn/stamp.rb:83:in `create_stamp'
  prawn (1.0.0) lib/prawn/repeater.rb:99:in `initialize'
  prawn (1.0.0) lib/prawn/repeater.rb:79:in `new'
  prawn (1.0.0) lib/prawn/repeater.rb:79:in `repeat'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/lib/prawn_handler.rb:30:in `method_missing'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/views/spree/admin/orders/invoice.pdf.prawn:8:in `_9de645c5feda03bf902dcb753ec0eb61'
  actionview (4.2.2) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.2) lib/active_support/notifications.rb:166:in `instrument'
  actionview (4.2.2) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.2) lib/action_view/template.rb:143:in `render'
  deface (1.0.1) lib/deface/action_view_extensions.rb:41:in `render'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
  actionview (4.2.2) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `instrument'
  actionview (4.2.2) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:14:in `render'
  actionview (4.2.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.2.2) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.2.2) lib/action_view/helpers/rendering_helper.rb:32:in `render'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/models/spree/order_decorator.rb:81:in `render_pdf'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/models/spree/order_decorator.rb:33:in `pdf_file'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/controllers/spree/admin/orders_controller_decorator.rb:13:in `block (2 levels) in show'
  responders (2.1.0) lib/action_controller/responder.rb:234:in `call'
  responders (2.1.0) lib/action_controller/responder.rb:234:in `default_render'
  responders (2.1.0) lib/action_controller/responder.rb:186:in `to_format'
  spree_core (3.0.1) lib/spree/responder.rb:24:in `to_format'
  responders (2.1.0) lib/action_controller/responder.rb:163:in `respond'
  responders (2.1.0) lib/action_controller/responder.rb:156:in `call'
  responders (2.1.0) lib/action_controller/respond_with.rb:203:in `respond_with'
  spree_core (3.0.1) lib/spree/core/controller_helpers/respond_with.rb:16:in `respond_with'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/spree_print_invoice-a4b8acfcaedf/app/controllers/spree/admin/orders_controller_decorator.rb:9:in `show'
  actionpack (4.2.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.2) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.2) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
  activesupport (4.2.2) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:92:in `_run_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.2) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.2) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.2) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.2) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.2) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:in `call'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:43:in `serve'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in `each'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in `call'
  railties (4.2.2) lib/rails/engine.rb:518:in `call'
  railties (4.2.2) lib/rails/railtie.rb:194:in `public_send'
  railties (4.2.2) lib/rails/railtie.rb:194:in `method_missing'
  actionpack (4.2.2) lib/action_dispatch/routing/mapper.rb:51:in `serve'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in `each'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in `call'
  warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.3) lib/warden/manager.rb:34:in `catch'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.2) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
  activerecord (4.2.2) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:88:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:88:in `_run_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.2) lib/rails/engine.rb:518:in `call'
  railties (4.2.2) lib/rails/application.rb:164:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'


  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (12.3ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (6.6ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (3.3ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (268.8ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (0.7ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (1.1ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.6ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.6ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (256.3ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.6ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.7ms)
  Rendered /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (534.7ms)

How can I solve the issue and fix this error?

Spree Print Invoice Blank

I am using Spree 3.0.0, Spree Print Invoice gem and I have set it up in my gemfile using the branch: '3-0-stable'.

I have installed it with the command

bundle && exec rails g spree_print_invoice:install

I have a simple config/initializers/print_invoice.rb

Spree::PrintInvoice::Config.set(page_layout: :portrait,page_size: 'A4')
Spree::PrintInvoice::Config.set(print_buttons: 'invoice')
Spree::PrintInvoice::Config.set(store_pdf: true) # Default: tmp/order_prints

I have now in my admin configuration a Print Invoice Settings section as well as a print invoice button with each orders.

Here is the log when creating invoice:

Started GET "/admin/orders/R123456789.pdf?template=invoice" for ::1 at 2015-07-22 17:10:00 -0500
Processing by Spree::Admin::OrdersController#show as PDF
  Parameters: {"template"=>"invoice", "id"=>"R123456789"}
  Spree::Preference Load (0.3ms)  SELECT  "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1  [["key", "spree/backend_configuration/locale"]]
  Spree::User Load (0.5ms)  SELECT  "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1  ORDER BY "spree_users"."id" ASC LIMIT 1  [["id", 6]]
   (0.4ms)  SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = $2  [["user_id", 6], ["name", "admin"]]
  Spree::Order Load (0.6ms)  SELECT  "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."number" = $1  ORDER BY "spree_orders"."id" ASC LIMIT 1  [["number", "R123456789"]]
  Spree::Adjustment Load (0.5ms)  SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."adjustable_id" IN (1)  ORDER BY spree_adjustments.created_at ASC
  Rendered text template (0.0ms)
Sent data  (2.7ms)
Completed 200 OK in 18ms (Views: 2.5ms | ActiveRecord: 2.3ms)

The invoices are created into tmp/order_prints but they all are completely blanks. The pdf viewer of my browser is blocked on loading...
Anything I need to do in order to make it work?

Only include "completed" payments?

The invoice template displays all payments for an order, even invalid or failed ones.

As a new user to this gem, I would have expected only "completed" payments to be displayed in the invoice PDF by default.

WDYT?

When upgrading from spree 3-0 to 3-1 custom templates stop working

While updating spree version 3-0 to 3-1 the print invoice also got updated apparently since the version did not change. All custom templated stopped working.

Might be a good idea to do something with the gem version if the complete templating system is changed :/

Forked 3-0-stable and updated gemspec to support spree 3.1.0. Works ;)

Automatically create invoice for completed orders

How can I call the document (invoice) constructor from within the checkout process or how can I call print_invoice without having to access the backend?

I would like to have the invoice created and stored as .pdf automatically as soon as the checkout is completed without having to create the invoice for every order manually.

Thank you!

Failed to render Chinese characters

Hi all, thanks for this awesome extension first.

I have tried to use it to generate an invoice of an order, but something unexpected is that it is failed to work with Chinese characters:

screenshot_7_5_13_12_45_am-2

Through the above screenshot, you can find many blanks with underlines, which should be Chinese characters in fact.

Maybe it a problem with encoding? Or, a problem which should be reported to prawn?

Can anyone help?

Pick List per Shipment

Currently it appears this gem targets an entire order. What are thoughts on changing / extending support for a print pick list for each shipment in an order?

Your document includes text that's not compatible with the Windows-1252 character set

I'm getting the following error for using local language characters:

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

How can I solve this, how can I use TTF fonts instead of PDF's built-in fonts for Prawn ?

I have found what appears to be a solution on stackoverflow: http://stackoverflow.com/questions/37286976/ruby-how-to-use-different-fonts-in-prawn

But I'm not sure where to insert this code:

Prawn::Document.generate("output.pdf") do
  font_families.update("Arial" => {
    :normal => "/assets/fonts/Arial.ttf",
    :italic => "/assets/fonts/Arial Italic.ttf",
  })
  font "Arial"
end

Any ideas ?

Could not find gem spree_core ~> 3.1.0.beta

Could not find gem 'spree_core (~> 3.1.0.beta) ruby', which is required by gem 'spree_print_invoice (>= 0) ruby', in any of the sources.


Bundler could not find compatible versions for gem "spree_core":
In Gemfile:
spree_print_invoice (>= 0) ruby depends on
spree_core (~> 3.1.0.beta) ruby

spree_slider (>= 0) ruby depends on
spree_core (3.0.1)

Gemfile

gem 'spree', '3.0.1'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
gem 'spree_slider', github: 'spree-contrib/spree_slider'
gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: 'master'

re: Error message on downloaded PDF

Hi,

I am currently using spree_print_invoice. There is an error message that comes up you open saved PDFs. This is the error message - "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem." Thanks.

The totals at the bottom of the invoice has disappeared in the saved PDF. This might have something to do with the total calculations and totals at the bottom of the invoice. Thanks.

Thanks,

K

Error/partial output in IE

When viewing an order's invoice in IE, the browser throws an error and doesn't show the shipping/tax/total info. at the bottom. I commented out app/views/spree/admin/orders/_totals.html.erb and it got rid of the error, so it's somewhere in there. Haven't had time to fix, sorry

Don't use Rails.application.assets

I have updated sprockets and now get ActionView::Template::Error (undefined methodfind_asset' for nil:NilClass)`.

Rails.application.assets is nil unless assets.compile is set, which defaults to false in production.

See rails/sprockets-rails#237, i.e.:

So it sounds like using those gems may have been behaving poorly in production before.

Making spree print invoice i18n ready

Is spree print invoice already supposed to work with i18n? I'm on a translated admin page when i click "print invoice", but get english text on my pdf.

Use Prawn 1.0.0

I have just pushed a branch prawn-1-0 that uses the prawn 1.0.0.rc1 and has updated views.

Just trying to think out the best way to merge this to master and how the Versionfile should be updated to reflect these changes. Or we can keep it on the branch and just update the README for the time being.

Anyone have any ideas on this?

Asset url

Hi futhr,

Nice work on this gem! I was trying to add the following to your _print.pdf.prawn template:

image asset_url 'logo.svg' , :at => [0,720], :scale => logo_scale

But i get a "image not found", while the url (http://localhost:3000/assets/logo.svg) actually exist.

Do you know how to add this image?

Check for pre-existing pdf mime type

engine.rb:10 doesn't check for a pre-existing mime type before initializing it. If another gem does the same then the rails server startup will throw warning: already initialized constant PDF.

Other gems have had similar issues, see: Whoops/prawn-rails#10

All PDFs have message on them

Sorry I am not sure if this is an issue, but not sure where to ask

All invoices have this displayed on them:

This is not an original invoice (DO NOT SEND THIS TO CUSTOMER)

Is there a reason for this? I want to be able to generate a PDF that maybe emailed to the customer or printed out and used as a packing sheet

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.