br_danfe 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -8
  3. data/.github/dependabot.yml +19 -0
  4. data/.rubocop.yml +24 -11
  5. data/Gemfile.lock +38 -30
  6. data/Guardfile +3 -1
  7. data/bin/_guard-core +29 -0
  8. data/bin/guard +29 -0
  9. data/br_danfe.gemspec +6 -5
  10. data/lib/br_danfe/danfe_lib/nfce.rb +10 -8
  11. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +1 -2
  12. data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
  13. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
  14. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +4 -5
  15. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
  16. data/lib/br_danfe/helper.rb +1 -1
  17. data/lib/br_danfe/mdfe.rb +1 -1
  18. data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +1 -1
  19. data/lib/br_danfe/mdfe_lib/fisco_control.rb +6 -25
  20. data/lib/br_danfe/mdfe_lib/header.rb +7 -8
  21. data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +1 -1
  22. data/lib/br_danfe/mdfe_lib/notes.rb +1 -1
  23. data/lib/br_danfe/qr_code.rb +1 -2
  24. data/lib/br_danfe/version.rb +1 -1
  25. data/lib/br_danfe.rb +2 -2
  26. data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +3 -2
  27. data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +2 -2
  28. data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +2 -2
  29. data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +2 -2
  30. data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +2 -2
  31. data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +10 -10
  32. data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +12 -12
  33. data/spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb +4 -4
  34. data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +178 -178
  35. data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +274 -274
  36. data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +77 -77
  37. data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +23 -23
  38. data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +37 -37
  39. data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +34 -34
  40. data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +19 -19
  41. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +237 -237
  42. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +3 -2
  43. data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +16 -16
  44. data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +13 -13
  45. data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +76 -76
  46. data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +40 -40
  47. data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +118 -118
  48. data/spec/br_danfe/danfe_spec.rb +2 -2
  49. data/spec/br_danfe/helper_spec.rb +15 -15
  50. data/spec/br_danfe/mdfe_lib/document_spec.rb +2 -2
  51. data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +21 -7
  52. data/spec/br_danfe/mdfe_lib/header_spec.rb +27 -18
  53. data/spec/br_danfe/mdfe_lib/notes_spec.rb +5 -5
  54. data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +1 -1
  55. data/spec/br_danfe/mdfe_spec.rb +4 -5
  56. data/spec/br_danfe/qr_code_spec.rb +4 -13
  57. data/spec/br_danfe/xml_spec.rb +6 -6
  58. data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
  59. data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
  60. data/spec/spec_helper.rb +1 -1
  61. metadata +35 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ddb33657303d50b425d475e7c493dde5272ed1d4e4bd7d96f9eab45a8f5c600
4
- data.tar.gz: 67ba29fde1351c27b7ff6479a6bfd5d803cc843b4a756f9594bc53c82f44a3a0
3
+ metadata.gz: 75c9447a1d0a80c9293026b9e0c746231a9e5763bfb7712d1c1c659f259aa0e9
4
+ data.tar.gz: edb0a29145a0b5b5b08f0904e4fbf234901b98f250ad72ac8dd5134698badfe3
5
5
  SHA512:
6
- metadata.gz: e99eb16d42eff7bf889afa5d697f75bdba24ebcc091b8713d55fa83e6950f5b2bc4269d7401292594dbcd5585b1698cd2fbfa3ec45fb96dadb94d0f117da4bfb
7
- data.tar.gz: cf348dbad5f7117cda63a7e3d88226c35900a99cfe3ae3dca13e9fab3b093a195c0e7a5331877275b9580ade584422fcb9a63f6b120f7f279eaaf9b647b1ae79
6
+ metadata.gz: 142c384cef5410d88dfe2241cb6ceddaab6fbf36db23341e9ab584cb7f626ea9839618c0860f275e7b0d9512e2cc23ebc6e1ac19a38c71971a56f82d99892aa0
7
+ data.tar.gz: 73bd5e390fcf3e8433aab1148f593db6361122379588195bbcae3aba0b82791657de02855a5b4724c05e8220e2a5287499e225ac150eb5f25958284f1a6d145c
data/.circleci/config.yml CHANGED
@@ -2,28 +2,37 @@ version: 2
2
2
  jobs:
3
3
  build:
4
4
  docker:
5
- - image: circleci/ruby:2.5.1
5
+ - image: circleci/ruby:2.7.4
6
6
  steps:
7
7
  - checkout
8
8
  - restore_cache:
9
- key: brdanfe-cache-v1-{{ checksum "Gemfile.lock" }}
9
+ key: brdanfe-cache-v2-{{ checksum "Gemfile.lock" }}
10
10
  - run: bundle check || bundle install
11
11
  - save_cache:
12
- key: brdanfe-cache-v1-{{ .Environment.CIRCLE_SHA1 }}
12
+ key: brdanfe-cache-v2-{{ .Environment.CIRCLE_SHA1 }}
13
13
  paths:
14
14
  - .
15
15
  - save_cache:
16
- key: brdanfe-cache-v1-{{ checksum "Gemfile.lock" }}
16
+ key: brdanfe-cache-v2-{{ checksum "Gemfile.lock" }}
17
17
  paths:
18
18
  - ./vendor/bundle
19
+ linter:
20
+ docker:
21
+ - image: circleci/ruby:2.7.4
22
+ steps:
23
+ - restore_cache:
24
+ key: brdanfe-cache-v2-{{ .Environment.CIRCLE_SHA1 }}
25
+ - restore_cache:
26
+ key: brdanfe-cache-v2-{{ checksum "Gemfile.lock" }}
27
+ - run: bundle exec rubocop --display-cop-names --parallel
19
28
  rspec:
20
29
  docker:
21
- - image: circleci/ruby:2.5.1
30
+ - image: circleci/ruby:2.7.4
22
31
  steps:
23
32
  - restore_cache:
24
- key: brdanfe-cache-v1-{{ .Environment.CIRCLE_SHA1 }}
33
+ key: brdanfe-cache-v2-{{ .Environment.CIRCLE_SHA1 }}
25
34
  - restore_cache:
26
- key: brdanfe-cache-v1-{{ checksum "Gemfile.lock" }}
35
+ key: brdanfe-cache-v2-{{ checksum "Gemfile.lock" }}
27
36
  - run:
28
37
  name: Install Test Coverage for CodeClimate
29
38
  command: |
@@ -37,6 +46,9 @@ workflows:
37
46
  main:
38
47
  jobs:
39
48
  - build
40
- - rspec:
49
+ - linter:
41
50
  requires:
42
51
  - build
52
+ - rspec:
53
+ requires:
54
+ - linter
@@ -0,0 +1,19 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "wednesday"
13
+ time: "09:00"
14
+ timezone: "America/Sao_Paulo"
15
+ open-pull-requests-limit: 10
16
+ allow:
17
+ - dependency-type: "direct"
18
+ pull-request-branch-name:
19
+ separator: "-"
data/.rubocop.yml CHANGED
@@ -1,29 +1,36 @@
1
- require: rubocop-performance
1
+ require:
2
+ - rubocop-performance
2
3
 
3
4
  AllCops:
4
- TargetRubyVersion: 2.5.1
5
+ TargetRubyVersion: 2.6
5
6
  Exclude:
6
- - 'config/**/*'
7
- - 'spec/spec_helper.rb'
7
+ - bin/**/*
8
+ - vendor/bundle/**/*
9
+ - config/**/*
10
+ - spec/spec_helper.rb
8
11
  - !ruby/regexp /old_and_unused\.rb$/
9
12
  DisplayCopNames: true
10
13
  DisplayStyleGuide: true
14
+ NewCops: enable
11
15
 
12
16
  Bundler/OrderedGems:
13
17
  Enabled: false
14
18
 
15
- Layout/AlignHash:
19
+ Layout/HashAlignment:
16
20
  Enabled: false
17
21
 
18
- Layout/AlignParameters:
22
+ Layout/ParameterAlignment:
19
23
  Enabled: false
20
24
 
21
- Layout/IndentArray:
25
+ Layout/FirstArrayElementIndentation:
22
26
  EnforcedStyle: consistent
23
27
 
24
28
  Layout/SpaceBeforeBlockBraces:
25
29
  EnforcedStyleForEmptyBraces: space
26
30
 
31
+ Layout/LineLength:
32
+ Max: 200
33
+
27
34
  Metrics/ClassLength:
28
35
  Max: 230
29
36
 
@@ -57,8 +64,14 @@ Style/IfUnlessModifier:
57
64
  Style/SymbolArray:
58
65
  EnforcedStyle: brackets
59
66
 
60
- Metrics/LineLength:
61
- Max: 200
67
+ Style/HashEachMethods:
68
+ Enabled: false
69
+
70
+ Style/HashTransformKeys:
71
+ Enabled: false
72
+
73
+ Style/HashTransformValues:
74
+ Enabled: false
62
75
 
63
76
  Lint/AmbiguousBlockAssociation:
64
77
  Exclude:
@@ -87,7 +100,7 @@ Naming/HeredocDelimiterNaming:
87
100
  Naming/HeredocDelimiterCase:
88
101
  Enabled: false
89
102
 
90
- Naming/UncommunicativeMethodParamName:
103
+ Naming/MethodParameterName:
91
104
  Enabled: false
92
105
 
93
106
  Naming/MethodName:
@@ -99,5 +112,5 @@ Naming/VariableName:
99
112
  Metrics/ParameterLists:
100
113
  Enabled: false
101
114
 
102
- Naming/UncommunicativeBlockParamName:
115
+ Naming/BlockParameterName:
103
116
  Enabled: false
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.17.0)
4
+ br_danfe (0.17.1)
5
5
  barby (= 0.6.8)
6
6
  br_documents (>= 0.1.3)
7
7
  i18n (>= 0.8.6)
8
8
  nokogiri (>= 1.8)
9
9
  prawn (~> 2.4.0)
10
10
  prawn-table (= 0.2.2)
11
- rqrcode (~> 1.1.1)
11
+ rqrcode (~> 2.1.0)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
16
  Ascii85 (1.1.0)
17
- activemodel (6.1.4)
18
- activesupport (= 6.1.4)
19
- activesupport (6.1.4)
17
+ activemodel (6.1.4.1)
18
+ activesupport (= 6.1.4.1)
19
+ activesupport (6.1.4.1)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
@@ -36,13 +36,13 @@ GEM
36
36
  docile (1.4.0)
37
37
  ffi (1.15.3)
38
38
  formatador (0.3.0)
39
- guard (2.16.2)
39
+ guard (2.18.0)
40
40
  formatador (>= 0.2.4)
41
41
  listen (>= 2.7, < 4.0)
42
42
  lumberjack (>= 1.0.12, < 2.0)
43
43
  nenv (~> 0.1)
44
44
  notiffany (~> 0.0)
45
- pry (>= 0.9.12)
45
+ pry (>= 0.13.0)
46
46
  shellany (~> 0.0)
47
47
  thor (>= 0.18.1)
48
48
  guard-compat (1.2.1)
@@ -51,23 +51,22 @@ GEM
51
51
  guard-compat (~> 1.1)
52
52
  rspec (>= 2.99.0, < 4.0)
53
53
  hashery (2.1.2)
54
- i18n (1.8.10)
54
+ i18n (1.8.11)
55
55
  concurrent-ruby (~> 1.0)
56
- jaro_winkler (1.5.4)
57
56
  json (2.5.1)
58
- listen (3.5.1)
57
+ listen (3.6.0)
59
58
  rb-fsevent (~> 0.10, >= 0.10.3)
60
59
  rb-inotify (~> 0.9, >= 0.9.10)
61
60
  lumberjack (1.2.8)
62
61
  method_source (1.0.0)
63
62
  minitest (5.14.4)
64
63
  nenv (0.3.0)
65
- nokogiri (1.11.7-x86_64-linux)
64
+ nokogiri (1.12.5-x86_64-darwin)
66
65
  racc (~> 1.4)
67
66
  notiffany (0.1.3)
68
67
  nenv (~> 0.1)
69
68
  shellany (~> 0.0)
70
- parallel (1.20.1)
69
+ parallel (1.21.0)
71
70
  parser (3.0.2.0)
72
71
  ast (~> 2.4.1)
73
72
  pdf-core (0.9.0)
@@ -87,17 +86,18 @@ GEM
87
86
  pry (0.14.1)
88
87
  coderay (~> 1.1)
89
88
  method_source (~> 1.0)
90
- psych (4.0.1)
91
- racc (1.5.2)
89
+ racc (1.6.0)
92
90
  rainbow (3.0.0)
93
91
  rake (13.0.6)
94
92
  rb-fsevent (0.11.0)
95
93
  rb-inotify (0.10.1)
96
94
  ffi (~> 1.0)
97
- rqrcode (1.1.2)
95
+ regexp_parser (2.1.1)
96
+ rexml (3.2.5)
97
+ rqrcode (2.1.0)
98
98
  chunky_png (~> 1.0)
99
- rqrcode_core (~> 0.1)
100
- rqrcode_core (0.2.0)
99
+ rqrcode_core (~> 1.0)
100
+ rqrcode_core (1.2.0)
101
101
  rspec (3.10.0)
102
102
  rspec-core (~> 3.10.0)
103
103
  rspec-expectations (~> 3.10.0)
@@ -111,16 +111,23 @@ GEM
111
111
  diff-lcs (>= 1.2.0, < 2.0)
112
112
  rspec-support (~> 3.10.0)
113
113
  rspec-support (3.10.2)
114
- rubocop (0.67.0)
115
- jaro_winkler (~> 1.5.1)
114
+ rubocop (0.93.1)
116
115
  parallel (~> 1.10)
117
- parser (>= 2.5, != 2.5.1.1)
118
- psych (>= 3.1.0)
116
+ parser (>= 2.7.1.5)
119
117
  rainbow (>= 2.2.2, < 4.0)
118
+ regexp_parser (>= 1.8)
119
+ rexml
120
+ rubocop-ast (>= 0.6.0)
120
121
  ruby-progressbar (~> 1.7)
121
- unicode-display_width (>= 1.4.0, < 1.6)
122
- rubocop-performance (1.1.0)
123
- rubocop (>= 0.67.0)
122
+ unicode-display_width (>= 1.4.0, < 2.0)
123
+ rubocop-ast (1.13.0)
124
+ parser (>= 3.0.1.1)
125
+ rubocop-performance (1.10.2)
126
+ rubocop (>= 0.90.0, < 2.0)
127
+ rubocop-ast (>= 0.4.0)
128
+ rubocop-rspec (1.44.1)
129
+ rubocop (~> 0.87)
130
+ rubocop-ast (>= 0.7.1)
124
131
  ruby-progressbar (1.11.0)
125
132
  ruby-rc4 (0.1.5)
126
133
  shellany (0.0.1)
@@ -133,8 +140,8 @@ GEM
133
140
  ttfunk (1.7.0)
134
141
  tzinfo (2.0.4)
135
142
  concurrent-ruby (~> 1.0)
136
- unicode-display_width (1.5.0)
137
- zeitwerk (2.4.2)
143
+ unicode-display_width (1.8.0)
144
+ zeitwerk (2.5.1)
138
145
 
139
146
  PLATFORMS
140
147
  ruby
@@ -142,15 +149,16 @@ PLATFORMS
142
149
  DEPENDENCIES
143
150
  br_danfe!
144
151
  byebug (= 11.1.3)
145
- guard (~> 2.16.2)
152
+ guard (~> 2.18.0)
146
153
  guard-rspec
147
154
  pdf-inspector (~> 1.3.0)
148
155
  rake (= 13.0.6)
149
156
  rspec (= 3.10.0)
150
- rubocop (= 0.67.0)
151
- rubocop-performance (~> 1.1.0)
157
+ rubocop (~> 0.93.1)
158
+ rubocop-performance (~> 1.10.2)
159
+ rubocop-rspec (~> 1.44.1)
152
160
  simplecov (= 0.17.1)
153
161
  simplecov-html (= 0.10.2)
154
162
 
155
163
  BUNDLED WITH
156
- 1.17.3
164
+ 2.1.4
data/Guardfile CHANGED
@@ -1,4 +1,6 @@
1
- guard :rspec, cmd: 'bundle exec rspec' do
1
+ directories %w[lib spec]
2
+
3
+ guard :rspec, cmd: 'NO_COVERAGE=true bundle exec rspec' do
2
4
  require 'guard/rspec/dsl'
3
5
  dsl = Guard::RSpec::Dsl.new(self)
4
6
 
data/bin/_guard-core ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application '_guard-core' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "_guard-core")
data/bin/guard ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'guard' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "guard")
data/br_danfe.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = `git ls-files -- { test,spec,features }/*`.split("\n")
15
15
  spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
16
  spec.require_paths = ['lib']
17
- spec.required_ruby_version = '>= 2.5.1'
17
+ spec.required_ruby_version = '>= 2.6'
18
18
 
19
19
  spec.add_dependency 'barby', '0.6.8'
20
20
  spec.add_dependency 'br_documents', '>= 0.1.3'
@@ -22,16 +22,17 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'nokogiri', '>= 1.8'
23
23
  spec.add_dependency 'prawn', '~> 2.4.0'
24
24
  spec.add_dependency 'prawn-table', '0.2.2'
25
- spec.add_dependency 'rqrcode', '~> 1.1.1'
25
+ spec.add_dependency 'rqrcode', '~> 2.1.0'
26
26
 
27
27
  spec.add_development_dependency 'byebug', '11.1.3'
28
- spec.add_development_dependency 'guard', '~> 2.16.2'
28
+ spec.add_development_dependency 'guard', '~> 2.18.0'
29
29
  spec.add_development_dependency 'guard-rspec'
30
30
  spec.add_development_dependency 'pdf-inspector', '~> 1.3.0'
31
31
  spec.add_development_dependency 'rake', '13.0.6'
32
32
  spec.add_development_dependency 'rspec', '3.10.0'
33
- spec.add_development_dependency 'rubocop', '0.67.0'
34
- spec.add_development_dependency 'rubocop-performance', '~> 1.1.0'
33
+ spec.add_development_dependency 'rubocop', '~> 0.93.1'
34
+ spec.add_development_dependency 'rubocop-performance', '~> 1.10.2'
35
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
35
36
  spec.add_development_dependency 'simplecov', '0.17.1'
36
37
  spec.add_development_dependency 'simplecov-html', '0.10.2'
37
38
  end
@@ -13,13 +13,15 @@ module BrDanfe
13
13
  def create_watermark
14
14
  @document.create_stamp('has_no_fiscal_value') do
15
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
16
+ @document.text_box(
17
+ I18n.t('danfe.others.has_no_fiscal_value'),
18
+ size: 0.8.cm,
19
+ width: 10.cm,
20
+ height: 1.2.cm,
21
+ at: [0, PAGE_HEIGHT - 3.8.cm],
22
+ rotate: 45,
23
+ rotate_around: :center
24
+ )
23
25
  end
24
26
  end
25
27
 
@@ -31,7 +33,7 @@ module BrDanfe
31
33
  NfceLib::Key.new(@document, xml).render
32
34
  NfceLib::Recipient.new(@document, xml).render
33
35
  NfceLib::NfceIdentification.new(@document, xml).render
34
- BrDanfe::QrCode.new(pdf: @document, xml: xml, qr_code_tag: xml['qrCode'], box_size: 4.5.cm).render
36
+ BrDanfe::QrCode.new(pdf: @document, qr_code_tag: xml['qrCode'], box_size: 4.5.cm).render
35
37
  NfceLib::Footer.new(@document, xml).render(footer_info)
36
38
 
37
39
  render_no_fiscal_value(xml)
@@ -42,8 +42,7 @@ module BrDanfe
42
42
 
43
43
  def cnpj(info)
44
44
  cnpj = BrDocuments::CnpjCpf::Cnpj.new info
45
- data = "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
46
- data
45
+ "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
47
46
  end
48
47
 
49
48
  def count_name_lines(company_name)
@@ -10,15 +10,17 @@ module BrDanfe
10
10
  def create_watermark
11
11
  @document.create_stamp('has_no_fiscal_value') do
12
12
  @document.fill_color '7d7d7d'
13
- @document.text_box I18n.t('danfe.others.has_no_fiscal_value'),
14
- size: 2.2.cm,
15
- width: @document.bounds.width,
16
- height: @document.bounds.height,
17
- align: :center,
18
- valign: :center,
19
- at: [0, @document.bounds.height],
20
- rotate: 45,
21
- rotate_around: :center
13
+ @document.text_box(
14
+ I18n.t('danfe.others.has_no_fiscal_value'),
15
+ size: 2.2.cm,
16
+ width: @document.bounds.width,
17
+ height: @document.bounds.height,
18
+ align: :center,
19
+ valign: :center,
20
+ at: [0, @document.bounds.height],
21
+ rotate: 45,
22
+ rotate_around: :center
23
+ )
22
24
  end
23
25
  end
24
26
 
@@ -38,8 +38,7 @@ module BrDanfe
38
38
 
39
39
  def dtduplicata(det)
40
40
  dtduplicata = det.css('dVenc').text
41
- dtduplicata = dtduplicata[8, 2] + '/' + dtduplicata[5, 2] + '/' + dtduplicata[0, 4]
42
- dtduplicata
41
+ "#{dtduplicata[8, 2]}/#{dtduplicata[5, 2]}/#{dtduplicata[0, 4]}"
43
42
  end
44
43
 
45
44
  def normal
@@ -38,11 +38,10 @@ module BrDanfe
38
38
  end
39
39
 
40
40
  def address
41
- formatted = @xml['enderEmit/xLgr'] + ', ' + @xml['enderEmit/nro'] + "\n"
42
- formatted += @xml['enderEmit/xBairro'] + ' - ' + cep + "\n"
43
- formatted += @xml['enderEmit/xMun'] + '/' + @xml['enderEmit/UF'] + "\n"
44
- formatted += phone + ' ' + @xml['enderEmit/email']
45
- formatted
41
+ "#{@xml['enderEmit/xLgr']}, #{@xml['enderEmit/nro']}\n" \
42
+ "#{@xml['enderEmit/xBairro']} - #{cep}\n" \
43
+ "#{@xml['enderEmit/xMun']}/#{@xml['enderEmit/UF']}\n" \
44
+ "#{phone} #{@xml['enderEmit/email']}"
46
45
  end
47
46
 
48
47
  def phone
@@ -93,7 +93,8 @@ module BrDanfe
93
93
  end
94
94
 
95
95
  def difal?
96
- @xml['ICMSTot/vICMSUFDest'].to_f != 0
96
+ value = @xml['ICMSTot/vICMSUFDest'].presence || '0.0'
97
+ BigDecimal(value).positive?
97
98
  end
98
99
 
99
100
  def fisco_content
@@ -20,7 +20,7 @@ module BrDanfe
20
20
  decimal_part = separated_number[1] || '00'
21
21
  decimal_part += '0' if decimal_part.size < 2
22
22
 
23
- integer_part + ',' + decimal_part
23
+ "#{integer_part},#{decimal_part}"
24
24
  end
25
25
 
26
26
  def self.format_datetime(xml_datetime, with_time_zone: false)
data/lib/br_danfe/mdfe.rb CHANGED
@@ -7,7 +7,7 @@ module BrDanfe
7
7
  attr_reader :logo_options
8
8
 
9
9
  def initialize(xml)
10
- @xml = xml
10
+ @xml = BrDanfe::XML.new(xml)
11
11
  @pdf = MdfeLib::Document.new
12
12
  @logo_options = BrDanfe::Logo::Config.new
13
13
  end
@@ -14,7 +14,7 @@ module BrDanfe
14
14
 
15
15
  def authorization
16
16
  title = 'Protocolo de autorização'
17
- protocol = @xml['infProt/nProt'] + ' - ' + Helper.format_datetime(@xml['infProt/dhRecbto'], with_time_zone: true)
17
+ protocol = "#{@xml['infProt/nProt']} - #{Helper.format_datetime(@xml['infProt/dhRecbto'], with_time_zone: true)}"
18
18
 
19
19
  @pdf.text_box(title, size: 9, align: :left, style: :bold, at: [0, 510])
20
20
  @pdf.text_box(protocol, size: 11, align: :left, at: [0, 500])
@@ -3,37 +3,18 @@ module BrDanfe
3
3
  class FiscoControl
4
4
  def initialize(pdf, xml)
5
5
  @pdf = pdf
6
- @xml = xml
6
+ @nfe_key = xml['mdfeProc > protMDFe > infProt > chMDFe']
7
7
  end
8
8
 
9
9
  def generate
10
- title
11
- barcode
12
- generate_nfe_key
13
- end
14
-
15
- private
16
-
17
- def title
18
- title = 'CONTROLE DO FISCO'
19
-
20
- @pdf.text_box(title, size: 9, align: :left, at: [250, 600])
21
- end
22
-
23
- def barcode
24
- barcode = Barby::Code128C.new(nfe_key)
25
- barcode.annotate_pdf(@pdf, x: 250, y: 530, height: 50)
26
- end
10
+ @pdf.text_box('CONTROLE DO FISCO', size: 9, align: :left, at: [250, 600])
27
11
 
28
- def nfe_key
29
- @xml['mdfeProc > protMDFe > infProt > chMDFe']
30
- end
12
+ return if @nfe_key.blank?
31
13
 
32
- def generate_nfe_key
33
- title = 'Chave de Acesso'
14
+ Barby::Code128C.new(@nfe_key).annotate_pdf(@pdf, x: 250, y: 530, height: 50)
34
15
 
35
- @pdf.text_box(title, size: 9, align: :left, style: :bold, at: [250, 510])
36
- @pdf.text_box(nfe_key, size: 11, align: :left, at: [250, 500])
16
+ @pdf.text_box('Chave de Acesso', size: 9, align: :left, style: :bold, at: [250, 510])
17
+ @pdf.text_box(@nfe_key, size: 11, align: :left, at: [250, 500])
37
18
  end
38
19
  end
39
20
  end
@@ -11,7 +11,7 @@ module BrDanfe
11
11
  def generate
12
12
  generate_emit
13
13
  generate_title
14
- qr_code
14
+ generate_qr_code if @xml['qrCodMDFe'].present?
15
15
  end
16
16
 
17
17
  private
@@ -34,9 +34,8 @@ module BrDanfe
34
34
  end
35
35
 
36
36
  def address
37
- formatted = @xml['enderEmit/xLgr'] + ', nº ' + @xml['enderEmit/nro'] + "\n"
38
- formatted += @xml['enderEmit/xMun'] + ' - ' + @xml['enderEmit/UF'] + ' ' + 'CEP ' + cep + "\n"
39
- formatted
37
+ "#{@xml['enderEmit/xLgr']}, nº #{@xml['enderEmit/nro']}\n" \
38
+ "#{@xml['enderEmit/xMun']} - #{@xml['enderEmit/UF']} CEP #{cep}\n"
40
39
  end
41
40
 
42
41
  def cep
@@ -44,7 +43,7 @@ module BrDanfe
44
43
  end
45
44
 
46
45
  def company_informations
47
- '<b>CNPJ: </b>' + @xml['emit/CNPJ'] + ' ' + '<b>IE: </b>' + @xml['emit/IE']
46
+ "<b>CNPJ: </b>#{@xml['emit/CNPJ']} <b>IE: </b>#{@xml['emit/IE']}"
48
47
  end
49
48
 
50
49
  def logo
@@ -65,12 +64,12 @@ module BrDanfe
65
64
  end
66
65
  end
67
66
 
68
- def qr_code
67
+ def generate_qr_code
69
68
  box_size = 40.mm
70
- security_margin = box_size + box_size / 10.0
69
+ security_margin = box_size + (box_size / 10.0)
71
70
 
72
71
  @pdf.bounding_box([414, 780], width: security_margin, height: security_margin) do
73
- BrDanfe::QrCode.new(pdf: @pdf, xml: @xml, qr_code_tag: @xml['qrCodMDFe'], box_size: box_size).render
72
+ BrDanfe::QrCode.new(pdf: @pdf, qr_code_tag: @xml['qrCodMDFe'], box_size: box_size).render
74
73
  end
75
74
  end
76
75
  end
@@ -48,7 +48,7 @@ module BrDanfe
48
48
  end
49
49
 
50
50
  def number_of_pages(page)
51
- text = page.to_s + '/' + @pdf.page_count.to_s
51
+ text = "#{page}/#{@pdf.page_count}"
52
52
  generate_box('FL', text, 125)
53
53
  end
54
54