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 +4 -4
- data/.rubocop_todo.yml +1 -1
- data/.ruby-version +1 -1
- data/README.md +2 -0
- data/lib/polish_invoicer/invoice.rb +33 -31
- data/lib/polish_invoicer/validator.rb +3 -0
- data/lib/polish_invoicer/version.rb +1 -1
- data/test/invoice_test.rb +4 -0
- data/test/test_generator.rb +12 -0
- data/test/validator_test.rb +7 -0
- data/test/writer_test.rb +21 -0
- data/tpl/invoice-en.slim +3 -0
- data/tpl/invoice-es.slim +3 -0
- data/tpl/invoice-pl.slim +3 -0
- data/tpl/invoice-pl_en.slim +5 -0
- metadata +2 -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)
|
|
@@ -3,37 +3,38 @@
|
|
|
3
3
|
module PolishInvoicer
|
|
4
4
|
class Invoice
|
|
5
5
|
AVAILABLE_PARAMS = [
|
|
6
|
-
:number,
|
|
7
|
-
:ksef_number,
|
|
8
|
-
:ksef_qr_code_url,
|
|
9
|
-
:create_date,
|
|
10
|
-
:trade_date,
|
|
11
|
-
:seller,
|
|
12
|
-
:seller_nip,
|
|
13
|
-
:buyer,
|
|
14
|
-
:buyer_nip,
|
|
15
|
-
:recipient,
|
|
16
|
-
:item_name,
|
|
17
|
-
:price,
|
|
18
|
-
:price_paid,
|
|
19
|
-
:gross_price,
|
|
20
|
-
:vat,
|
|
21
|
-
:pkwiu,
|
|
22
|
-
:payment_type,
|
|
23
|
-
:payment_date,
|
|
24
|
-
:comments,
|
|
25
|
-
:paid,
|
|
26
|
-
:footer,
|
|
27
|
-
:proforma,
|
|
28
|
-
:no_vat_reason,
|
|
29
|
-
:foreign_buyer,
|
|
30
|
-
:lang,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
:reverse_charge,
|
|
35
|
-
:
|
|
36
|
-
:
|
|
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'
|
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
|
@@ -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
|
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
data/tpl/invoice-es.slim
CHANGED
data/tpl/invoice-pl.slim
CHANGED
data/tpl/invoice-pl_en.slim
CHANGED
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
|
|
@@ -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:
|
|
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: []
|