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 +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -1
- data/README.md +2 -0
- data/doc/invoice.rb +1 -0
- data/lib/polish_invoicer/invoice.rb +2 -0
- data/lib/polish_invoicer/validator.rb +5 -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/test_helper.rb +1 -1
- data/test/validator_test.rb +7 -0
- data/test/writer_test.rb +25 -0
- data/tpl/invoice-en.slim +2 -2
- data/tpl/invoice-es.slim +2 -2
- data/tpl/invoice-pl.slim +2 -2
- data/tpl/invoice-pl_en.slim +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7841efb19f4004918611cfdf6285d00bea3eabb9b30668ed4c3c66a30beb051b
|
|
4
|
+
data.tar.gz: a0adea29111258609c515d5a3e7bb4fe918e450fbe0382ea6513663f128ec1da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce0507874aed78cd6ee23153d427133ebd76a9b47fe46a69581730937ffce0b60a219e56e1bebf0df49b31c9310de4e3416cdd4d667e10facb3f2955d3968766
|
|
7
|
+
data.tar.gz: 7474c626f98a89cdb58e3f25e6dc2bd558ae78127593ef72b891ca684ee8eebbd8e7808961ce315fbf77a8fc5f65049b4d712c0b42bdb180824f15d2848907bf
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
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
|
@@ -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)
|
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
|
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.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
data/test/validator_test.rb
CHANGED
|
@@ -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
|
data/tpl/invoice-pl_en.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,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
|