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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b849c45a1e7d926c43d77ce6e3460a35157e015393f76ebc5b37c736b9b679
|
4
|
+
data.tar.gz: 134cf5bf664dd4695aa4d895bd11d035850501045d36db501652d9cb06b5d3cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50dcef75a540af68ba9b9830880cff94a175a28c9eca51a02157a7cff07a73bdaa704deed374ab9e5005a45de2390bd7e8f75a2691dc1d5ee5efed13443455eb
|
7
|
+
data.tar.gz: 06e6fecd59fd4624e061efa637799f2e61bedc2a83d909e62a12709926946eb1f1fc30ed14ee5458b8d6cd4c1c82f3e88f15130bbbc830e8aedfda7354f77474
|
data/.rubocop.yml
CHANGED
@@ -12,13 +12,13 @@ AllCops:
|
|
12
12
|
Bundler/OrderedGems:
|
13
13
|
Enabled: false
|
14
14
|
|
15
|
-
Layout/
|
15
|
+
Layout/AlignHash:
|
16
16
|
Enabled: false
|
17
17
|
|
18
|
-
Layout/
|
18
|
+
Layout/AlignParameters:
|
19
19
|
Enabled: false
|
20
20
|
|
21
|
-
Layout/
|
21
|
+
Layout/IndentArray:
|
22
22
|
EnforcedStyle: consistent
|
23
23
|
|
24
24
|
Layout/SpaceBeforeBlockBraces:
|
@@ -26,8 +26,6 @@ Layout/SpaceBeforeBlockBraces:
|
|
26
26
|
|
27
27
|
Metrics/ClassLength:
|
28
28
|
Max: 230
|
29
|
-
Exclude:
|
30
|
-
- 'app/models/invoice_product.rb'
|
31
29
|
|
32
30
|
Metrics/CyclomaticComplexity:
|
33
31
|
Max: 8
|
@@ -38,12 +36,8 @@ Metrics/PerceivedComplexity:
|
|
38
36
|
Metrics/MethodLength:
|
39
37
|
Max: 19
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
- 'spec/**/*.rb'
|
44
|
-
- 'lib/tasks/export_nfes_to_portal.rake'
|
45
|
-
- 'lib/tasks/karma.rake'
|
46
|
-
- 'lib/tasks/backup_restore.rake'
|
39
|
+
Style/ClassAndModuleChildren:
|
40
|
+
Enabled: false
|
47
41
|
|
48
42
|
Style/DateTime:
|
49
43
|
Enabled: false
|
@@ -63,22 +57,18 @@ Style/IfUnlessModifier:
|
|
63
57
|
Style/SymbolArray:
|
64
58
|
EnforcedStyle: brackets
|
65
59
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
Style/HashTransformKeys:
|
70
|
-
Enabled: true
|
71
|
-
|
72
|
-
Style/HashTransformValues:
|
73
|
-
Enabled: true
|
74
|
-
|
75
|
-
Layout/LineLength:
|
76
|
-
Max: 150
|
60
|
+
Metrics/LineLength:
|
61
|
+
Max: 200
|
77
62
|
|
78
63
|
Lint/AmbiguousBlockAssociation:
|
79
64
|
Exclude:
|
80
65
|
- 'spec/**/*'
|
81
66
|
|
67
|
+
Metrics/BlockLength:
|
68
|
+
Exclude:
|
69
|
+
- 'spec/**/*'
|
70
|
+
- 'br_danfe.gemspec'
|
71
|
+
|
82
72
|
Metrics/ModuleLength:
|
83
73
|
Max: 118
|
84
74
|
|
@@ -97,7 +87,7 @@ Naming/HeredocDelimiterNaming:
|
|
97
87
|
Naming/HeredocDelimiterCase:
|
98
88
|
Enabled: false
|
99
89
|
|
100
|
-
Naming/
|
90
|
+
Naming/UncommunicativeMethodParamName:
|
101
91
|
Enabled: false
|
102
92
|
|
103
93
|
Naming/MethodName:
|
@@ -106,8 +96,8 @@ Naming/MethodName:
|
|
106
96
|
Naming/VariableName:
|
107
97
|
Enabled: false
|
108
98
|
|
109
|
-
|
99
|
+
Metrics/ParameterLists:
|
110
100
|
Enabled: false
|
111
101
|
|
112
|
-
|
102
|
+
Naming/UncommunicativeBlockParamName:
|
113
103
|
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
br_danfe (0.
|
4
|
+
br_danfe (0.14.0)
|
5
5
|
barby (= 0.5.1)
|
6
6
|
br_documents (>= 0.1.3)
|
7
7
|
i18n (>= 0.8.6)
|
@@ -13,44 +13,76 @@ PATH
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
activemodel (6.0.
|
17
|
-
activesupport (= 6.0.
|
18
|
-
activesupport (6.0.
|
16
|
+
activemodel (6.0.3.2)
|
17
|
+
activesupport (= 6.0.3.2)
|
18
|
+
activesupport (6.0.3.2)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 0.7, < 2)
|
21
21
|
minitest (~> 5.1)
|
22
22
|
tzinfo (~> 1.1)
|
23
|
-
zeitwerk (~> 2.2)
|
23
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
24
24
|
ast (2.4.0)
|
25
25
|
barby (0.5.1)
|
26
26
|
br_documents (0.1.3)
|
27
27
|
activemodel (>= 4.0.0)
|
28
28
|
i18n (>= 0.6.5)
|
29
|
-
byebug (11.1.
|
30
|
-
chunky_png (1.3.
|
31
|
-
|
29
|
+
byebug (11.1.3)
|
30
|
+
chunky_png (1.3.12)
|
31
|
+
coderay (1.1.3)
|
32
|
+
concurrent-ruby (1.1.7)
|
32
33
|
diff-lcs (1.3)
|
33
34
|
docile (1.3.2)
|
34
|
-
|
35
|
+
ffi (1.13.1)
|
36
|
+
formatador (0.2.5)
|
37
|
+
guard (2.16.2)
|
38
|
+
formatador (>= 0.2.4)
|
39
|
+
listen (>= 2.7, < 4.0)
|
40
|
+
lumberjack (>= 1.0.12, < 2.0)
|
41
|
+
nenv (~> 0.1)
|
42
|
+
notiffany (~> 0.0)
|
43
|
+
pry (>= 0.9.12)
|
44
|
+
shellany (~> 0.0)
|
45
|
+
thor (>= 0.18.1)
|
46
|
+
guard-compat (1.2.1)
|
47
|
+
guard-rspec (4.7.3)
|
48
|
+
guard (~> 2.1)
|
49
|
+
guard-compat (~> 1.1)
|
50
|
+
rspec (>= 2.99.0, < 4.0)
|
51
|
+
i18n (1.8.5)
|
35
52
|
concurrent-ruby (~> 1.0)
|
36
53
|
jaro_winkler (1.5.4)
|
37
54
|
json (2.3.0)
|
55
|
+
listen (3.2.1)
|
56
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
57
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
58
|
+
lumberjack (1.2.8)
|
59
|
+
method_source (1.0.0)
|
38
60
|
mini_portile2 (2.4.0)
|
39
|
-
minitest (5.14.
|
40
|
-
|
61
|
+
minitest (5.14.1)
|
62
|
+
nenv (0.3.0)
|
63
|
+
nokogiri (1.10.10)
|
41
64
|
mini_portile2 (~> 2.4.0)
|
65
|
+
notiffany (0.1.3)
|
66
|
+
nenv (~> 0.1)
|
67
|
+
shellany (~> 0.0)
|
42
68
|
parallel (1.19.1)
|
43
69
|
parser (2.7.0.4)
|
44
70
|
ast (~> 2.4.0)
|
45
|
-
pdf-core (0.
|
46
|
-
prawn (2.
|
47
|
-
pdf-core (~> 0.
|
48
|
-
ttfunk (~> 1.
|
71
|
+
pdf-core (0.8.1)
|
72
|
+
prawn (2.3.0)
|
73
|
+
pdf-core (~> 0.8.1)
|
74
|
+
ttfunk (~> 1.6)
|
49
75
|
prawn-table (0.2.2)
|
50
76
|
prawn (>= 1.3.0, < 3.0.0)
|
77
|
+
pry (0.13.1)
|
78
|
+
coderay (~> 1.1)
|
79
|
+
method_source (~> 1.0)
|
51
80
|
psych (3.1.0)
|
52
81
|
rainbow (3.0.0)
|
53
82
|
rake (13.0.1)
|
83
|
+
rb-fsevent (0.10.4)
|
84
|
+
rb-inotify (0.10.1)
|
85
|
+
ffi (~> 1.0)
|
54
86
|
rqrcode (1.1.2)
|
55
87
|
chunky_png (~> 1.0)
|
56
88
|
rqrcode_core (~> 0.1)
|
@@ -79,24 +111,28 @@ GEM
|
|
79
111
|
rubocop-performance (1.1.0)
|
80
112
|
rubocop (>= 0.67.0)
|
81
113
|
ruby-progressbar (1.10.1)
|
114
|
+
shellany (0.0.1)
|
82
115
|
simplecov (0.17.1)
|
83
116
|
docile (~> 1.1)
|
84
117
|
json (>= 1.8, < 3)
|
85
118
|
simplecov-html (~> 0.10.0)
|
86
119
|
simplecov-html (0.10.2)
|
120
|
+
thor (1.0.1)
|
87
121
|
thread_safe (0.3.6)
|
88
122
|
ttfunk (1.6.2.1)
|
89
|
-
tzinfo (1.2.
|
123
|
+
tzinfo (1.2.7)
|
90
124
|
thread_safe (~> 0.1)
|
91
125
|
unicode-display_width (1.5.0)
|
92
|
-
zeitwerk (2.
|
126
|
+
zeitwerk (2.4.0)
|
93
127
|
|
94
128
|
PLATFORMS
|
95
129
|
ruby
|
96
130
|
|
97
131
|
DEPENDENCIES
|
98
132
|
br_danfe!
|
99
|
-
byebug (= 11.1.
|
133
|
+
byebug (= 11.1.3)
|
134
|
+
guard (~> 2.16.2)
|
135
|
+
guard-rspec
|
100
136
|
rake (= 13.0.1)
|
101
137
|
rspec (= 3.9.0)
|
102
138
|
rubocop (= 0.67.0)
|
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# BrDanfe
|
2
2
|
|
3
|
-
[![Code Climate](https://codeclimate.com/github/asseinfo/br_danfe.png)](https://codeclimate.com/github/asseinfo/br_danfe)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/asseinfo/br_danfe.png)](https://codeclimate.com/github/asseinfo/br_danfe)
|
4
4
|
|
5
5
|
This gem generates PDF files for Brazilian DANFE (_Documento Auxiliar da Nota Fiscal Eletrônica_) from a valid NF-e XML. It also can generates PDF file for CC-e (_Carta de Correção Eletrônica_).
|
6
6
|
|
@@ -114,10 +114,10 @@ The following variables are necessary to be set:
|
|
114
114
|
|
115
115
|
Environment var | Development? | Test? | CI? | Production? | Data
|
116
116
|
----------------------|--------------|-------|-------|-------------|-----
|
117
|
-
TZ | no | no | yes | no | America/Sao_Paulo
|
118
|
-
BUNDLE_PATH | no | no | yes | no | vendor/bundle
|
119
|
-
CC_TEST_REPORTER_ID | no | no | yes | no | get at codeclimate
|
120
|
-
RAILS_ENV | no | no | yes | no | test
|
117
|
+
TZ | no | no | yes | no | America/Sao_Paulo
|
118
|
+
BUNDLE_PATH | no | no | yes | no | vendor/bundle
|
119
|
+
CC_TEST_REPORTER_ID | no | no | yes | no | get at codeclimate
|
120
|
+
RAILS_ENV | no | no | yes | no | test
|
121
121
|
|
122
122
|
### Code coverage
|
123
123
|
|
data/br_danfe.gemspec
CHANGED
@@ -24,11 +24,13 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'prawn-table', '0.2.2'
|
25
25
|
spec.add_dependency 'rqrcode', '~> 1.1.1'
|
26
26
|
|
27
|
-
spec.add_development_dependency 'byebug', '11.1.
|
27
|
+
spec.add_development_dependency 'byebug', '11.1.3'
|
28
28
|
spec.add_development_dependency 'rake', '13.0.1'
|
29
29
|
spec.add_development_dependency 'rspec', '3.9.0'
|
30
30
|
spec.add_development_dependency 'rubocop', '0.67.0'
|
31
31
|
spec.add_development_dependency 'rubocop-performance', '~> 1.1.0'
|
32
32
|
spec.add_development_dependency 'simplecov', '0.17.1'
|
33
33
|
spec.add_development_dependency 'simplecov-html', '0.10.2'
|
34
|
+
spec.add_development_dependency 'guard', '~> 2.16.2'
|
35
|
+
spec.add_development_dependency 'guard-rspec'
|
34
36
|
end
|
data/lib/br_danfe.rb
CHANGED
@@ -9,7 +9,6 @@ require 'yaml'
|
|
9
9
|
require 'ostruct'
|
10
10
|
require 'i18n'
|
11
11
|
require 'br_documents'
|
12
|
-
require 'br_danfe/danfe_lib/consts'
|
13
12
|
|
14
13
|
Dir[File.dirname(__FILE__) + '/**/*.rb'].sort.each { |f| require f }
|
15
14
|
I18n.load_path << File.expand_path('../config/locales/pt-BR.yml', __dir__)
|
data/lib/br_danfe/danfe.rb
CHANGED
@@ -1,97 +1,13 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Danfe
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(xml)
|
6
|
-
@xml = BrDanfe::XML.new(xml)
|
7
|
-
@pdf = DanfeLib::Document.new
|
8
|
-
@options = BrDanfe::Logo::Config.new
|
9
|
-
|
10
|
-
create_watermark
|
11
|
-
end
|
12
|
-
|
13
|
-
def save_pdf(filename, footer_info = '')
|
14
|
-
generate footer_info
|
15
|
-
@pdf.render_file filename
|
16
|
-
end
|
17
|
-
|
18
|
-
def render_pdf(footer_info = '')
|
19
|
-
generate footer_info
|
20
|
-
@pdf.render
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def create_watermark
|
26
|
-
@pdf.create_stamp('has_no_fiscal_value') do
|
27
|
-
@pdf.fill_color '7d7d7d'
|
28
|
-
@pdf.text_box I18n.t('danfe.others.has_no_fiscal_value'),
|
29
|
-
size: 2.2.cm,
|
30
|
-
width: @pdf.bounds.width,
|
31
|
-
height: @pdf.bounds.height,
|
32
|
-
align: :center,
|
33
|
-
valign: :center,
|
34
|
-
at: [0, @pdf.bounds.height],
|
35
|
-
rotate: 45,
|
36
|
-
rotate_around: :center
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def generate(footer_info)
|
41
|
-
render_on_first_page
|
42
|
-
render_on_each_page footer_info
|
43
|
-
@pdf
|
44
|
-
end
|
45
|
-
|
46
|
-
def render_on_first_page
|
47
|
-
DanfeLib::Ticket.new(@pdf, @xml).render
|
48
|
-
DanfeLib::Dest.new(@pdf, @xml).render
|
49
|
-
DanfeLib::Dup.new(@pdf, @xml).render
|
50
|
-
DanfeLib::Icmstot.new(@pdf, @xml).render
|
51
|
-
DanfeLib::Transp.new(@pdf, @xml).render
|
52
|
-
n_vol = DanfeLib::Vol.new(@pdf, @xml).render
|
53
|
-
has_issqn = DanfeLib::Issqn.new(@pdf, @xml).render
|
54
|
-
DanfeLib::Infadic.new(@pdf, @xml).render(n_vol)
|
55
|
-
|
56
|
-
render_products has_issqn
|
57
|
-
end
|
58
|
-
|
59
|
-
def render_products(has_issqn)
|
60
|
-
DanfeLib::DetBody.new(@pdf, @xml).render(has_issqn)
|
61
|
-
end
|
62
|
-
|
63
|
-
def render_on_each_page(footer_info)
|
64
|
-
emitter = DanfeLib::EmitHeader.new(@pdf, @xml, @options.logo, @options.logo_dimensions)
|
65
|
-
|
66
|
-
@pdf.page_count.times do |i|
|
67
|
-
page = i + 1
|
68
|
-
position = page == 1 ? 3.96 : 1.85
|
69
|
-
repeated_information page, position, emitter, footer_info
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def repeated_information(page, y_position, emitter, footer_info)
|
74
|
-
@pdf.go_to_page(page)
|
75
|
-
|
76
|
-
emitter.render page, y_position
|
77
|
-
render_product_table_title page
|
78
|
-
render_footer_information footer_info
|
79
|
-
render_no_fiscal_value
|
80
|
-
end
|
81
|
-
|
82
|
-
def render_product_table_title(page)
|
83
|
-
y_position = page == 1 ? 18.91 : 7.40
|
84
|
-
@pdf.ititle 0.42, 10.00, 0.75, y_position, 'det.title'
|
85
|
-
end
|
86
|
-
|
87
|
-
def render_footer_information(footer_info)
|
88
|
-
if footer_info.present?
|
89
|
-
@pdf.ibox 0.35, 12.45, 0.75, 30.21, '', footer_info, { size: 5, border: 0 }
|
90
|
-
end
|
3
|
+
def self.new(xml)
|
4
|
+
create_danfe BrDanfe::XML.new(xml)
|
91
5
|
end
|
92
6
|
|
93
|
-
def
|
94
|
-
|
7
|
+
def self.create_danfe(xml)
|
8
|
+
nfe_code = '55'
|
9
|
+
xml['ide > mod'] == nfe_code ? DanfeLib::Nfe.new(xml) : DanfeLib::Nfce.new(xml)
|
95
10
|
end
|
11
|
+
private_class_method :create_danfe
|
96
12
|
end
|
97
13
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
class Base
|
4
|
+
attr_reader :options
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
@xml = xml
|
8
|
+
@document = document
|
9
|
+
@options = BrDanfe::Logo::Config.new
|
10
|
+
|
11
|
+
create_watermark
|
12
|
+
end
|
13
|
+
|
14
|
+
def save_pdf(filename, footer_info = '')
|
15
|
+
generate footer_info
|
16
|
+
@document.render_file filename
|
17
|
+
end
|
18
|
+
|
19
|
+
def render_pdf(footer_info = '')
|
20
|
+
generate footer_info
|
21
|
+
@document.render
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def document; end
|
27
|
+
|
28
|
+
def create_watermark; end
|
29
|
+
|
30
|
+
def generate(footer_info); end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
class Nfce < Base
|
4
|
+
PAGE_WIDTH = 8.cm
|
5
|
+
PAGE_HEIGHT = 100.cm
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def document
|
10
|
+
NfceLib::Document.new(PAGE_WIDTH, PAGE_HEIGHT)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_watermark
|
14
|
+
@document.create_stamp('has_no_fiscal_value') do
|
15
|
+
@document.fill_color '7d7d7d'
|
16
|
+
@document.text_box I18n.t('danfe.others.has_no_fiscal_value'),
|
17
|
+
size: 0.8.cm,
|
18
|
+
width: 10.cm,
|
19
|
+
height: 1.2.cm,
|
20
|
+
at: [0, PAGE_HEIGHT - 3.8.cm],
|
21
|
+
rotate: 45,
|
22
|
+
rotate_around: :center
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate(footer_info)
|
27
|
+
NfceLib::Header.new(@document, @xml, @options.logo, @options.logo_dimensions).render
|
28
|
+
NfceLib::ProductList.new(@document, @xml).render
|
29
|
+
NfceLib::TotalList.new(@document, @xml).render
|
30
|
+
NfceLib::Key.new(@document, @xml).render
|
31
|
+
NfceLib::Recipient.new(@document, @xml).render
|
32
|
+
NfceLib::NfceIdentification.new(@document, @xml).render
|
33
|
+
NfceLib::QrCode.new(@document, @xml).render
|
34
|
+
NfceLib::Footer.new(@document, @xml).render(footer_info)
|
35
|
+
|
36
|
+
render_no_fiscal_value
|
37
|
+
resize_page_height
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_no_fiscal_value
|
41
|
+
@document.stamp('has_no_fiscal_value') if BrDanfe::Helper.unauthorized?(@xml)
|
42
|
+
end
|
43
|
+
|
44
|
+
def resize_page_height
|
45
|
+
@document.page.dictionary.data[:MediaBox] = [0, @document.y - 10, PAGE_WIDTH, PAGE_HEIGHT]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|