polish_invoicer 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -0
- data/.travis.yml +4 -3
- data/README.md +3 -9
- data/lib/polish_invoicer/presenter.rb +3 -3
- data/lib/polish_invoicer/validator.rb +14 -6
- data/lib/polish_invoicer/vat.rb +0 -2
- data/lib/polish_invoicer/version.rb +1 -1
- data/test/presenter_test.rb +2 -2
- data/test/validator_test.rb +30 -24
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fc8bf6fc56f4965b836ec978706298b87fe546c
|
4
|
+
data.tar.gz: 52143a033a9b5b28f3ba2fe679133483e7db345a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53519d2d129f94d734b08e11b0c42793fe31e00bc407dc205d242742bc876890c39c6b89e8cbdf51217b18c9856a77d2a0cf650df34891286d297559e20033cb
|
7
|
+
data.tar.gz: 475133fcbf1c2ea0a483560b953652c2f6cfc538d5ca4b2e2820786737fbc5bbe5ae47d6e67eca552f708451edc36999a8c5c64819e724aa14d6aac0f091680f
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# PolishInvoicer [](https://codeclimate.com/github/macuk/polish_invoicer) [](https://travis-ci.org/macuk/polish_invoicer)
|
2
2
|
|
3
|
-
PolishInvoicer gem creates
|
4
|
-
Gem description will be in polish language because of specific case of this gem.
|
3
|
+
PolishInvoicer gem creates Polish invoices and proforms in HTML and PDF formats.
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
[Krótkie podsumowanie zmian w wystawianiu faktur](https://www.jzk.pl/2017).
|
5
|
+
Description is in Polish because of a specific case of this gem.
|
9
6
|
|
10
7
|
## Installation
|
11
8
|
|
@@ -130,10 +127,7 @@ invoice.valid?
|
|
130
127
|
puts invoice.errors.inspect
|
131
128
|
```
|
132
129
|
|
133
|
-
{
|
134
|
-
:vat=>"Stawka VAT spoza listy dopuszczalnych wartości",
|
135
|
-
:create_date=>"Data wystawienia nie może być późniejsza niż 15 dzień następnego miesiąca po wykonaniu usługi"
|
136
|
-
}
|
130
|
+
{ :vat=>"Stawka VAT spoza listy dopuszczalnych wartości" }
|
137
131
|
|
138
132
|
## Dodatkowe metody
|
139
133
|
|
@@ -31,13 +31,13 @@ module PolishInvoicer
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def copy_additional_params
|
34
|
-
%w
|
34
|
+
%w[net_value vat_value gross_value].each do |field|
|
35
35
|
@out[field.to_sym] = @invoice.send(field)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def format_dates
|
40
|
-
%w
|
40
|
+
%w[trade_date create_date payment_date].each do |field|
|
41
41
|
v = @invoice.send(field)
|
42
42
|
next unless v
|
43
43
|
@out[field.to_sym] = v.strftime '%d.%m.%Y'
|
@@ -45,7 +45,7 @@ module PolishInvoicer
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def format_prices
|
48
|
-
%w
|
48
|
+
%w[net_value vat_value gross_value].each do |field|
|
49
49
|
v = @invoice.send(field)
|
50
50
|
next unless v
|
51
51
|
@out[field.to_sym] = sprintf('%02.2f', v).tr('.', ',')
|
@@ -17,6 +17,7 @@ module PolishInvoicer
|
|
17
17
|
check_price
|
18
18
|
check_vat
|
19
19
|
check_proforma
|
20
|
+
check_create_and_payment_date
|
20
21
|
@errors.empty?
|
21
22
|
end
|
22
23
|
|
@@ -71,20 +72,20 @@ module PolishInvoicer
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def check_price
|
74
|
-
|
75
|
-
@errors[:price] = 'Cena musi być liczbą'
|
76
|
-
else
|
75
|
+
if @invoice.price.is_a?(Numeric)
|
77
76
|
@errors[:price] = 'Cena musi być liczbą dodatnią' unless @invoice.price > 0
|
77
|
+
else
|
78
|
+
@errors[:price] = 'Cena musi być liczbą'
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
82
|
def check_vat
|
82
|
-
|
83
|
-
@errors[:vat] = 'Stawka VAT spoza listy dopuszczalnych wartości'
|
84
|
-
else
|
83
|
+
if Vat.valid?(@invoice.vat)
|
85
84
|
if Vat.zw?(@invoice.vat) && blank?(@invoice.no_vat_reason)
|
86
85
|
@errors[:no_vat_reason] = 'Konieczne jest podanie podstawy prawnej zwolnienia z podatku VAT'
|
87
86
|
end
|
87
|
+
else
|
88
|
+
@errors[:vat] = 'Stawka VAT spoza listy dopuszczalnych wartości'
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
@@ -94,6 +95,13 @@ module PolishInvoicer
|
|
94
95
|
@errors[:paid] = 'Proforma nie może być opłacona'
|
95
96
|
end
|
96
97
|
|
98
|
+
def check_create_and_payment_date
|
99
|
+
return if @errors[:create_date]
|
100
|
+
return if @errors[:payment_date]
|
101
|
+
return if @invoice.create_date <= @invoice.payment_date
|
102
|
+
@errors[:payment_date] = 'Termin płatności musi być wcześniejszy niż data wystawienia'
|
103
|
+
end
|
104
|
+
|
97
105
|
def blank?(value)
|
98
106
|
value.to_s.strip == ''
|
99
107
|
end
|
data/lib/polish_invoicer/vat.rb
CHANGED
data/test/presenter_test.rb
CHANGED
@@ -35,9 +35,9 @@ module PolishInvoicer
|
|
35
35
|
@invoice.comments = 'Test'
|
36
36
|
data = Presenter.new(@invoice).data
|
37
37
|
assert_equal ['Test'], data[:comments]
|
38
|
-
@invoice.comments = %w
|
38
|
+
@invoice.comments = %w[A B]
|
39
39
|
data = Presenter.new(@invoice).data
|
40
|
-
assert_equal %w
|
40
|
+
assert_equal %w[A B], data[:comments]
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_vat
|
data/test/validator_test.rb
CHANGED
@@ -8,20 +8,6 @@ module PolishInvoicer
|
|
8
8
|
@invoice = OpenStruct.new
|
9
9
|
end
|
10
10
|
|
11
|
-
def check_error(field, value = nil)
|
12
|
-
@invoice.send("#{field}=", value)
|
13
|
-
v = Validator.new(@invoice)
|
14
|
-
v.valid?
|
15
|
-
assert v.errors[field]
|
16
|
-
end
|
17
|
-
|
18
|
-
def check_ok(field, value = nil)
|
19
|
-
@invoice.send("#{field}=", value)
|
20
|
-
v = Validator.new(@invoice)
|
21
|
-
v.valid?
|
22
|
-
assert_nil v.errors[field]
|
23
|
-
end
|
24
|
-
|
25
11
|
def test_number_validation
|
26
12
|
check_error(:number)
|
27
13
|
check_ok(:number, '1/2014')
|
@@ -110,7 +96,7 @@ module PolishInvoicer
|
|
110
96
|
check_ok(:proforma, false)
|
111
97
|
end
|
112
98
|
|
113
|
-
def
|
99
|
+
def test_proforma_not_paid
|
114
100
|
@invoice.paid = true
|
115
101
|
@invoice.proforma = true
|
116
102
|
v = Validator.new(@invoice)
|
@@ -122,21 +108,13 @@ module PolishInvoicer
|
|
122
108
|
assert_nil v.errors[:paid]
|
123
109
|
end
|
124
110
|
|
125
|
-
def
|
111
|
+
def test_nip_presence
|
126
112
|
check_error(:seller_nip)
|
127
113
|
check_ok(:buyer_nip)
|
128
114
|
check_ok(:seller_nip, '123')
|
129
115
|
check_ok(:buyer_nip, '123')
|
130
116
|
end
|
131
117
|
|
132
|
-
def check_dates_ok(create_date, trade_date, msg = nil)
|
133
|
-
@invoice.create_date = Date.parse(create_date)
|
134
|
-
@invoice.trade_date = Date.parse(trade_date)
|
135
|
-
v = Validator.new(@invoice)
|
136
|
-
v.valid?
|
137
|
-
assert_nil v.errors[:create_date], msg
|
138
|
-
end
|
139
|
-
|
140
118
|
def test_no_vat_reason_presence
|
141
119
|
@invoice.vat = 23
|
142
120
|
v = Validator.new(@invoice)
|
@@ -151,5 +129,33 @@ module PolishInvoicer
|
|
151
129
|
v.valid?
|
152
130
|
assert_nil v.errors[:no_vat_reason]
|
153
131
|
end
|
132
|
+
|
133
|
+
def test_create_and_payment_date
|
134
|
+
@invoice.create_date = Date.parse('2018-04-10')
|
135
|
+
@invoice.payment_date = Date.parse('2018-04-01')
|
136
|
+
v = Validator.new(@invoice)
|
137
|
+
v.valid?
|
138
|
+
assert v.errors[:payment_date]
|
139
|
+
@invoice.payment_date = Date.parse('2018-04-17')
|
140
|
+
v = Validator.new(@invoice)
|
141
|
+
v.valid?
|
142
|
+
assert_nil v.errors[:payment_date]
|
143
|
+
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
def check_error(field, value = nil)
|
148
|
+
@invoice.send("#{field}=", value)
|
149
|
+
v = Validator.new(@invoice)
|
150
|
+
v.valid?
|
151
|
+
assert v.errors[field]
|
152
|
+
end
|
153
|
+
|
154
|
+
def check_ok(field, value = nil)
|
155
|
+
@invoice.send("#{field}=", value)
|
156
|
+
v = Validator.new(@invoice)
|
157
|
+
v.valid?
|
158
|
+
assert_nil v.errors[field]
|
159
|
+
end
|
154
160
|
end
|
155
161
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polish_invoicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Macuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
105
106
|
- ".travis.yml"
|
106
107
|
- Gemfile
|
107
108
|
- LICENSE.txt
|
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
153
|
version: '0'
|
153
154
|
requirements: []
|
154
155
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.6.14.1
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Creates polish invoices and proforms as HTML or PDF files
|