br_danfe 0.12.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -25
- data/Gemfile.lock +54 -18
- data/Guardfile +14 -0
- data/README.md +5 -5
- data/br_danfe.gemspec +3 -1
- data/lib/br_danfe.rb +0 -1
- data/lib/br_danfe/danfe.rb +6 -90
- data/lib/br_danfe/danfe_lib/base.rb +33 -0
- data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
- data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +125 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
- data/lib/br_danfe/helper.rb +8 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
- data/spec/{features → br_danfe}/cce_spec.rb +0 -0
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +45 -4
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
- data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
- data/spec/br_danfe/danfe_spec.rb +40 -0
- data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
- data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
- data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
- data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
- data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
- data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#address-shipment.pdf +108 -0
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +7 -7
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +7 -7
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +12 -12
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +10 -10
- metadata +114 -77
- data/lib/br_danfe/danfe_lib/cep.rb +0 -9
- data/lib/br_danfe/danfe_lib/consts.rb +0 -6
- data/lib/br_danfe/danfe_lib/cst.rb +0 -32
- data/lib/br_danfe/danfe_lib/dest.rb +0 -94
- data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
- data/lib/br_danfe/danfe_lib/document.rb +0 -140
- data/lib/br_danfe/danfe_lib/dup.rb +0 -53
- data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
- data/lib/br_danfe/danfe_lib/helper.rb +0 -61
- data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
- data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
- data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
- data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
- data/lib/br_danfe/danfe_lib/phone.rb +0 -13
- data/lib/br_danfe/danfe_lib/plate.rb +0 -9
- data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
- data/lib/br_danfe/danfe_lib/transp.rb +0 -56
- data/lib/br_danfe/danfe_lib/vol.rb +0 -42
- data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
- data/lib/br_danfe/danfe_nfce.rb +0 -43
- data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
- data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
- data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
- data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
- data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
- data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
- data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
- data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
- data/spec/features/danfe_nfce_spec.rb +0 -31
@@ -1,115 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class EmitHeader
|
4
|
-
def initialize(pdf, xml, logo, logo_dimensions)
|
5
|
-
@pdf = pdf
|
6
|
-
@xml = xml
|
7
|
-
@logo = logo
|
8
|
-
@logo_dimensions = logo_dimensions
|
9
|
-
end
|
10
|
-
|
11
|
-
def render(page, y_position)
|
12
|
-
@y_position = y_position
|
13
|
-
company_box
|
14
|
-
danfe_box page
|
15
|
-
access_key_box
|
16
|
-
sefaz_box
|
17
|
-
render_emit y_position
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def company_box
|
23
|
-
@pdf.ibox 3.92, 7.46, 0.75, @y_position
|
24
|
-
@pdf.ibox 3.92, 7.46, 0.75, @y_position, '', @xml['emit/xNome'],
|
25
|
-
{ size: 12, align: :center, border: 0, style: :bold }
|
26
|
-
|
27
|
-
address_company
|
28
|
-
end
|
29
|
-
|
30
|
-
def address_company
|
31
|
-
if @logo.blank?
|
32
|
-
@pdf.ibox 3.92, 7.46, 1.25, @y_position + 1.46, '', address, { align: :left, border: 0 }
|
33
|
-
else
|
34
|
-
@pdf.ibox 3.92, 7.46, 3.60, @y_position + 1.46, '', address, { size: 8, align: :left, border: 0 }
|
35
|
-
logo
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def address
|
40
|
-
formatted = @xml['enderEmit/xLgr'] + ', ' + @xml['enderEmit/nro'] + "\n"
|
41
|
-
formatted += @xml['enderEmit/xBairro'] + ' - ' + cep + "\n"
|
42
|
-
formatted += @xml['enderEmit/xMun'] + '/' + @xml['enderEmit/UF'] + "\n"
|
43
|
-
formatted += phone + ' ' + @xml['enderEmit/email']
|
44
|
-
formatted
|
45
|
-
end
|
46
|
-
|
47
|
-
def phone
|
48
|
-
Phone.format(@xml['enderEmit/fone'])
|
49
|
-
end
|
50
|
-
|
51
|
-
def cep
|
52
|
-
Cep.format(@xml['enderEmit/CEP'])
|
53
|
-
end
|
54
|
-
|
55
|
-
def logo
|
56
|
-
bounding_box_size = 80
|
57
|
-
logo_options = BrDanfe::Logo::Options.new(bounding_box_size, @logo_dimensions).options
|
58
|
-
|
59
|
-
@pdf.bounding_box(
|
60
|
-
[0.83.cm, Helper.invert(@y_position.cm + 1.02.cm)], width: bounding_box_size, height: bounding_box_size
|
61
|
-
) do
|
62
|
-
@pdf.image @logo, logo_options
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def danfe_box(page)
|
67
|
-
@pdf.ibox 3.92, 2.08, 8.21, @y_position
|
68
|
-
|
69
|
-
@pdf.ibox 0.60, 2.08, 8.21, @y_position, '', 'DANFE',
|
70
|
-
{ size: 12, align: :center, border: 0, style: :bold }
|
71
|
-
|
72
|
-
@pdf.ibox 1.20, 2.08, 8.21, @y_position + 0.60, '', I18n.t('danfe.others.danfe'),
|
73
|
-
{ size: 8, align: :center, border: 0 }
|
74
|
-
|
75
|
-
@pdf.ibox 0.60, 2.08, 8.21, @y_position + 1.80, '',
|
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
|
-
|
80
|
-
@pdf.ibox 1.00, 2.08, 8.21, @y_position + 2.40, '',
|
81
|
-
I18n.t('danfe.ide.document', nNF: @xml['ide/nNF'], serie: @xml['ide/serie']),
|
82
|
-
{ size: 8, align: :center, valign: :center, border: 0, style: :bold }
|
83
|
-
|
84
|
-
@pdf.ibox 1.00, 2.08, 8.21, @y_position + 3.00, '',
|
85
|
-
I18n.t('danfe.others.page', current: page, total: @pdf.page_count),
|
86
|
-
{ size: 8, align: :center, valign: :center, border: 0, style: :bold }
|
87
|
-
end
|
88
|
-
|
89
|
-
def access_key_box
|
90
|
-
@pdf.ibox 2.22, 10.02, 10.29, @y_position
|
91
|
-
@pdf.ibarcode 1.50, 8.00, 10.4010, @y_position + 1.90, @xml['chNFe']
|
92
|
-
@pdf.ibox 0.85, 10.02, 10.29, @y_position + 2.22, I18n.t('danfe.chNFe'),
|
93
|
-
@xml['chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), { style: :bold, align: :center }
|
94
|
-
end
|
95
|
-
|
96
|
-
def sefaz_box
|
97
|
-
@pdf.ibox 0.85, 10.02, 10.29, @y_position + 3.07, '', I18n.t('danfe.others.sefaz'),
|
98
|
-
{ align: :center, size: 8 }
|
99
|
-
end
|
100
|
-
|
101
|
-
def render_emit(y_position)
|
102
|
-
y_first_line = y_position + 3.92
|
103
|
-
y_second_line = y_first_line + LINE_HEIGHT
|
104
|
-
|
105
|
-
@pdf.lbox LINE_HEIGHT, 10.04, 0.75, y_first_line, @xml, 'ide/natOp'
|
106
|
-
@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: :center }
|
108
|
-
|
109
|
-
@pdf.lie LINE_HEIGHT, 6.36, 0.75, y_second_line, @xml, 'enderEmit/UF', 'emit/IE'
|
110
|
-
@pdf.lie LINE_HEIGHT, 6.86, 7.11, y_second_line, @xml, 'enderDest/UF', 'emit/IEST'
|
111
|
-
@pdf.lcnpj LINE_HEIGHT, 6.34, 13.97, y_second_line, @xml, 'emit/CNPJ'
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class Helper
|
4
|
-
def self.invert(y)
|
5
|
-
29.7.cm - y
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.format_date(xml_datetime)
|
9
|
-
formated = ''
|
10
|
-
|
11
|
-
unless xml_datetime.empty?
|
12
|
-
date = DateTime.strptime(xml_datetime, '%Y-%m-%d')
|
13
|
-
formated = date.strftime('%d/%m/%Y')
|
14
|
-
end
|
15
|
-
|
16
|
-
formated
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.format_time(xml_datetime)
|
20
|
-
formated = ''
|
21
|
-
|
22
|
-
if xml_datetime.length == 8
|
23
|
-
formated = xml_datetime
|
24
|
-
elsif xml_datetime.length > 8
|
25
|
-
date = DateTime.strptime(xml_datetime, '%Y-%m-%dT%H:%M:%S %Z').to_time
|
26
|
-
formated = date.strftime('%H:%M:%S')
|
27
|
-
end
|
28
|
-
|
29
|
-
formated
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.no_fiscal_value?(xml)
|
33
|
-
BrDanfe::Helper.homologation?(xml) || unauthorized?(xml)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.unauthorized?(xml)
|
37
|
-
xml.css('nfeProc/protNFe/infProt/dhRecbto').empty?
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.mensure_text(pdf, text)
|
41
|
-
pdf.width_of(text)
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.address_is_too_big(pdf, address)
|
45
|
-
Helper.mensure_text(pdf, address) > Dest::MAXIMUM_SIZE_FOR_STREET
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.generate_address(xml)
|
49
|
-
address_complement = " - #{xml_text(xml, 'enderDest/xCpl')}" if xml_text(xml, 'enderDest/xCpl').present?
|
50
|
-
address_number = " #{xml_text(xml, 'enderDest/nro')}" if xml_text(xml, 'enderDest/nro').present?
|
51
|
-
"#{xml_text(xml, 'enderDest/xLgr')}#{address_number}#{address_complement}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.xml_text(xml, property)
|
55
|
-
xml.css(property).text
|
56
|
-
end
|
57
|
-
|
58
|
-
private_class_method :xml_text
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class Icmstot
|
4
|
-
Y = 13.77 + SPACE_BETWEEN_GROUPS
|
5
|
-
|
6
|
-
def initialize(pdf, xml)
|
7
|
-
@pdf = pdf
|
8
|
-
@xml = xml
|
9
|
-
|
10
|
-
@ltitle = Y - 0.42
|
11
|
-
@l1 = Y
|
12
|
-
@l2 = Y + LINE_HEIGHT
|
13
|
-
end
|
14
|
-
|
15
|
-
def render
|
16
|
-
@pdf.ititle 0.42, 5.60, 0.75, @ltitle, 'ICMSTot.title'
|
17
|
-
|
18
|
-
@pdf.lnumeric LINE_HEIGHT, 3.56, 0.75, @l1, @xml, 'ICMSTot/vBC'
|
19
|
-
@pdf.lnumeric LINE_HEIGHT, 4.06, 4.31, @l1, @xml, 'ICMSTot/vICMS'
|
20
|
-
@pdf.lnumeric LINE_HEIGHT, 4.06, 8.37, @l1, @xml, 'ICMSTot/vBCST'
|
21
|
-
@pdf.lnumeric LINE_HEIGHT, 4.06, 12.43, @l1, @xml, 'ICMSTot/vST'
|
22
|
-
@pdf.lnumeric LINE_HEIGHT, 3.82, 16.49, @l1, @xml, 'ICMSTot/vProd'
|
23
|
-
|
24
|
-
@pdf.lnumeric LINE_HEIGHT, 2.55, 0.75, @l2, @xml, 'ICMSTot/vFrete'
|
25
|
-
@pdf.lnumeric LINE_HEIGHT, 3.05, 3.30, @l2, @xml, 'ICMSTot/vSeg'
|
26
|
-
@pdf.lnumeric LINE_HEIGHT, 3.04, 6.35, @l2, @xml, 'ICMSTot/vDesc'
|
27
|
-
@pdf.lnumeric LINE_HEIGHT, 3.04, 9.39, @l2, @xml, 'ICMSTot/vOutro'
|
28
|
-
@pdf.lnumeric LINE_HEIGHT, 4.06, 12.43, @l2, @xml, 'ICMSTot/vIPI'
|
29
|
-
@pdf.lnumeric LINE_HEIGHT, 3.82, 16.49, @l2, @xml, 'ICMSTot/vNF', style: :bold
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class Infadic
|
4
|
-
Y_POSITION = 27.04 + SPACE_BETWEEN_GROUPS
|
5
|
-
|
6
|
-
def initialize(pdf, xml)
|
7
|
-
@pdf = pdf
|
8
|
-
@xml = xml
|
9
|
-
@title_position = Y_POSITION - 0.41
|
10
|
-
@y_position = Y_POSITION
|
11
|
-
end
|
12
|
-
|
13
|
-
def render(volumes_number)
|
14
|
-
render_title
|
15
|
-
render_subtitle
|
16
|
-
render_volumes if volumes_number > 1
|
17
|
-
render_additional_data generate_y_position(volumes_number) if additional_data?
|
18
|
-
render_reserved_fisco
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def render_title
|
24
|
-
@pdf.ititle 0.42, 10.00, 0.75, @title_position, 'infAdic.title'
|
25
|
-
end
|
26
|
-
|
27
|
-
def render_subtitle
|
28
|
-
@pdf.ibox 2.65, 12.45, 0.75, @y_position, I18n.t('danfe.infAdic.infCpl'), '', size: 8, valign: :top
|
29
|
-
end
|
30
|
-
|
31
|
-
def render_volumes
|
32
|
-
InfadicVol.new(@xml, @pdf).render
|
33
|
-
end
|
34
|
-
|
35
|
-
def render_additional_data(y_position)
|
36
|
-
data = generate_additional_data
|
37
|
-
@pdf.ibox 2.65, 12.45, 0.75, y_position, '', data, { size: 6, valign: :top, border: 0 }
|
38
|
-
end
|
39
|
-
|
40
|
-
def generate_additional_data
|
41
|
-
additional_data = []
|
42
|
-
additional_data.push(complementary_content) if complementary?
|
43
|
-
additional_data.push(address_content) if address?
|
44
|
-
additional_data.push(difal_content) if difal?
|
45
|
-
additional_data.push(fisco_content) if fisco?
|
46
|
-
additional_data.join(' * ')
|
47
|
-
end
|
48
|
-
|
49
|
-
def complementary_content
|
50
|
-
@xml['infAdic/infCpl'].to_s
|
51
|
-
end
|
52
|
-
|
53
|
-
def complementary?
|
54
|
-
@xml['infAdic/infCpl'].to_s != ''
|
55
|
-
end
|
56
|
-
|
57
|
-
def address_content
|
58
|
-
"Endereço: #{Helper.generate_address @xml}"
|
59
|
-
end
|
60
|
-
|
61
|
-
def address?
|
62
|
-
Helper.address_is_too_big @pdf, Helper.generate_address(@xml)
|
63
|
-
end
|
64
|
-
|
65
|
-
def difal_content
|
66
|
-
I18n.t(
|
67
|
-
'danfe.infAdic.difal',
|
68
|
-
vICMSUFDest: numerify(@xml['ICMSTot/vICMSUFDest']),
|
69
|
-
vFCPUFDest: numerify(@xml['ICMSTot/vFCPUFDest']),
|
70
|
-
vICMSUFRemet: numerify(@xml['ICMSTot/vICMSUFRemet'])
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
def numerify(value)
|
75
|
-
BrDanfe::Helper.numerify(value) if value != ''
|
76
|
-
end
|
77
|
-
|
78
|
-
def difal?
|
79
|
-
@xml['ICMSTot/vICMSUFDest'].to_f != 0
|
80
|
-
end
|
81
|
-
|
82
|
-
def fisco_content
|
83
|
-
@xml['infAdic/infAdFisco'].to_s
|
84
|
-
end
|
85
|
-
|
86
|
-
def fisco?
|
87
|
-
@xml['infAdic/infAdFisco'].to_s.present?
|
88
|
-
end
|
89
|
-
|
90
|
-
def generate_y_position(volumes_number)
|
91
|
-
if volumes_number > 1
|
92
|
-
return Y_POSITION + 0.30 + volumes_number * 0.15 + 0.2
|
93
|
-
end
|
94
|
-
|
95
|
-
Y_POSITION + 0.30
|
96
|
-
end
|
97
|
-
|
98
|
-
def additional_data?
|
99
|
-
complementary? || address? || difal? || fisco?
|
100
|
-
end
|
101
|
-
|
102
|
-
def render_reserved_fisco
|
103
|
-
@pdf.ibox 2.65, 7.15, 13.20, @y_position, I18n.t('danfe.infAdic.reserved')
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class InfadicVol
|
4
|
-
def initialize(xml, pdf)
|
5
|
-
@xml = xml
|
6
|
-
@pdf = pdf
|
7
|
-
@y_position = 27.56
|
8
|
-
end
|
9
|
-
|
10
|
-
def render
|
11
|
-
render_volume_title
|
12
|
-
render_volume
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def render_volume_title
|
18
|
-
@pdf.ibox 2.65, 12.45, 0.75, @y_position + 0.30, '', I18n.t('danfe.infAdic.vol.title'), size: 5, valign: :top,
|
19
|
-
border: 0
|
20
|
-
end
|
21
|
-
|
22
|
-
def render_volume
|
23
|
-
volumes = 0
|
24
|
-
y_position = @y_position + 0.47
|
25
|
-
|
26
|
-
@xml.collect('xmlns', 'vol') do |det|
|
27
|
-
volumes += 1
|
28
|
-
|
29
|
-
if volumes > 1
|
30
|
-
render_fields det, y_position
|
31
|
-
y_position += 0.15
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def render_fields(det, y_position)
|
37
|
-
render_esp det, y_position
|
38
|
-
render_marca det, y_position
|
39
|
-
render_qvol det, y_position
|
40
|
-
render_nvol det, y_position
|
41
|
-
render_pesob det, y_position
|
42
|
-
render_pesol det, y_position
|
43
|
-
end
|
44
|
-
|
45
|
-
def render_esp(det, y_position)
|
46
|
-
render_item_title 0.5, 1.35, 'esp', y_position
|
47
|
-
render_item_field det.css('esp').text, 3, 1.75, y_position
|
48
|
-
end
|
49
|
-
|
50
|
-
def render_item_title(width, x_position, field, y_position)
|
51
|
-
label = I18n.t("danfe.infAdic.vol.#{field}")
|
52
|
-
@pdf.ibox 0.35, width, x_position, y_position, '', label, style_normal
|
53
|
-
end
|
54
|
-
|
55
|
-
def style_normal
|
56
|
-
{ size: 4, border: 0 }
|
57
|
-
end
|
58
|
-
|
59
|
-
def render_item_field(value, width, x_position, y_position)
|
60
|
-
@pdf.ibox 0.35, width, x_position, y_position, '', value, style_italic
|
61
|
-
end
|
62
|
-
|
63
|
-
def style_italic
|
64
|
-
style_normal.merge(style: :italic)
|
65
|
-
end
|
66
|
-
|
67
|
-
def render_marca(det, y_position)
|
68
|
-
render_item_title 0.7, 4.15, 'marca', y_position
|
69
|
-
render_item_field det.css('marca').text, 2, 4.75, y_position
|
70
|
-
end
|
71
|
-
|
72
|
-
def render_qvol(det, y_position)
|
73
|
-
render_item_title 0.7, 0.75, 'qVol', y_position
|
74
|
-
render_item_field det.css('qVol').text, 0.7, 1.04, y_position
|
75
|
-
end
|
76
|
-
|
77
|
-
def render_nvol(det, y_position)
|
78
|
-
render_item_title 1, 6.1, 'nVol', y_position
|
79
|
-
render_item_field det.css('nVol').text, 1, 6.7, y_position
|
80
|
-
end
|
81
|
-
|
82
|
-
def render_pesob(det, y_position)
|
83
|
-
render_item_title 1.3, 7, 'pesoB', y_position
|
84
|
-
render_peso_item_field det.css('pesoB').text, 1.3, 7, y_position
|
85
|
-
end
|
86
|
-
|
87
|
-
def render_peso_item_field(value, width, x_position, y_pos)
|
88
|
-
@pdf.inumeric 0.35, width, x_position, y_pos, '', value, style_decimal
|
89
|
-
end
|
90
|
-
|
91
|
-
def style_decimal
|
92
|
-
style_italic.merge(decimals: 3)
|
93
|
-
end
|
94
|
-
|
95
|
-
def render_pesol(det, y_position)
|
96
|
-
render_item_title 0.9, 8.5, 'pesoL', y_position
|
97
|
-
render_peso_item_field det.css('pesoL').text, 1.5, 8.5, y_position
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeLib
|
3
|
-
class Issqn
|
4
|
-
Y_POSITION = 25.72 + SPACE_BETWEEN_GROUPS
|
5
|
-
|
6
|
-
def initialize(pdf, xml)
|
7
|
-
@pdf = pdf
|
8
|
-
@xml = xml
|
9
|
-
|
10
|
-
@title = Y_POSITION - 0.42
|
11
|
-
@y_position = Y_POSITION
|
12
|
-
|
13
|
-
@serv = 'total/ISSQNtot/vServ'
|
14
|
-
@bc = 'total/ISSQNtot/vBC'
|
15
|
-
@iss = 'total/ISSQNtot/vISS'
|
16
|
-
end
|
17
|
-
|
18
|
-
def render
|
19
|
-
if can_render?
|
20
|
-
@pdf.ititle 0.42, 10.00, 0.75, @title, 'issqn.title'
|
21
|
-
@pdf.lbox LINE_HEIGHT, 4.64, 0.75, @y_position, @xml, 'emit/IM'
|
22
|
-
@pdf.lnumeric LINE_HEIGHT, 5.14, 5.39, @y_position, @xml, @serv
|
23
|
-
@pdf.lnumeric LINE_HEIGHT, 5.14, 10.53, @y_position, @xml, @bc
|
24
|
-
@pdf.lnumeric LINE_HEIGHT, 4.64, 15.67, @y_position, @xml, @iss
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def can_render?
|
31
|
-
@xml[@serv].to_i.positive? || @xml[@bc].to_i.positive? || @xml[@iss].to_i.positive?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|