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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/br_invoices_pdf/cfe/parser/cnpj.rb +15 -0
- data/lib/br_invoices_pdf/cfe/parser.rb +3 -1
- data/lib/br_invoices_pdf/cfe/renderer/base_renderer.rb +3 -2
- data/lib/br_invoices_pdf/cfe/renderer/header.rb +16 -8
- data/lib/br_invoices_pdf/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88244a31c52a4223162c3d18ca2379ee85a74bcd
|
4
|
+
data.tar.gz: b2c0d52ff91333ff71d2f45578c35a083ba8b86e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21914368acef8f81e21b87734dbc8a018e614c6dd0eb654db9d958195f4787ebd966260182312c243bcdb9c38a2569180de99108f8366fd0acd360f7d5acafe
|
7
|
+
data.tar.gz: ad7902f053f39847e56460aa418175b91d795a83e2cd03538a26d2a995cc88c3330b5f79734c6f80699365e78b2ab53b7a12c509f54a91b17cb10e3f2cefb358
|
data/CHANGELOG.md
CHANGED
@@ -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 = '%
|
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],
|
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,
|
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
|
21
|
-
cpf
|
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 :
|
31
|
+
private_class_method :identificator
|
24
32
|
|
25
|
-
def add_header_config(pdf, data,
|
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(
|
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
|
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.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-
|
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:
|
277
|
+
version: 1.3.1
|
277
278
|
requirements: []
|
278
279
|
rubyforge_project:
|
279
280
|
rubygems_version: 2.6.13
|