br_danfe 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -25
  3. data/Gemfile.lock +1 -1
  4. data/README.md +5 -5
  5. data/lib/br_danfe.rb +0 -1
  6. data/lib/br_danfe/danfe.rb +6 -90
  7. data/lib/br_danfe/danfe_lib/base.rb +33 -0
  8. data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
  9. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
  10. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
  11. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
  12. data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
  13. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
  14. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
  15. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
  16. data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
  17. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
  18. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
  19. data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
  20. data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
  21. data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
  22. data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
  23. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
  24. data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
  25. data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
  26. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
  27. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
  28. data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
  29. data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
  30. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +109 -0
  31. data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
  32. data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
  33. data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
  34. data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
  35. data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
  36. data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
  37. data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
  38. data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
  39. data/lib/br_danfe/helper.rb +8 -0
  40. data/lib/br_danfe/version.rb +1 -1
  41. data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
  42. data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
  43. data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
  44. data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
  45. data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
  46. data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
  47. data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
  48. data/spec/{features → br_danfe}/cce_spec.rb +0 -0
  49. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
  50. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
  51. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
  52. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
  53. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
  54. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
  55. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
  56. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
  57. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
  58. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
  59. data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
  60. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
  61. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
  62. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
  63. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
  64. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
  65. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
  66. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
  67. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
  68. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
  69. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +2 -2
  70. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
  71. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
  72. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
  73. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
  74. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
  75. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
  76. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
  77. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
  78. data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
  79. data/spec/br_danfe/danfe_spec.rb +35 -0
  80. data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
  81. data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
  82. data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
  83. data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
  84. data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
  85. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  86. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
  87. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  88. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
  89. data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
  90. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  91. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  92. metadata +82 -75
  93. data/lib/br_danfe/danfe_lib/cep.rb +0 -9
  94. data/lib/br_danfe/danfe_lib/consts.rb +0 -6
  95. data/lib/br_danfe/danfe_lib/cst.rb +0 -32
  96. data/lib/br_danfe/danfe_lib/dest.rb +0 -94
  97. data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
  98. data/lib/br_danfe/danfe_lib/document.rb +0 -140
  99. data/lib/br_danfe/danfe_lib/dup.rb +0 -53
  100. data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
  101. data/lib/br_danfe/danfe_lib/helper.rb +0 -61
  102. data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
  103. data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
  104. data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
  105. data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
  106. data/lib/br_danfe/danfe_lib/phone.rb +0 -13
  107. data/lib/br_danfe/danfe_lib/plate.rb +0 -9
  108. data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
  109. data/lib/br_danfe/danfe_lib/transp.rb +0 -56
  110. data/lib/br_danfe/danfe_lib/vol.rb +0 -42
  111. data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
  112. data/lib/br_danfe/danfe_nfce.rb +0 -43
  113. data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
  114. data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
  115. data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
  116. data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
  117. data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
  118. data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
  119. data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
  120. data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
  121. data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
  122. data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
  123. data/spec/features/danfe_nfce_spec.rb +0 -31
@@ -6,7 +6,7 @@
6
6
  <cUF>42</cUF>
7
7
  <cNF>18291023</cNF>
8
8
  <natOp>Venda</natOp>
9
- <mod>55</mod>
9
+ <mod>65</mod>
10
10
  <serie>1</serie>
11
11
  <nNF>1629</nNF>
12
12
  <dhEmi>2020-03-24T13:33:20-05:00</dhEmi>
@@ -44,7 +44,7 @@
44
44
  </emit>
45
45
  <dest>
46
46
  <CNPJ>18191228000171</CNPJ>
47
- <xNome>NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xNome>
47
+ <xNome>John Doe</xNome>
48
48
  <enderDest>
49
49
  <xLgr>Rua Tijucas</xLgr>
50
50
  <nro>99</nro>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_danfe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: barby
@@ -235,45 +235,88 @@ files:
235
235
  - lib/br_danfe/cce_lib/nfe_key.rb
236
236
  - lib/br_danfe/cce_lib/protocol.rb
237
237
  - lib/br_danfe/danfe.rb
238
- - lib/br_danfe/danfe_lib/cep.rb
239
- - lib/br_danfe/danfe_lib/consts.rb
240
- - lib/br_danfe/danfe_lib/cst.rb
241
- - lib/br_danfe/danfe_lib/dest.rb
242
- - lib/br_danfe/danfe_lib/det_body.rb
243
- - lib/br_danfe/danfe_lib/document.rb
244
- - lib/br_danfe/danfe_lib/dup.rb
245
- - lib/br_danfe/danfe_lib/emit_header.rb
246
- - lib/br_danfe/danfe_lib/helper.rb
247
- - lib/br_danfe/danfe_lib/icmstot.rb
248
- - lib/br_danfe/danfe_lib/infadic.rb
249
- - lib/br_danfe/danfe_lib/infadic_vol.rb
250
- - lib/br_danfe/danfe_lib/issqn.rb
251
- - lib/br_danfe/danfe_lib/phone.rb
252
- - lib/br_danfe/danfe_lib/plate.rb
253
- - lib/br_danfe/danfe_lib/ticket.rb
254
- - lib/br_danfe/danfe_lib/transp.rb
255
- - lib/br_danfe/danfe_lib/vol.rb
256
- - lib/br_danfe/danfe_lib/xprod.rb
257
- - lib/br_danfe/danfe_nfce.rb
258
- - lib/br_danfe/danfe_nfce_lib/document.rb
259
- - lib/br_danfe/danfe_nfce_lib/footer.rb
260
- - lib/br_danfe/danfe_nfce_lib/header.rb
261
- - lib/br_danfe/danfe_nfce_lib/helper.rb
262
- - lib/br_danfe/danfe_nfce_lib/key.rb
263
- - lib/br_danfe/danfe_nfce_lib/nfce_identification.rb
264
- - lib/br_danfe/danfe_nfce_lib/product_list.rb
265
- - lib/br_danfe/danfe_nfce_lib/qr_code.rb
266
- - lib/br_danfe/danfe_nfce_lib/recipient.rb
267
- - lib/br_danfe/danfe_nfce_lib/total_list.rb
238
+ - lib/br_danfe/danfe_lib/base.rb
239
+ - lib/br_danfe/danfe_lib/nfce.rb
240
+ - lib/br_danfe/danfe_lib/nfce_lib/document.rb
241
+ - lib/br_danfe/danfe_lib/nfce_lib/footer.rb
242
+ - lib/br_danfe/danfe_lib/nfce_lib/header.rb
243
+ - lib/br_danfe/danfe_lib/nfce_lib/helper.rb
244
+ - lib/br_danfe/danfe_lib/nfce_lib/key.rb
245
+ - lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb
246
+ - lib/br_danfe/danfe_lib/nfce_lib/product_list.rb
247
+ - lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
248
+ - lib/br_danfe/danfe_lib/nfce_lib/recipient.rb
249
+ - lib/br_danfe/danfe_lib/nfce_lib/total_list.rb
250
+ - lib/br_danfe/danfe_lib/nfe.rb
251
+ - lib/br_danfe/danfe_lib/nfe_lib/cep.rb
252
+ - lib/br_danfe/danfe_lib/nfe_lib/consts.rb
253
+ - lib/br_danfe/danfe_lib/nfe_lib/cst.rb
254
+ - lib/br_danfe/danfe_lib/nfe_lib/dest.rb
255
+ - lib/br_danfe/danfe_lib/nfe_lib/det_body.rb
256
+ - lib/br_danfe/danfe_lib/nfe_lib/document.rb
257
+ - lib/br_danfe/danfe_lib/nfe_lib/dup.rb
258
+ - lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb
259
+ - lib/br_danfe/danfe_lib/nfe_lib/helper.rb
260
+ - lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb
261
+ - lib/br_danfe/danfe_lib/nfe_lib/infadic.rb
262
+ - lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb
263
+ - lib/br_danfe/danfe_lib/nfe_lib/issqn.rb
264
+ - lib/br_danfe/danfe_lib/nfe_lib/phone.rb
265
+ - lib/br_danfe/danfe_lib/nfe_lib/plate.rb
266
+ - lib/br_danfe/danfe_lib/nfe_lib/ticket.rb
267
+ - lib/br_danfe/danfe_lib/nfe_lib/transp.rb
268
+ - lib/br_danfe/danfe_lib/nfe_lib/vol.rb
269
+ - lib/br_danfe/danfe_lib/nfe_lib/xprod.rb
268
270
  - lib/br_danfe/helper.rb
269
271
  - lib/br_danfe/logo_config.rb
270
272
  - lib/br_danfe/logo_options.rb
271
273
  - lib/br_danfe/uf.rb
272
274
  - lib/br_danfe/version.rb
273
275
  - lib/br_danfe/xml.rb
274
- - spec/features/cce_spec.rb
275
- - spec/features/danfe_nfce_spec.rb
276
- - spec/features/danfe_spec.rb
276
+ - spec/br_danfe/cce_lib/barcode_spec.rb
277
+ - spec/br_danfe/cce_lib/correction_spec.rb
278
+ - spec/br_danfe/cce_lib/document_spec.rb
279
+ - spec/br_danfe/cce_lib/footer_spec.rb
280
+ - spec/br_danfe/cce_lib/header_spec.rb
281
+ - spec/br_danfe/cce_lib/nfe_key_spec.rb
282
+ - spec/br_danfe/cce_lib/protocol_spec.rb
283
+ - spec/br_danfe/cce_spec.rb
284
+ - spec/br_danfe/danfe_lib/nfce_lib/document_spec.rb
285
+ - spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb
286
+ - spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb
287
+ - spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb
288
+ - spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb
289
+ - spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb
290
+ - spec/br_danfe/danfe_lib/nfce_lib/product_list_spec.rb
291
+ - spec/br_danfe/danfe_lib/nfce_lib/qr_code_spec.rb
292
+ - spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb
293
+ - spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb
294
+ - spec/br_danfe/danfe_lib/nfce_spec.rb
295
+ - spec/br_danfe/danfe_lib/nfe_lib/cep_spec.rb
296
+ - spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb
297
+ - spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb
298
+ - spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb
299
+ - spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb
300
+ - spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb
301
+ - spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb
302
+ - spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb
303
+ - spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb
304
+ - spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb
305
+ - spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb
306
+ - spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb
307
+ - spec/br_danfe/danfe_lib/nfe_lib/phone_spec.rb
308
+ - spec/br_danfe/danfe_lib/nfe_lib/plate_spec.rb
309
+ - spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb
310
+ - spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb
311
+ - spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb
312
+ - spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb
313
+ - spec/br_danfe/danfe_lib/nfe_spec.rb
314
+ - spec/br_danfe/danfe_spec.rb
315
+ - spec/br_danfe/helper_spec.rb
316
+ - spec/br_danfe/logo_config_spec.rb
317
+ - spec/br_danfe/logo_options_spec.rb
318
+ - spec/br_danfe/uf_spec.rb
319
+ - spec/br_danfe/xml_spec.rb
277
320
  - spec/fixtures/cce/lib/barcode#render.pdf
278
321
  - spec/fixtures/cce/lib/correction#render.pdf
279
322
  - spec/fixtures/cce/lib/document#box.pdf
@@ -319,6 +362,10 @@ files:
319
362
  - spec/fixtures/nfce/lib/total_list#render-totals.pdf
320
363
  - spec/fixtures/nfce/lib/total_list#render-without_payment.pdf
321
364
  - spec/fixtures/nfce/lib/total_list#render.pdf
365
+ - spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf
366
+ - spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml
367
+ - spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf
368
+ - spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml
322
369
  - spec/fixtures/nfce/v4.00/nfce.xml
323
370
  - spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf
324
371
  - spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf
@@ -397,46 +444,6 @@ files:
397
444
  - spec/fixtures/nfe/v3.10/with_three_pages.xml
398
445
  - spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf
399
446
  - spec/fixtures/nfe/v3.10/without_issqn.xml
400
- - spec/lib/cce_lib/barcode_spec.rb
401
- - spec/lib/cce_lib/correction_spec.rb
402
- - spec/lib/cce_lib/document_spec.rb
403
- - spec/lib/cce_lib/footer_spec.rb
404
- - spec/lib/cce_lib/header_spec.rb
405
- - spec/lib/cce_lib/nfe_key_spec.rb
406
- - spec/lib/cce_lib/protocol_spec.rb
407
- - spec/lib/danfe_lib/cep_spec.rb
408
- - spec/lib/danfe_lib/cst_spec.rb
409
- - spec/lib/danfe_lib/dest_spec.rb
410
- - spec/lib/danfe_lib/det_body_spec.rb
411
- - spec/lib/danfe_lib/document_spec.rb
412
- - spec/lib/danfe_lib/dup_spec.rb
413
- - spec/lib/danfe_lib/emit_header_spec.rb
414
- - spec/lib/danfe_lib/helper_spec.rb
415
- - spec/lib/danfe_lib/icmstot_spec.rb
416
- - spec/lib/danfe_lib/infadic_spec.rb
417
- - spec/lib/danfe_lib/infadic_vol_spec.rb
418
- - spec/lib/danfe_lib/issqn_spec.rb
419
- - spec/lib/danfe_lib/phone_spec.rb
420
- - spec/lib/danfe_lib/plate_spec.rb
421
- - spec/lib/danfe_lib/ticket_spec.rb
422
- - spec/lib/danfe_lib/transp_spec.rb
423
- - spec/lib/danfe_lib/vol_spec.rb
424
- - spec/lib/danfe_lib/xprod_spec.rb
425
- - spec/lib/danfe_nfce_lib/document_spec.rb
426
- - spec/lib/danfe_nfce_lib/footer_spec.rb
427
- - spec/lib/danfe_nfce_lib/header_spec.rb
428
- - spec/lib/danfe_nfce_lib/helper_spec.rb
429
- - spec/lib/danfe_nfce_lib/key_spec.rb
430
- - spec/lib/danfe_nfce_lib/nfce_identification_spec.rb
431
- - spec/lib/danfe_nfce_lib/product_list_spec.rb
432
- - spec/lib/danfe_nfce_lib/qr_code_spec.rb
433
- - spec/lib/danfe_nfce_lib/recipient_spec.rb
434
- - spec/lib/danfe_nfce_lib/total_list_spec.rb
435
- - spec/lib/helper_spec.rb
436
- - spec/lib/logo_config_spec.rb
437
- - spec/lib/logo_options_spec.rb
438
- - spec/lib/uf_spec.rb
439
- - spec/lib/xml_spec.rb
440
447
  - spec/spec_helper.rb
441
448
  - spec/support/have_same_content_of.rb
442
449
  homepage: http://github.com/asseinfo/br_danfe
@@ -1,9 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Cep
4
- def self.format(cep)
5
- cep.sub(/(\d{2})(\d{3})(\d{3})/, '\\1.\\2-\\3')
6
- end
7
- end
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- LINE_HEIGHT = 0.80
4
- SPACE_BETWEEN_GROUPS = 0.52
5
- end
6
- end
@@ -1,32 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Cst
4
- def self.to_danfe(xml)
5
- value = origin(xml)
6
-
7
- if csosn?(xml)
8
- value += xml.css('ICMS/*/CSOSN').text
9
- elsif cst?(xml)
10
- value += xml.css('ICMS/*/CST').text
11
- end
12
-
13
- value
14
- end
15
-
16
- def self.origin(xml)
17
- xml.css('ICMS/*/orig').text
18
- end
19
- private_class_method :origin
20
-
21
- def self.cst?(xml)
22
- xml.css('ICMS/*/CST').text != ''
23
- end
24
- private_class_method :cst?
25
-
26
- def self.csosn?(xml)
27
- xml.css('ICMS/*/CSOSN').text != ''
28
- end
29
- private_class_method :csosn?
30
- end
31
- end
32
- end
@@ -1,94 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Dest
4
- Y = 10.00
5
- MAXIMUM_SIZE_FOR_STREET = 319
6
-
7
- def initialize(pdf, xml)
8
- @pdf = pdf
9
- @xml = xml
10
- @xml_version_is_310_or_newer = @xml.version_is_310_or_newer?
11
-
12
- @ltitle = Y - 0.42
13
- @l1 = Y
14
- @l2 = Y + LINE_HEIGHT
15
- @l3 = Y + (LINE_HEIGHT * 2)
16
- end
17
-
18
- def render
19
- @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'dest.title'
20
-
21
- render_line1
22
- render_line2
23
- render_line3
24
-
25
- @xml_version_is_310_or_newer ? render_dates_for_nfe_310_or_newer : render_dates_for_older_nfes
26
- end
27
-
28
- private
29
-
30
- def render_line1
31
- @pdf.lbox LINE_HEIGHT, 11.82, 0.75, @l1, @xml, 'dest/xNome'
32
- render_cnpj_cpf
33
- end
34
-
35
- def render_cnpj_cpf
36
- if @xml['dest/CNPJ'] == ''
37
- @pdf.i18n_lbox LINE_HEIGHT, 4.37, 12.57, @l1, 'dest.CPF', cpf
38
- else
39
- @pdf.lcnpj LINE_HEIGHT, 4.37, 12.57, @l1, @xml, 'dest/CNPJ'
40
- end
41
- end
42
-
43
- def cpf
44
- cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['dest/CPF'])
45
- cpf.formatted
46
- end
47
-
48
- def render_line2
49
- @pdf.i18n_lbox LINE_HEIGHT, 9.66, 0.75, @l2, 'enderDest.xLgr', address
50
- @pdf.lbox LINE_HEIGHT, 4.33, 10.41, @l2, @xml, 'enderDest/xBairro'
51
- @pdf.i18n_lbox LINE_HEIGHT, 2.20, 14.74, @l2, 'enderDest.CEP', cep
52
- end
53
-
54
- def address
55
- address = Helper.generate_address @xml
56
-
57
- if Helper.address_is_too_big(@pdf, address)
58
- address = address[0..address.length - 2] while Helper.mensure_text(@pdf, "#{address.strip}...") > MAXIMUM_SIZE_FOR_STREET && !address.empty?
59
- address = "#{address.strip}..."
60
- end
61
- address
62
- end
63
-
64
- def cep
65
- Cep.format(@xml['enderDest/CEP'])
66
- end
67
-
68
- def render_line3
69
- @pdf.lbox LINE_HEIGHT, 6.61, 0.75, @l3, @xml, 'enderDest/xMun'
70
- @pdf.i18n_lbox LINE_HEIGHT, 4.06, 7.36, @l3, 'enderDest.fone', phone
71
- @pdf.lbox LINE_HEIGHT, 1.14, 11.42, @l3, @xml, 'enderDest/UF'
72
- @pdf.lie LINE_HEIGHT, 4.38, 12.56, @l3, @xml, 'enderDest/UF', 'dest/IE'
73
- end
74
-
75
- def phone
76
- Phone.format(@xml['enderDest/fone'])
77
- end
78
-
79
- def render_dates_for_nfe_310_or_newer
80
- render_dates 'ide/dhEmi', 'ide/dhSaiEnt', 'ide/dhSaiEnt'
81
- end
82
-
83
- def render_dates(emitted_at_date_and_hour, exited_at_date, exited_at_hour)
84
- @pdf.ldate LINE_HEIGHT, 2.92, 17.40, @l1, 'ide.dEmi', @xml[emitted_at_date_and_hour], { align: :right }
85
- @pdf.ldate LINE_HEIGHT, 2.92, 17.40, @l2, 'ide.dSaiEnt', @xml[exited_at_date], { align: :right }
86
- @pdf.ltime LINE_HEIGHT, 2.92, 17.40, @l3, 'ide.hSaiEnt', @xml[exited_at_hour], { align: :right }
87
- end
88
-
89
- def render_dates_for_older_nfes
90
- render_dates 'ide/dEmi', 'ide/dSaiEnt', 'ide/hSaiEnt'
91
- end
92
- end
93
- end
94
- end
@@ -1,135 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class DetBody
4
- def initialize(pdf, xml)
5
- @pdf = pdf
6
- @xml = xml
7
- end
8
-
9
- def render(has_issqn)
10
- table_height_on_first_page = table_height_on_first_page has_issqn
11
- first_table = create_table
12
- next_table = create_table
13
-
14
- fill_tables first_table, next_table, table_height_on_first_page
15
- render_tables first_table, next_table, table_height_on_first_page
16
- end
17
-
18
- private
19
-
20
- def table_height_on_first_page(has_issqn)
21
- has_issqn ? 6.35.cm : 7.72.cm
22
- end
23
-
24
- def create_table
25
- [create_header]
26
- end
27
-
28
- def create_header
29
- header = [[
30
- header_column('prod.cProd'), header_column('prod.xProd'), header_column('prod.NCM'),
31
- header_column('ICMS.CST'), header_column('prod.CFOP'), header_column('prod.uCom'),
32
- header_column('prod.qCom'), header_column('prod.vUnCom'), header_column('prod.vProd'),
33
- header_column('ICMS.vBC'), header_column('ICMS.vICMS'), header_column('IPI.vIPI'),
34
- header_column('ICMS.pICMS'), header_column('IPI.pIPI')
35
- ]]
36
- @pdf.make_table(header, options)
37
- end
38
-
39
- def header_column(title)
40
- { content: I18n.t("danfe.det.#{title}"), align: :left, size: 6, valign: :top }
41
- end
42
-
43
- def options
44
- { column_widths: column_widths, cell_style: { padding: 2, border_width: 0.3 } }
45
- end
46
-
47
- def column_widths
48
- {
49
- 0 => 1.60.cm, 1 => 6.10.cm, 2 => 1.05.cm, 3 => 0.60.cm, 4 => 0.70.cm, 5 => 1.05.cm, 6 => 1.20.cm,
50
- 7 => 1.20.cm, 8 => 1.20.cm, 9 => 1.20.cm, 10 => 1.00.cm, 11 => 1.00.cm, 12 => 0.90.cm, 13 => 0.76.cm
51
- }
52
- end
53
-
54
- def fill_tables(first_table, next_table, first_table_height)
55
- total_height = first_table.first.height
56
-
57
- products.each do |product|
58
- row = create_row product
59
- total_height += row.height
60
- total_height <= first_table_height ? first_table << row : next_table << row
61
- end
62
- end
63
-
64
- def products
65
- @xml.collect('xmlns', 'det') { |det| product(det) }
66
- end
67
-
68
- def product(det)
69
- [
70
- cell_text(det.css('prod/cProd').text),
71
- cell_text(Xprod.new(det).render),
72
- cell_text(det.css('prod/NCM').text),
73
- cell_text(Cst.to_danfe(det)),
74
- cell_text(det.css('prod/CFOP').text),
75
- cell_text(det.css('prod/uCom').text),
76
- cell_number(numerify(det, 'prod/qCom')),
77
- cell_number(numerify(det, 'prod/vUnCom')),
78
- cell_number(numerify(det, 'prod/vProd')),
79
- cell_number(numerify(det, 'ICMS/*/vBC')),
80
- cell_number(numerify(det, 'ICMS/*/vICMS')),
81
- cell_number(numerify(det, 'IPI/*/vIPI')),
82
- cell_number(numerify(det, 'ICMS/*/pICMS')),
83
- cell_number(numerify(det, 'IPI/*/pIPI'))
84
- ]
85
- end
86
-
87
- def cell_text(text, options = {})
88
- cell = { content: text, border_lines: [:solid], size: 6.5 }
89
- cell.merge!(options)
90
- cell
91
- end
92
-
93
- def cell_number(text)
94
- cell_text(text, { align: :right })
95
- end
96
-
97
- def numerify(det, xpath)
98
- BrDanfe::Helper.numerify(det.css(xpath.to_s).text)
99
- end
100
-
101
- def create_row(data)
102
- @pdf.make_table([data], options)
103
- end
104
-
105
- def render_tables(first_table, next_table, first_table_height)
106
- render_table first_table, table_position_on_first_page, first_table_height
107
-
108
- table_with_only_header = 1
109
- if next_table.size > table_with_only_header
110
- @pdf.start_new_page
111
- render_table next_table, table_position_on_next_pages, table_height_on_next_pages
112
- end
113
- end
114
-
115
- def render_table(data, start_position, height)
116
- @pdf.y = start_position
117
- @pdf.bounding_box [0.75.cm, @pdf.cursor], width: 19.56.cm, height: height do
118
- @pdf.table data.map { |item| [item] }, { header: true }
119
- end
120
- end
121
-
122
- def table_position_on_first_page
123
- Helper.invert(18.07.cm)
124
- end
125
-
126
- def table_position_on_next_pages
127
- Helper.invert(6.57.cm)
128
- end
129
-
130
- def table_height_on_next_pages
131
- 22.58.cm
132
- end
133
- end
134
- end
135
- end