solidus_print_invoice 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +65 -0
- data/app/assets/javascripts/spree/backend/solidus_print_invoice.js +0 -0
- data/app/assets/javascripts/spree/frontend/solidus_print_invoice.js +0 -0
- data/app/assets/stylesheets/spree/backend/solidus_print_invoice.css +0 -0
- data/app/assets/stylesheets/spree/frontend/solidus_print_invoice.css +0 -0
- data/app/controllers/spree/admin/general_settings_controller_decorator.rb +11 -0
- data/app/controllers/spree/admin/orders_controller_decorator.rb +19 -0
- data/app/helpers/spree/admin/print_invoice_helper.rb +14 -0
- data/app/models/spree/print_invoice_configuration.rb +22 -0
- data/app/overrides/admin_invoices_settings.rb +8 -0
- data/app/overrides/layouts_admin_print_buttons_decorator.rb +16 -0
- data/app/views/spree/admin/general_settings/_invoice.html.erb +19 -0
- data/app/views/spree/admin/orders/_address.pdf.prawn +47 -0
- data/app/views/spree/admin/orders/_bye.pdf.prawn +6 -0
- data/app/views/spree/admin/orders/_footer.pdf.prawn +5 -0
- data/app/views/spree/admin/orders/_header.pdf.prawn +8 -0
- data/app/views/spree/admin/orders/_line_items_box.pdf.prawn +63 -0
- data/app/views/spree/admin/orders/_print.pdf.prawn +52 -0
- data/app/views/spree/admin/orders/_print_buttons.html.erb +7 -0
- data/app/views/spree/admin/orders/_totals.pdf.prawn +21 -0
- data/app/views/spree/admin/orders/invoice.pdf.prawn +1 -0
- data/app/views/spree/admin/orders/packaging_slip.pdf.prawn +3 -0
- data/config/routes.rb +11 -0
- data/lib/generators/solidus_print_invoice/install/install_generator.rb +19 -0
- data/lib/prawn_handler.rb +29 -0
- data/lib/solidus_print_invoice.rb +11 -0
- data/lib/solidus_print_invoice/engine.rb +27 -0
- data/lib/solidus_print_invoice/version.rb +5 -0
- metadata +224 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fee82c5484c94ebee0ac539549ef47a2dcd3e99e
|
4
|
+
data.tar.gz: 5a34dc84b8ae8c7310cd7153a6be887ce1c9692e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 957b1b0f786d47874657600709ade7f44bafbe00023f14ca2c4b96eb9076568fb3abd28d45f23e7539f573f9fc4eea08773e3f2c641a93d2e3e7ed8a0a1ce44c
|
7
|
+
data.tar.gz: 4b2201e0535a28617745db27572b01c59418515a9215c9a2a80c32089891ce8bff85c93d432c1148764f19f74046666dd3bb5b4973130ce4e81bfcd2cc788f1e
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
SUMMARY
|
2
|
+
=======
|
3
|
+
|
4
|
+
This extension provides a "Print Invoice" button on the Admin Orders view screen which generates a PDF of the order details.
|
5
|
+
|
6
|
+
This is meant to provide an example of how this can be done, and is easily extended by overriding the templates however you prefer.
|
7
|
+
|
8
|
+
|
9
|
+
INSTALLATION
|
10
|
+
============
|
11
|
+
|
12
|
+
1. The gem relies only on the prawn gem, to install you need to add the following lines to your Gemfile
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'solidus_print_invoice' , github: 'solidusio-contrib/solidus_print_invoice'
|
16
|
+
```
|
17
|
+
|
18
|
+
2. Run bundler
|
19
|
+
|
20
|
+
```shell
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
3. Install migrations
|
25
|
+
|
26
|
+
```shell
|
27
|
+
$ rails g solidus_print_invoice:install
|
28
|
+
```
|
29
|
+
|
30
|
+
Configuration
|
31
|
+
==============
|
32
|
+
|
33
|
+
1. Set the logo path preference to include your store / company logo.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Spree::PrintInvoice::Config.set(print_invoice_logo_path: "/path/to/public/images/company-logo.png")
|
37
|
+
```
|
38
|
+
|
39
|
+
2. 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.
|
40
|
+
|
41
|
+
3. Override any of the partial templates. They are address, footer, totals, header, bye, and the line_items. In bye the text `:thanks` is printed. The `:extra_note` hook has been deprecated as Spree no longer supports hooks.
|
42
|
+
|
43
|
+
4. Set `:suppress_anonymous_address` option to get blank addresses for anonymous email addresses (as created by my spree_last_address extension for empty/unknown user info)
|
44
|
+
|
45
|
+
5. Many european countries requires numeric and sequential invoices numbers. To use invoices sequential number fill the specific field in "General Settings" or by set
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Spree::PrintInvoice::Config.set(print_invoice_next_number: [1|{your current next invoice number}])
|
49
|
+
```
|
50
|
+
|
51
|
+
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.
|
52
|
+
|
53
|
+
6. Enable packaging slips, by setting
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Spree::PrintInvoice::Config.set(print_buttons: "invoice,packaging_slip") #comma separated list
|
57
|
+
```
|
58
|
+
|
59
|
+
Use above feature for your own template if you want. For each button_name, define `button_name_print` text in your locale.
|
60
|
+
|
61
|
+
7. Set page/document options with
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Spree::PrintInvoice::Config.set(prawn_options: { page_layout: :landscape, page_size: "A4", margin: [50, 100, 150, 200] })
|
65
|
+
```
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Spree::Admin::GeneralSettingsController.class_eval do
|
2
|
+
before_filter :update_print_invoice_next_number_settings, only: :update
|
3
|
+
|
4
|
+
private
|
5
|
+
def update_print_invoice_next_number_settings
|
6
|
+
params.each do |name, value|
|
7
|
+
next unless Spree::PrintInvoice::Config.has_preference? name
|
8
|
+
Spree::PrintInvoice::Config[name] = value
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Spree::Admin::OrdersController.class_eval do
|
2
|
+
respond_to :pdf
|
3
|
+
|
4
|
+
def show
|
5
|
+
load_order
|
6
|
+
respond_with(@order) do |format|
|
7
|
+
format.pdf do
|
8
|
+
template = params[:template] || "invoice"
|
9
|
+
if (template == "invoice") && Spree::PrintInvoice::Config.use_sequential_number? && !@order.invoice_number.present?
|
10
|
+
@order.invoice_number = Spree::PrintInvoice::Config.increase_invoice_number
|
11
|
+
@order.invoice_date = Date.today
|
12
|
+
@order.save!
|
13
|
+
end
|
14
|
+
render :layout => false , :template => "spree/admin/orders/#{template}.pdf.prawn"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
module PrintInvoiceHelper
|
4
|
+
def font_faces
|
5
|
+
fonts = Prawn::Font::AFM::BUILT_INS.reject { |f| f =~ /zapf|symbol|bold|italic|oblique/i }.map { |f| [f.tr('-', ' '), f] }
|
6
|
+
options_for_select(fonts, Spree::PrintInvoice::Config[:print_invoice_font_face])
|
7
|
+
end
|
8
|
+
|
9
|
+
def logo_scale
|
10
|
+
Spree::PrintInvoice::Config[:print_invoice_logo_scale].to_f / 100
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Spree
|
2
|
+
class PrintInvoiceConfiguration < Preferences::Configuration
|
3
|
+
|
4
|
+
preference :print_invoice_next_number, :integer, :default => nil
|
5
|
+
preference :print_invoice_logo_path, :string, :default => Spree::Config[:admin_interface_logo]
|
6
|
+
preference :print_invoice_logo_scale, :integer, :default => 50
|
7
|
+
preference :print_invoice_font_face, :string, :default => 'Helvetica'
|
8
|
+
preference :print_buttons, :string, :default => 'invoice'
|
9
|
+
preference :prawn_options, :hash, :default => {}
|
10
|
+
|
11
|
+
def use_sequential_number?
|
12
|
+
print_invoice_next_number.present? && print_invoice_next_number > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def increase_invoice_number
|
16
|
+
current_invoice_number = print_invoice_next_number
|
17
|
+
set_preference(:print_invoice_next_number, current_invoice_number + 1)
|
18
|
+
current_invoice_number
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => "spree/admin/general_settings/edit",
|
2
|
+
:name => "admin_print_invoice_settings",
|
3
|
+
:insert_before => ".filter-actions.form-buttons",
|
4
|
+
:partial => "spree/admin/general_settings/invoice",
|
5
|
+
# :disabled => false)
|
6
|
+
:disabled => !Object.const_defined?('SolidusPrintInvoice'))
|
7
|
+
|
8
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# TODO Axe in favor of content_for
|
2
|
+
# Versions of solidus >= 1.2
|
3
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/_header",
|
4
|
+
:name => "print_buttons",
|
5
|
+
:insert_top => ".page-actions",
|
6
|
+
:partial => "spree/admin/orders/print_buttons",
|
7
|
+
:disabled => false)
|
8
|
+
|
9
|
+
# Versions of solidus < 1.2
|
10
|
+
# content_header was renamed in later versions and was restructured
|
11
|
+
# into _header. So only one of these will ever get applied.
|
12
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/_content_header",
|
13
|
+
:name => "print_buttons",
|
14
|
+
:insert_top => "[data-hook='toolbar']>ul",
|
15
|
+
:partial => "spree/admin/orders/print_buttons",
|
16
|
+
:disabled => false)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<fieldset class="currency no-border-bottom">
|
2
|
+
<legend align="center"><%= Spree.t(:invoices_settings)%></legend>
|
3
|
+
|
4
|
+
<div class="field">
|
5
|
+
<%= label_tag :invoice_font_face, Spree.t(:invoice_font_face) %><br>
|
6
|
+
<%= select_tag :print_invoice_font_face, font_faces, :class => 'fullwidth select2' %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="field">
|
10
|
+
<%= label_tag :print_invoice_next_number, Spree.t(:next_invoice_number) %><br>
|
11
|
+
<%= number_field_tag :print_invoice_next_number, Spree::PrintInvoice::Config[:print_invoice_next_number], :size => 8 %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= label_tag :print_invoice_logo_scale, Spree.t(:invoice_logo_scale) %><br>
|
16
|
+
<%= number_field_tag :print_invoice_logo_scale, Spree::PrintInvoice::Config[:print_invoice_logo_scale], :in => 1...100 %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
</fieldset>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Address Stuff
|
2
|
+
|
3
|
+
bill_address = @order.bill_address
|
4
|
+
ship_address = @order.ship_address
|
5
|
+
anonymous = @order.email =~ /@example.net$/
|
6
|
+
|
7
|
+
|
8
|
+
def address_info(address)
|
9
|
+
info = %Q{
|
10
|
+
#{address.first_name} #{address.last_name}
|
11
|
+
#{address.address1}
|
12
|
+
}
|
13
|
+
info += "#{address.address2}\n" if address.address2.present?
|
14
|
+
state = address.state ? address.state.abbr : ""
|
15
|
+
info += "#{address.zipcode} #{address.city} #{state}\n"
|
16
|
+
info += "#{address.country.name}\n"
|
17
|
+
info += "#{address.phone}\n"
|
18
|
+
info.strip
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[Spree.t(:billing_address), Spree.t(:shipping_address)],
|
24
|
+
[address_info(bill_address), address_info(ship_address) + "\n\nvia #{@order.shipments.first.shipping_method.name}"]
|
25
|
+
]
|
26
|
+
|
27
|
+
move_down 75
|
28
|
+
table(data, :width => 540) do
|
29
|
+
row(0).font_style = :bold
|
30
|
+
|
31
|
+
# Billing address header
|
32
|
+
row(0).column(0).borders = [:top, :right, :bottom, :left]
|
33
|
+
row(0).column(0).border_widths = [0.5, 0, 0.5, 0.5]
|
34
|
+
|
35
|
+
# Shipping address header
|
36
|
+
row(0).column(1).borders = [:top, :right, :bottom, :left]
|
37
|
+
row(0).column(1).border_widths = [0.5, 0.5, 0.5, 0]
|
38
|
+
|
39
|
+
# Bill address information
|
40
|
+
row(1).column(0).borders = [:top, :right, :bottom, :left]
|
41
|
+
row(1).column(0).border_widths = [0.5, 0, 0.5, 0.5]
|
42
|
+
|
43
|
+
# Ship address information
|
44
|
+
row(1).column(1).borders = [:top, :right, :bottom, :left]
|
45
|
+
row(1).column(1).border_widths = [0.5, 0.5, 0.5, 0]
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
data = []
|
2
|
+
|
3
|
+
if @hide_prices
|
4
|
+
@column_widths = { 0 => 100, 1 => 165, 2 => 75, 3 => 75 }
|
5
|
+
@align = { 0 => :left, 1 => :left, 2 => :right, 3 => :right }
|
6
|
+
data << [Spree.t(:sku), Spree.t(:item_description), Spree.t(:options), Spree.t(:qty)]
|
7
|
+
else
|
8
|
+
@column_widths = { 0 => 75, 1 => 205, 2 => 75, 3 => 50, 4 => 75, 5 => 60 }
|
9
|
+
@align = { 0 => :left, 1 => :left, 2 => :left, 3 => :right, 4 => :right, 5 => :right}
|
10
|
+
data << [Spree.t(:sku), Spree.t(:item_description), Spree.t(:options), Spree.t(:price), Spree.t(:qty), Spree.t(:total)]
|
11
|
+
end
|
12
|
+
|
13
|
+
@order.line_items.each do |item|
|
14
|
+
row = [ item.variant.product.sku, item.variant.product.name]
|
15
|
+
row << item.variant.options_text
|
16
|
+
row << item.single_display_amount.to_s unless @hide_prices
|
17
|
+
row << item.quantity
|
18
|
+
row << item.display_total.to_s unless @hide_prices
|
19
|
+
data << row
|
20
|
+
end
|
21
|
+
|
22
|
+
extra_row_count = 0
|
23
|
+
|
24
|
+
unless @hide_prices
|
25
|
+
extra_row_count += 1
|
26
|
+
data << [""] * 5
|
27
|
+
data << [nil, nil, nil, nil, Spree.t(:subtotal), @order.display_item_total.to_s]
|
28
|
+
|
29
|
+
@order.all_adjustments.eligible.each do |adjustment|
|
30
|
+
extra_row_count += 1
|
31
|
+
data << [nil, nil, nil, nil, adjustment.label, adjustment.display_amount.to_s]
|
32
|
+
end
|
33
|
+
|
34
|
+
@order.shipments.each do |shipment|
|
35
|
+
extra_row_count += 1
|
36
|
+
data << [nil, nil, nil, nil, shipment.shipping_method.name, shipment.display_cost.to_s]
|
37
|
+
end
|
38
|
+
|
39
|
+
data << [nil, nil, nil, nil, Spree.t(:total), @order.display_total.to_s]
|
40
|
+
end
|
41
|
+
|
42
|
+
move_down(250)
|
43
|
+
table(data, :width => @column_widths.values.compact.sum, :column_widths => @column_widths) do
|
44
|
+
cells.border_width = 0.5
|
45
|
+
|
46
|
+
row(0).borders = [:bottom]
|
47
|
+
row(0).font_style = :bold
|
48
|
+
|
49
|
+
last_column = data[0].length - 1
|
50
|
+
row(0).columns(0..last_column).borders = [:top, :right, :bottom, :left]
|
51
|
+
row(0).columns(0..last_column).border_widths = [0.5, 0, 0.5, 0.5]
|
52
|
+
|
53
|
+
row(0).column(last_column).border_widths = [0.5, 0.5, 0.5, 0.5]
|
54
|
+
|
55
|
+
if extra_row_count > 0
|
56
|
+
extra_rows = row((-2-extra_row_count)..-2)
|
57
|
+
extra_rows.columns(0..5).borders = []
|
58
|
+
extra_rows.column(4).font_style = :bold
|
59
|
+
|
60
|
+
row(-1).columns(0..5).borders = []
|
61
|
+
row(-1).column(4).font_style = :bold
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'prawn/layout'
|
2
|
+
|
3
|
+
@font_face = Spree::PrintInvoice::Config[:print_invoice_font_face]
|
4
|
+
|
5
|
+
font @font_face
|
6
|
+
|
7
|
+
im = Rails.application.assets.find_asset(Spree::PrintInvoice::Config[:print_invoice_logo_path])
|
8
|
+
image im.filename , :at => [0,720], :scale => logo_scale
|
9
|
+
|
10
|
+
fill_color "E99323"
|
11
|
+
if @hide_prices
|
12
|
+
text Spree.t(:packaging_slip), :align => :right, :style => :bold, :size => 18
|
13
|
+
else
|
14
|
+
text Spree.t(:customer_invoice), :align => :right, :style => :bold, :size => 18
|
15
|
+
end
|
16
|
+
fill_color "000000"
|
17
|
+
|
18
|
+
move_down 4
|
19
|
+
|
20
|
+
if Spree::PrintInvoice::Config.use_sequential_number? && @order.invoice_number.present? && !@hide_prices
|
21
|
+
|
22
|
+
font @font_face, :size => 9, :style => :bold
|
23
|
+
text "#{Spree.t(:invoice_number)} #{@order.invoice_number}", :align => :right
|
24
|
+
|
25
|
+
move_down 2
|
26
|
+
font @font_face, :size => 9
|
27
|
+
text "#{Spree.t(:invoice_date)} #{I18n.l @order.invoice_date}", :align => :right
|
28
|
+
|
29
|
+
else
|
30
|
+
|
31
|
+
move_down 2
|
32
|
+
font @font_face, :size => 9
|
33
|
+
text "#{Spree.t(:order_number, :number => @order.number)}", :align => :right
|
34
|
+
|
35
|
+
move_down 2
|
36
|
+
font @font_face, :size => 9
|
37
|
+
text "#{I18n.l @order.completed_at.to_date}", :align => :right
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
render :partial => "address"
|
43
|
+
|
44
|
+
move_down 30
|
45
|
+
|
46
|
+
render :partial => "line_items_box"
|
47
|
+
|
48
|
+
move_down 8
|
49
|
+
|
50
|
+
# Footer
|
51
|
+
render :partial => "footer"
|
52
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<% if @order and @order.completed_at? %>
|
2
|
+
<% buttons = Spree::PrintInvoice::Config[:print_buttons]
|
3
|
+
buttons = buttons.split(",").collect{|b| b.strip } %>
|
4
|
+
<% buttons.each do |button| %>
|
5
|
+
<li><%= link_to(Spree.t(button.to_s + "_print"), spree.admin_order_path(@order, :pdf , :template => button), :class => "button fa fa-print") %></li>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
totals = []
|
2
|
+
|
3
|
+
totals << [Prawn::Table::Cell.new( :text => Spree.t(:subtotal), :font_style => :bold), @order.display_item_total.to_s]
|
4
|
+
|
5
|
+
@order.adjustments.eligible.each do |charge|
|
6
|
+
totals << [Prawn::Table::Cell.new( :text => charge.label + ":", :font_style => :bold), charge.display_amount.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
totals << [Prawn::Table::Cell.new( :text => Spree.t(:order_total), :font_style => :bold), @order.display_total.to_s]
|
10
|
+
|
11
|
+
bounding_box [bounds.right - 500, bounds.bottom + (totals.length * 18)], :width => 500 do
|
12
|
+
table totals,
|
13
|
+
:position => :right,
|
14
|
+
:border_width => 0,
|
15
|
+
:vertical_padding => 2,
|
16
|
+
:horizontal_padding => 6,
|
17
|
+
:font_size => 9,
|
18
|
+
:column_widths => { 0 => 425, 1 => 75 } ,
|
19
|
+
:align => { 0 => :right, 1 => :right }
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
render :partial => "print"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module SolidusPrintInvoice
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
class_option :auto_run_migrations, :type => :boolean, :default => true
|
5
|
+
|
6
|
+
def add_migrations
|
7
|
+
run 'rake railties:install:migrations FROM=solidus_print_invoice'
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_migrations
|
11
|
+
if options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask "Would you like to run the migrations now? [Y/n]")
|
12
|
+
run 'rake db:migrate'
|
13
|
+
else
|
14
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'prawn'
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Template::Handlers
|
5
|
+
class Prawn
|
6
|
+
def self.register!
|
7
|
+
Template.register_template_handler :prawn, self
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.call(template)
|
11
|
+
%(extend #{DocumentProxy}; #{template.source}; pdf.render)
|
12
|
+
end
|
13
|
+
|
14
|
+
module DocumentProxy
|
15
|
+
def pdf
|
16
|
+
@pdf ||= ::Prawn::Document.new(Spree::PrintInvoice::Config[:prawn_options])
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def method_missing(method, *args, &block)
|
22
|
+
pdf.respond_to?(method) ? pdf.send(method, *args, &block) : super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
ActionView::Template::Handlers::Prawn.register!
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'deface'
|
2
|
+
|
3
|
+
module SolidusPrintInvoice
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
engine_name 'solidus_print_invoice'
|
6
|
+
|
7
|
+
initializer "spree.print_invoice.environment", :before => :load_config_initializers do |app|
|
8
|
+
Spree::PrintInvoice::Config = Spree::PrintInvoiceConfiguration.new
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer "spree.print_invoice.mimetypes" do |app|
|
12
|
+
Mime::Type.register('application/pdf', :pdf) unless Mime::Type.lookup_by_extension(:pdf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.activate
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
24
|
+
config.to_prepare &method(:activate).to_proc
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solidus_print_invoice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spree & Solidus Community
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prawn
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: solidus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: deface
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: selenium-webdriver
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: poltergeist
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: database_cleaner
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: factory_girl_rails
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: sqlite3
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description:
|
168
|
+
email:
|
169
|
+
executables: []
|
170
|
+
extensions: []
|
171
|
+
extra_rdoc_files: []
|
172
|
+
files:
|
173
|
+
- README.md
|
174
|
+
- app/assets/javascripts/spree/backend/solidus_print_invoice.js
|
175
|
+
- app/assets/javascripts/spree/frontend/solidus_print_invoice.js
|
176
|
+
- app/assets/stylesheets/spree/backend/solidus_print_invoice.css
|
177
|
+
- app/assets/stylesheets/spree/frontend/solidus_print_invoice.css
|
178
|
+
- app/controllers/spree/admin/general_settings_controller_decorator.rb
|
179
|
+
- app/controllers/spree/admin/orders_controller_decorator.rb
|
180
|
+
- app/helpers/spree/admin/print_invoice_helper.rb
|
181
|
+
- app/models/spree/print_invoice_configuration.rb
|
182
|
+
- app/overrides/admin_invoices_settings.rb
|
183
|
+
- app/overrides/layouts_admin_print_buttons_decorator.rb
|
184
|
+
- app/views/spree/admin/general_settings/_invoice.html.erb
|
185
|
+
- app/views/spree/admin/orders/_address.pdf.prawn
|
186
|
+
- app/views/spree/admin/orders/_bye.pdf.prawn
|
187
|
+
- app/views/spree/admin/orders/_footer.pdf.prawn
|
188
|
+
- app/views/spree/admin/orders/_header.pdf.prawn
|
189
|
+
- app/views/spree/admin/orders/_line_items_box.pdf.prawn
|
190
|
+
- app/views/spree/admin/orders/_print.pdf.prawn
|
191
|
+
- app/views/spree/admin/orders/_print_buttons.html.erb
|
192
|
+
- app/views/spree/admin/orders/_totals.pdf.prawn
|
193
|
+
- app/views/spree/admin/orders/invoice.pdf.prawn
|
194
|
+
- app/views/spree/admin/orders/packaging_slip.pdf.prawn
|
195
|
+
- config/routes.rb
|
196
|
+
- lib/generators/solidus_print_invoice/install/install_generator.rb
|
197
|
+
- lib/prawn_handler.rb
|
198
|
+
- lib/solidus_print_invoice.rb
|
199
|
+
- lib/solidus_print_invoice/engine.rb
|
200
|
+
- lib/solidus_print_invoice/version.rb
|
201
|
+
homepage: https://github.com/solidusio-contrib/solidus_print_invoice
|
202
|
+
licenses: []
|
203
|
+
metadata: {}
|
204
|
+
post_install_message:
|
205
|
+
rdoc_options: []
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: 1.9.3
|
213
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
requirements: []
|
219
|
+
rubyforge_project:
|
220
|
+
rubygems_version: 2.2.3
|
221
|
+
signing_key:
|
222
|
+
specification_version: 4
|
223
|
+
summary: Print invoices from a spree order
|
224
|
+
test_files: []
|