polish_invoicer 0.0.33 → 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 +4 -4
- data/.rubocop_todo.yml +1 -1
- data/.ruby-version +1 -1
- data/README.md +3 -0
- data/lib/polish_invoicer/invoice.rb +39 -30
- data/lib/polish_invoicer/presenter.rb +1 -1
- data/lib/polish_invoicer/validator.rb +3 -0
- data/lib/polish_invoicer/version.rb +1 -1
- data/lib/polish_invoicer.rb +1 -0
- data/polish_invoicer.gemspec +1 -0
- data/test/invoice_test.rb +4 -0
- data/test/test_generator.rb +15 -1
- data/test/validator_test.rb +7 -0
- data/test/writer_test.rb +21 -0
- data/tpl/invoice-en.slim +15 -2
- data/tpl/invoice-es.slim +15 -2
- data/tpl/invoice-pl.slim +15 -2
- data/tpl/invoice-pl_en.slim +17 -5
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d9264ab4e0ba871b374cfdfd43cdf887426b8f9da6c17498cad7e9f3d02a8ea
|
|
4
|
+
data.tar.gz: 44eb2add8debce3cbf7fc32c7cd76a3d3f20dd4021621e161d0d189344ed7835
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
|
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.
|
|
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)
|
|
@@ -110,6 +112,7 @@ invoice.save_to_pdf('/path/to/invoice.pdf')
|
|
|
110
112
|
:footer, # treść umieszczana w stopce faktury (string)
|
|
111
113
|
:price_paid, # kwota częściowego opłacenia faktury w złotych (float)
|
|
112
114
|
:ksef_number, # numer faktury w KSeF (string)
|
|
115
|
+
:ksef_qr_code_url, # adres URL kodu QR dla faktury w KSeF (string)
|
|
113
116
|
|
|
114
117
|
### Parametry systemowe
|
|
115
118
|
|
|
@@ -3,36 +3,38 @@
|
|
|
3
3
|
module PolishInvoicer
|
|
4
4
|
class Invoice
|
|
5
5
|
AVAILABLE_PARAMS = [
|
|
6
|
-
:number,
|
|
7
|
-
:ksef_number,
|
|
8
|
-
:
|
|
9
|
-
:
|
|
10
|
-
:
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
21
|
-
:
|
|
22
|
-
:
|
|
23
|
-
:
|
|
24
|
-
:
|
|
25
|
-
:
|
|
26
|
-
:
|
|
27
|
-
:
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
:
|
|
35
|
-
:
|
|
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)
|
|
36
38
|
].freeze
|
|
37
39
|
|
|
38
40
|
attr_accessor(*AVAILABLE_PARAMS, :template_path, :logger, :wkhtmltopdf_path, :wkhtmltopdf_command)
|
|
@@ -113,6 +115,12 @@ module PolishInvoicer
|
|
|
113
115
|
proforma ? "proforma-#{template_lang}.slim" : "invoice-#{template_lang}.slim"
|
|
114
116
|
end
|
|
115
117
|
|
|
118
|
+
def qr_code_data_url
|
|
119
|
+
return unless ksef_qr_code_url
|
|
120
|
+
|
|
121
|
+
RQRCode::QRCode.new(ksef_qr_code_url).as_png(size: 220).to_data_url
|
|
122
|
+
end
|
|
123
|
+
|
|
116
124
|
private
|
|
117
125
|
|
|
118
126
|
def set_defaults
|
|
@@ -123,6 +131,7 @@ module PolishInvoicer
|
|
|
123
131
|
@proforma = false
|
|
124
132
|
@foreign_buyer = false
|
|
125
133
|
@reverse_charge = false
|
|
134
|
+
@vat_cash_accounting = false
|
|
126
135
|
@currency = 'PLN'
|
|
127
136
|
@exchange_rate = 1.0000
|
|
128
137
|
@recipient = []
|
|
@@ -33,7 +33,7 @@ module PolishInvoicer
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def copy_additional_params
|
|
36
|
-
%w[net_value vat_value gross_value exchanged_tax].each do |field|
|
|
36
|
+
%w[net_value vat_value gross_value exchanged_tax qr_code_data_url].each do |field|
|
|
37
37
|
@out[field.to_sym] = @invoice.send(field)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -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'
|
data/lib/polish_invoicer.rb
CHANGED
data/polish_invoicer.gemspec
CHANGED
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
|
data/test/test_generator.rb
CHANGED
|
@@ -9,10 +9,15 @@ i = PolishInvoicer::Invoice.new(
|
|
|
9
9
|
item_name: 'Jakiś długi tytuł i jeszcze jakieś informacje na różne tematy oraz dodatkowy komentarz w sprawie różnej.',
|
|
10
10
|
price: 123.45, payment_date: Date.today,
|
|
11
11
|
comments: 'Test uwag', footer: 'Stopka faktury plus tekst promocyjny',
|
|
12
|
-
seller_nip: '123-456-78-90', buyer_nip: '987-654-32-10'
|
|
12
|
+
seller_nip: '123-456-78-90', buyer_nip: '987-654-32-10',
|
|
13
|
+
ksef_number: '1234567890-20260211-0200C0785341-F8',
|
|
14
|
+
ksef_qr_code_url: 'https://qr-test.ksef.mf.gov.pl/invoice/1234567890/11-02-2026/vgAXyW8BGst1ply1ag8hwbZ84Qz4Fgi0GDw6r84u6Pg'
|
|
13
15
|
)
|
|
14
16
|
|
|
15
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
|
|
16
21
|
i.recipient = ['Szkoła Podstawowa Nr 1', 'ul. Zielona 10', '81-222 Gdynia', 'Nr ewid: SP1/2017']
|
|
17
22
|
i.save_to_pdf('/tmp/invoice-with-recipient.pdf')
|
|
18
23
|
i.paid = false
|
|
@@ -31,9 +36,18 @@ i.save_to_pdf('/tmp/invoice-pkwiu-fv-reason.pdf')
|
|
|
31
36
|
i.foreign_buyer = true
|
|
32
37
|
i.lang = 'pl_en'
|
|
33
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
|
|
34
42
|
i.reverse_charge = true
|
|
35
43
|
i.save_to_pdf('/tmp/invoice-reverse-charge.pdf')
|
|
36
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
|
|
37
48
|
i.save_to_pdf('/tmp/invoice-foreign-buyer-reverse-charge.pdf')
|
|
38
49
|
i.lang = 'es'
|
|
39
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
|
data/test/validator_test.rb
CHANGED
|
@@ -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,8 +18,8 @@ html
|
|
|
18
18
|
|
|
19
19
|
h3 = "Invoice number #{number}"
|
|
20
20
|
|
|
21
|
-
- if
|
|
22
|
-
|
|
21
|
+
- if vat_cash_accounting
|
|
22
|
+
b VAT cash accounting
|
|
23
23
|
|
|
24
24
|
.row
|
|
25
25
|
.col-xs-6
|
|
@@ -117,3 +117,16 @@ html
|
|
|
117
117
|
br
|
|
118
118
|
br
|
|
119
119
|
b Levy of VAT reverse charged to recipient of service (reverse charge)
|
|
120
|
+
|
|
121
|
+
- if ksef_number && ksef_qr_code_url
|
|
122
|
+
hr
|
|
123
|
+
.row
|
|
124
|
+
.col-xs-4
|
|
125
|
+
img src=qr_code_data_url
|
|
126
|
+
.col-xs-8
|
|
127
|
+
br
|
|
128
|
+
h4 KSeF
|
|
129
|
+
= ksef_number
|
|
130
|
+
br
|
|
131
|
+
br
|
|
132
|
+
a href=ksef_qr_code_url #{ksef_qr_code_url}
|
data/tpl/invoice-es.slim
CHANGED
|
@@ -18,8 +18,8 @@ html
|
|
|
18
18
|
|
|
19
19
|
h3 = "Factura No. #{number}"
|
|
20
20
|
|
|
21
|
-
- if
|
|
22
|
-
|
|
21
|
+
- if vat_cash_accounting
|
|
22
|
+
b Contabilidad de caja de IVA
|
|
23
23
|
|
|
24
24
|
.row
|
|
25
25
|
.col-xs-6
|
|
@@ -117,3 +117,16 @@ html
|
|
|
117
117
|
br
|
|
118
118
|
br
|
|
119
119
|
b Recaudación del IVA con cargo revertido al destinatario del servicio (cargo revertido)
|
|
120
|
+
|
|
121
|
+
- if ksef_number && ksef_qr_code_url
|
|
122
|
+
hr
|
|
123
|
+
.row
|
|
124
|
+
.col-xs-4
|
|
125
|
+
img src=qr_code_data_url
|
|
126
|
+
.col-xs-8
|
|
127
|
+
br
|
|
128
|
+
h4 KSeF
|
|
129
|
+
= ksef_number
|
|
130
|
+
br
|
|
131
|
+
br
|
|
132
|
+
a href=ksef_qr_code_url #{ksef_qr_code_url}
|
data/tpl/invoice-pl.slim
CHANGED
|
@@ -18,8 +18,8 @@ html
|
|
|
18
18
|
|
|
19
19
|
h3 = "Faktura nr #{number}"
|
|
20
20
|
|
|
21
|
-
- if
|
|
22
|
-
|
|
21
|
+
- if vat_cash_accounting
|
|
22
|
+
b Metoda kasowa
|
|
23
23
|
|
|
24
24
|
.row
|
|
25
25
|
.col-xs-6
|
|
@@ -135,3 +135,16 @@ html
|
|
|
135
135
|
b Podstawa zwolnienia z podatku VAT:
|
|
136
136
|
br
|
|
137
137
|
= no_vat_reason
|
|
138
|
+
|
|
139
|
+
- if ksef_number && ksef_qr_code_url
|
|
140
|
+
hr
|
|
141
|
+
.row
|
|
142
|
+
.col-xs-4
|
|
143
|
+
img src=qr_code_data_url
|
|
144
|
+
.col-xs-8
|
|
145
|
+
br
|
|
146
|
+
h4 KSeF
|
|
147
|
+
= ksef_number
|
|
148
|
+
br
|
|
149
|
+
br
|
|
150
|
+
a href=ksef_qr_code_url #{ksef_qr_code_url}
|
data/tpl/invoice-pl_en.slim
CHANGED
|
@@ -20,11 +20,10 @@ html
|
|
|
20
20
|
h6.small
|
|
21
21
|
em = "Invoice number #{number}"
|
|
22
22
|
|
|
23
|
-
- if
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
em
|
|
27
|
-
|
|
23
|
+
- if vat_cash_accounting
|
|
24
|
+
b Metoda kasowa
|
|
25
|
+
.small
|
|
26
|
+
em VAT cash accounting
|
|
28
27
|
|
|
29
28
|
.row
|
|
30
29
|
.col-xs-6
|
|
@@ -210,3 +209,16 @@ html
|
|
|
210
209
|
.small
|
|
211
210
|
em Basis for VAT exemption:
|
|
212
211
|
= no_vat_reason
|
|
212
|
+
|
|
213
|
+
- if ksef_number && ksef_qr_code_url
|
|
214
|
+
hr
|
|
215
|
+
.row
|
|
216
|
+
.col-xs-4
|
|
217
|
+
img src=qr_code_data_url
|
|
218
|
+
.col-xs-8
|
|
219
|
+
br
|
|
220
|
+
h4 KSeF
|
|
221
|
+
= ksef_number
|
|
222
|
+
br
|
|
223
|
+
br
|
|
224
|
+
a href=ksef_qr_code_url #{ksef_qr_code_url}
|
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.
|
|
4
|
+
version: 0.0.35
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Piotr Macuk
|
|
@@ -107,6 +107,20 @@ dependencies:
|
|
|
107
107
|
- - ">="
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
109
|
version: '0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: rqrcode
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
type: :runtime
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
110
124
|
- !ruby/object:Gem::Dependency
|
|
111
125
|
name: slim2pdf
|
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -185,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
185
199
|
- !ruby/object:Gem::Version
|
|
186
200
|
version: '0'
|
|
187
201
|
requirements: []
|
|
188
|
-
rubygems_version:
|
|
202
|
+
rubygems_version: 4.0.9
|
|
189
203
|
specification_version: 4
|
|
190
204
|
summary: Creates polish invoices and proforms as HTML or PDF files
|
|
191
205
|
test_files: []
|