Skip to content

AteqEjaz/spree_print_invoice

Repository files navigation

Spree Print Invoice

Build Status Dependency Status Coverage Status

This extension provides a "Print Invoice" button (per default) on the Admin Orders view screen which generates a PDF of the order details. It's fully extendable so you can add own print slips from your own Rails app. It also comes with a packaging slip.

Installation

Add to your Gemfile

gem 'spree_print_invoice' , github: 'futhr/spree_print_invoice', branch: '2-0-stable'

Run

bundle install
rails g spree_print_invoice:install

Happy printing!

Configuration

  1. Set the logo path preference to include your store/company logo.
Spree::PrintInvoice::Config.set(logo_path: '/path/to/assets/images/company-logo.png')
  1. Under admin contiguration you find Print Invoice Settings where you can change standard settings for printing.

Extending with new slips

In your Rails app create new prawn template in:

views/spree/admin/orders/my_custom_slip.pdf.prawn

For each custom slip, define its representation in your config/locales/ for each locale you use:

---
en:
  spree:
    print_invoice:
      buttons:
        my_custom_slip: My Custom Slip

Note: You can also add any xtra text keys here for your slip.

Enable your custom slip, by adding it to the list of slips you would like to use:

Spree::PrintInvoice::Config.set(print_buttons: 'invoice,packaging_slip,my_custom_slip') # comma separated list

Prawn-handler

A Rails template handler for PDF library Prawn. Prawn-handler is lightweight, simple, and less of a hassle to use.

Usage

  1. Name PDF view files like foo.pdf.prawn. Inside, use the pdf method to access a Prawn::Document object. In addition, this handler allows for lazy method calls: you don't have to specify the receiver explicitely, which cleans up the resulting view code.

For example, the following code with formal calls:

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

Is equivalent to this one with lazy calls:

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

This is accomplished without instance_eval, so that access to instance variables set by the controller is retained.

Contributing

In the spirit of free software, everyone is encouraged to help improve this project.

Here are some ways you can contribute:

  • by using prerelease versions
  • by reporting bugs
  • by suggesting new features
  • by writing translations
  • by writing or editing documentation
  • by writing specifications
  • by writing code (no patch is too small: fix typos, add comments, clean up inconsistent whitespace)
  • by refactoring code
  • by resolving issues
  • by reviewing patches

Starting point:

  • Fork the repo
  • Clone your repo
  • Run bundle install
  • Run bundle exec rake test_app to create the test application in spec/test_app
  • Make your changes and follow this Style Guide
  • Ensure specs pass by running bundle exec rspec spec
  • Submit your pull request

Copyright (c) 2013 Roman Le Négrate, Torsten Rüger and other contributors, released under the New BSD License

About

Create a PDF invoice for Spree orders

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published