br_invoices_pdf 0.2.5 → 0.2.6.alpha.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/br_invoices_pdf/cfe/parser/products_data.rb +1 -1
- data/lib/br_invoices_pdf/cfe/renderer/base_renderer.rb +6 -4
- data/lib/br_invoices_pdf/cfe/renderer/payment_forms.rb +3 -3
- data/lib/br_invoices_pdf/cfe/renderer/product_table.rb +4 -3
- data/lib/br_invoices_pdf/cfe/renderer/taxes_info.rb +2 -1
- data/lib/br_invoices_pdf/cfe/renderer/totals.rb +3 -3
- data/lib/br_invoices_pdf/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8466b5aa82c9ae365763684137f02215b387b78e
|
4
|
+
data.tar.gz: b740bfb2eedabf4db4ddb81489fb41a686295a59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7f98066dfbe83d0d6bd51fdc9ccf0b055ae919e5a0a6916da703eb441d86ca23ad4792ad57d58c4444c776a7382b9d7e27855a183c6c176f0e3065dac0b79f
|
7
|
+
data.tar.gz: 30d51244bf0f02fd8cb407422c6ff4b07a1eec0a1b3a09c2489e6deb2a83d5861ae820b6431ac2bc62ccae5ae878a9383ce5e1296322f70e7685efb6f9f17160
|
data/CHANGELOG.md
CHANGED
@@ -27,7 +27,7 @@ module BrInvoicesPdf
|
|
27
27
|
|
28
28
|
def product_by(element)
|
29
29
|
FIELDS
|
30
|
-
.map { |(key, field)| [key, node_locate(element, field)] }
|
30
|
+
.map { |(key, field)| [key, node_locate(element, field).force_encoding('UTF-8'.freeze)] }
|
31
31
|
.to_h
|
32
32
|
end
|
33
33
|
private_class_method :product_by
|
@@ -47,13 +47,15 @@ module BrInvoicesPdf
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# :reek:FeatureEnvy
|
50
|
-
def format_currency(
|
51
|
-
|
50
|
+
def format_currency(number_string)
|
51
|
+
number = BigDecimal(number_string)
|
52
|
+
format('%.2f', number.truncate(2)).tr('.', ',')
|
52
53
|
end
|
53
54
|
|
54
55
|
# :reek:FeatureEnvy
|
55
|
-
def format_number(
|
56
|
-
|
56
|
+
def format_number(number_string, prec: 4)
|
57
|
+
number = BigDecimal(number_string)
|
58
|
+
format("%.#{prec}f", number.truncate(prec)).tr('.', ',')
|
57
59
|
end
|
58
60
|
|
59
61
|
# :reek:FeatureEnvy
|
@@ -36,7 +36,7 @@ module BrInvoicesPdf
|
|
36
36
|
PAYMENTS_TABLE_BASE_DATA = [['FORMA DE PAGAMENTO', 'VALOR']].freeze
|
37
37
|
def payments_table_data(data)
|
38
38
|
payments_data = data[:payments].reduce(PAYMENTS_TABLE_BASE_DATA) do |result, cur|
|
39
|
-
result + [[cur[:type], format_currency(
|
39
|
+
result + [[cur[:type], format_currency(cur[:amount])]]
|
40
40
|
end
|
41
41
|
|
42
42
|
add_default_values(payments_data, data[:payment])
|
@@ -44,8 +44,8 @@ module BrInvoicesPdf
|
|
44
44
|
private_class_method :payments_table_data
|
45
45
|
|
46
46
|
def add_default_values(payments_data, data)
|
47
|
-
payments_data.push(['TROCO', format_currency(
|
48
|
-
payments_data.push(['TOTAL', format_currency(
|
47
|
+
payments_data.push(['TROCO', format_currency(data[:cashback])])
|
48
|
+
payments_data.push(['TOTAL', format_currency(data[:paid])])
|
49
49
|
end
|
50
50
|
private_class_method :add_default_values
|
51
51
|
end
|
@@ -49,15 +49,16 @@ module BrInvoicesPdf
|
|
49
49
|
private_class_method :table_widths
|
50
50
|
|
51
51
|
PRODUCT_TABLE_BASE_DATA = [['CÓD.', 'DESCRIÇÃO', 'QTD.', 'UND.', 'V.UNIT', 'V.TOT']].freeze
|
52
|
+
# :reek:FeatureEnvy
|
52
53
|
def product_table_data(data)
|
53
54
|
data[:products].reduce(PRODUCT_TABLE_BASE_DATA) do |result, cur|
|
54
55
|
result + [[
|
55
56
|
cur[:code],
|
56
57
|
cur[:description],
|
57
|
-
format_number(
|
58
|
+
format_number(cur[:quantity]),
|
58
59
|
cur[:unit_label],
|
59
|
-
format_currency(
|
60
|
-
format_currency(
|
60
|
+
format_currency(cur[:unit_value]),
|
61
|
+
format_currency(cur[:total_value])
|
61
62
|
]]
|
62
63
|
end
|
63
64
|
end
|
@@ -21,9 +21,10 @@ module BrInvoicesPdf
|
|
21
21
|
end
|
22
22
|
private_class_method :date_values
|
23
23
|
|
24
|
+
# :reek:FeatureEnvy
|
24
25
|
def tribute_values(pdf, payment)
|
25
26
|
pdf.text("Tributos\n\n", style: :italic)
|
26
|
-
value = format_currency(
|
27
|
+
value = format_currency(payment[:approximate_value_of_taxes])
|
27
28
|
text = "Informação dos tributos totais incidentes (Lei Federal 12.741/2012):\n R$ #{value}\n\n"
|
28
29
|
pdf.text(text, align: :center)
|
29
30
|
end
|
@@ -38,9 +38,9 @@ module BrInvoicesPdf
|
|
38
38
|
|
39
39
|
def box_info(data_payment)
|
40
40
|
[
|
41
|
-
['Total bruto dos itens', format_currency(
|
42
|
-
['Desconto', format_currency(
|
43
|
-
['Total', format_currency(
|
41
|
+
['Total bruto dos itens', format_currency(data_payment[:total_price])],
|
42
|
+
['Desconto', format_currency(data_payment[:discount])],
|
43
|
+
['Total', format_currency(data_payment[:total])]
|
44
44
|
]
|
45
45
|
end
|
46
46
|
private_class_method :box_info
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_invoices_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6.alpha.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Ribeiro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-09
|
12
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: prawn
|
@@ -272,9 +272,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
274
|
requirements:
|
275
|
-
- - "
|
275
|
+
- - ">"
|
276
276
|
- !ruby/object:Gem::Version
|
277
|
-
version:
|
277
|
+
version: 1.3.1
|
278
278
|
requirements: []
|
279
279
|
rubyforge_project:
|
280
280
|
rubygems_version: 2.6.13
|