polish_invoicer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/vat_test.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ module PolishInvoicer
4
+ class VatTest < MiniTest::Unit::TestCase
5
+ def test_valid
6
+ assert Vat.valid?(23)
7
+ assert Vat.valid?(0)
8
+ assert Vat.valid?(-1)
9
+ assert_equal false, Vat.valid?(123)
10
+ assert_equal false, Vat.valid?(-10)
11
+ assert_equal false, Vat.valid?('test')
12
+ end
13
+
14
+ def test_zw
15
+ assert Vat.zw?(-1)
16
+ assert_equal false, Vat.zw?(23)
17
+ end
18
+
19
+ def test_to_s
20
+ assert_equal '23%', Vat.to_s(23)
21
+ assert_equal '0%', Vat.to_s(0)
22
+ assert_equal 'zw.', Vat.to_s(-1)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+
4
+ module PolishInvoicer
5
+ class WriterTest < MiniTest::Unit::TestCase
6
+ def test_save_to_html
7
+ invoice = create_valid_invoice
8
+ writer = Writer.new(invoice)
9
+ path = '/tmp/test.html'
10
+ writer.save_to_html(path)
11
+ assert File.exists?(path)
12
+ File.unlink(path)
13
+ end
14
+
15
+ def test_save_to_pdf
16
+ invoice = create_valid_invoice
17
+ writer = Writer.new(invoice)
18
+ path = '/tmp/test.pdf'
19
+ writer.save_to_pdf(path)
20
+ assert File.exists?(path)
21
+ File.unlink(path)
22
+ end
23
+
24
+ def test_setting_additional_params
25
+ invoice = create_valid_invoice
26
+ invoice.template_path = 'tpl.slim'
27
+ invoice.logger = 'FakeLogger'
28
+ invoice.wkhtmltopdf_command = 'wkhtmltopdf_fake_command'
29
+ writer = Writer.new(invoice)
30
+ assert_equal 'tpl.slim', writer.template_path
31
+ assert_equal 'FakeLogger', writer.logger
32
+ assert_equal 'wkhtmltopdf_fake_command', writer.wkhtmltopdf_command
33
+ end
34
+ end
35
+ end
data/tpl/invoice.slim ADDED
@@ -0,0 +1,136 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta charset="utf-8"
5
+ link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"
6
+ title
7
+ = proforma ? 'Proforma' : 'Faktura'
8
+ = " nr #{number}"
9
+ css:
10
+ body, h1, h2, h3, h4, h5, h6 { font-family: verdana, helvetica, arial, sans-serif; }
11
+
12
+ body
13
+ .container
14
+
15
+ - if proforma
16
+ h5.text-center Proforma nie jest dowodem księgowym i nie należy jej księgować.
17
+
18
+ br
19
+ br
20
+
21
+ h2
22
+ = proforma ? 'Proforma' : 'Faktura'
23
+ h3
24
+ = "Nr #{number}"
25
+
26
+ br
27
+ br
28
+
29
+ .row
30
+ .col-xs-6
31
+ h4 Sprzedawca
32
+ - seller.each do |line|
33
+ = line
34
+ br
35
+ = "NIP: #{seller_nip}"
36
+ .col-xs-6
37
+ h4 Nabywca
38
+ - buyer.each do |line|
39
+ = line
40
+ br
41
+ = "NIP: #{buyer_nip}"
42
+
43
+ hr
44
+
45
+ .row
46
+ .col-xs-3
47
+ | Data wystawienia:
48
+ - unless proforma
49
+ br
50
+ | Wykonanie usługi:
51
+ .col-xs-3
52
+ = create_date
53
+ - unless proforma
54
+ br
55
+ = trade_date
56
+ .col-xs-3
57
+ | Termin płatności:
58
+ br
59
+ | Sposób zapłaty:
60
+ .col-xs-3
61
+ = payment_date
62
+ br
63
+ = payment_type
64
+
65
+ br
66
+ br
67
+
68
+ table.table.table-condensed
69
+ tr
70
+ th width="40%" Usługa
71
+ - if pkwiu
72
+ th.text-center width="1%" PKWiU
73
+ th.text-center width="7%" Ilość
74
+ th.text-center width="7%" Cena netto
75
+ th.text-center width="7%" Wart. netto
76
+ - unless proforma
77
+ th.text-center width="1%" VAT
78
+ th.text-center width="7%" Kwota VAT
79
+ th.text-center width="7%" Wart. brutto
80
+ tr
81
+ td = item_name
82
+ - if pkwiu
83
+ td.text-center = pkwiu
84
+ td.text-center
85
+ | 1&nbsp;usł.
86
+ td.text-center = net_value
87
+ td.text-center = net_value
88
+ - unless proforma
89
+ td.text-center = vat
90
+ td.text-center = vat_value
91
+ td.text-center = gross_value
92
+ tr
93
+ td colspan="#{pkwiu ? 3 : 2}"
94
+ | &nbsp;
95
+ th.text-center Razem
96
+ td.text-center = net_value
97
+ - unless proforma
98
+ td.text-center = vat
99
+ td.text-center = vat_value
100
+ th.text-center = gross_value
101
+
102
+ br
103
+
104
+ .row
105
+ .col-xs-3
106
+ b Razem do zapłaty:
107
+ br
108
+ | Zapłacono:
109
+ br
110
+ | Zostało do zapłaty:
111
+ .col-xs-3
112
+ b = "#{gross_value} zł"
113
+ br
114
+ - if paid
115
+ = "#{gross_value} zł"
116
+ - else
117
+ | 0,00 zł
118
+ br
119
+ - if paid
120
+ | 0,00 zł
121
+ - else
122
+ = "#{gross_value} zł"
123
+ - if comments.any?
124
+ .col-xs-6
125
+ b Uwagi:
126
+ br
127
+ - comments.each do |line|
128
+ = line
129
+ br
130
+
131
+ - if no_vat_reason
132
+ br
133
+ p
134
+ b Podstawa zwolnienia z podatku VAT:
135
+ br
136
+ = no_vat_reason
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: polish_invoicer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Macuk
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: slim2pdf
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.0.2
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.0.2
78
+ description: Creates polish invoices and proforms as HTML or PDF files
79
+ email:
80
+ - piotr@macuk.pl
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .travis.yml
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - doc/invoice.html
92
+ - doc/invoice.pdf
93
+ - doc/invoice.rb
94
+ - doc/proforma.html
95
+ - doc/proforma.pdf
96
+ - doc/proforma.rb
97
+ - lib/polish_invoicer.rb
98
+ - lib/polish_invoicer/invoice.rb
99
+ - lib/polish_invoicer/presenter.rb
100
+ - lib/polish_invoicer/validator.rb
101
+ - lib/polish_invoicer/vat.rb
102
+ - lib/polish_invoicer/version.rb
103
+ - lib/polish_invoicer/writer.rb
104
+ - polish_invoicer.gemspec
105
+ - test/invoice_test.rb
106
+ - test/presenter_test.rb
107
+ - test/test_helper.rb
108
+ - test/validator_test.rb
109
+ - test/vat_test.rb
110
+ - test/writer_test.rb
111
+ - tpl/invoice.slim
112
+ homepage: ''
113
+ licenses:
114
+ - MIT
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
127
+ hash: -4419558403918347538
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: -4419558403918347538
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.25
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Creates polish invoices and proforms as HTML or PDF files
143
+ test_files:
144
+ - test/invoice_test.rb
145
+ - test/presenter_test.rb
146
+ - test/test_helper.rb
147
+ - test/validator_test.rb
148
+ - test/vat_test.rb
149
+ - test/writer_test.rb