br_danfe 2.1.0 → 3.1.0
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 +4 -4
- data/.github/workflows/config.yml +19 -10
- data/.octocov.yml +18 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +23 -24
- data/config/locales/pt-BR.yml +4 -3
- data/fonts/Arimo-LICENSE.txt +118 -0
- data/fonts/arimo.ttf +0 -0
- data/fonts/arimo_bold.ttf +0 -0
- data/fonts/arimo_bold_italic.ttf +0 -0
- data/fonts/arimo_italic.ttf +0 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +1 -5
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +7 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +12 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +27 -14
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +34 -20
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +34 -17
- data/lib/br_danfe/danfe_lib/nfe_lib/entrega.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +8 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +4 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +30 -6
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +1 -1
- data/lib/br_danfe/document_builder.rb +7 -0
- data/lib/br_danfe/helper.rb +4 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/br_danfe/cce_lib/document_spec.rb +12 -0
- data/spec/br_danfe/danfe_lib/nfce_lib/document_spec.rb +12 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +12 -0
- data/spec/br_danfe/helper_spec.rb +25 -0
- data/spec/fixtures/nfe/lib/dest#render-v2.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-v3.10.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-v4.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_cpf.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_ie.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf +0 -0
- data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +1234 -1223
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +836 -771
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +613 -527
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +619 -534
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +609 -522
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +10032 -11157
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +9834 -10928
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +609 -522
- data/spec/fixtures/nfe/lib/det_body#render-with_entrega.pdf +620 -527
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +614 -539
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +4812 -5222
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +4454 -5414
- data/spec/fixtures/nfe/lib/document#lcnpj_cpf-blank.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lcnpj_cpf-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lcnpj_cpf-valid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-blank.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-valid.pdf +0 -0
- data/spec/fixtures/nfe/lib/dup#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/dup#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/emit_header#render-nfe_key.pdf +225 -251
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +225 -251
- data/spec/fixtures/nfe/lib/emit_header#render-with_cpf.pdf +222 -249
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +225 -251
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +223 -249
- data/spec/fixtures/nfe/lib/entrega#render-v2.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with-address-bigger.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with_cpf.pdf +0 -0
- data/spec/fixtures/nfe/lib/icmstot#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/icmstot#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-difal.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-extra_volume.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_complementary_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_dup_additional_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_fisco_additional_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_street_data.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-without_dup_additional_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic_vol#render-extra_volume.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_issqn.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-without_issqn.pdf +4 -4
- data/spec/fixtures/nfe/lib/ticket#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/ticket#render_with_dEmit.pdf +0 -0
- data/spec/fixtures/nfe/lib/ticket#render_with_dhEmit.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_0.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_1.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_2.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_3.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_4.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_9.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render-blank-boxes.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render.pdf +0 -0
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +1484 -1417
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +1481 -1407
- data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml.fixture.pdf +1544 -1451
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +4604 -6164
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +1091 -1005
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +4657 -6185
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +1492 -1449
- data/spec/fixtures/nfe/v3.10/multiples.xmls.on.the.same.pdf.pdf +5190 -5309
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +2684 -2771
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +4095 -5042
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +3704 -3901
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +11692 -13493
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +4569 -5591
- data/spec/spec_helper.rb +6 -6
- metadata +13 -9
- data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +0 -11
- data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +0 -28
|
@@ -2,6 +2,8 @@ module BrDanfe
|
|
|
2
2
|
module DanfeLib
|
|
3
3
|
module NfeLib
|
|
4
4
|
class EmitHeader
|
|
5
|
+
OPERATION_TYPE_BOX_LINE_WIDTH = 0.75
|
|
6
|
+
|
|
5
7
|
def initialize(pdf, xml, logo, logo_dimensions)
|
|
6
8
|
@pdf = pdf
|
|
7
9
|
@xml = xml
|
|
@@ -23,16 +25,16 @@ module BrDanfe
|
|
|
23
25
|
def company_box
|
|
24
26
|
@pdf.ibox 3.92, 7.46, 0.75, @y_position
|
|
25
27
|
@pdf.ibox 3.92, 7.46, 0.75, @y_position, '', @xml['emit/xNome'],
|
|
26
|
-
size:
|
|
28
|
+
size: 8, align: :center, border: 0, style: :bold
|
|
27
29
|
|
|
28
30
|
address_company
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def address_company
|
|
32
34
|
if @logo.blank?
|
|
33
|
-
@pdf.ibox 3.92, 7.46,
|
|
35
|
+
@pdf.ibox 3.92, 7.46, 0.75, @y_position + 1.46, '', address, align: :center, border: 0, leading: 2
|
|
34
36
|
else
|
|
35
|
-
@pdf.ibox 3.92, 4.7, 3.65, @y_position + 1.46, '', address,
|
|
37
|
+
@pdf.ibox 3.92, 4.7, 3.65, @y_position + 1.46, '', address, align: :left, border: 0, leading: 2
|
|
36
38
|
logo
|
|
37
39
|
end
|
|
38
40
|
end
|
|
@@ -67,35 +69,50 @@ module BrDanfe
|
|
|
67
69
|
@pdf.ibox 3.92, 2.08, 8.21, @y_position
|
|
68
70
|
|
|
69
71
|
@pdf.ibox 0.60, 2.08, 8.21, @y_position, '', 'DANFE',
|
|
70
|
-
size:
|
|
72
|
+
size: 8, align: :center, border: 0, style: :bold
|
|
71
73
|
|
|
74
|
+
@pdf.fill_color LABEL_COLOR
|
|
72
75
|
@pdf.ibox 1.20, 2.08, 8.21, @y_position + 0.60, '', I18n.t('danfe.others.danfe'),
|
|
73
|
-
size:
|
|
76
|
+
size: 4.5, align: :center, border: 0
|
|
77
|
+
@pdf.fill_color TEXT_COLOR
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
"#{@xml['ide/tpNF']} - " +
|
|
77
|
-
(@xml['ide/tpNF'] == '0' ? I18n.t('danfe.ide.tpNF.entry') : I18n.t('danfe.ide.tpNF.departure')),
|
|
78
|
-
size: 8, align: :center, border: 0
|
|
79
|
+
operation_type_box
|
|
79
80
|
|
|
80
|
-
@pdf.ibox
|
|
81
|
-
I18n.t('danfe.ide.
|
|
82
|
-
size:
|
|
81
|
+
@pdf.ibox 0.32, 2.08, 8.21, @y_position + 2.55, '',
|
|
82
|
+
I18n.t('danfe.ide.nNF', nNF: Helper.format_number(@xml['ide/nNF'])),
|
|
83
|
+
size: 5.5, align: :center, border: 0
|
|
84
|
+
@pdf.ibox 0.32, 2.08, 8.21, @y_position + 2.80, '',
|
|
85
|
+
I18n.t('danfe.ide.serie', serie: Helper.format_serie(@xml['ide/serie'])),
|
|
86
|
+
size: 5, align: :center, border: 0
|
|
83
87
|
|
|
84
88
|
@pdf.ibox 1.00, 2.08, 8.21, @y_position + 3.00, '',
|
|
85
89
|
I18n.t('danfe.others.page', current: page, total: total),
|
|
86
|
-
size:
|
|
90
|
+
size: 5, align: :center, valign: :center, border: 0
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def operation_type_box
|
|
94
|
+
@pdf.ibox 0.60, 1.50, 8.21, @y_position + 1.80, '',
|
|
95
|
+
"0 - #{I18n.t('danfe.ide.tpNF.entry')}\n1 - #{I18n.t('danfe.ide.tpNF.departure')}",
|
|
96
|
+
size: 5, valign: :center, border: 0
|
|
97
|
+
@pdf.line_width OPERATION_TYPE_BOX_LINE_WIDTH
|
|
98
|
+
@pdf.ibox 0.55, 0.55, 9.66, @y_position + 1.83, '', @xml['ide/tpNF'],
|
|
99
|
+
size: 6.5, align: :center, valign: :center
|
|
100
|
+
@pdf.line_width LINE_WIDTH
|
|
87
101
|
end
|
|
88
102
|
|
|
89
103
|
def access_key_box
|
|
90
104
|
@pdf.ibox 2.22, 10.02, 10.29, @y_position
|
|
91
105
|
@pdf.ibarcode 1.50, 8.00, 10.4010, @y_position + 1.90, @xml['infProt > chNFe']
|
|
92
106
|
@pdf.ibox 0.85, 10.02, 10.29, @y_position + 2.22, I18n.t('danfe.chNFe'),
|
|
93
|
-
@xml['infProt > chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '),
|
|
107
|
+
@xml['infProt > chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), size: 6.5, style: :bold,
|
|
108
|
+
align: :center
|
|
94
109
|
end
|
|
95
110
|
|
|
96
111
|
def sefaz_box
|
|
112
|
+
@pdf.fill_color LABEL_COLOR
|
|
97
113
|
@pdf.ibox 0.85, 10.02, 10.29, @y_position + 3.07, '', I18n.t('danfe.others.sefaz'),
|
|
98
|
-
|
|
114
|
+
valign: :center, size: 4.5
|
|
115
|
+
@pdf.fill_color TEXT_COLOR
|
|
99
116
|
end
|
|
100
117
|
|
|
101
118
|
def render_emit(y_position)
|
|
@@ -104,11 +121,11 @@ module BrDanfe
|
|
|
104
121
|
|
|
105
122
|
@pdf.lbox LINE_HEIGHT, 10.04, 0.75, y_first_line, @xml, 'ide/natOp'
|
|
106
123
|
@pdf.ibox LINE_HEIGHT, 9.52, 10.79, y_first_line, I18n.t('danfe.infProt'),
|
|
107
|
-
"#{@xml['infProt/nProt']} #{BrDanfe::Helper.format_datetime(@xml['infProt/dhRecbto'])}", align: :
|
|
124
|
+
"#{@xml['infProt/nProt']} #{BrDanfe::Helper.format_datetime(@xml['infProt/dhRecbto'])}", align: :right
|
|
108
125
|
|
|
109
126
|
@pdf.lie LINE_HEIGHT, 6.36, 0.75, y_second_line, @xml, 'enderEmit/UF', 'emit/IE'
|
|
110
127
|
@pdf.lie LINE_HEIGHT, 6.86, 7.11, y_second_line, @xml, 'enderDest/UF', 'emit/IEST'
|
|
111
|
-
@pdf.lcnpj_cpf LINE_HEIGHT, 6.34, 13.97, y_second_line, @xml, cnpj_cpf
|
|
128
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 6.34, 13.97, y_second_line, @xml, cnpj_cpf, align: :right
|
|
112
129
|
end
|
|
113
130
|
|
|
114
131
|
def cnpj_cpf
|
|
@@ -35,7 +35,7 @@ module BrDanfe
|
|
|
35
35
|
def render_line1
|
|
36
36
|
@pdf.lbox LINE_HEIGHT, 11.82, 0.75, @l1, @xml, 'entrega/xNome'
|
|
37
37
|
render_cnpj_cpf
|
|
38
|
-
@pdf.lie LINE_HEIGHT, 2.
|
|
38
|
+
@pdf.lie LINE_HEIGHT, 2.91, 17.40, @l1, @xml, 'entrega/UF', 'entrega/IE'
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def render_cnpj_cpf
|
|
@@ -46,7 +46,7 @@ module BrDanfe
|
|
|
46
46
|
def render_line2
|
|
47
47
|
@pdf.i18n_lbox LINE_HEIGHT, 11.82, 0.75, @l2, 'entrega.xLgr', address
|
|
48
48
|
@pdf.lbox LINE_HEIGHT, 4.37, 12.57, @l2, @xml, 'entrega/xBairro'
|
|
49
|
-
@pdf.i18n_lbox LINE_HEIGHT, 2.
|
|
49
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.91, 17.40, @l2, 'entrega.CEP', cep
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def address
|
|
@@ -66,7 +66,7 @@ module BrDanfe
|
|
|
66
66
|
def render_line3
|
|
67
67
|
@pdf.lbox LINE_HEIGHT, 15.05, 0.75, @l3, @xml, 'entrega/xMun'
|
|
68
68
|
@pdf.lbox LINE_HEIGHT, 1.14, 15.8, @l3, @xml, 'entrega/UF'
|
|
69
|
-
@pdf.i18n_lbox LINE_HEIGHT, 2.
|
|
69
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.91, 17.40, @l3, 'entrega.fone', phone
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def phone
|
|
@@ -6,6 +6,14 @@ module BrDanfe
|
|
|
6
6
|
29.7.cm - y
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
def self.format_number(number)
|
|
10
|
+
number.to_s.rjust(9, '0').scan(/\d{3}/).join('.')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.format_serie(serie)
|
|
14
|
+
serie.to_s.rjust(3, '0')
|
|
15
|
+
end
|
|
16
|
+
|
|
9
17
|
def self.format_date(xml_datetime)
|
|
10
18
|
formated = ''
|
|
11
19
|
|
|
@@ -7,7 +7,7 @@ module BrDanfe
|
|
|
7
7
|
def initialize(pdf, xml)
|
|
8
8
|
@pdf = pdf
|
|
9
9
|
@xml = xml
|
|
10
|
-
@title_position = Y_POSITION - 0.
|
|
10
|
+
@title_position = Y_POSITION - 0.42
|
|
11
11
|
@y_position = Y_POSITION
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -26,7 +26,7 @@ module BrDanfe
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def render_subtitle
|
|
29
|
-
@pdf.ibox 2.65, 12.45, 0.75, @y_position, I18n.t('danfe.infAdic.infCpl'), '',
|
|
29
|
+
@pdf.ibox 2.65, 12.45, 0.75, @y_position, I18n.t('danfe.infAdic.infCpl'), '', label_size: 4.5
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def render_volumes
|
|
@@ -35,7 +35,7 @@ module BrDanfe
|
|
|
35
35
|
|
|
36
36
|
def render_additional_data(y_position)
|
|
37
37
|
data = generate_additional_data
|
|
38
|
-
@pdf.ibox 2.65, 12.45, 0.75, y_position, '', data, size:
|
|
38
|
+
@pdf.ibox 2.65, 12.45, 0.75, y_position, '', data, size: 5, valign: :top, border: 0
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def generate_additional_data
|
|
@@ -120,7 +120,7 @@ module BrDanfe
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
def render_reserved_fisco
|
|
123
|
-
@pdf.ibox 2.65, 7.
|
|
123
|
+
@pdf.ibox 2.65, 7.11, 13.20, @y_position, I18n.t('danfe.infAdic.reserved'), '', label_size: 4.5
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -7,18 +7,42 @@ module BrDanfe
|
|
|
7
7
|
@xml = xml
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
CUT_LINE_Y_POSITION = 3.75
|
|
11
|
+
CUT_LINE_WIDTH = 0.48
|
|
12
|
+
CUT_LINE_COLOR = '888888'.freeze
|
|
13
|
+
|
|
10
14
|
def render
|
|
11
15
|
render_additional_data
|
|
12
|
-
@pdf.ibox 0.85, 3.85, 0.75, 2.7, I18n.t('danfe.ticket.received_at')
|
|
13
|
-
@pdf.ibox 0.85, 11.75, 4.60, 2.7, I18n.t('danfe.ticket.receiver')
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
align: :center, valign: :center
|
|
16
|
+
@pdf.ibox 0.85, 3.85, 0.75, 2.7, I18n.t('danfe.ticket.received_at'), '', label_size: 5
|
|
17
|
+
@pdf.ibox 0.85, 11.75, 4.60, 2.7, I18n.t('danfe.ticket.receiver'), '', label_size: 5
|
|
18
|
+
render_document
|
|
19
|
+
render_cut_line
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def render_additional_data
|
|
20
23
|
data = generate_additional_data
|
|
21
|
-
@pdf.ibox 0.85, 15.60, 0.75, 1.85, '', data, size:
|
|
24
|
+
@pdf.ibox 0.85, 15.60, 0.75, 1.85, '', data, size: 5.5, style: :bold, valign: :center
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def render_document
|
|
28
|
+
@pdf.ibox 1.70, 3.96, 16.35, 1.85
|
|
29
|
+
@pdf.ibox 0.40, 3.96, 16.35, 2.30, '', I18n.t('danfe.ticket.title'),
|
|
30
|
+
size: 8, align: :center, border: 0, style: :bold
|
|
31
|
+
@pdf.ibox 0.32, 3.96, 16.35, 2.68, '', I18n.t('danfe.ide.nNF', nNF: Helper.format_number(@xml['ide/nNF'])),
|
|
32
|
+
size: 5.5, align: :center, border: 0
|
|
33
|
+
@pdf.ibox 0.32, 3.96, 16.35, 2.90, '', I18n.t('danfe.ide.serie', serie: Helper.format_serie(@xml['ide/serie'])),
|
|
34
|
+
size: 5.5, align: :center, border: 0
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def render_cut_line
|
|
38
|
+
y = Helper.invert(CUT_LINE_Y_POSITION.cm)
|
|
39
|
+
@pdf.line_width CUT_LINE_WIDTH
|
|
40
|
+
@pdf.stroke_color CUT_LINE_COLOR
|
|
41
|
+
@pdf.dash [1.44, 0.48]
|
|
42
|
+
@pdf.stroke_line [0.75.cm, y], [(0.75 + CONTENT_WIDTH).cm, y]
|
|
43
|
+
@pdf.undash
|
|
44
|
+
@pdf.stroke_color TEXT_COLOR
|
|
45
|
+
@pdf.line_width LINE_WIDTH
|
|
22
46
|
end
|
|
23
47
|
|
|
24
48
|
def generate_additional_data
|
|
@@ -25,11 +25,11 @@ module BrDanfe
|
|
|
25
25
|
@pdf.lbox LINE_HEIGHT, 1.78, 12.06, @l1, @xml, 'veicTransp/RNTC'
|
|
26
26
|
@pdf.i18n_lbox LINE_HEIGHT, 2.29, 13.84, @l1, 'veicTransp.placa', plate
|
|
27
27
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l1, @xml, 'veicTransp/UF'
|
|
28
|
-
@pdf.lcnpj_cpf LINE_HEIGHT, 3.
|
|
28
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 3.42, 16.89, @l1, @xml, 'transporta/CNPJ'
|
|
29
29
|
@pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l2, @xml, 'transporta/xEnder'
|
|
30
30
|
@pdf.lbox LINE_HEIGHT, 6.86, 9.27, @l2, @xml, 'transporta/xMun'
|
|
31
31
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l2, @xml, 'transporta/UF'
|
|
32
|
-
@pdf.lie LINE_HEIGHT, 3.
|
|
32
|
+
@pdf.lie LINE_HEIGHT, 3.42, 16.89, @l2, @xml, 'transporta/UF', 'transporta/IE'
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
private
|
|
@@ -36,7 +36,7 @@ module BrDanfe
|
|
|
36
36
|
@pdf.ibox 0.85, 3.05, 6.22, @l1, I18n.t('danfe.vol.marca'), det.css('marca').text
|
|
37
37
|
@pdf.ibox 0.85, 4.83, 9.27, @l1, I18n.t('danfe.vol.nVol')
|
|
38
38
|
@pdf.inumeric 0.85, 3.43, 14.10, @l1, 'vol.pesoB', det.css('pesoB').text, decimals: 3
|
|
39
|
-
@pdf.inumeric 0.85, 2.
|
|
39
|
+
@pdf.inumeric 0.85, 2.78, 17.53, @l1, 'vol.pesoL', det.css('pesoL').text, decimals: 3
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def render_blank_boxes
|
|
@@ -10,6 +10,13 @@ module BrDanfe
|
|
|
10
10
|
normal: "#{BrDanfe.root_path}/fonts/tinos.ttf"
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
document.font_families['arimo'] = {
|
|
14
|
+
bold: "#{BrDanfe.root_path}/fonts/arimo_bold.ttf",
|
|
15
|
+
italic: "#{BrDanfe.root_path}/fonts/arimo_italic.ttf",
|
|
16
|
+
bold_italic: "#{BrDanfe.root_path}/fonts/arimo_bold_italic.ttf",
|
|
17
|
+
normal: "#{BrDanfe.root_path}/fonts/arimo.ttf"
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
document
|
|
14
21
|
end
|
|
15
22
|
end
|
data/lib/br_danfe/helper.rb
CHANGED
|
@@ -37,5 +37,9 @@ module BrDanfe
|
|
|
37
37
|
def self.format_cep(cep)
|
|
38
38
|
cep.sub(/(\d{2})(\d{3})(\d{3})/, '\\1.\\2-\\3')
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
def self.address(ender_tag)
|
|
42
|
+
"#{ender_tag.css('xLgr').text}, #{ender_tag.css('nro').text}, #{ender_tag.css('xBairro').text}, #{ender_tag.css('xMun').text} - #{ender_tag.css('UF').text}"
|
|
43
|
+
end
|
|
40
44
|
end
|
|
41
45
|
end
|
data/lib/br_danfe/version.rb
CHANGED
|
@@ -112,4 +112,16 @@ describe BrDanfe::CceLib::Document do
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
|
+
|
|
116
|
+
describe 'delegating unknown methods to the underlying Prawn document' do
|
|
117
|
+
context 'when the underlying document also does not know the method' do
|
|
118
|
+
it 'raises NoMethodError' do
|
|
119
|
+
expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'does not respond to it' do
|
|
123
|
+
expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
115
127
|
end
|
|
@@ -16,4 +16,16 @@ describe BrDanfe::DanfeLib::NfceLib::ProductList do
|
|
|
16
16
|
|
|
17
17
|
expect("#{base_dir}document#render.pdf").to have_same_content_of file: output_pdf
|
|
18
18
|
end
|
|
19
|
+
|
|
20
|
+
describe 'delegating unknown methods to the underlying Prawn document' do
|
|
21
|
+
context 'when the underlying document also does not know the method' do
|
|
22
|
+
it 'raises NoMethodError' do
|
|
23
|
+
expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'does not respond to it' do
|
|
27
|
+
expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
19
31
|
end
|
|
@@ -194,4 +194,16 @@ describe BrDanfe::DanfeLib::NfeLib::Document do
|
|
|
194
194
|
end
|
|
195
195
|
end
|
|
196
196
|
end
|
|
197
|
+
|
|
198
|
+
describe 'delegating unknown methods to the underlying Prawn document' do
|
|
199
|
+
context 'when the underlying document also does not know the method' do
|
|
200
|
+
it 'raises NoMethodError' do
|
|
201
|
+
expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it 'does not respond to it' do
|
|
205
|
+
expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
197
209
|
end
|
|
@@ -225,4 +225,29 @@ describe BrDanfe::Helper do
|
|
|
225
225
|
expect(described_class.format_cep('12345678')).to eql '12.345-678'
|
|
226
226
|
end
|
|
227
227
|
end
|
|
228
|
+
|
|
229
|
+
describe '.address' do
|
|
230
|
+
let(:xml) do
|
|
231
|
+
xml = <<~XML
|
|
232
|
+
<enderDest>
|
|
233
|
+
<xLgr>Rua Tijucas</xLgr>
|
|
234
|
+
<nro>99</nro>
|
|
235
|
+
<xCpl>dwdwa</xCpl>
|
|
236
|
+
<xBairro>Centro</xBairro>
|
|
237
|
+
<cMun>4218004</cMun>
|
|
238
|
+
<xMun>TIJUCAS</xMun>
|
|
239
|
+
<UF>SC</UF>
|
|
240
|
+
<CEP>88200000</CEP>
|
|
241
|
+
<cPais>1058</cPais>
|
|
242
|
+
<xPais>Brasil</xPais>
|
|
243
|
+
</enderDest>
|
|
244
|
+
XML
|
|
245
|
+
|
|
246
|
+
BrDanfe::XML.new(xml)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it 'returns a formated address string' do
|
|
250
|
+
expect(described_class.address(xml)).to eql 'Rua Tijucas, 99, Centro, TIJUCAS - SC'
|
|
251
|
+
end
|
|
252
|
+
end
|
|
228
253
|
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|