polish_invoicer 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 30aae34862581c0cf334768c5e69ed53441f4b9dc6c6cde5294798798d1d57f0
4
- data.tar.gz: b991b0506ae5cf5f26ac420c21109459b50b963de2e001e20bafbb2c892d3627
2
+ SHA1:
3
+ metadata.gz: 0fc8bf6fc56f4965b836ec978706298b87fe546c
4
+ data.tar.gz: 52143a033a9b5b28f3ba2fe679133483e7db345a
5
5
  SHA512:
6
- metadata.gz: 67189d35f8560f7d8518dcc42c06d04342f34976bb145bb121e38b01df79cd0fdc86e3eede9e92ffdafbf2f47a35022977e7c1e369f4a37586c57673e14e6ce2
7
- data.tar.gz: 53b2303d40daa51205c0c37e51790cb6abf43b154d6973908f57761f67a22c96ad9ba90f80e4397ba6b1b437be02bf37155870438039488c19f11d427e9f9f61
6
+ metadata.gz: 53519d2d129f94d734b08e11b0c42793fe31e00bc407dc205d242742bc876890c39c6b89e8cbdf51217b18c9856a77d2a0cf650df34891286d297559e20033cb
7
+ data.tar.gz: 475133fcbf1c2ea0a483560b953652c2f6cfc538d5ca4b2e2820786737fbc5bbe5ae47d6e67eca552f708451edc36999a8c5c64819e724aa14d6aac0f091680f
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Enabled: true
6
+ Max: 100
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.7
4
- - 2.3.4
5
- - 2.4.1
3
+ - 2.2.10
4
+ - 2.3.7
5
+ - 2.4.4
6
+ - 2.5.1
data/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # PolishInvoicer [![Code Climate](https://codeclimate.com/github/macuk/polish_invoicer.png)](https://codeclimate.com/github/macuk/polish_invoicer) [![Build Status](https://travis-ci.org/macuk/polish_invoicer.png?branch=master)](https://travis-ci.org/macuk/polish_invoicer)
2
2
 
3
- PolishInvoicer gem creates polish invoices and proforms as HTML or PDF files.
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
- Gem jest zgodny z nową [ustawą o podatku VAT](http://www.przepisy.gofin.pl/przepisy,2,32,32,670,,,ustawa-z-dnia-11032004-r-o-podatku-od-towarow-i-uslug.html), która weszła w życie z dniem 1 stycznia 2017.
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(net_value vat_value gross_value).each do |field|
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(trade_date create_date payment_date).each do |field|
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(net_value vat_value gross_value).each do |field|
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
- unless @invoice.price.is_a?(Numeric)
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
- unless Vat.valid?(@invoice.vat)
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
@@ -22,8 +22,6 @@ module PolishInvoicer
22
22
  rate != -1 ? rate : 0
23
23
  end
24
24
 
25
- private
26
-
27
25
  def self.hash
28
26
  h = {}
29
27
  rates.each do |r|
@@ -1,3 +1,3 @@
1
1
  module PolishInvoicer
2
- VERSION = '0.0.17'.freeze
2
+ VERSION = '0.0.18'.freeze
3
3
  end
@@ -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(A B)
38
+ @invoice.comments = %w[A B]
39
39
  data = Presenter.new(@invoice).data
40
- assert_equal %w(A B), data[:comments]
40
+ assert_equal %w[A B], data[:comments]
41
41
  end
42
42
 
43
43
  def test_vat
@@ -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 test_proforma_could_not_be_paid
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 test_seller_and_buyer_nip_presence
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.17
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-03-26 00:00:00.000000000 Z
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.7.6
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