polish_invoicer 0.0.34 → 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: a28a6aa9425c98da6aa3779b3c1251438efcd6976f876448d6c2bab5acedf5d1
4
- data.tar.gz: b6f4c0ed789da7f1333fad67ebb02a624dc63545db19f314e6e7a209888f67ee
3
+ metadata.gz: 7841efb19f4004918611cfdf6285d00bea3eabb9b30668ed4c3c66a30beb051b
4
+ data.tar.gz: a0adea29111258609c515d5a3e7bb4fe918e450fbe0382ea6513663f128ec1da
5
5
  SHA512:
6
- metadata.gz: 1ef7113d42bb6cf1eb62b5cd6fab2dd5fd08612594618cf5d449fe18b796cc4686771293f8d4d5c9f4dcc667a39553ff4d8969a73e074b8b7cb06e969ec54ecf
7
- data.tar.gz: 3a6f869d6ff8618b83c9d2e97bedfab5231ab7aca08bf516a1a5e79882d9098c1dcdd5b811a483984530c5cda92409401d5d7225ad463c320ea13d7cb69163d6
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/.rubocop_todo.yml CHANGED
@@ -36,7 +36,7 @@ Metrics/AbcSize:
36
36
  # Offense count: 4
37
37
  # Configuration parameters: CountComments, CountAsOne.
38
38
  Metrics/ClassLength:
39
- Max: 196
39
+ Max: 220
40
40
 
41
41
  # Offense count: 14
42
42
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.10
1
+ 3.4.9
data/README.md CHANGED
@@ -95,6 +95,10 @@ invoice.save_to_pdf('/path/to/invoice.pdf')
95
95
  # wartość domyślna: false
96
96
  :reverse_charge # faktura z odwrotnym obciążeniem VAT (boolean)
97
97
  # wartość domyślna: false
98
+ :vat_cash_accounting # faktura z metodą kasową (boolean)
99
+ # wartość domyślna: false
100
+ :prepayment_invoice # faktura zaliczkowa (boolean)
101
+ # wartość domyślna: false
98
102
  :currency # waluta rozliczeniowa (string)
99
103
  # wartość domyślna: PLN
100
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',
@@ -3,37 +3,39 @@
3
3
  module PolishInvoicer
4
4
  class Invoice
5
5
  AVAILABLE_PARAMS = [
6
- :number, # numer faktury (string)
7
- :ksef_number, # numer faktury w KSeF (string)
8
- :ksef_qr_code_url, # adres URL kodu QR dla faktury w KSeF
9
- :create_date, # data wystawienia faktury (date)
10
- :trade_date, # data sprzedaży (date)
11
- :seller, # adres sprzedawcy (tablica stringów)
12
- :seller_nip, # NIP sprzedawcy (string)
13
- :buyer, # adres nabywcy (tablica stringów)
14
- :buyer_nip, # NIP nabywcy (string)
15
- :recipient, # odbiorca faktury (tablica stringów)
16
- :item_name, # nazwa usługi (string)
17
- :price, # cena w złotych (float)
18
- :price_paid, # kwota częściowego opłacenia faktury w złotych
19
- :gross_price, # znacznik rodzaju ceny (netto/brutto), domyślnie: true (boolean)
20
- :vat, # stawka vat, domyślnie: 23 (integer)
21
- :pkwiu, # numer PKWiU (string)
22
- :payment_type, # rodzaj płatności, domyślnie: 'Przelew' (string)
23
- :payment_date, # termin płatności (date)
24
- :comments, # uwagi (string lub tablica stringów)
25
- :paid, # znacznik opłacenia faktury, domyślnie: true (boolean)
26
- :footer, # treść umieszczana w stopce faktury (string)
27
- :proforma, # znacznik faktury pro-forma, domyślnie: false (boolean)
28
- :no_vat_reason, # podstawa prawna zwolnienia z VAT (string)
29
- :foreign_buyer, # nabywcą jest firma spoza Polski, domyślnie: false (boolean)
30
- :lang, # język na fakturze, domyślnie: zależny od ustawienia foreign_buyer
31
- # foreign_buyer = false => lang = 'pl'
32
- # foreign_buyer = true => lang = 'pl_en'
33
- # możliwe wartości: pl | pl_en | en | es
34
- :reverse_charge, # faktura z odwrotnym obciążeniem VAT
35
- :currency, # waluta rozliczeniowa, domyślnie: PLN (string)
36
- :exchange_rate # kurs waluty rozliczeniowej, domyślnie: 1.0000 (float)
6
+ :number, # numer faktury (string)
7
+ :ksef_number, # numer faktury w KSeF (string)
8
+ :ksef_qr_code_url, # adres URL kodu QR dla faktury w KSeF
9
+ :create_date, # data wystawienia faktury (date)
10
+ :trade_date, # data sprzedaży (date)
11
+ :seller, # adres sprzedawcy (tablica stringów)
12
+ :seller_nip, # NIP sprzedawcy (string)
13
+ :buyer, # adres nabywcy (tablica stringów)
14
+ :buyer_nip, # NIP nabywcy (string)
15
+ :recipient, # odbiorca faktury (tablica stringów)
16
+ :item_name, # nazwa usługi (string)
17
+ :price, # cena w złotych (float)
18
+ :price_paid, # kwota częściowego opłacenia faktury w złotych
19
+ :gross_price, # znacznik rodzaju ceny (netto/brutto), domyślnie: true (boolean)
20
+ :vat, # stawka vat, domyślnie: 23 (integer)
21
+ :pkwiu, # numer PKWiU (string)
22
+ :payment_type, # rodzaj płatności, domyślnie: 'Przelew' (string)
23
+ :payment_date, # termin płatności (date)
24
+ :comments, # uwagi (string lub tablica stringów)
25
+ :paid, # znacznik opłacenia faktury, domyślnie: true (boolean)
26
+ :footer, # treść umieszczana w stopce faktury (string)
27
+ :proforma, # znacznik faktury pro-forma, domyślnie: false (boolean)
28
+ :no_vat_reason, # podstawa prawna zwolnienia z VAT (string)
29
+ :foreign_buyer, # nabywcą jest firma spoza Polski, domyślnie: false (boolean)
30
+ :lang, # język na fakturze, domyślnie: zależny od ustawienia foreign_buyer
31
+ # foreign_buyer = false => lang = 'pl'
32
+ # foreign_buyer = true => lang = 'pl_en'
33
+ # możliwe wartości: pl | pl_en | en | es
34
+ :reverse_charge, # faktura z odwrotnym obciążeniem VAT
35
+ :vat_cash_accounting, # faktura z metodą kasową
36
+ :prepayment_invoice, # faktura zaliczkowa
37
+ :currency, # waluta rozliczeniowa, domyślnie: PLN (string)
38
+ :exchange_rate # kurs waluty rozliczeniowej, domyślnie: 1.0000 (float)
37
39
  ].freeze
38
40
 
39
41
  attr_accessor(*AVAILABLE_PARAMS, :template_path, :logger, :wkhtmltopdf_path, :wkhtmltopdf_command)
@@ -130,6 +132,8 @@ module PolishInvoicer
130
132
  @proforma = false
131
133
  @foreign_buyer = false
132
134
  @reverse_charge = false
135
+ @vat_cash_accounting = false
136
+ @prepayment_invoice = false
133
137
  @currency = 'PLN'
134
138
  @exchange_rate = 1.0000
135
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'
@@ -69,10 +70,17 @@ module PolishInvoicer
69
70
  unless [true, false].include?(@invoice.foreign_buyer)
70
71
  @errors[:foreign_buyer] = 'Znacznik zagranicznego nabywcy musi być podany jako boolean'
71
72
  end
73
+ unless [true, false].include?(@invoice.vat_cash_accounting)
74
+ @errors[:vat_cash_accounting] = 'Znacznik metody kasowej musi być podany jako boolean'
75
+ end
76
+ unless [true, false].include?(@invoice.prepayment_invoice)
77
+ @errors[:prepayment_invoice] = 'Znacznik faktury zaliczkowej musi być podany jako boolean'
78
+ end
72
79
  return if [true, false].include?(@invoice.reverse_charge)
73
80
 
74
81
  @errors[:reverse_charge] = 'Znacznik odwrotnego obciążenia VAT musi być podany jako boolean'
75
82
  end
83
+ # rubocop:enable Metrics/CyclomaticComplexity
76
84
 
77
85
  def check_dates
78
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.34'
4
+ VERSION = '0.0.36'
5
5
  end
data/test/invoice_test.rb CHANGED
@@ -14,6 +14,12 @@ module PolishInvoicer
14
14
  i = Invoice.new(number: '1/2014')
15
15
 
16
16
  assert_equal '1/2014', i.number
17
+ i = Invoice.new(vat_cash_accounting: true)
18
+
19
+ assert i.vat_cash_accounting
20
+ i = Invoice.new(prepayment_invoice: true)
21
+
22
+ assert i.prepayment_invoice
17
23
  end
18
24
 
19
25
  def test_set_unavailable_param
@@ -127,6 +133,8 @@ module PolishInvoicer
127
133
  assert_equal 'Przelew', i.payment_type
128
134
  assert i.paid
129
135
  refute i.proforma
136
+ refute i.vat_cash_accounting
137
+ refute i.prepayment_invoice
130
138
  end
131
139
 
132
140
  def test_raise_when_save_to_html_and_not_valid
@@ -15,6 +15,12 @@ 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
21
+ i.vat_cash_accounting = true
22
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting.pdf')
23
+ i.vat_cash_accounting = false
18
24
  i.recipient = ['Szkoła Podstawowa Nr 1', 'ul. Zielona 10', '81-222 Gdynia', 'Nr ewid: SP1/2017']
19
25
  i.save_to_pdf('/tmp/invoice-with-recipient.pdf')
20
26
  i.paid = false
@@ -33,9 +39,27 @@ i.save_to_pdf('/tmp/invoice-pkwiu-fv-reason.pdf')
33
39
  i.foreign_buyer = true
34
40
  i.lang = 'pl_en'
35
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
45
+ i.vat_cash_accounting = true
46
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-pl-en.pdf')
47
+ i.vat_cash_accounting = false
36
48
  i.reverse_charge = true
37
49
  i.save_to_pdf('/tmp/invoice-reverse-charge.pdf')
38
50
  i.lang = 'en'
51
+ i.prepayment_invoice = true
52
+ i.save_to_pdf('/tmp/invoice-prepayment-en.pdf')
53
+ i.prepayment_invoice = false
54
+ i.vat_cash_accounting = true
55
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-en.pdf')
56
+ i.vat_cash_accounting = false
39
57
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge.pdf')
40
58
  i.lang = 'es'
59
+ i.prepayment_invoice = true
60
+ i.save_to_pdf('/tmp/invoice-prepayment-es.pdf')
61
+ i.prepayment_invoice = false
41
62
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge-es.pdf')
63
+ i.vat_cash_accounting = true
64
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-es.pdf')
65
+ i.vat_cash_accounting = false
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__)
@@ -108,6 +108,20 @@ module PolishInvoicer
108
108
  check_ok(:proforma, false)
109
109
  end
110
110
 
111
+ def test_vat_cash_accounting_validation
112
+ check_error(:vat_cash_accounting)
113
+ check_error(:vat_cash_accounting, 'test')
114
+ check_ok(:vat_cash_accounting, true)
115
+ check_ok(:vat_cash_accounting, false)
116
+ end
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
+
111
125
  def test_proforma_not_paid
112
126
  @invoice.paid = true
113
127
  @invoice.proforma = true
data/test/writer_test.rb CHANGED
@@ -35,5 +35,51 @@ module PolishInvoicer
35
35
  assert_equal 'FakeLogger', writer.logger
36
36
  assert_equal 'wkhtmltopdf_fake_command', writer.wkhtmltopdf_command
37
37
  end
38
+
39
+ def test_vat_cash_accounting_note_in_templates
40
+ expected_label_per_lang = {
41
+ 'pl' => 'Metoda kasowa',
42
+ 'pl_en' => 'VAT cash accounting',
43
+ 'en' => 'VAT cash accounting',
44
+ 'es' => 'Contabilidad de caja de IVA'
45
+ }
46
+
47
+ expected_label_per_lang.each do |lang, label|
48
+ invoice = create_valid_invoice
49
+ invoice.lang = lang
50
+ invoice.vat_cash_accounting = true
51
+ path = "/tmp/test-vat-cash-accounting-#{lang}.html"
52
+
53
+ invoice.save_to_html(path)
54
+
55
+ assert_includes File.read(path), label
56
+ File.unlink(path)
57
+ end
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
38
84
  end
39
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,10 @@ 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
+
21
+ - if vat_cash_accounting
22
+ b VAT cash accounting
20
23
 
21
24
  .row
22
25
  .col-xs-6
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,10 @@ 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
+
21
+ - if vat_cash_accounting
22
+ b Contabilidad de caja de IVA
20
23
 
21
24
  .row
22
25
  .col-xs-6
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,10 @@ 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
+
21
+ - if vat_cash_accounting
22
+ b Metoda kasowa
20
23
 
21
24
  .row
22
25
  .col-xs-6
@@ -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,14 @@ 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
+
23
+ - if vat_cash_accounting
24
+ b Metoda kasowa
25
+ .small
26
+ em VAT cash accounting
22
27
 
23
28
  .row
24
29
  .col-xs-6
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.34
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Macuk
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubygems_version: 3.7.2
202
+ rubygems_version: 4.0.9
203
203
  specification_version: 4
204
204
  summary: Creates polish invoices and proforms as HTML or PDF files
205
205
  test_files: []