polish_invoicer 0.0.34 → 0.0.35

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: 5d9264ab4e0ba871b374cfdfd43cdf887426b8f9da6c17498cad7e9f3d02a8ea
4
+ data.tar.gz: 44eb2add8debce3cbf7fc32c7cd76a3d3f20dd4021621e161d0d189344ed7835
5
5
  SHA512:
6
- metadata.gz: 1ef7113d42bb6cf1eb62b5cd6fab2dd5fd08612594618cf5d449fe18b796cc4686771293f8d4d5c9f4dcc667a39553ff4d8969a73e074b8b7cb06e969ec54ecf
7
- data.tar.gz: 3a6f869d6ff8618b83c9d2e97bedfab5231ab7aca08bf516a1a5e79882d9098c1dcdd5b811a483984530c5cda92409401d5d7225ad463c320ea13d7cb69163d6
6
+ metadata.gz: 634fb2a77a974aaae43274d21874501945b590a3650d45ac4ceb873928f7af728b80fd52cd19d24b58d66250740462d7a00ebc4232fb74df632f214757533ba6
7
+ data.tar.gz: 3ea7b9b8da655dc18f0b5847c5480161d6bfc3af7d8330af7c54bee512872586dbbeffdf870a8e5097cc36b2859a7fd94fb3424fa10540ffec933fa9f9d339a5
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,8 @@ 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
98
100
  :currency # waluta rozliczeniowa (string)
99
101
  # wartość domyślna: PLN
100
102
  :exchange_rate # kurs waluty rozliczeniowej (float)
@@ -3,37 +3,38 @@
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
+ :currency, # waluta rozliczeniowa, domyślnie: PLN (string)
37
+ :exchange_rate # kurs waluty rozliczeniowej, domyślnie: 1.0000 (float)
37
38
  ].freeze
38
39
 
39
40
  attr_accessor(*AVAILABLE_PARAMS, :template_path, :logger, :wkhtmltopdf_path, :wkhtmltopdf_command)
@@ -130,6 +131,7 @@ module PolishInvoicer
130
131
  @proforma = false
131
132
  @foreign_buyer = false
132
133
  @reverse_charge = false
134
+ @vat_cash_accounting = false
133
135
  @currency = 'PLN'
134
136
  @exchange_rate = 1.0000
135
137
  @recipient = []
@@ -69,6 +69,9 @@ module PolishInvoicer
69
69
  unless [true, false].include?(@invoice.foreign_buyer)
70
70
  @errors[:foreign_buyer] = 'Znacznik zagranicznego nabywcy musi być podany jako boolean'
71
71
  end
72
+ unless [true, false].include?(@invoice.vat_cash_accounting)
73
+ @errors[:vat_cash_accounting] = 'Znacznik metody kasowej musi być podany jako boolean'
74
+ end
72
75
  return if [true, false].include?(@invoice.reverse_charge)
73
76
 
74
77
  @errors[:reverse_charge] = 'Znacznik odwrotnego obciążenia VAT musi być podany jako boolean'
@@ -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.35'
5
5
  end
data/test/invoice_test.rb CHANGED
@@ -14,6 +14,9 @@ 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
17
20
  end
18
21
 
19
22
  def test_set_unavailable_param
@@ -127,6 +130,7 @@ module PolishInvoicer
127
130
  assert_equal 'Przelew', i.payment_type
128
131
  assert i.paid
129
132
  refute i.proforma
133
+ refute i.vat_cash_accounting
130
134
  end
131
135
 
132
136
  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.vat_cash_accounting = true
19
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting.pdf')
20
+ i.vat_cash_accounting = false
18
21
  i.recipient = ['Szkoła Podstawowa Nr 1', 'ul. Zielona 10', '81-222 Gdynia', 'Nr ewid: SP1/2017']
19
22
  i.save_to_pdf('/tmp/invoice-with-recipient.pdf')
20
23
  i.paid = false
@@ -33,9 +36,18 @@ i.save_to_pdf('/tmp/invoice-pkwiu-fv-reason.pdf')
33
36
  i.foreign_buyer = true
34
37
  i.lang = 'pl_en'
35
38
  i.save_to_pdf('/tmp/invoice-foreign-buyer.pdf')
39
+ i.vat_cash_accounting = true
40
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-pl-en.pdf')
41
+ i.vat_cash_accounting = false
36
42
  i.reverse_charge = true
37
43
  i.save_to_pdf('/tmp/invoice-reverse-charge.pdf')
38
44
  i.lang = 'en'
45
+ i.vat_cash_accounting = true
46
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-en.pdf')
47
+ i.vat_cash_accounting = false
39
48
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge.pdf')
40
49
  i.lang = 'es'
41
50
  i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge-es.pdf')
51
+ i.vat_cash_accounting = true
52
+ i.save_to_pdf('/tmp/invoice-vat-cash-accounting-es.pdf')
53
+ i.vat_cash_accounting = false
@@ -108,6 +108,13 @@ 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
+
111
118
  def test_proforma_not_paid
112
119
  @invoice.paid = true
113
120
  @invoice.proforma = true
data/test/writer_test.rb CHANGED
@@ -35,5 +35,26 @@ 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
38
59
  end
39
60
  end
data/tpl/invoice-en.slim CHANGED
@@ -18,6 +18,9 @@ html
18
18
 
19
19
  h3 = "Invoice number #{number}"
20
20
 
21
+ - if vat_cash_accounting
22
+ b VAT cash accounting
23
+
21
24
  .row
22
25
  .col-xs-6
23
26
  h4 Seller
data/tpl/invoice-es.slim CHANGED
@@ -18,6 +18,9 @@ html
18
18
 
19
19
  h3 = "Factura No. #{number}"
20
20
 
21
+ - if vat_cash_accounting
22
+ b Contabilidad de caja de IVA
23
+
21
24
  .row
22
25
  .col-xs-6
23
26
  h4 Vendedor
data/tpl/invoice-pl.slim CHANGED
@@ -18,6 +18,9 @@ html
18
18
 
19
19
  h3 = "Faktura nr #{number}"
20
20
 
21
+ - if vat_cash_accounting
22
+ b Metoda kasowa
23
+
21
24
  .row
22
25
  .col-xs-6
23
26
  h4 Sprzedawca
@@ -20,6 +20,11 @@ html
20
20
  h6.small
21
21
  em = "Invoice number #{number}"
22
22
 
23
+ - if vat_cash_accounting
24
+ b Metoda kasowa
25
+ .small
26
+ em VAT cash accounting
27
+
23
28
  .row
24
29
  .col-xs-6
25
30
  h4 Sprzedawca
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.35
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: []