br_invoices_pdf 0.2.4 → 0.2.5.alpha.16

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: 6497dbb88eaa1ddbe1402f648e3768451023a1d6
4
- data.tar.gz: 141d5ef03f5ba2e827ef6f2331cb5f6c4372bc73
3
+ metadata.gz: 88244a31c52a4223162c3d18ca2379ee85a74bcd
4
+ data.tar.gz: b2c0d52ff91333ff71d2f45578c35a083ba8b86e
5
5
  SHA512:
6
- metadata.gz: 833b95cb360a8e132abbc7e88d830d6aab2f3c1f8d0ae9a278f6963166641c43eac005751e584135021f4ae6dc7d9f5a1732ca0c37ab49881b0c1628b5a0b044
7
- data.tar.gz: 21ec40424b2320cf1f28b80ab785faee852e0715deb180a97569736573cc37d21d90dcae9c3be6458b4d37541362af573ff22e4da6180e84527b79e0a587095a
6
+ metadata.gz: c21914368acef8f81e21b87734dbc8a018e614c6dd0eb654db9d958195f4787ebd966260182312c243bcdb9c38a2569180de99108f8366fd0acd360f7d5acafe
7
+ data.tar.gz: ad7902f053f39847e56460aa418175b91d795a83e2cd03538a26d2a995cc88c3330b5f79734c6f80699365e78b2ab53b7a12c509f54a91b17cb10e3f2cefb358
data/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  ### Unreleased
6
6
 
7
+ ### 0.2.5 [2017-09-28]
8
+ - [Corrigido] CNPJ na CFE.
9
+
7
10
  ### 0.2.4 [2017-09-27]
8
11
  - [Corrigido] Tabela de produtos na CFE.
9
12
 
@@ -0,0 +1,15 @@
1
+ module BrInvoicesPdf
2
+ module Cfe
3
+ module Parser
4
+ module Cnpj
5
+ extend BaseParser
6
+
7
+ module_function
8
+
9
+ def execute(xml)
10
+ locate_element(xml, 'infCFe/dest/CNPJ')
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,6 +1,7 @@
1
1
  require 'br_invoices_pdf/cfe/parser/access_key'
2
2
  require 'br_invoices_pdf/cfe/parser/company_attributes'
3
3
  require 'br_invoices_pdf/cfe/parser/cpf'
4
+ require 'br_invoices_pdf/cfe/parser/cnpj'
4
5
  require 'br_invoices_pdf/cfe/parser/document_number'
5
6
  require 'br_invoices_pdf/cfe/parser/fisco_obs'
6
7
  require 'br_invoices_pdf/cfe/parser/payment'
@@ -22,7 +23,8 @@ module BrInvoicesPdf
22
23
  company_attributes: CompanyAttributes,
23
24
  fisco_obs: FiscoObs,
24
25
  access_key: AccessKey,
25
- cpf: Cpf
26
+ cpf: Cpf,
27
+ cnpj: Cnpj
26
28
  }.freeze
27
29
 
28
30
  def parse(xml)
@@ -33,10 +33,11 @@ module BrInvoicesPdf
33
33
  end
34
34
  end
35
35
 
36
- CNPJ_FORMAT = '%d.%d.%d/%d-%d'.freeze
36
+ CNPJ_FORMAT = '%02d.%03d.%03d/%04d-%02d'.freeze
37
37
  # :reek:FeatureEnvy
38
38
  def format_cnpj(cnpj)
39
- format(CNPJ_FORMAT, cnpj[0, 2], cnpj[2, 3], cnpj[5, 3], cnpj[8, 4], cnpj[12, 2])
39
+ format(CNPJ_FORMAT, cnpj[0, 2].to_i, cnpj[2, 3].to_i, cnpj[5, 3].to_i,
40
+ cnpj[8, 4].to_i, cnpj[12, 2].to_i)
40
41
  end
41
42
 
42
43
  CPF_FORMAT = '%d.%d.%d-%d'.freeze
@@ -8,24 +8,32 @@ module BrInvoicesPdf
8
8
 
9
9
  # :reek:FeatureEnvy
10
10
  def execute(pdf, data)
11
- cpf = cpf_vlue(data[:cpf])
12
-
13
11
  pdf_setup(pdf) do
14
- add_header_config(pdf, data, cpf)
12
+ add_header_config(pdf, data, identificator(data))
15
13
  end
16
14
 
17
15
  pdf.move_down(5)
18
16
  end
19
17
 
20
- def cpf_vlue(cpf)
21
- cpf ? 'CONSUMIDOR: ' + format_cpf(cpf) : 'CONSUMIDOR NAO IDENTIFICADO'
18
+ def identificator(data)
19
+ cpf = data[:cpf]
20
+ cnpj = data[:cnpj]
21
+ if cpf.to_s.empty?
22
+ if cnpj.to_s.empty?
23
+ 'CONSUMIDOR NAO IDENTIFICADO'
24
+ else
25
+ 'CONSUMIDOR: ' + format_cnpj(cnpj)
26
+ end
27
+ else
28
+ 'CONSUMIDOR: ' + format_cpf(cpf)
29
+ end
22
30
  end
23
- private_class_method :cpf_vlue
31
+ private_class_method :identificator
24
32
 
25
- def add_header_config(pdf, data, cpf)
33
+ def add_header_config(pdf, data, identificator)
26
34
  pdf.font('Helvetica', style: :bold)
27
35
  pdf.text("Extrato: #{data[:document_number]}", align: :center)
28
- pdf.text(cpf, align: :center)
36
+ pdf.text(identificator, align: :center)
29
37
  pdf.text('CUPOM FISCAL ELETRONICO - SAT', align: :center)
30
38
  pdf.font('Helvetica', style: :normal, align: :center)
31
39
  end
@@ -1,3 +1,3 @@
1
1
  module BrInvoicesPdf
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.5'.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.4
4
+ version: 0.2.5.alpha.16
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-27 00:00:00.000000000 Z
12
+ date: 2017-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn
@@ -235,6 +235,7 @@ files:
235
235
  - lib/br_invoices_pdf/cfe/parser.rb
236
236
  - lib/br_invoices_pdf/cfe/parser/access_key.rb
237
237
  - lib/br_invoices_pdf/cfe/parser/base_parser.rb
238
+ - lib/br_invoices_pdf/cfe/parser/cnpj.rb
238
239
  - lib/br_invoices_pdf/cfe/parser/company_attributes.rb
239
240
  - lib/br_invoices_pdf/cfe/parser/cpf.rb
240
241
  - lib/br_invoices_pdf/cfe/parser/document_number.rb
@@ -271,9 +272,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
272
  version: '0'
272
273
  required_rubygems_version: !ruby/object:Gem::Requirement
273
274
  requirements:
274
- - - ">="
275
+ - - ">"
275
276
  - !ruby/object:Gem::Version
276
- version: '0'
277
+ version: 1.3.1
277
278
  requirements: []
278
279
  rubyforge_project:
279
280
  rubygems_version: 2.6.13