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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 264791bb8fcde20e3ddf8c875557fcd02f2788e4
4
- data.tar.gz: 31f743a32327b3b060d4ba88116c2138425d1771
3
+ metadata.gz: 8466b5aa82c9ae365763684137f02215b387b78e
4
+ data.tar.gz: b740bfb2eedabf4db4ddb81489fb41a686295a59
5
5
  SHA512:
6
- metadata.gz: 4f88e67059ac0a958718070fa0149f776e327c2e0e2a4ec3825b6dd77e0762961f5283e1b4d3d2f27af629310a1080307ac471c71136217df533573f03b2bbcb
7
- data.tar.gz: 6718c6b16fe0c0dd7081fa1bbd494a24f76acdf2b043d91c904a67181433cfa6902f2573605f8642d8ffb1f2914387b69ef93dde1726bf0e58ab7c3508a9538d
6
+ metadata.gz: 5d7f98066dfbe83d0d6bd51fdc9ccf0b055ae919e5a0a6916da703eb441d86ca23ad4792ad57d58c4444c776a7382b9d7e27855a183c6c176f0e3065dac0b79f
7
+ data.tar.gz: 30d51244bf0f02fd8cb407422c6ff4b07a1eec0a1b3a09c2489e6deb2a83d5861ae820b6431ac2bc62ccae5ae878a9383ce5e1296322f70e7685efb6f9f17160
@@ -4,6 +4,10 @@
4
4
 
5
5
  ### Unreleased
6
6
 
7
+ ### 0.2.6 [2017-10-06]
8
+ - [Corrigido] Valores de CFE.
9
+ - [Corrigido] Encoding de produtos na CFE.
10
+
7
11
  ### 0.2.5 [2017-09-28]
8
12
  - [Corrigido] CNPJ na CFE.
9
13
 
@@ -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(num)
51
- num.truncate.to_s.reverse.split(/.../).join('.').reverse + format(',%02d', (num.frac * 100).truncate)
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(num, prec: 4)
56
- num.truncate.to_s + (prec > 0 ? format(",%0#{prec}d", (num.frac * 10**prec).truncate) : '')
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(BigDecimal(cur[:amount]))]]
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(BigDecimal(data[:cashback]))])
48
- payments_data.push(['TOTAL', format_currency(BigDecimal(data[:paid]))])
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(BigDecimal(cur[:quantity])),
58
+ format_number(cur[:quantity]),
58
59
  cur[:unit_label],
59
- format_currency(BigDecimal(cur[:unit_value])),
60
- format_currency(BigDecimal(cur[:total_value]))
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(BigDecimal(payment[:approximate_value_of_taxes]))
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(BigDecimal(data_payment[:total_price]))],
42
- ['Desconto', format_currency(BigDecimal(data_payment[:discount]))],
43
- ['Total', format_currency(BigDecimal(data_payment[:total]))]
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
@@ -1,3 +1,3 @@
1
1
  module BrInvoicesPdf
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
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.5
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-28 00:00:00.000000000 Z
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: '0'
277
+ version: 1.3.1
278
278
  requirements: []
279
279
  rubyforge_project:
280
280
  rubygems_version: 2.6.13