br_danfe 0.15.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) 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/.tool-versions +1 -0
  6. data/Gemfile.lock +69 -50
  7. data/Guardfile +4 -2
  8. data/README.md +23 -0
  9. data/bin/_guard-core +29 -0
  10. data/bin/guard +29 -0
  11. data/br_danfe.gemspec +9 -7
  12. data/lib/br_danfe/danfe_lib/nfce.rb +11 -9
  13. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +1 -1
  14. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +2 -2
  15. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +30 -16
  16. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +3 -3
  17. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +3 -3
  18. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +44 -53
  19. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +1 -1
  20. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +16 -15
  21. data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
  22. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +1 -1
  23. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
  24. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +5 -6
  25. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
  26. data/lib/br_danfe/document_builder.rb +1 -1
  27. data/lib/br_danfe/helper.rb +8 -10
  28. data/lib/br_danfe/mdfe.rb +55 -0
  29. data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +24 -0
  30. data/lib/br_danfe/mdfe_lib/document.rb +26 -0
  31. data/lib/br_danfe/mdfe_lib/drivers.rb +70 -0
  32. data/lib/br_danfe/mdfe_lib/fisco_control.rb +21 -0
  33. data/lib/br_danfe/mdfe_lib/header.rb +77 -0
  34. data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +69 -0
  35. data/lib/br_danfe/mdfe_lib/notes.rb +94 -0
  36. data/lib/br_danfe/mdfe_lib/totalizer.rb +57 -0
  37. data/lib/br_danfe/mdfe_lib/vehicles.rb +80 -0
  38. data/lib/br_danfe/qr_code.rb +21 -0
  39. data/lib/br_danfe/version.rb +1 -1
  40. data/lib/br_danfe.rb +2 -2
  41. data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +3 -2
  42. data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +6 -4
  43. data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +2 -2
  44. data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +2 -2
  45. data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +2 -2
  46. data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +10 -10
  47. data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +12 -12
  48. data/spec/br_danfe/danfe_lib/nfce_spec.rb +2 -1
  49. data/spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb +4 -4
  50. data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +178 -178
  51. data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +274 -274
  52. data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +77 -77
  53. data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +23 -23
  54. data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +37 -37
  55. data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +34 -34
  56. data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +19 -19
  57. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +240 -240
  58. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +3 -2
  59. data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +16 -16
  60. data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +13 -13
  61. data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +76 -76
  62. data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +40 -40
  63. data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +118 -118
  64. data/spec/br_danfe/danfe_spec.rb +2 -2
  65. data/spec/br_danfe/helper_spec.rb +26 -14
  66. data/spec/br_danfe/mdfe_lib/authorization_protocol_spec.rb +35 -0
  67. data/spec/br_danfe/mdfe_lib/document_spec.rb +20 -0
  68. data/spec/br_danfe/mdfe_lib/drivers_spec.rb +88 -0
  69. data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +69 -0
  70. data/spec/br_danfe/mdfe_lib/header_spec.rb +135 -0
  71. data/spec/br_danfe/mdfe_lib/mdfe_identification_spec.rb +104 -0
  72. data/spec/br_danfe/mdfe_lib/notes_spec.rb +97 -0
  73. data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +63 -0
  74. data/spec/br_danfe/mdfe_lib/vehicles_spec.rb +66 -0
  75. data/spec/br_danfe/mdfe_spec.rb +45 -0
  76. data/spec/br_danfe/qr_code_spec.rb +31 -0
  77. data/spec/br_danfe/xml_spec.rb +6 -6
  78. data/spec/fixtures/mdfe/lib/document#render.pdf +0 -0
  79. data/spec/fixtures/mdfe/lib/document#text.align.pdf +0 -0
  80. data/spec/fixtures/mdfe/lib/document#text.pad.pdf +0 -0
  81. data/spec/fixtures/mdfe/lib/document#text.simple.pdf +0 -0
  82. data/spec/fixtures/mdfe/lib/document#text.size.pdf +0 -0
  83. data/spec/fixtures/mdfe/lib/document#text.style.pdf +0 -0
  84. data/spec/fixtures/mdfe/lib/fisco_control#barcode.pdf +0 -0
  85. data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
  86. data/spec/fixtures/mdfe/lib/header#render-qr-code.pdf +0 -0
  87. data/spec/fixtures/mdfe/lib/header#render-with_logo.pdf +0 -0
  88. data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
  89. data/spec/fixtures/mdfe/lib/header#render-without_logo.pdf +0 -0
  90. data/spec/fixtures/mdfe/lib/mdfe-with-multiple-pages.pdf +1945 -0
  91. data/spec/fixtures/mdfe/lib/mdfe.fixture.pdf +1286 -0
  92. data/spec/fixtures/mdfe/lib/notes#render-big-aditional-information.pdf +1943 -0
  93. data/spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml +116 -0
  94. data/spec/fixtures/mdfe/lib/xml-mdfe.xml +250 -0
  95. data/spec/fixtures/nfce/lib/document#render.pdf +12 -23
  96. data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +0 -0
  97. data/spec/fixtures/nfce/lib/footer#render.pdf +0 -0
  98. data/spec/fixtures/nfce/lib/header#render-homologation.pdf +0 -0
  99. data/spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf +0 -0
  100. data/spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf +0 -0
  101. data/spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf +0 -0
  102. data/spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf +0 -0
  103. data/spec/fixtures/nfce/lib/key#render.pdf +0 -0
  104. data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +0 -0
  105. data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +0 -0
  106. data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +0 -0
  107. data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +0 -0
  108. data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +0 -0
  109. data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +2 -2
  110. data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +1 -1
  111. data/spec/fixtures/nfce/lib/recipient#render-company.pdf +0 -0
  112. data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +0 -0
  113. data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +0 -0
  114. data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +0 -0
  115. data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +0 -0
  116. data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +0 -0
  117. data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +0 -0
  118. data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +0 -0
  119. data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +0 -0
  120. data/spec/fixtures/nfce/lib/total_list#render.pdf +0 -0
  121. data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +568 -447
  122. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  123. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  124. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  125. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  126. data/spec/fixtures/qr_code/qr_code#render.pdf +0 -0
  127. data/spec/spec_helper.rb +1 -1
  128. metadata +118 -48
  129. data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +0 -25
  130. data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +0 -11
  131. data/spec/br_danfe/danfe_lib/nfce_lib/qr_code_spec.rb +0 -35
  132. data/spec/br_danfe/danfe_lib/nfe_lib/cep_spec.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 210c7c1c3a0ea98ed48753e1432c91ae8f4795400d5df40d7d9c2e0a91d4c502
4
- data.tar.gz: 611c666027eca9cac90640753446085f58b4b9deacc43c8d0df5f7150d623a1f
3
+ metadata.gz: 7d7ff47128c1eb8696ae40615a70cda26ce2a79e78e9e08ca4b87022a05e80a0
4
+ data.tar.gz: a69988df12809c67c14fd780c9f9863511113f954c4e1e18743eefd6c92e1bd7
5
5
  SHA512:
6
- metadata.gz: 4c04ab16fdac8a9285024a018b2c23cdd5d65c6e2748b8cafa9e97ec67cf10f49cc0e0766a475e060f2c65793a6400795988e299d6931bd4cacb2ed01d18092f
7
- data.tar.gz: b894f40fba2376bd795beadfbf47dabe2db2c9d7a40e69c728d29550397c6df2baf14acb39ff73cface9df9ffd2de7832b2762647ccf2ab6715134fcfb740c82
6
+ metadata.gz: 2b7bb8b7db6a30564905827ee2c89e427db7d9ad6b771740f9c90f36140ef8705266f42dacc2dcf60981d828846f60ad2cf7064364f7688955b7fa8871218589
7
+ data.tar.gz: f473cd9b67ad5c62e21a1d0f152e8c951f4158c4a13ac17bb4f7f0df87734c924171d56f2504f81a48038fd76355b0e22d0c3931491855f110d5adf0fc24d277
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/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.4
data/Gemfile.lock CHANGED
@@ -1,29 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.15.1)
4
+ br_danfe (0.17.2)
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
- activemodel (6.1.3.2)
17
- activesupport (= 6.1.3.2)
18
- activesupport (6.1.3.2)
16
+ Ascii85 (1.1.0)
17
+ activemodel (6.1.4.1)
18
+ activesupport (= 6.1.4.1)
19
+ activesupport (6.1.4.1)
19
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
21
  i18n (>= 1.6, < 2)
21
22
  minitest (>= 5.1)
22
23
  tzinfo (~> 2.0)
23
24
  zeitwerk (~> 2.3)
24
- ast (2.4.0)
25
+ afm (0.2.2)
26
+ ast (2.4.2)
25
27
  barby (0.6.8)
26
- br_documents (0.2.0)
28
+ br_documents (0.2.1)
27
29
  activemodel (>= 4.0.0)
28
30
  i18n (>= 0.6.5)
29
31
  byebug (11.1.3)
@@ -31,16 +33,16 @@ GEM
31
33
  coderay (1.1.3)
32
34
  concurrent-ruby (1.1.9)
33
35
  diff-lcs (1.4.4)
34
- docile (1.3.2)
35
- ffi (1.13.1)
36
- formatador (0.2.5)
37
- guard (2.16.2)
36
+ docile (1.4.0)
37
+ ffi (1.15.3)
38
+ formatador (0.3.0)
39
+ guard (2.18.0)
38
40
  formatador (>= 0.2.4)
39
41
  listen (>= 2.7, < 4.0)
40
42
  lumberjack (>= 1.0.12, < 2.0)
41
43
  nenv (~> 0.1)
42
44
  notiffany (~> 0.0)
43
- pry (>= 0.9.12)
45
+ pry (>= 0.13.0)
44
46
  shellany (~> 0.0)
45
47
  thor (>= 0.18.1)
46
48
  guard-compat (1.2.1)
@@ -48,83 +50,98 @@ GEM
48
50
  guard (~> 2.1)
49
51
  guard-compat (~> 1.1)
50
52
  rspec (>= 2.99.0, < 4.0)
51
- i18n (1.8.10)
53
+ hashery (2.1.2)
54
+ i18n (1.8.11)
52
55
  concurrent-ruby (~> 1.0)
53
- jaro_winkler (1.5.4)
54
- json (2.3.0)
55
- listen (3.2.1)
56
+ json (2.5.1)
57
+ listen (3.6.0)
56
58
  rb-fsevent (~> 0.10, >= 0.10.3)
57
59
  rb-inotify (~> 0.9, >= 0.9.10)
58
60
  lumberjack (1.2.8)
59
61
  method_source (1.0.0)
60
- mini_portile2 (2.5.3)
61
62
  minitest (5.14.4)
62
63
  nenv (0.3.0)
63
- nokogiri (1.11.7)
64
- mini_portile2 (~> 2.5.0)
64
+ nokogiri (1.12.5-x86_64-darwin)
65
65
  racc (~> 1.4)
66
66
  notiffany (0.1.3)
67
67
  nenv (~> 0.1)
68
68
  shellany (~> 0.0)
69
- parallel (1.19.1)
70
- parser (2.7.0.4)
71
- ast (~> 2.4.0)
69
+ parallel (1.21.0)
70
+ parser (3.0.2.0)
71
+ ast (~> 2.4.1)
72
72
  pdf-core (0.9.0)
73
+ pdf-inspector (1.3.0)
74
+ pdf-reader (>= 1.0, < 3.0.a)
75
+ pdf-reader (2.5.0)
76
+ Ascii85 (~> 1.0)
77
+ afm (~> 0.2.1)
78
+ hashery (~> 2.0)
79
+ ruby-rc4
80
+ ttfunk
73
81
  prawn (2.4.0)
74
82
  pdf-core (~> 0.9.0)
75
83
  ttfunk (~> 1.7)
76
84
  prawn-table (0.2.2)
77
85
  prawn (>= 1.3.0, < 3.0.0)
78
- pry (0.13.1)
86
+ pry (0.14.1)
79
87
  coderay (~> 1.1)
80
88
  method_source (~> 1.0)
81
- psych (3.1.0)
82
- racc (1.5.2)
89
+ racc (1.6.0)
83
90
  rainbow (3.0.0)
84
- rake (13.0.1)
85
- rb-fsevent (0.10.4)
91
+ rake (13.0.6)
92
+ rb-fsevent (0.11.0)
86
93
  rb-inotify (0.10.1)
87
94
  ffi (~> 1.0)
88
- rqrcode (1.1.2)
95
+ regexp_parser (2.1.1)
96
+ rexml (3.2.5)
97
+ rqrcode (2.1.0)
89
98
  chunky_png (~> 1.0)
90
- rqrcode_core (~> 0.1)
91
- rqrcode_core (0.2.0)
99
+ rqrcode_core (~> 1.0)
100
+ rqrcode_core (1.2.0)
92
101
  rspec (3.10.0)
93
102
  rspec-core (~> 3.10.0)
94
103
  rspec-expectations (~> 3.10.0)
95
104
  rspec-mocks (~> 3.10.0)
96
- rspec-core (3.10.0)
105
+ rspec-core (3.10.1)
97
106
  rspec-support (~> 3.10.0)
98
- rspec-expectations (3.10.0)
107
+ rspec-expectations (3.10.1)
99
108
  diff-lcs (>= 1.2.0, < 2.0)
100
109
  rspec-support (~> 3.10.0)
101
- rspec-mocks (3.10.0)
110
+ rspec-mocks (3.10.2)
102
111
  diff-lcs (>= 1.2.0, < 2.0)
103
112
  rspec-support (~> 3.10.0)
104
- rspec-support (3.10.0)
105
- rubocop (0.67.0)
106
- jaro_winkler (~> 1.5.1)
113
+ rspec-support (3.10.2)
114
+ rubocop (0.93.1)
107
115
  parallel (~> 1.10)
108
- parser (>= 2.5, != 2.5.1.1)
109
- psych (>= 3.1.0)
116
+ parser (>= 2.7.1.5)
110
117
  rainbow (>= 2.2.2, < 4.0)
118
+ regexp_parser (>= 1.8)
119
+ rexml
120
+ rubocop-ast (>= 0.6.0)
111
121
  ruby-progressbar (~> 1.7)
112
- unicode-display_width (>= 1.4.0, < 1.6)
113
- rubocop-performance (1.1.0)
114
- rubocop (>= 0.67.0)
115
- ruby-progressbar (1.10.1)
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)
131
+ ruby-progressbar (1.11.0)
132
+ ruby-rc4 (0.1.5)
116
133
  shellany (0.0.1)
117
134
  simplecov (0.17.1)
118
135
  docile (~> 1.1)
119
136
  json (>= 1.8, < 3)
120
137
  simplecov-html (~> 0.10.0)
121
138
  simplecov-html (0.10.2)
122
- thor (1.0.1)
139
+ thor (1.1.0)
123
140
  ttfunk (1.7.0)
124
141
  tzinfo (2.0.4)
125
142
  concurrent-ruby (~> 1.0)
126
- unicode-display_width (1.5.0)
127
- zeitwerk (2.4.2)
143
+ unicode-display_width (1.8.0)
144
+ zeitwerk (2.5.1)
128
145
 
129
146
  PLATFORMS
130
147
  ruby
@@ -132,14 +149,16 @@ PLATFORMS
132
149
  DEPENDENCIES
133
150
  br_danfe!
134
151
  byebug (= 11.1.3)
135
- guard (~> 2.16.2)
152
+ guard (~> 2.18.0)
136
153
  guard-rspec
137
- rake (= 13.0.1)
154
+ pdf-inspector (~> 1.3.0)
155
+ rake (= 13.0.6)
138
156
  rspec (= 3.10.0)
139
- rubocop (= 0.67.0)
140
- rubocop-performance (~> 1.1.0)
157
+ rubocop (~> 0.93.1)
158
+ rubocop-performance (~> 1.10.2)
159
+ rubocop-rspec (~> 1.44.1)
141
160
  simplecov (= 0.17.1)
142
161
  simplecov-html (= 0.10.2)
143
162
 
144
163
  BUNDLED WITH
145
- 1.17.3
164
+ 2.1.4
data/Guardfile CHANGED
@@ -1,5 +1,7 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
2
- require "guard/rspec/dsl"
1
+ directories %w[lib spec]
2
+
3
+ guard :rspec, cmd: 'NO_COVERAGE=true bundle exec rspec' do
4
+ require 'guard/rspec/dsl'
3
5
  dsl = Guard::RSpec::Dsl.new(self)
4
6
 
5
7
  # RSpec files
data/README.md CHANGED
@@ -88,6 +88,29 @@ XML version | Supported?
88
88
  end
89
89
  end
90
90
 
91
+ ### DAMDFE - _Documento Auxiliar do Manifesto Eletrônico de Documentos Fiscais_
92
+
93
+ #### Usage in Ruby
94
+
95
+ xml = File.read("mdfe.xml")
96
+
97
+ mdfe = BrDanfe::Mdfe.new(xml)
98
+ mdfe.save_pdf("mdfe.pdf")
99
+
100
+ #### Usage in Rails Controller
101
+
102
+ class MdfeController < ApplicationController
103
+ def new
104
+ mdfe = Mdfe.find(params[:id])
105
+ xml_as_string = mdfe.generate_xml # your method that generates the MDF-e's xml
106
+
107
+ mdfe = BrDanfe::Mdfe.new(xml_as_string)
108
+
109
+ send_data mdfe.render_pdf, filename: "mdfe.pdf", type: "application/pdf"
110
+ end
111
+ end
112
+
113
+
91
114
  ## I18n
92
115
 
93
116
  By default, your rails application must be configured to `pt-Br`.
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,15 +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 'rake', '13.0.1'
28
+ spec.add_development_dependency 'guard', '~> 2.18.0'
29
+ spec.add_development_dependency 'guard-rspec'
30
+ spec.add_development_dependency 'pdf-inspector', '~> 1.3.0'
31
+ spec.add_development_dependency 'rake', '13.0.6'
29
32
  spec.add_development_dependency 'rspec', '3.10.0'
30
- spec.add_development_dependency 'rubocop', '0.67.0'
31
- 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'
32
36
  spec.add_development_dependency 'simplecov', '0.17.1'
33
37
  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'
36
38
  end
@@ -1,7 +1,7 @@
1
1
  module BrDanfe
2
2
  module DanfeLib
3
3
  class Nfce < Base
4
- PAGE_WIDTH = 8.cm
4
+ PAGE_WIDTH = 7.cm
5
5
  PAGE_HEIGHT = 100.cm
6
6
 
7
7
  private
@@ -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
- NfceLib::QrCode.new(@document, xml).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)
@@ -12,7 +12,7 @@ module BrDanfe
12
12
  botton_margin: 0
13
13
  )
14
14
 
15
- @document.font 'Courier'
15
+ @document.font 'tinos'
16
16
  @document.line_width = 0.3
17
17
  end
18
18
 
@@ -9,11 +9,11 @@ module BrDanfe
9
9
 
10
10
  def render(info = '')
11
11
  tot_trib = @xml['ICMSTot/vTotTrib'].present? ? BrDanfe::Helper.numerify(@xml['ICMSTot/vTotTrib']) : '0,00'
12
- @pdf.text "Tributos Totais Incidentes (Lei Federal 12.741/2012): R$ #{tot_trib}", size: 5, align: :center
12
+ @pdf.text "Tributos Totais Incidentes (Lei Federal 12.741/2012): R$ #{tot_trib}", size: 8, align: :center
13
13
 
14
14
  if info.present?
15
15
  @pdf.render_blank_line
16
- @pdf.text info, size: 5, align: :center
16
+ @pdf.text info, size: 8, align: :center
17
17
  end
18
18
  end
19
19
  end
@@ -12,38 +12,40 @@ module BrDanfe
12
12
  def render
13
13
  cursor = @pdf.cursor
14
14
 
15
- render_company_info(cursor)
15
+ render_company_info
16
16
  render_logo(cursor) if @logo.present?
17
+ render_doc
17
18
 
18
19
  render_homologation if BrDanfe::Helper.homologation?(@xml)
19
20
  end
20
21
 
21
22
  private
22
23
 
23
- def render_company_info(cursor)
24
+ def render_company_info
24
25
  one_line = 1
25
26
 
26
- @pdf.bounding_box([x_position, cursor], width: width_box, height: 45) do
27
- @pdf.text (@xml['emit/xNome']).to_s, size: 7, align: :left, style: :bold
28
- @pdf.text cnpj(@xml['emit/CNPJ']), size: 6, align: :left
29
- @pdf.text BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), size: 6, align: :left
30
- @pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
31
- @pdf.text 'Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica', size: 6, align: :left
32
- end
27
+ @pdf.text_box (@xml['emit/xNome']).to_s, at: [x_position, @pdf.cursor], height: 36, size: 9, align: :left, style: :bold, overflow: :shrink_to_fit
28
+ @pdf.move_down 36
29
+
30
+ @pdf.text_box cnpj(@xml['emit/CNPJ']), at: [x_position, @pdf.cursor], height: 9, size: 9, align: :left, overflow: :shrink_to_fit
31
+ @pdf.move_down 9
32
+
33
+ @pdf.text_box BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), at: [x_position, @pdf.cursor], height: 20, size: 9, align: :left, overflow: :shrink_to_fit
34
+ @pdf.move_down 20
35
+ @pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
33
36
  end
34
37
 
35
38
  def x_position
36
- @logo.present? ? 1.7.cm : 0
39
+ @logo.present? ? 2.2.cm : 0
37
40
  end
38
41
 
39
42
  def width_box
40
- @logo.present? ? 5.7.cm : 7.4.cm
43
+ @logo.present? ? 4.5.cm : 6.7.cm
41
44
  end
42
45
 
43
46
  def cnpj(info)
44
47
  cnpj = BrDocuments::CnpjCpf::Cnpj.new info
45
- data = "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
46
- data
48
+ "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
47
49
  end
48
50
 
49
51
  def count_name_lines(company_name)
@@ -51,7 +53,7 @@ module BrDanfe
51
53
  end
52
54
 
53
55
  def render_logo(cursor)
54
- box_size = 45
56
+ box_size = 60
55
57
  logo_options = BrDanfe::Logo::Options.new(box_size, @logo_dimensions).options
56
58
 
57
59
  @pdf.bounding_box([0, cursor], width: box_size, height: box_size) do
@@ -59,9 +61,21 @@ module BrDanfe
59
61
  end
60
62
  end
61
63
 
62
- def render_homologation
64
+ def render_doc
63
65
  @pdf.render_blank_line
64
- @pdf.text 'EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL', size: 7, align: :center, style: :bold
66
+
67
+ @pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
68
+ @pdf.text 'Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica', size: 9, align: :center
69
+ end
70
+ end
71
+
72
+ def render_homologation
73
+ 2.times { @pdf.render_blank_line }
74
+
75
+ @pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
76
+ @pdf.text 'EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO', size: 8, align: :center, style: :bold
77
+ @pdf.text 'SEM VALOR FISCAL', size: 8, align: :center, style: :bold
78
+ end
65
79
  end
66
80
  end
67
81
  end