polish_invoicer 0.0.35 → 0.0.36

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d9264ab4e0ba871b374cfdfd43cdf887426b8f9da6c17498cad7e9f3d02a8ea
4
- data.tar.gz: 44eb2add8debce3cbf7fc32c7cd76a3d3f20dd4021621e161d0d189344ed7835
3
+ metadata.gz: 7841efb19f4004918611cfdf6285d00bea3eabb9b30668ed4c3c66a30beb051b
4
+ data.tar.gz: a0adea29111258609c515d5a3e7bb4fe918e450fbe0382ea6513663f128ec1da
5
5
  SHA512:
6
- metadata.gz: 634fb2a77a974aaae43274d21874501945b590a3650d45ac4ceb873928f7af728b80fd52cd19d24b58d66250740462d7a00ebc4232fb74df632f214757533ba6
7
- data.tar.gz: 3ea7b9b8da655dc18f0b5847c5480161d6bfc3af7d8330af7c54bee512872586dbbeffdf870a8e5097cc36b2859a7fd94fb3424fa10540ffec933fa9f9d339a5
6
+ metadata.gz: ce0507874aed78cd6ee23153d427133ebd76a9b47fe46a69581730937ffce0b60a219e56e1bebf0df49b31c9310de4e3416cdd4d667e10facb3f2955d3968766
7
+ data.tar.gz: 7474c626f98a89cdb58e3f25e6dc2bd558ae78127593ef72b891ca684ee8eebbd8e7808961ce315fbf77a8fc5f65049b4d712c0b42bdb180824f15d2848907bf
data/.gitignore CHANGED
@@ -15,3 +15,6 @@ test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
17
  /.idea
18
+ /bin
19
+ /.env*
20
+ opencode.json
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-minitest
3
3
  - rubocop-rake
4
4
 
data/README.md CHANGED
@@ -97,6 +97,8 @@ invoice.save_to_pdf('/path/to/invoice.pdf')
97
97
  # wartość domyślna: false
98
98
  :vat_cash_accounting # faktura z metodą kasową (boolean)
99
99
  # wartość domyślna: false
100
+ :prepayment_invoice # faktura zaliczkowa (boolean)
101
+ # wartość domyślna: false
100
102
  :currency # waluta rozliczeniowa (string)
101
103
  # wartość domyślna: PLN
102
104
  :exchange_rate # kurs waluty rozliczeniowej (float)
data/doc/invoice.rb CHANGED
@@ -20,6 +20,7 @@ invoice = PolishInvoicer::Invoice.new(
20
20
  gross_price: false,
21
21
  # proforma: true,
22
22
  # paid: false,
23
+ # prepayment_invoice: true,
23
24
  foreign_buyer: true,
24
25
  reverse_charge: true,
25
26
  currency: 'EUR',
@@ -33,6 +33,7 @@ module PolishInvoicer
33
33
  # możliwe wartości: pl | pl_en | en | es
34
34
  :reverse_charge, # faktura z odwrotnym obciążeniem VAT
35
35
  :vat_cash_accounting, # faktura z metodą kasową
36
+ :prepayment_invoice, # faktura zaliczkowa
36
37
  :currency, # waluta rozliczeniowa, domyślnie: PLN (string)
37
38
  :exchange_rate # kurs waluty rozliczeniowej, domyślnie: 1.0000 (float)
38
39
  ].freeze
@@ -132,6 +133,7 @@ module PolishInvoicer
132
133
  @foreign_buyer = false
133
134
  @reverse_charge = false
134
135
  @vat_cash_accounting = false
136
+ @prepayment_invoice = false
135
137
  @currency = 'PLN'
136
138
  @exchange_rate = 1.0000
137
139
  @recipient = []
@@ -57,6 +57,7 @@ module PolishInvoicer
57
57
  @errors[:buyer] = 'Nabywca musi być podany jako tablica stringów' unless @invoice.buyer.is_a?(Array)
58
58
  end
59
59
 
60
+ # rubocop:disable Metrics/CyclomaticComplexity
60
61
  def check_booleans
61
62
  unless [true, false].include?(@invoice.gross_price)
62
63
  @errors[:gross_price] = 'Znacznik rodzaju ceny musi być podany jako boolean'
@@ -72,10 +73,14 @@ module PolishInvoicer
72
73
  unless [true, false].include?(@invoice.vat_cash_accounting)
73
74
  @errors[:vat_cash_accounting] = 'Znacznik metody kasowej musi być podany jako boolean'
74
75
  end
76
+ unless [true, false].include?(@invoice.prepayment_invoice)
77
+ @errors[:prepayment_invoice] = 'Znacznik faktury zaliczkowej musi być podany jako boolean'
78
+ end
75
79
  return if [true, false].include?(@invoice.reverse_charge)
76
80
 
77
81
  @errors[:reverse_charge] = 'Znacznik odwrotnego obciążenia VAT musi być podany jako boolean'
78
82
  end
83
+ # rubocop:enable Metrics/CyclomaticComplexity
79
84
 
80
85
  def check_dates
81
86
  @errors[:create_date] = 'Data wystawienia musi być typu Date' unless @invoice.create_date.is_a?(Date)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PolishInvoicer
4
- VERSION = '0.0.35'
4
+ VERSION = '0.0.36'
5
5
  end
data/test/invoice_test.rb CHANGED
@@ -17,6 +17,9 @@ module PolishInvoicer
17
17
  i = Invoice.new(vat_cash_accounting: true)
18
18
 
19
19
  assert i.vat_cash_accounting
20
+ i = Invoice.new(prepayment_invoice: true)
21
+
22
+ assert i.prepayment_invoice
20
23
  end
21
24
 
22
25
  def test_set_unavailable_param
@@ -131,6 +134,7 @@ module PolishInvoicer
131
134
  assert i.paid
132
135
  refute i.proforma
133
136
  refute i.vat_cash_accounting
137
+ refute i.prepayment_invoice
134
138
  end
135
139
 
136
140
  def test_raise_when_save_to_html_and_not_valid
@@ -15,6 +15,9 @@ i = PolishInvoicer::Invoice.new(
15
15
  )
16
16
 
17
17
  i.save_to_pdf('/tmp/invoice-default.pdf')
18
+ i.prepayment_invoice = true
19
+ i.save_to_pdf('/tmp/invoice-prepayment.pdf')
20
+ i.prepayment_invoice = false
18
21
  i.vat_cash_accounting = true
19
22
  i.save_to_pdf('/tmp/invoice-vat-cash-accounting.pdf')
20
23
  i.vat_cash_accounting = false
@@ -36,17 +39,26 @@ i.save_to_pdf('/tmp/invoice-pkwiu-fv-reason.pdf')
36
39
  i.foreign_buyer = true
37
40
  i.lang = 'pl_en'
38
41
  i.save_to_pdf('/tmp/invoice-foreign-buyer.pdf')
42
+ i.prepayment_invoice = true
43
+ i.save_to_pdf('/tmp/invoice-prepayment-pl-en.pdf')
44
+ i.prepayment_invoice = false
39
45
  i.vat_cash_accounting = true
40
46
  i.save_to_pdf('/tmp/invoice-vat-cash-accounting-pl-en.pdf')
41
47
  i.vat_cash_accounting = false
42
48
  i.reverse_charge = true
43
49
  i.save_to_pdf('/tmp/invoice-reverse-charge.pdf')
44
50
  i.lang = 'en'
51
+ i.prepayment_invoice = true
52
+ i.save_to_pdf('/tmp/invoice-prepayment-en.pdf')
53
+ i.prepayment_invoice = false
45
54
  i.vat_cash_accounting = true
46
55
  i.save_to_pdf('/tmp/invoice-vat-cash-accounting-en.pdf')
47
56
  i.vat_cash_accounting = false
48
57
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge.pdf')
49
58
  i.lang = 'es'
59
+ i.prepayment_invoice = true
60
+ i.save_to_pdf('/tmp/invoice-prepayment-es.pdf')
61
+ i.prepayment_invoice = false
50
62
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge-es.pdf')
51
63
  i.vat_cash_accounting = true
52
64
  i.save_to_pdf('/tmp/invoice-vat-cash-accounting-es.pdf')
data/test/test_helper.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'simplecov'
4
4
  SimpleCov.start do
5
- add_filter '/test/'
5
+ skip '/test/'
6
6
  end
7
7
 
8
8
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
@@ -115,6 +115,13 @@ module PolishInvoicer
115
115
  check_ok(:vat_cash_accounting, false)
116
116
  end
117
117
 
118
+ def test_prepayment_invoice_validation
119
+ check_error(:prepayment_invoice)
120
+ check_error(:prepayment_invoice, 'test')
121
+ check_ok(:prepayment_invoice, true)
122
+ check_ok(:prepayment_invoice, false)
123
+ end
124
+
118
125
  def test_proforma_not_paid
119
126
  @invoice.paid = true
120
127
  @invoice.proforma = true
data/test/writer_test.rb CHANGED
@@ -56,5 +56,30 @@ module PolishInvoicer
56
56
  File.unlink(path)
57
57
  end
58
58
  end
59
+
60
+ def test_prepayment_invoice_header_in_templates
61
+ expected_labels_per_lang = {
62
+ 'pl' => ['Faktura zaliczkowa nr 1/2014'],
63
+ 'pl_en' => ['Faktura zaliczkowa nr 1/2014', 'Prepayment Invoice number 1/2014'],
64
+ 'en' => ['Prepayment Invoice number 1/2014'],
65
+ 'es' => ['Factura de anticipo No. 1/2014']
66
+ }
67
+
68
+ expected_labels_per_lang.each do |lang, labels|
69
+ invoice = create_valid_invoice
70
+ invoice.lang = lang
71
+ invoice.prepayment_invoice = true
72
+ path = "/tmp/test-prepayment-invoice-#{lang}.html"
73
+
74
+ invoice.save_to_html(path)
75
+
76
+ html = File.read(path)
77
+
78
+ labels.each do |label|
79
+ assert_includes html, label
80
+ end
81
+ File.unlink(path)
82
+ end
83
+ end
59
84
  end
60
85
  end
data/tpl/invoice-en.slim CHANGED
@@ -2,7 +2,7 @@ doctype html
2
2
  html
3
3
  head
4
4
  meta charset="utf-8"
5
- title = "Invoice number #{number}"
5
+ title = prepayment_invoice ? "Prepayment Invoice number #{number}" : "Invoice number #{number}"
6
6
  css:
7
7
  /*!
8
8
  * Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -16,7 +16,7 @@ html
16
16
  body
17
17
  .container
18
18
 
19
- h3 = "Invoice number #{number}"
19
+ h3 = prepayment_invoice ? "Prepayment Invoice number #{number}" : "Invoice number #{number}"
20
20
 
21
21
  - if vat_cash_accounting
22
22
  b VAT cash accounting
data/tpl/invoice-es.slim CHANGED
@@ -2,7 +2,7 @@ doctype html
2
2
  html
3
3
  head
4
4
  meta charset="utf-8"
5
- title = "Factura No. #{number}"
5
+ title = prepayment_invoice ? "Factura de anticipo No. #{number}" : "Factura No. #{number}"
6
6
  css:
7
7
  /*!
8
8
  * Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -16,7 +16,7 @@ html
16
16
  body
17
17
  .container
18
18
 
19
- h3 = "Factura No. #{number}"
19
+ h3 = prepayment_invoice ? "Factura de anticipo No. #{number}" : "Factura No. #{number}"
20
20
 
21
21
  - if vat_cash_accounting
22
22
  b Contabilidad de caja de IVA
data/tpl/invoice-pl.slim CHANGED
@@ -2,7 +2,7 @@ doctype html
2
2
  html
3
3
  head
4
4
  meta charset="utf-8"
5
- title = "Faktura nr #{number}"
5
+ title = prepayment_invoice ? "Faktura zaliczkowa nr #{number}" : "Faktura nr #{number}"
6
6
  css:
7
7
  /*!
8
8
  * Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -16,7 +16,7 @@ html
16
16
  body
17
17
  .container
18
18
 
19
- h3 = "Faktura nr #{number}"
19
+ h3 = prepayment_invoice ? "Faktura zaliczkowa nr #{number}" : "Faktura nr #{number}"
20
20
 
21
21
  - if vat_cash_accounting
22
22
  b Metoda kasowa
@@ -2,7 +2,7 @@ doctype html
2
2
  html
3
3
  head
4
4
  meta charset="utf-8"
5
- title = "Faktura nr #{number}"
5
+ title = prepayment_invoice ? "Faktura zaliczkowa nr #{number}" : "Faktura nr #{number}"
6
6
  css:
7
7
  /*!
8
8
  * Bootstrap v3.3.7 (http://getbootstrap.com)
@@ -16,9 +16,9 @@ html
16
16
  body
17
17
  .container
18
18
 
19
- h3 = "Faktura nr #{number}"
19
+ h3 = prepayment_invoice ? "Faktura zaliczkowa nr #{number}" : "Faktura nr #{number}"
20
20
  h6.small
21
- em = "Invoice number #{number}"
21
+ em = prepayment_invoice ? "Prepayment Invoice number #{number}" : "Invoice number #{number}"
22
22
 
23
23
  - if vat_cash_accounting
24
24
  b Metoda kasowa
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polish_invoicer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Macuk