print_clerk 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad9e7cf0f17dc36d825fc99fb43f8b53f163859f
4
+ data.tar.gz: d87357b5910bfb54c2f71aa5d9bfe092c0dda932
5
+ SHA512:
6
+ metadata.gz: c16b6dc8eb4715495c92b396e148fb67ae08f96a66fbf0bd93e50447c7ae8e83b4b8f6229f963280359b1887ad0d47661a93dca2efec08c4c289f4f03560a1ed
7
+ data.tar.gz: 14361cc2604235ad331f50a04d62534537c57cf8941ca3d3fa8a7ec2a19b98ff7d324148b2657c7572c7f78c2f1b435d200e162c3199b36d37e567cc7075f066
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ SUMMARY
2
+ =======
3
+
4
+ This extension provides a "Print Invoice" button on the Orders view screen which opens a printable html page with the order details.
5
+
6
+ You have to set up your computer for printing, or PDF generation. Off course, if you cave a mac that is as easy as pressing the print + save as pdf buttons.
7
+
8
+ INSTALLATION
9
+ ============
10
+
11
+ 1. To install you need to add the following lines to your Gemfile (no external dependencies)
12
+
13
+ gem 'print_clerk' , :git => 'https://github.com/rubyclerks/print_clerk.git'
14
+
15
+ 2. run bundler
16
+
17
+ bundle
18
+
19
+ 3. Configure your logo and footer text or more. It's easy as it's html.
20
+
21
+ 4. Enjoy!
22
+
23
+
24
+ Configuration
25
+ ==============
26
+
27
+ The templates are split into quite small chunks that you can just replace with your own.
28
+
29
+ Some texts are stored in locale files say print.yml
30
+
31
+ 1. Set the logo path preference to include your store / company logo.
32
+
33
+ invoice_logo_path: "company-logo.png"
34
+
35
+ Somewhere in your asset path
36
+
37
+ 2. Override any of the partial templates. they are address, footer, totals, header, thanks , and the items. The whole tanks is wrapped in a thanks hook, so replace or add at will.
38
+
39
+ 4. Enable packaging slips, by setting
40
+
41
+ print_buttons: "invoice,slip"
42
+
43
+ Use above feature for your own template if you want. For each button_name, define a subsection with header, print, and thanks, in your locale.
44
+
45
+
46
+ Extra
47
+ =====
48
+
49
+ There is now a receipt template, for a normal receipt printer (ie 70mm). This works for us, but what about you?
50
+
51
+ Contributions welcome
52
+
53
+ Torsten
Binary file
Binary file
@@ -0,0 +1,140 @@
1
+ div.a4 {
2
+ width: 620px;
3
+ font-size: 12px;
4
+ font-family: helvetica, verdana, serif;
5
+
6
+ }
7
+
8
+ img#logo {
9
+ width: 280px;
10
+ padding-bottom: 12px;
11
+ }
12
+
13
+ div.header {
14
+ width: 620px;
15
+ height: 100px;
16
+ }
17
+
18
+ div.address {
19
+ width: 620px;
20
+ border-top:1px solid grey;
21
+ margin-bottom: 10px;
22
+ padding: 6px;
23
+
24
+ }
25
+ .items {
26
+ width: 620px;
27
+ }
28
+
29
+ .items .price, .items .total {
30
+ text-align: right;
31
+ }
32
+
33
+ .items .qty {
34
+ text-align: center;
35
+ }
36
+
37
+ div.wrapper {
38
+ width: 620px;
39
+ height: 540px;
40
+ border-top:1px solid grey;
41
+ padding: 6px;
42
+
43
+ }
44
+
45
+ div.thanks {
46
+ width: 620px;
47
+ margin-top: 20px;
48
+ margin-bottom: 20px;
49
+ line-height: 10px;
50
+ }
51
+ div.spacer {
52
+ width: 620px;
53
+ }
54
+ div.totals {
55
+ height: 100px;
56
+ margin-bottom: 20px;
57
+ float: right;
58
+ }
59
+
60
+ .totals .cell {
61
+ width: 130px;
62
+ }
63
+
64
+ div.footer {
65
+ width: 620px;
66
+ border-top:1px solid grey;
67
+ padding: 6px;
68
+ }
69
+
70
+ .footer .bold {
71
+ width: 100px;
72
+ }
73
+ .footer .cell {
74
+ width: 220px;
75
+ }
76
+
77
+
78
+ .title { font-weight: bold; color: #FF9933; font-size: 18px; }
79
+ .bold { font-weight: bold; }
80
+ .price { width: 80px ; }
81
+
82
+ table.address{
83
+ width: 620px;
84
+ }
85
+ table.index th {
86
+ background: #cdcdcd top left repeat-x;
87
+ padding: 7px 10px;
88
+ border-left: 1px solid #ddd;
89
+ border-top: 1px solid #ddd;
90
+ border-right: 1px solid #aaa;
91
+ border-bottom: 1px solid #aaa;
92
+ text-shadow: #efefef 1px 1px 0px; }
93
+ table.index th .right {
94
+ float:right;
95
+ font-weight:normal;
96
+ }
97
+ table.index th.id-col {
98
+ text-align: center; }
99
+ table.index td {
100
+ border-bottom:1px solid #ddd;
101
+ padding: 3px 10px;
102
+ }
103
+ table.index td.lbl-col {
104
+ width: 12%; }
105
+ table.index td.val-col {
106
+ width: 38%; }
107
+ table.index tr.alt td {
108
+ background-color: #efefef; }
109
+ table.index.green th {
110
+ background: #cfefa7 top left repeat-x;
111
+ border-left: 1px solid #E4FDB4;
112
+ border-top: 1px solid #E4FDB4;
113
+ border-right: 1px solid #B7CB90;
114
+ border-bottom: 1px solid #B7CB90; }
115
+ table.index.green td {
116
+ background-color: #efe; }
117
+ table.index.order-summary {
118
+ clear: both; }
119
+ table.index.order-summary tr.totals th {
120
+ background: transparent;
121
+ text-align: right;
122
+ border: none; }
123
+ table.index td.actions {text-align:right;}
124
+
125
+ table.footer td{
126
+ line-height: 16px;
127
+ padding-bottom: 3px;
128
+ }
129
+
130
+
131
+ div.cod {
132
+ float: left;
133
+ background: black;
134
+ color: white;
135
+ font-size: 16px;
136
+ padding: 5px;
137
+ font-weight: bold;
138
+ }
139
+
140
+
@@ -0,0 +1,77 @@
1
+ @page {
2
+ margin-left:8mm;
3
+ margin-right:8mm;
4
+ margin-top:8mm;
5
+ margin-bottom:8mm;
6
+ }
7
+
8
+ body {
9
+ font-family:"Trebuchet MS";
10
+ font-size:32px;
11
+ color:#000000;
12
+ width: 700px;
13
+ }
14
+
15
+
16
+ div#header {
17
+ text-align: center;
18
+ padding: 6px;
19
+ line-height: 1.3;
20
+ width: 700px;
21
+ }
22
+
23
+ #header img {
24
+ max-width: 670px;
25
+ }
26
+
27
+ .shop { font-weight: bold; font-size: 40px; line-height: 1.2;}
28
+ .info { padding: 6px; font-size: 30px; text-align: center; line-height: 1.3; width: 700px;}
29
+
30
+ .line_items {
31
+ width: 700px;
32
+ }
33
+
34
+ div.wrapper {
35
+ width: 700px;
36
+ padding-top: 48px;
37
+ text-align: left;
38
+ }
39
+
40
+ div.totals {
41
+ margin-bottom: 20px;
42
+ padding: 6px;
43
+ }
44
+
45
+ table.totals {
46
+ width: 700px;
47
+ }
48
+
49
+
50
+ .cell.total {
51
+ text-align: right;
52
+ }
53
+
54
+ .cel1 {
55
+ width: 200px;
56
+ }
57
+
58
+ .cel2 {
59
+ width: 80px;
60
+ }
61
+
62
+
63
+ div.footer {
64
+ width: 700px;
65
+ padding: 6px;
66
+ text-align: center;
67
+ }
68
+
69
+ .footer .bold {
70
+ width: 100px;
71
+ }
72
+ .footer .cell {
73
+ width: 220px;
74
+ }
75
+
76
+
77
+
@@ -0,0 +1,30 @@
1
+ # encoding : utf-8
2
+ OrdersController.class_eval do
3
+
4
+ def invoice
5
+ load_order
6
+ @invoice = true
7
+ @template = "invoice"
8
+ render :layout => false
9
+ end
10
+
11
+ def receipt
12
+ load_order
13
+ render :layout => false
14
+ end
15
+
16
+ def slip
17
+ load_order
18
+ @slip = true
19
+ @template = "slip"
20
+ render "invoice" , :layout => false
21
+ end
22
+
23
+ def reminder
24
+ load_order
25
+ @reminder = true
26
+ @template = "reminder"
27
+ render "invoice" , :layout => false
28
+ end
29
+
30
+ end
@@ -0,0 +1,5 @@
1
+ #Deface::Override.new(:virtual_path => "spree/admin/shared/_order_tabs",
2
+ # :name => "add_html_invoice_buttons",
3
+ # :insert_after => ".sidebar",
4
+ # :partial => "spree/admin/orders/html_buttons",
5
+ # :disabled => false)
@@ -0,0 +1,4 @@
1
+ - buttons = t(:print_buttons) || "invoice"
2
+ - buttons = buttons.split(",").collect{|b| b.strip }
3
+ - buttons.each do |button|
4
+ = button_link_to(t(button.to_s+".print"), "/print/#{@order.number}/#{button}" , :target => "_blank")
@@ -0,0 +1,14 @@
1
+ - addresses = [ @order.name , @order.street, @order.city , @order.phone ]
2
+
3
+ %table.address
4
+ %tr
5
+ %td.billing_header.bold{:width => "45%"}= I18n.t(:address)
6
+ %td{:width => "17%"}
7
+ %td.shiping_header.bold{:width => "45%"}
8
+ - addresses.each do |row|
9
+ %tr
10
+ %td.cell{:height => "15px", :width => "45%"}
11
+ = row
12
+ %td{:width => "17%"}
13
+ %td.cell{:height => "15px", :width => "45%"}
14
+ = " "
@@ -0,0 +1,7 @@
1
+ %table.footer
2
+ %tr
3
+ %td.cel1.bold{:valign => "top"}= raw I18n.t(:footer_left)
4
+ %td.cel2.cell{:valign => "top"}= raw I18n.t(:footer_left2)
5
+ %td.cel3.bold{:valign => "top"}
6
+ = raw I18n.t(:footer_right)
7
+ %td.cel4.cell{:valign => "top"}= raw I18n.t(:footer_right2)
@@ -0,0 +1,9 @@
1
+ %table
2
+ %tr
3
+ %td{:width => "345"}= image_tag t(:invoice_logo_path) , :id => "logo"
4
+ %td{:width => "345"}
5
+ %div{:align => "right"}
6
+ %p.title= I18n.t("#{@template}.header")
7
+ %p.bold= I18n.t(:order_number).to_s + " " + @order.number
8
+ %p.bold
9
+ = I18n.l(@order.ordered_on.to_date) if @order.ordered_on
@@ -0,0 +1,24 @@
1
+ %table.items
2
+ %colgroup
3
+ %col/
4
+ %col/
5
+ %col.price/
6
+ %col.qty/
7
+ %col.total/
8
+ %tr
9
+ %td.sku.bold= t(:ean) unless @receipt
10
+ %td.desc.bold= t(:description)
11
+ %td.price.bold= t(:price) unless @receipt
12
+ %td.qty.bold
13
+ = t(:qty)
14
+ %td.total.bold= t(:total)
15
+ - @order.basket.items.each do |item|
16
+ %tr
17
+ %td.cell= item.product.ean unless @receipt
18
+ %td.cell
19
+ = item.product.fullname rescue item.product.name
20
+ - if item.discount > 0
21
+ (#{-item.discount}%)
22
+ %td.cell.price= number_to_currency(item.price) unless @receipt
23
+ %td.cell.qty= item.quantity
24
+ %td.cell.total= number_to_currency(item.price * item.quantity)
@@ -0,0 +1,18 @@
1
+ - base = @order.number[1 .. -1]
2
+ - viite = open("http://www1.nordea.fi/P636V/H636VTXT.asp?action=tekstiLista&lkm=1&alkuViite=#{base}&L=1").read[/\d+ \d+/]
3
+ - unless @slip
4
+ %table
5
+ %tr
6
+ %td{:colspan => "2"}
7
+ \ 
8
+ %tr
9
+ %td{:colspan => "2"}
10
+ Maksaessasi käytä viitenumeroa: #{viite}
11
+ %table.thanks_table
12
+ %tr
13
+ %td.cell{:cellspan => "2"}
14
+ %td.cell  
15
+ %tr
16
+ %td.thanks.cell{:cellspan => "2"}
17
+ = raw t("#{@template}.thanks" )
18
+ %td.cell  
@@ -0,0 +1,18 @@
1
+ %table.totals
2
+ %tr
3
+ %td.cel1.bold
4
+ = t(:item_total)
5
+ \:
6
+ %td.cel2.bold.cell{:align => "right"}= number_to_currency @order.total_price
7
+ - @order.taxes.each do |tax , value|
8
+ %tr
9
+ %td.cel1.bold
10
+ = "#{t(:vat)} #{tax}:"
11
+ %td.cel2.cell{:align => "right"}= number_to_currency value
12
+ %tr
13
+ %td.cel1.bold
14
+ %strong
15
+ = "#{t(:order_total)}:"
16
+ %td.cel2.cell{:align => "right"}
17
+ %strong
18
+ %span#summary-order-total= number_to_currency @order.total_price
@@ -0,0 +1,6 @@
1
+ %br/
2
+ www.auringostaitaan.fi
3
+ %br/
4
+ info@www.auringostaitaan.fi
5
+ %br/
6
+ puh 09- 621 7001
@@ -0,0 +1,9 @@
1
+ = image_tag "receipt-logo.gif"
2
+ %br/
3
+ %br/
4
+ .shop
5
+ Auringosta Itään, Kuusta Länteen
6
+ .info
7
+ Fredrikinkatu 19 (Viiskulma)
8
+ %br/
9
+ 00120 Helsinki
@@ -0,0 +1 @@
1
+ = render :partial => "orders/invoice_items"
@@ -0,0 +1,14 @@
1
+ %table.items
2
+ %colgroup
3
+ %col/
4
+ %col/
5
+ %tr
6
+ %td.sku.bold= t(:ean) unless @receipt
7
+ %td.desc.bold= t(:description)
8
+ %td.qty.bold= t(:qty)
9
+ - @order.basket.items.each do |item|
10
+ %tr
11
+ %td.cell= item.product.ean unless @receipt
12
+ %td.cell
13
+ = item.product.fullname rescue item.product.name
14
+ %td.cell.qty= item.quantity
@@ -0,0 +1,23 @@
1
+ !!!
2
+ %html{:xmlns => "http://www.w3.org/1999/xhtml"}
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}
5
+ = stylesheet_link_tag "print-invoice.css" , :media => "all"
6
+ %title= t("#{@template}.header")
7
+ %body
8
+ .a4
9
+ #header
10
+ = render :partial => "orders/invoice_header"
11
+ .address
12
+ = render :partial => "orders/invoice_address"
13
+ .wrapper
14
+ .items
15
+ = render :partial => "orders/#{@template}_items"
16
+ .thanks
17
+ = render :partial => "orders/invoice_thanks"
18
+ .spacer
19
+ \ 
20
+ .totals
21
+ = render :partial => "orders/invoice_totals" unless @slip
22
+ .footer
23
+ = render :partial => "orders/invoice_footer"
@@ -0,0 +1,52 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:charset => "utf-8"}
5
+ %title= t("receipt.header")
6
+ = stylesheet_link_tag "print-receipt", :media => "all"
7
+ %body{onload: "self.print()"}
8
+ .receipt
9
+ #header
10
+ = render :partial => "orders/receipt_header"
11
+ .info
12
+ - date = @order.ordered_on || @order.ordered_on
13
+ =l(date.to_date)
14
+ /
15
+ =t(:order)
16
+ =@order.number
17
+ %br/
18
+ .wrapper
19
+ .line_items
20
+ %table.line_items
21
+ %thead
22
+ %tr
23
+ %th Tuote
24
+ %th Määrä
25
+ %th Loppusumma
26
+ %tbody
27
+ - @order.basket.items.each do |i|
28
+ %tr
29
+ %td.cell= i.product.full_name
30
+ %td.cell.qty= i.quantity
31
+ %td.cell.total= euros i.total
32
+ .spacer
33
+  
34
+ .totals
35
+ %table.totals
36
+ %tbody
37
+ %tr
38
+ %td.cel1.bold
39
+ %strong= t(:order_total)
40
+ %td.cel2.cell{align: "right"}
41
+ %strong
42
+ %span#summary-order-total= euros @order.total_price
43
+ %tr
44
+ %td.cel1
45
+ %td.cel2
46
+ -@order.taxes.each do |tax_rate , amount|
47
+ %tr.total
48
+ %td.cel1.bold
49
+ = t(:vat) + " " + tax_rate.to_s + " % "
50
+ %td.cel2.cell{align: "right"}= euros amount
51
+ .footer
52
+ = render :partial => "orders/receipt_footer"
data/config/routes.rb ADDED
@@ -0,0 +1,10 @@
1
+ OfficeClerk::Application.routes.append do
2
+ resources :orders do
3
+ member do
4
+ get :invoice
5
+ get :receipt
6
+ get :slip
7
+ get :reminder
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ module PrintClerk
2
+ class Engine < Rails::Engine
3
+ engine_name 'print_clerk'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ initializer "print_invoice.assets.precompile", :after => "clerk.assets.precompile" do |app|
8
+ app.config.assets.precompile += [ "print-invoice.css", "print-receipt.css" ]
9
+ end
10
+
11
+ def self.activate
12
+ Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator.rb')) do |c|
13
+ Rails.configuration.cache_classes ? require(c) : load(c)
14
+ end
15
+
16
+ Dir.glob(File.join(File.dirname(__FILE__), '../app/overrides/*.rb')) do |c|
17
+ Rails.configuration.cache_classes ? require(c) : load(c)
18
+ end
19
+ end
20
+
21
+ config.to_prepare &method(:activate).to_proc
22
+ end
23
+ end
24
+
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: print_clerk
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - Torsten Ruger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: office_clerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - README.md
34
+ - app/assets/images/invoice_logo.jpg
35
+ - app/assets/images/receipt-logo.gif
36
+ - app/assets/stylesheets/print-invoice.css
37
+ - app/assets/stylesheets/print-receipt.css.scss
38
+ - app/controllers/orders_decorator.rb
39
+ - app/overrides/add_html_invoice_buttons.rb
40
+ - app/views/orders/_html_buttons.haml
41
+ - app/views/orders/_invoice_address.haml
42
+ - app/views/orders/_invoice_footer.haml
43
+ - app/views/orders/_invoice_header.haml
44
+ - app/views/orders/_invoice_items.haml
45
+ - app/views/orders/_invoice_thanks.haml
46
+ - app/views/orders/_invoice_totals.haml
47
+ - app/views/orders/_receipt_footer.haml
48
+ - app/views/orders/_receipt_header.haml
49
+ - app/views/orders/_reminder_items.haml
50
+ - app/views/orders/_slip_items.haml
51
+ - app/views/orders/invoice.haml
52
+ - app/views/orders/receipt.haml
53
+ - config/routes.rb
54
+ - lib/print_clerk.rb
55
+ homepage:
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.9.3
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements:
73
+ - none
74
+ rubyforge_project:
75
+ rubygems_version: 2.2.2
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Print invoices from an order
79
+ test_files: []