spree-print-invoice 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.hound.yml +3 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +11 -0
  6. data/CONTRIBUTING.md +30 -0
  7. data/Gemfile +5 -0
  8. data/Guardfile +9 -0
  9. data/LICENSE.md +26 -0
  10. data/README.md +48 -0
  11. data/Rakefile +15 -0
  12. data/app/assets/javascripts/admin/spree_print_invoice.js +1 -0
  13. data/app/assets/stylesheets/admin/spree_print_invoice.css +3 -0
  14. data/app/controllers/spree/admin/orders_controller_decorator.rb +18 -0
  15. data/app/controllers/spree/admin/print_invoice_settings_controller.rb +16 -0
  16. data/app/overrides/add_print_invoice_to_admin_configuration_sidebar.rb +6 -0
  17. data/app/overrides/layouts_admin_print_buttons_decorator.rb +6 -0
  18. data/app/views/spree/admin/orders/_print_buttons.html.erb +12 -0
  19. data/app/views/spree/admin/orders/invoice.pdf.prawn +155 -0
  20. data/app/views/spree/admin/orders/packaging_slip.pdf.prawn +128 -0
  21. data/app/views/spree/admin/print_invoice_settings/edit.html.erb +90 -0
  22. data/bin/rails +7 -0
  23. data/config/locales/de.yml +37 -0
  24. data/config/locales/en.yml +37 -0
  25. data/config/locales/es.yml +37 -0
  26. data/config/locales/fr.yml +37 -0
  27. data/config/locales/sv.yml +37 -0
  28. data/config/routes.rb +11 -0
  29. data/db/migrate/20140123094547_add_invoice_details_to_spree_orders.rb +6 -0
  30. data/lib/generators/spree_print_invoice/install/install_generator.rb +19 -0
  31. data/lib/prawn_handler.rb +29 -0
  32. data/lib/spree/print_invoice_setting.rb +35 -0
  33. data/lib/spree_print_invoice.rb +13 -0
  34. data/lib/spree_print_invoice/engine.rb +29 -0
  35. data/lib/spree_print_invoice/version.rb +18 -0
  36. data/spec/features/spree/admin/print_invoice_setting_spec.rb +45 -0
  37. data/spec/features/spree/admin/print_invoice_spec.rb +60 -0
  38. data/spec/lib/prawn_handler_spec.rb +30 -0
  39. data/spec/spec_helper.rb +28 -0
  40. data/spec/support/capybara.rb +17 -0
  41. data/spec/support/databse_cleaner.rb +18 -0
  42. data/spec/support/factory_girl.rb +5 -0
  43. data/spec/support/i18n.rb +13 -0
  44. data/spec/support/matchers/have_text_like.rb +8 -0
  45. data/spec/support/spree.rb +12 -0
  46. data/spec/support/test.pdf.prawn +2 -0
  47. data/spec/translations/locale_spec.rb +15 -0
  48. data/spree_print_invoice.gemspec +47 -0
  49. metadata +398 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2d33f08c18b4f9e205319dc38437c7a39e35a94c
4
+ data.tar.gz: 24a5d139084b510b6fe1e826800b43dc87d10c8b
5
+ SHA512:
6
+ metadata.gz: 19878476a8d422f7cfd025024fd77655d29886e216459188035638be2e4a8cb7b1573e2cef284d30b6a50c552d4223f349994d02f47b542faaa334ef5f4aea67
7
+ data.tar.gz: 7c5d6dd88bf9901d2154393ee01e6531d325b01829811f08629f264da72aeabbba0deb00d3559a97f0d6c450b4702f9f0791a80779170abb14ad2ab93959551b
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .bundle
6
+ coverage
7
+ Gemfile.lock
8
+ tmp
9
+ pkg
10
+ spec/dummy
11
+ .rvmrc
12
+ .localeapp
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ LineLength:
3
+ Enabled: false
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ before_script:
3
+ - sh -e /etc/init.d/xvfb start
4
+ - export DISPLAY=:99.0
5
+ - bundle exec rake test_app
6
+ script:
7
+ - bundle exec rspec spec
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
4
+
5
+ Here are some ways *you* can contribute:
6
+
7
+ * by using prerelease versions
8
+ * by reporting [bugs][2]
9
+ * by suggesting new features
10
+ * by writing [translations][3]
11
+ * by writing or editing documentation
12
+ * by writing specifications
13
+ * by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
14
+ * by refactoring code
15
+ * by resolving [issues][2]
16
+ * by reviewing patches
17
+
18
+ Starting point:
19
+
20
+ * Fork the repo
21
+ * Clone your repo
22
+ * Run `bundle install`
23
+ * Run `bundle exec rake test_app` to create the test application in `spec/test_app`
24
+ * Make your changes
25
+ * Ensure specs pass by running `bundle exec rspec spec`
26
+ * Submit your pull request
27
+
28
+ [1]: http://www.fsf.org/licensing/essays/free-sw.html
29
+ [2]: https://github.com/spree/spree_print_invoice/issues
30
+ [3]: http://www.localeapp.com/projects/6630
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '2-1-stable'
4
+
5
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ guard 'rspec', cmd: 'bundle exec rspec', all_on_start: false, all_after_pass: false do
2
+ watch('spec/spec_helper.rb') { 'spec' }
3
+ watch('config/routes.rb') { 'spec/controllers' }
4
+ watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
5
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch(%r{^app/(.*)(\.erb)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
9
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2011-2014 Christopher Angileri, Tobias Bohwalli, and other contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Spree Print Invoice
2
+
3
+ [![Build Status](https://api.travis-ci.org/futhr/spree-print-invoice.png?branch=2-1-stable)](https://travis-ci.org/futhr/spree-print-invoice)
4
+ [![Coverage Status](https://coveralls.io/repos/futhr/spree-print-invoice/badge.png?branch=2-1-stable)](https://coveralls.io/r/futhr/spree-print-invoice)
5
+ [![Code Climate](https://codeclimate.com/github/futhr/spree-print-invoice.png)](https://codeclimate.com/github/futhr/spree-print-invoice)
6
+ [![Gem Version](https://badge.fury.io/rb/spree-print-invoice.png)](http://badge.fury.io/rb/spree-print-invoice)
7
+
8
+ 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.
9
+
10
+ ## Installation
11
+
12
+ Add to your `Gemfile`
13
+ ```ruby
14
+ gem 'spree-print-invoice', '~> 2.1.0'
15
+ ```
16
+
17
+ Run
18
+ ```
19
+ bundle install
20
+ rails g spree_print_invoice:install
21
+ ```
22
+
23
+ Enjoy! Now allow to generate invoices with sequential numbers.
24
+
25
+ ---
26
+
27
+ ## Configuration and extending slips
28
+
29
+ See corresponding [wiki pages][1]
30
+
31
+ ---
32
+
33
+ ## Contributing
34
+
35
+ See corresponding [guidelines][2]
36
+
37
+ ---
38
+
39
+ ## License
40
+
41
+ Copyright (c) 2011-2014 [Christopher Angileri][3], [Tobias Bohwalli][4], and other [contributors][5], released under the [New BSD License][6]
42
+
43
+ [1]: https://github.com/futhr/spree-print-invoice/wiki
44
+ [2]: https://github.com/futhr/spree-print-invoice/blob/master/CONTRIBUTING.md
45
+ [3]: https://github.com/angileri
46
+ [4]: https://github.com/futhr
47
+ [5]: https://github.com/futhr/spree-print-invoice/contributors
48
+ [6]: https://github.com/futhr/spree-print-invoice/blob/master/LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task default: [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_print_invoice'
14
+ Rake::Task['common:test_app'].invoke
15
+ end
@@ -0,0 +1 @@
1
+ //= require admin/spree_backend
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_backend
3
+ */
@@ -0,0 +1,18 @@
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
+ end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ module Admin
3
+ class PrintInvoiceSettingsController < ResourceController
4
+
5
+ def update
6
+ settings = Spree::PrintInvoiceSetting.new
7
+ params[:preferences].each do |name, value|
8
+ next unless settings.has_preference? name
9
+ settings[name] = value
10
+ end
11
+ flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:settings, scope: :print_invoice))
12
+ redirect_to edit_admin_print_invoice_settings_path
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(virtual_path: "spree/admin/shared/_configuration_menu",
2
+ name: "print_invoice_admin_configurations_menu",
3
+ insert_bottom: "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
4
+ text: "<%= configurations_sidebar_menu_item Spree.t(:settings, scope: :print_invoice), edit_admin_print_invoice_settings_path %>",
5
+ original: "737741636d3b0e7dcffd17c5b463c2983647e168 ",
6
+ disabled: false)
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/shared/_content_header",
2
+ :name => "print_buttons",
3
+ :insert_top => "[data-hook='toolbar']>ul",
4
+ :partial => "spree/admin/orders/print_buttons",
5
+ :original => 'a3a6281b8d3543510afa905d0a1602f03f14d7b9',
6
+ :disabled => false)
@@ -0,0 +1,12 @@
1
+ <% if @order && @order.completed_at? %>
2
+ <div style="margin-bottom:4px" data-hook="admin_order_print_buttons">
3
+ <% buttons = Spree::PrintInvoice::Config[:print_buttons].split(',').compact.collect{|b| b.strip } %>
4
+ <% buttons.each do |button| %>
5
+ <li>
6
+ <%= link_to(Spree.t(:"#{button}", scope: [:print_invoice, :buttons], default: 'PDF Slip'),
7
+ spree.admin_order_path(@order, :pdf , template: button),
8
+ class: 'button icon-print', target: :blank) %>
9
+ </li>
10
+ <% end %>
11
+ </div>
12
+ <% end %>
@@ -0,0 +1,155 @@
1
+ define_grid(columns: 5, rows: 8, gutter: 10)
2
+
3
+ # HEADER
4
+ repeat(:all) do
5
+ im = Rails.application.assets.find_asset(Spree::PrintInvoice::Config[:print_invoice_logo_path])
6
+ if File.exists? im
7
+ image im, vposition: :top, height: 40
8
+ end
9
+
10
+ grid([0,3], [0,4]).bounding_box do
11
+ font 'Helvetica', size: 9
12
+ text Spree.t(:invoice, scope: :print_invoice), align: :right, style: :bold, size: 18
13
+ move_down 4
14
+ text Spree.t(:order_number, number: @order.number), align: :right
15
+ move_down 2
16
+ text I18n.l(@order.completed_at.to_date), align: :right
17
+ end
18
+ end
19
+
20
+ # CONTENT
21
+ grid([1,0], [6,4]).bounding_box do
22
+
23
+ font 'Helvetica', size: 9
24
+
25
+ # address block on first page only
26
+ repeat(lambda { |pg| pg == 1 }) do
27
+ bill_address = @order.bill_address
28
+ ship_address = @order.ship_address
29
+
30
+ move_down 2
31
+ address_cell_billing = make_cell(content: Spree.t(:billing_address), font_style: :bold)
32
+ address_cell_shipping = make_cell(content: Spree.t(:shipping_address), font_style: :bold)
33
+
34
+ billing = "#{bill_address.firstname} #{bill_address.lastname}"
35
+ billing << "\n#{bill_address.address1}"
36
+ billing << "\n#{bill_address.address2}" unless bill_address.address2.blank?
37
+ billing << "\n#{bill_address.city}, #{bill_address.state_text} #{bill_address.zipcode}"
38
+ billing << "\n#{bill_address.country.name}"
39
+ billing << "\n#{bill_address.phone}"
40
+
41
+ shipping = "#{ship_address.firstname} #{ship_address.lastname}"
42
+ shipping << "\n#{ship_address.address1}"
43
+ shipping << "\n#{ship_address.address2}" unless ship_address.address2.blank?
44
+ shipping << "\n#{ship_address.city}, #{ship_address.state_text} #{ship_address.zipcode}"
45
+ shipping << "\n#{ship_address.country.name}"
46
+ shipping << "\n#{ship_address.phone}"
47
+ shipping << "\n\n#{Spree.t(:via, scope: :print_invoice)} #{@order.shipments.first.shipping_method.name}"
48
+
49
+ data = [[address_cell_billing, address_cell_shipping], [billing, shipping]]
50
+ table(data, position: :center, column_widths: [270, 270])
51
+ end
52
+
53
+ move_down 10
54
+
55
+ header = [
56
+ make_cell(content: Spree.t(:sku)),
57
+ make_cell(content: Spree.t(:item_description)),
58
+ make_cell(content: Spree.t(:options)),
59
+ make_cell(content: Spree.t(:price)),
60
+ make_cell(content: Spree.t(:qty)),
61
+ make_cell(content: Spree.t(:total))
62
+ ]
63
+ data = [header]
64
+
65
+ @order.line_items.each do |item|
66
+ row = [
67
+ item.variant.product.sku,
68
+ item.variant.product.name,
69
+ item.variant.options_text,
70
+ item.single_display_amount.to_s,
71
+ item.quantity,
72
+ item.display_total.to_s
73
+ ]
74
+ data += [row]
75
+ end
76
+
77
+ table(data, header: true, position: :center, column_widths: [70, 200, 100, 65, 40, 65]) do
78
+ row(0).style align: :center, font_style: :bold
79
+ column(0..2).style align: :left
80
+ column(3..6).style align: :right
81
+ end
82
+
83
+ # TOTALS
84
+ move_down 10
85
+ totals = []
86
+
87
+ # Subtotal
88
+ totals << [make_cell(content: Spree.t(:subtotal)), @order.display_item_total.to_s]
89
+
90
+ # Adjustments
91
+ @order.all_adjustments.eligible.each do |adjustment|
92
+ totals << [make_cell(content: adjustment.label), adjustment.display_amount.to_s]
93
+ end
94
+
95
+ # Shipments
96
+ @order.shipments.each do |shipment|
97
+ totals << [make_cell(content: shipment.shipping_method.name), shipment.display_cost.to_s]
98
+ end
99
+
100
+ # Totals
101
+ totals << [make_cell(content: Spree.t(:order_total)), @order.display_total.to_s]
102
+
103
+ # Payments
104
+ total_payments = 0.0
105
+ @order.payments.each do |payment|
106
+ totals << [
107
+ make_cell(content: Spree.t(:payment_via,
108
+ gateway: (payment.source_type || Spree.t(:unprocessed, scope: :print_invoice)),
109
+ number: payment.identifier,
110
+ date: I18n.l(payment.updated_at.to_date, format: :long),
111
+ scope: :print_invoice)),
112
+ payment.display_amount.to_s
113
+ ]
114
+ total_payments += payment.amount
115
+ end
116
+
117
+ table(totals, column_widths: [475, 65]) do
118
+ row(0..6).style align: :right
119
+ column(0).style borders: [], font_style: :bold
120
+ end
121
+
122
+ move_down 30
123
+ text Spree::PrintInvoice::Config[:return_message], align: :right, size: 9
124
+ end
125
+
126
+ # FOOTER
127
+ if Spree::PrintInvoice::Config[:use_footer]
128
+ repeat(:all) do
129
+ grid([7,0], [7,4]).bounding_box do
130
+
131
+ data = []
132
+ data << [ make_cell(content: Spree.t(:vat, scope: :print_invoice), colspan: 2, align: :center) ]
133
+ data << [ make_cell(content: '', colspan: 2) ]
134
+ data << [ make_cell(content: Spree::PrintInvoice::Config[:footer_left], align: :left),
135
+ make_cell(content: Spree::PrintInvoice::Config[:footer_right], align: :right) ]
136
+
137
+ table(data, position: :center, column_widths: [270, 270]) do
138
+ row(0..2).style borders: []
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ # PAGE NUMBER
145
+ if Spree::PrintInvoice::Config[:use_page_numbers]
146
+ string = "#{Spree.t(:page, scope: :print_invoice)} <page> #{Spree.t(:of, scope: :print_invoice)} <total>"
147
+ options = {
148
+ at: [bounds.right - 155, 0],
149
+ width: 150,
150
+ align: :right,
151
+ start_count_at: 1,
152
+ color: '000000'
153
+ }
154
+ number_pages string, options
155
+ end
@@ -0,0 +1,128 @@
1
+ define_grid(columns: 5, rows: 8, gutter: 10)
2
+
3
+ # HEADER
4
+ repeat(:all) do
5
+ im = Rails.application.assets.find_asset(Spree::PrintInvoice::Config[:print_invoice_logo_path])
6
+ if File.exists? im
7
+ image im, vposition: :top, height: 40
8
+ end
9
+
10
+ grid([0,3], [0,4]).bounding_box do
11
+ font 'Helvetica', size: 9
12
+ text Spree.t(:packaging_slip, scope: :print_invoice), align: :right, style: :bold, size: 18
13
+ move_down 4
14
+
15
+ if Spree::PrintInvoice::Config.use_sequential_number? && @order.invoice_number.present?
16
+
17
+ text Spree.t(:invoice_number, number: @order.invoice_number, scope: :print_invoice), align: :right
18
+ move_down 2
19
+ text "#{Spree.t(:invoice_date)} #{I18n.l @order.invoice_date}", align: :right
20
+
21
+ else
22
+
23
+ text Spree.t(:order_number, number: @order.number), align: :right
24
+ move_down 2
25
+ text I18n.l(@order.completed_at.to_date), align: :right
26
+
27
+ end
28
+ end
29
+ end
30
+
31
+ # CONTENT
32
+ grid([1,0], [6,4]).bounding_box do
33
+
34
+ font 'Helvetica', size: 9
35
+
36
+ # address block on first page only
37
+ repeat(lambda { |pg| pg == 1 }) do
38
+ bill_address = @order.bill_address
39
+ ship_address = @order.ship_address
40
+
41
+ move_down 2
42
+ address_cell_billing = make_cell(content: Spree.t(:billing_address), font_style: :bold)
43
+ address_cell_shipping = make_cell(content: Spree.t(:shipping_address), font_style: :bold)
44
+
45
+ billing = "#{bill_address.firstname} #{bill_address.lastname}"
46
+ billing << "\n#{bill_address.address1}"
47
+ billing << "\n#{bill_address.address2}" unless bill_address.address2.blank?
48
+ billing << "\n#{bill_address.city}, #{bill_address.state_text} #{bill_address.zipcode}"
49
+ billing << "\n#{bill_address.country.name}"
50
+ billing << "\n#{bill_address.phone}"
51
+
52
+ shipping = "#{ship_address.firstname} #{ship_address.lastname}"
53
+ shipping << "\n#{ship_address.address1}"
54
+ shipping << "\n#{ship_address.address2}" unless ship_address.address2.blank?
55
+ shipping << "\n#{ship_address.city}, #{ship_address.state_text} #{ship_address.zipcode}"
56
+ shipping << "\n#{ship_address.country.name}"
57
+ shipping << "\n#{ship_address.phone}"
58
+ shipping << "\n\n#{Spree.t(:via, scope: :print_invoice)} #{@order.shipments.first.shipping_method.name}"
59
+
60
+ data = [[address_cell_billing, address_cell_shipping], [billing, shipping]]
61
+ table(data, position: :center, column_widths: [270, 270])
62
+ end
63
+
64
+ move_down 10
65
+
66
+ header = [
67
+ make_cell(content: Spree.t(:sku)),
68
+ make_cell(content: Spree.t(:item_description)),
69
+ make_cell(content: Spree.t(:options)),
70
+ make_cell(content: Spree.t(:qty))
71
+ ]
72
+ data = [header]
73
+
74
+ @order.line_items.each do |item|
75
+ row = [
76
+ item.variant.product.sku,
77
+ item.variant.product.name,
78
+ item.variant.options_text,
79
+ item.quantity
80
+ ]
81
+ data += [row]
82
+ end
83
+
84
+ table(data, header: true, position: :center, column_widths: [70, 300, 130, 40]) do
85
+ row(0).style align: :center, font_style: :bold
86
+ column(0..2).style align: :left
87
+ column(3).style align: :center
88
+ end
89
+
90
+ move_down 30
91
+ text Spree::PrintInvoice::Config[:anomaly_message], align: :left, size: 9
92
+
93
+ move_down 20
94
+ bounding_box([0, cursor], width: 540, height: 250) do
95
+ transparent(0.5) { stroke_bounds }
96
+ end
97
+ end
98
+
99
+ # FOOTER
100
+ if Spree::PrintInvoice::Config[:use_footer]
101
+ repeat(:all) do
102
+ grid([7,0], [7,4]).bounding_box do
103
+
104
+ data = []
105
+ data << [ make_cell(content: Spree.t(:vat, scope: :print_invoice) , colspan: 2, align: :center) ]
106
+ data << [ make_cell(content: '', colspan: 2) ]
107
+ data << [ make_cell(content: Spree::PrintInvoice::Config[:footer_left], align: :left),
108
+ make_cell(content: Spree::PrintInvoice::Config[:footer_right], align: :right) ]
109
+
110
+ table(data, position: :center, column_widths: [270, 270]) do
111
+ row(0..2).style borders: []
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ # PAGE NUMBER
118
+ if Spree::PrintInvoice::Config[:use_page_numbers]
119
+ string = "#{Spree.t(:page, scope: :print_invoice)} <page> #{Spree.t(:of, scope: :print_invoice)} <total>"
120
+ options = {
121
+ at: [bounds.right - 150, 0],
122
+ width: 150,
123
+ align: :right,
124
+ start_count_at: 1,
125
+ color: '000000'
126
+ }
127
+ number_pages string, options
128
+ end