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.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -25
  3. data/Gemfile.lock +54 -18
  4. data/Guardfile +14 -0
  5. data/README.md +5 -5
  6. data/br_danfe.gemspec +3 -1
  7. data/lib/br_danfe.rb +0 -1
  8. data/lib/br_danfe/danfe.rb +6 -90
  9. data/lib/br_danfe/danfe_lib/base.rb +33 -0
  10. data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
  11. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
  12. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
  13. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
  14. data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
  15. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
  16. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
  17. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
  18. data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
  19. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
  20. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
  21. data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
  22. data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
  23. data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
  24. data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
  25. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
  26. data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
  27. data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
  28. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
  29. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
  30. data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
  31. data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
  32. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +125 -0
  33. data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
  34. data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
  35. data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
  36. data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
  37. data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
  38. data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
  39. data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
  40. data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
  41. data/lib/br_danfe/helper.rb +8 -0
  42. data/lib/br_danfe/version.rb +1 -1
  43. data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
  44. data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
  45. data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
  46. data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
  47. data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
  48. data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
  49. data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
  50. data/spec/{features → br_danfe}/cce_spec.rb +0 -0
  51. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
  52. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
  53. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
  54. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
  55. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
  56. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
  57. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
  58. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
  59. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
  60. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
  61. data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
  62. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
  63. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
  64. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
  65. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
  66. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
  67. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
  68. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
  69. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
  70. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
  71. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +45 -4
  72. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
  73. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
  74. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
  75. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
  76. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
  77. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
  78. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
  79. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
  80. data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
  81. data/spec/br_danfe/danfe_spec.rb +40 -0
  82. data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
  83. data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
  84. data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
  85. data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
  86. data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
  87. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  88. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
  89. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  90. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
  91. data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
  92. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  93. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  94. data/spec/fixtures/nfe/lib/infadic#address-shipment.pdf +108 -0
  95. data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +7 -7
  96. data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +10 -10
  97. data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +8 -8
  98. data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +10 -10
  99. data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +8 -8
  100. data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +10 -10
  101. data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +7 -7
  102. data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +8 -8
  103. data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +10 -10
  104. data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +10 -10
  105. data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +12 -12
  106. data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +10 -10
  107. metadata +114 -77
  108. data/lib/br_danfe/danfe_lib/cep.rb +0 -9
  109. data/lib/br_danfe/danfe_lib/consts.rb +0 -6
  110. data/lib/br_danfe/danfe_lib/cst.rb +0 -32
  111. data/lib/br_danfe/danfe_lib/dest.rb +0 -94
  112. data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
  113. data/lib/br_danfe/danfe_lib/document.rb +0 -140
  114. data/lib/br_danfe/danfe_lib/dup.rb +0 -53
  115. data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
  116. data/lib/br_danfe/danfe_lib/helper.rb +0 -61
  117. data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
  118. data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
  119. data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
  120. data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
  121. data/lib/br_danfe/danfe_lib/phone.rb +0 -13
  122. data/lib/br_danfe/danfe_lib/plate.rb +0 -9
  123. data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
  124. data/lib/br_danfe/danfe_lib/transp.rb +0 -56
  125. data/lib/br_danfe/danfe_lib/vol.rb +0 -42
  126. data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
  127. data/lib/br_danfe/danfe_nfce.rb +0 -43
  128. data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
  129. data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
  130. data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
  131. data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
  132. data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
  133. data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
  134. data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
  135. data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
  136. data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
  137. data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
  138. data/spec/features/danfe_nfce_spec.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4797e22c4338892c66b0cd3d68be10f286afd9bb5901cbbfc75f2517a1d057b1
4
- data.tar.gz: 256d5000c34b831bf3f1ca10b4d32e1fb346f7249b9ad5484da21e19d769ebf8
3
+ metadata.gz: 07b849c45a1e7d926c43d77ce6e3460a35157e015393f76ebc5b37c736b9b679
4
+ data.tar.gz: 134cf5bf664dd4695aa4d895bd11d035850501045d36db501652d9cb06b5d3cc
5
5
  SHA512:
6
- metadata.gz: 8768877973c009a595a131be31bc03dd3cd6ce26fc6adfcc0eba600e71aea75a268b067afef2805b1aca4649990a8269942b95c8678910c7977ef7ea42608e13
7
- data.tar.gz: a8aa93af20088a6acc235cfb31045493e91243352a8314b6b3dd0e97e11bbb812002f091a139aee5fa6b7e622a19066464b6915f9b71504452ce76eb237789e1
6
+ metadata.gz: 50dcef75a540af68ba9b9830880cff94a175a28c9eca51a02157a7cff07a73bdaa704deed374ab9e5005a45de2390bd7e8f75a2691dc1d5ee5efed13443455eb
7
+ data.tar.gz: 06e6fecd59fd4624e061efa637799f2e61bedc2a83d909e62a12709926946eb1f1fc30ed14ee5458b8d6cd4c1c82f3e88f15130bbbc830e8aedfda7354f77474
@@ -12,13 +12,13 @@ AllCops:
12
12
  Bundler/OrderedGems:
13
13
  Enabled: false
14
14
 
15
- Layout/HashAlignment:
15
+ Layout/AlignHash:
16
16
  Enabled: false
17
17
 
18
- Layout/ParameterAlignment:
18
+ Layout/AlignParameters:
19
19
  Enabled: false
20
20
 
21
- Layout/FirstArrayElementIndentation:
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
- Metrics/BlockLength:
42
- Exclude:
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
- Style/HashEachMethods:
67
- Enabled: true
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/MethodParameterName:
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
- Style/ClassAndModuleChildren:
99
+ Metrics/ParameterLists:
110
100
  Enabled: false
111
101
 
112
- Metrics/ParameterLists:
102
+ Naming/UncommunicativeBlockParamName:
113
103
  Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.12.1)
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.2.2)
17
- activesupport (= 6.0.2.2)
18
- activesupport (6.0.2.2)
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.1)
30
- chunky_png (1.3.11)
31
- concurrent-ruby (1.1.6)
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
- i18n (1.8.2)
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.0)
40
- nokogiri (1.10.9)
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.7.0)
46
- prawn (2.2.2)
47
- pdf-core (~> 0.7.0)
48
- ttfunk (~> 1.5)
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.6)
123
+ tzinfo (1.2.7)
90
124
  thread_safe (~> 0.1)
91
125
  unicode-display_width (1.5.0)
92
- zeitwerk (2.3.0)
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.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)
@@ -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
 
@@ -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.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
@@ -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__)
@@ -1,97 +1,13 @@
1
1
  module BrDanfe
2
2
  class Danfe
3
- attr_reader :options
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 render_no_fiscal_value
94
- @pdf.stamp('has_no_fiscal_value') if DanfeLib::Helper.no_fiscal_value?(@xml)
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