br_danfe 0.17.1 → 0.17.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75c9447a1d0a80c9293026b9e0c746231a9e5763bfb7712d1c1c659f259aa0e9
4
- data.tar.gz: edb0a29145a0b5b5b08f0904e4fbf234901b98f250ad72ac8dd5134698badfe3
3
+ metadata.gz: 7d7ff47128c1eb8696ae40615a70cda26ce2a79e78e9e08ca4b87022a05e80a0
4
+ data.tar.gz: a69988df12809c67c14fd780c9f9863511113f954c4e1e18743eefd6c92e1bd7
5
5
  SHA512:
6
- metadata.gz: 142c384cef5410d88dfe2241cb6ceddaab6fbf36db23341e9ab584cb7f626ea9839618c0860f275e7b0d9512e2cc23ebc6e1ac19a38c71971a56f82d99892aa0
7
- data.tar.gz: 73bd5e390fcf3e8433aab1148f593db6361122379588195bbcae3aba0b82791657de02855a5b4724c05e8220e2a5287499e225ac150eb5f25958284f1a6d145c
6
+ metadata.gz: 2b7bb8b7db6a30564905827ee2c89e427db7d9ad6b771740f9c90f36140ef8705266f42dacc2dcf60981d828846f60ad2cf7064364f7688955b7fa8871218589
7
+ data.tar.gz: f473cd9b67ad5c62e21a1d0f152e8c951f4158c4a13ac17bb4f7f0df87734c924171d56f2504f81a48038fd76355b0e22d0c3931491855f110d5adf0fc24d277
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.17.1)
4
+ br_danfe (0.17.2)
5
5
  barby (= 0.6.8)
6
6
  br_documents (>= 0.1.3)
7
7
  i18n (>= 0.8.6)
@@ -12,7 +12,7 @@ module BrDanfe
12
12
  def render
13
13
  cursor = @pdf.cursor
14
14
 
15
- render_company_info(cursor)
15
+ render_company_info
16
16
  render_logo(cursor) if @logo.present?
17
17
  render_doc
18
18
 
@@ -21,15 +21,18 @@ module BrDanfe
21
21
 
22
22
  private
23
23
 
24
- def render_company_info(cursor)
24
+ def render_company_info
25
25
  one_line = 1
26
26
 
27
- @pdf.bounding_box([x_position, cursor], width: width_box, height: 65) do
28
- @pdf.text (@xml['emit/xNome']).to_s, size: 10, align: :left, style: :bold
29
- @pdf.text cnpj(@xml['emit/CNPJ']), size: 9, align: :left
30
- @pdf.text BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), size: 9, align: :left
31
- @pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
32
- end
27
+ @pdf.text_box (@xml['emit/xNome']).to_s, at: [x_position, @pdf.cursor], height: 36, size: 9, align: :left, style: :bold, overflow: :shrink_to_fit
28
+ @pdf.move_down 36
29
+
30
+ @pdf.text_box cnpj(@xml['emit/CNPJ']), at: [x_position, @pdf.cursor], height: 9, size: 9, align: :left, overflow: :shrink_to_fit
31
+ @pdf.move_down 9
32
+
33
+ @pdf.text_box BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), at: [x_position, @pdf.cursor], height: 20, size: 9, align: :left, overflow: :shrink_to_fit
34
+ @pdf.move_down 20
35
+ @pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
33
36
  end
34
37
 
35
38
  def x_position
@@ -60,9 +63,8 @@ module BrDanfe
60
63
 
61
64
  def render_doc
62
65
  @pdf.render_blank_line
63
- cursor = @pdf.cursor
64
66
 
65
- @pdf.bounding_box([0, cursor], width: 6.7.cm, height: 20) do
67
+ @pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
66
68
  @pdf.text 'Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica', size: 9, align: :center
67
69
  end
68
70
  end
@@ -70,8 +72,7 @@ module BrDanfe
70
72
  def render_homologation
71
73
  2.times { @pdf.render_blank_line }
72
74
 
73
- cursor = @pdf.cursor
74
- @pdf.bounding_box([0, cursor], width: 6.7.cm, height: 20) do
75
+ @pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
75
76
  @pdf.text 'EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO', size: 8, align: :center, style: :bold
76
77
  @pdf.text 'SEM VALOR FISCAL', size: 8, align: :center, style: :bold
77
78
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = '0.17.1'.freeze
2
+ VERSION = '0.17.2'.freeze
3
3
  end
@@ -52,6 +52,8 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
52
52
  File.delete(output_pdf) if File.exist?(output_pdf)
53
53
  end
54
54
 
55
+ after { File.delete(output_pdf) if File.exist?(output_pdf) }
56
+
55
57
  context 'when has a short name' do
56
58
  let(:company_name) { 'Test company' }
57
59
 
@@ -81,7 +83,7 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
81
83
  let(:company_name) { 'Test company with some very long name to do a line break' }
82
84
 
83
85
  context 'when has a logo' do
84
- it 'renders the header with company name line breaked' do
86
+ it 'renders the header with company name line breaked and shrinked to fit' do
85
87
  expect(File.exist?(output_pdf)).to be_falsey
86
88
  pdf.render_file output_pdf
87
89
 
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe BrDanfe::DanfeLib::Nfce do
4
- let(:output_pdf) { "#{base_dir}output.pdf" }
5
4
  let(:base_dir) { './spec/fixtures/nfce/v4.00/' }
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
  let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce.xml")) }
7
7
 
8
8
  subject { described_class.new [xml] }
@@ -15,6 +15,7 @@ describe BrDanfe::DanfeLib::Nfce do
15
15
  describe '#render_pdf' do
16
16
  it 'renders the NFC-e pdf' do
17
17
  expected = IO.binread("#{base_dir}rendered_nfce.fixture.pdf")
18
+
18
19
  expect(subject.render_pdf).to eq expected
19
20
  end
20
21
  end