br_nfe 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (495) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +12 -2
  5. data/README.markdown +3 -1
  6. data/Rakefile +20 -1
  7. data/lib/br_nfe/active_model/associations.rb +11 -0
  8. data/lib/br_nfe/active_model/has_many.rb +65 -0
  9. data/lib/br_nfe/active_model/has_one.rb +57 -0
  10. data/lib/br_nfe/active_model_base.rb +38 -1
  11. data/lib/br_nfe/base.rb +9 -0
  12. data/lib/br_nfe/calculos/fatores_de_multiplicacao.rb +67 -0
  13. data/lib/br_nfe/calculos/modulo11.rb +54 -0
  14. data/lib/br_nfe/calculos/modulo11_fator_de2a9.rb +83 -0
  15. data/lib/br_nfe/calculos/modulo11_fator_de2a9_resto_zero.rb +29 -0
  16. data/lib/br_nfe/constants.rb +46 -1
  17. data/lib/br_nfe/endereco.rb +6 -2
  18. data/lib/br_nfe/helper/cpf_cnpj.rb +8 -1
  19. data/lib/br_nfe/person.rb +32 -3
  20. data/lib/br_nfe/product/destinatario.rb +45 -0
  21. data/lib/br_nfe/product/emitente.rb +14 -1
  22. data/lib/br_nfe/product/evento/base.rb +146 -0
  23. data/lib/br_nfe/product/evento/cancelamento.rb +46 -0
  24. data/lib/br_nfe/product/gateway/base.rb +16 -43
  25. data/lib/br_nfe/product/gateway/web_service_am.rb +140 -0
  26. data/lib/br_nfe/product/gateway/web_service_ba.rb +140 -0
  27. data/lib/br_nfe/product/gateway/web_service_ce.rb +162 -0
  28. data/lib/br_nfe/product/gateway/web_service_go.rb +140 -0
  29. data/lib/br_nfe/product/gateway/web_service_mg.rb +140 -0
  30. data/lib/br_nfe/product/gateway/web_service_ms.rb +140 -0
  31. data/lib/br_nfe/product/gateway/web_service_mt.rb +140 -0
  32. data/lib/br_nfe/product/gateway/web_service_pe.rb +140 -0
  33. data/lib/br_nfe/product/gateway/web_service_pr.rb +140 -0
  34. data/lib/br_nfe/product/gateway/web_service_rs.rb +140 -0
  35. data/lib/br_nfe/product/gateway/web_service_sp.rb +140 -0
  36. data/lib/br_nfe/product/gateway/web_service_svan.rb +162 -0
  37. data/lib/br_nfe/product/gateway/web_service_svc_an.rb +131 -0
  38. data/lib/br_nfe/product/gateway/web_service_svc_rs.rb +20 -0
  39. data/lib/br_nfe/product/gateway/web_service_svrs.rb +111 -10
  40. data/lib/br_nfe/product/nf_xml_value.rb +278 -0
  41. data/lib/br_nfe/product/nfe/adicao_importacao.rb +76 -0
  42. data/lib/br_nfe/product/nfe/cobranca/duplicata.rb +44 -0
  43. data/lib/br_nfe/product/nfe/cobranca/fatura.rb +64 -0
  44. data/lib/br_nfe/product/nfe/cobranca/pagamento.rb +99 -0
  45. data/lib/br_nfe/product/nfe/declaracao_importacao.rb +221 -0
  46. data/lib/br_nfe/product/nfe/detalhe_exportacao.rb +89 -0
  47. data/lib/br_nfe/product/nfe/item.rb +678 -0
  48. data/lib/br_nfe/product/nfe/item_tax/cofins.rb +138 -0
  49. data/lib/br_nfe/product/nfe/item_tax/cofins_st.rb +68 -0
  50. data/lib/br_nfe/product/nfe/item_tax/icms.rb +593 -0
  51. data/lib/br_nfe/product/nfe/item_tax/icms_uf_destino.rb +169 -0
  52. data/lib/br_nfe/product/nfe/item_tax/importacao.rb +62 -0
  53. data/lib/br_nfe/product/nfe/item_tax/ipi.rb +179 -0
  54. data/lib/br_nfe/product/nfe/item_tax/issqn.rb +256 -0
  55. data/lib/br_nfe/product/nfe/item_tax/pis.rb +138 -0
  56. data/lib/br_nfe/product/nfe/item_tax/pis_st.rb +68 -0
  57. data/lib/br_nfe/product/nfe/processo_referencia.rb +48 -0
  58. data/lib/br_nfe/product/nfe/transporte/base.rb +264 -0
  59. data/lib/br_nfe/product/nfe/transporte/transportador.rb +15 -0
  60. data/lib/br_nfe/product/nfe/transporte/veiculo.rb +53 -0
  61. data/lib/br_nfe/product/nfe/transporte/volume.rb +89 -0
  62. data/lib/br_nfe/product/nota_fiscal.rb +1173 -0
  63. data/lib/br_nfe/product/operation/base.rb +255 -0
  64. data/lib/br_nfe/product/operation/nfe_autorizacao.rb +118 -0
  65. data/lib/br_nfe/product/operation/nfe_consulta_protocolo.rb +61 -0
  66. data/lib/br_nfe/product/operation/nfe_download_nf.rb +86 -0
  67. data/lib/br_nfe/product/operation/nfe_inutilizacao.rb +168 -0
  68. data/lib/br_nfe/product/operation/nfe_recepcao_evento.rb +70 -0
  69. data/lib/br_nfe/product/operation/nfe_ret_autorizacao.rb +63 -0
  70. data/lib/br_nfe/product/operation/nfe_status_servico.rb +46 -0
  71. data/lib/br_nfe/product/response/base.rb +97 -0
  72. data/lib/br_nfe/product/response/build/base.rb +287 -0
  73. data/lib/br_nfe/product/response/build/nfe_autorizacao.rb +102 -0
  74. data/lib/br_nfe/product/response/build/nfe_consulta_protocolo.rb +133 -0
  75. data/lib/br_nfe/product/response/build/nfe_inutilizacao.rb +53 -0
  76. data/lib/br_nfe/product/response/build/nfe_ret_autorizacao.rb +65 -0
  77. data/lib/br_nfe/product/response/build/nfe_status_servico.rb +43 -0
  78. data/lib/br_nfe/product/response/event.rb +89 -0
  79. data/lib/br_nfe/product/response/nfe_autorizacao.rb +12 -0
  80. data/lib/br_nfe/product/response/nfe_consulta_protocolo.rb +13 -0
  81. data/lib/br_nfe/product/response/nfe_inutilizacao.rb +89 -0
  82. data/lib/br_nfe/product/response/nfe_ret_autorizacao.rb +9 -0
  83. data/lib/br_nfe/product/response/nfe_status_servico.rb +31 -0
  84. data/lib/br_nfe/product/xml/_signed_info_sh1.xml.slim +9 -0
  85. data/lib/br_nfe/product/xml/_tc_cpf_cnpj.xml.slim +7 -0
  86. data/lib/br_nfe/product/xml/signature_sh1.xml.slim +12 -0
  87. data/lib/br_nfe/product/xml/v1_00/evento/infEventoCancelamento.xml.slim +19 -0
  88. data/lib/br_nfe/product/xml/v1_00/root/NfeDownloadNf.xml.slim +5 -0
  89. data/lib/br_nfe/product/xml/v1_00/root/NfeRecepcaoEvento.xml.slim +7 -0
  90. data/lib/br_nfe/product/xml/v2_00/_tc_endereco.xml.slim +19 -0
  91. data/lib/br_nfe/product/xml/v2_00/_tc_infNFe.xml.slim +39 -0
  92. data/lib/br_nfe/product/xml/v2_00/infInut.xml.slim +12 -0
  93. data/lib/br_nfe/product/xml/v2_00/infNFe/NFe.xml.slim +4 -0
  94. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_cobr.xml.slim +19 -0
  95. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_dest.xml.slim +14 -0
  96. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_det.xml.slim +7 -0
  97. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_emit.xml.slim +19 -0
  98. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_entrega.xml.slim +11 -0
  99. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_exporta.xml.slim +2 -0
  100. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_ide.xml.slim +24 -0
  101. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_infAdic.xml.slim +13 -0
  102. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_retirada.xml.slim +11 -0
  103. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_total.xml.slim +50 -0
  104. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_transp.xml.slim +35 -0
  105. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_imposto.xml.slim +31 -0
  106. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_prod.xml.slim +37 -0
  107. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS00.xml.slim +6 -0
  108. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS10.xml.slim +16 -0
  109. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS101.xml.slim +4 -0
  110. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS102.xml.slim +3 -0
  111. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +6 -0
  112. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS201.xml.slim +15 -0
  113. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS202.xml.slim +14 -0
  114. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +12 -0
  115. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  116. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS500.xml.slim +6 -0
  117. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +13 -0
  118. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS60.xml.slim +5 -0
  119. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +18 -0
  120. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +21 -0
  121. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS900.xml.slim +25 -0
  122. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS.xml.slim +26 -0
  123. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS_ST.xml.slim +7 -0
  124. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_ICMS.xml.slim +45 -0
  125. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_II.xml.slim +4 -0
  126. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_IPI.xml.slim +30 -0
  127. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS.xml.slim +26 -0
  128. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS_ST.xml.slim +7 -0
  129. data/lib/br_nfe/product/xml/v2_00/infNFe/det/prod/_tc_di.xml.slim +13 -0
  130. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_retTransp.xml.slim +6 -0
  131. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_transporta.xml.slim +17 -0
  132. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_vol.xml.slim +15 -0
  133. data/lib/br_nfe/product/xml/v2_00/infNFe.xml.slim +3 -0
  134. data/lib/br_nfe/product/xml/v2_00/root/NfeAutorizacao.xml.slim +5 -0
  135. data/lib/br_nfe/product/xml/v2_00/root/NfeInutilizacao.xml.slim +4 -0
  136. data/lib/br_nfe/product/xml/v2_00/root/NfeRetAutorizacao.xml.slim +3 -0
  137. data/lib/br_nfe/product/xml/v2_00/root/NfeStatusServico.xml.slim +4 -0
  138. data/lib/br_nfe/product/xml/v2_01/root/NfeConsultaProtocolo.xml.slim +4 -0
  139. data/lib/br_nfe/product/xml/v3_10/_tc_infNFe.xml.slim +44 -0
  140. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_dest.xml.slim +25 -0
  141. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_det.xml.slim +14 -0
  142. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_exporta.xml.slim +4 -0
  143. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_ide.xml.slim +26 -0
  144. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_pag.xml.slim +7 -0
  145. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_total.xml.slim +78 -0
  146. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_imposto.xml.slim +37 -0
  147. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_prod.xml.slim +48 -0
  148. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +12 -0
  149. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +17 -0
  150. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  151. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +19 -0
  152. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +23 -0
  153. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +26 -0
  154. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +8 -0
  155. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ISSQN.xml.slim +35 -0
  156. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_det_export.xml.slim +8 -0
  157. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_di.xml.slim +28 -0
  158. data/lib/br_nfe/product/xml/v3_10/root/NfeAutorizacao.xml.slim +6 -0
  159. data/lib/br_nfe/service/base.rb +1 -105
  160. data/lib/br_nfe/service/betha/v1/cancela_nfse.rb +1 -1
  161. data/lib/br_nfe/service/response/default.rb +1 -1
  162. data/lib/br_nfe/service/simpliss/v1/base.rb +2 -0
  163. data/lib/br_nfe/version.rb +2 -2
  164. data/lib/br_nfe.rb +180 -22
  165. data/lib/config/locales/br_nfe/en/product/nfe/cobranca/fatura.yml +6 -0
  166. data/lib/config/locales/br_nfe/en/product/nfe/declaracao_importacao.yml +10 -0
  167. data/lib/config/locales/br_nfe/en/product/nfe/item.yml +20 -0
  168. data/lib/config/locales/br_nfe/en/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  169. data/lib/config/locales/br_nfe/en/product/nfe/transporte/base.yml +9 -0
  170. data/lib/config/locales/br_nfe/en/product/nota_fiscal.yml +21 -0
  171. data/lib/config/locales/br_nfe/en/product/operation/nfe_autorizacao.yml +10 -0
  172. data/lib/config/locales/br_nfe/en/product/operation/nfe_recepcao_evento.yml +6 -0
  173. data/lib/config/locales/br_nfe/pt-BR/product/nfe/cobranca/fatura.yml +6 -0
  174. data/lib/config/locales/br_nfe/pt-BR/product/nfe/declaracao_importacao.yml +10 -0
  175. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item.yml +20 -0
  176. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  177. data/lib/config/locales/br_nfe/pt-BR/product/nfe/transporte/base.yml +9 -0
  178. data/lib/config/locales/br_nfe/pt-BR/product/nota_fiscal.yml +21 -0
  179. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_autorizacao.yml +10 -0
  180. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_recepcao_evento.yml +6 -0
  181. data/test/br_nfe/association/have_destinatario_test.rb +8 -8
  182. data/test/br_nfe/association/have_emitente_test.rb +6 -6
  183. data/test/br_nfe/base_test.rb +15 -4
  184. data/test/br_nfe/endereco_test.rb +15 -0
  185. data/test/br_nfe/person_test.rb +55 -6
  186. data/test/br_nfe/product/destinatario_test.rb +26 -0
  187. data/test/br_nfe/product/emitente_test.rb +1 -2
  188. data/test/br_nfe/product/evento/base_test.rb +58 -0
  189. data/test/br_nfe/product/evento/cancelamento_test.rb +32 -0
  190. data/test/br_nfe/product/gateway/web_service_am_test.rb +242 -0
  191. data/test/br_nfe/product/gateway/web_service_ba_test.rb +242 -0
  192. data/test/br_nfe/product/gateway/web_service_ce_test.rb +242 -0
  193. data/test/br_nfe/product/gateway/web_service_go_test.rb +242 -0
  194. data/test/br_nfe/product/gateway/web_service_mg_test.rb +242 -0
  195. data/test/br_nfe/product/gateway/web_service_ms_test.rb +242 -0
  196. data/test/br_nfe/product/gateway/web_service_mt_test.rb +408 -0
  197. data/test/br_nfe/product/gateway/web_service_pe_test.rb +408 -0
  198. data/test/br_nfe/product/gateway/web_service_pr_test.rb +408 -0
  199. data/test/br_nfe/product/gateway/web_service_rs_test.rb +407 -0
  200. data/test/br_nfe/product/gateway/web_service_sp_test.rb +408 -0
  201. data/test/br_nfe/product/gateway/web_service_svan_test.rb +242 -0
  202. data/test/br_nfe/product/gateway/web_service_svc_an_test.rb +185 -0
  203. data/test/br_nfe/product/gateway/web_service_svc_rs_test.rb +185 -0
  204. data/test/br_nfe/product/gateway/web_service_svrs_test.rb +208 -2
  205. data/test/br_nfe/product/nfe/adicao_importacao_test.rb +19 -0
  206. data/test/br_nfe/product/nfe/cobranca/duplicata_test.rb +19 -0
  207. data/test/br_nfe/product/nfe/cobranca/fatura_test.rb +32 -0
  208. data/test/br_nfe/product/nfe/cobranca/pagamento_test.rb +105 -0
  209. data/test/br_nfe/product/nfe/declaracao_importacao_test.rb +116 -0
  210. data/test/br_nfe/product/nfe/detalhe_exportacao_test.rb +97 -0
  211. data/test/br_nfe/product/nfe/item_tax/cofins_st_test.rb +22 -0
  212. data/test/br_nfe/product/nfe/item_tax/cofins_test.rb +113 -0
  213. data/test/br_nfe/product/nfe/item_tax/icms_test.rb +1011 -0
  214. data/test/br_nfe/product/nfe/item_tax/icms_uf_destino_test.rb +99 -0
  215. data/test/br_nfe/product/nfe/item_tax/importacao_test.rb +23 -0
  216. data/test/br_nfe/product/nfe/item_tax/ipi_test.rb +160 -0
  217. data/test/br_nfe/product/nfe/item_tax/issqn_test.rb +84 -0
  218. data/test/br_nfe/product/nfe/item_tax/pis_st_test.rb +22 -0
  219. data/test/br_nfe/product/nfe/item_tax/pis_test.rb +113 -0
  220. data/test/br_nfe/product/nfe/item_test.rb +381 -0
  221. data/test/br_nfe/product/nfe/processo_referencia_test.rb +30 -0
  222. data/test/br_nfe/product/nfe/transporte/base_test.rb +182 -0
  223. data/test/br_nfe/product/nfe/transporte/transportador_test.rb +13 -0
  224. data/test/br_nfe/product/nfe/transporte/veiculo_test.rb +13 -0
  225. data/test/br_nfe/product/nfe/transporte/volume_test.rb +42 -0
  226. data/test/br_nfe/product/nota_fiscal_test.rb +662 -0
  227. data/test/br_nfe/product/operation/base_test.rb +538 -0
  228. data/test/br_nfe/product/operation/nfe_autorizacao_test.rb +378 -0
  229. data/test/br_nfe/product/operation/nfe_consulta_protocolo_test.rb +349 -0
  230. data/test/br_nfe/product/operation/nfe_download_nf_test.rb +93 -0
  231. data/test/br_nfe/product/operation/nfe_inutilizacao_test.rb +210 -0
  232. data/test/br_nfe/product/operation/nfe_recepcao_evento_test.rb +84 -0
  233. data/test/br_nfe/product/operation/nfe_ret_autorizacao_test.rb +309 -0
  234. data/test/br_nfe/product/operation/nfe_status_servico_test.rb +122 -0
  235. data/test/br_nfe/product/response/base_test.rb +75 -0
  236. data/test/br_nfe/product/response/build/base_test.rb +34 -0
  237. data/test/br_nfe/product/response/nfe_ret_autorizacao_test.rb +14 -0
  238. data/test/br_nfe/service/association/have_intermediario_test.rb +10 -10
  239. data/test/br_nfe/service/base_test.rb +9 -206
  240. data/test/br_nfe/service/betha/v1/cancela_nfse_test.rb +8 -6
  241. data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +6 -3
  242. data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +6 -3
  243. data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +7 -4
  244. data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +12 -9
  245. data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +6 -3
  246. data/test/br_nfe/service/rps_test.rb +2 -2
  247. data/test/br_nfe/service/simpliss/v1/cancela_nfse_test.rb +6 -3
  248. data/test/br_nfe/service/simpliss/v1/consulta_lote_rps_test.rb +7 -4
  249. data/test/br_nfe/service/simpliss/v1/consulta_nfs_por_rps_test.rb +7 -4
  250. data/test/br_nfe/service/simpliss/v1/consulta_nfse_test.rb +8 -5
  251. data/test/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps_test.rb +9 -6
  252. data/test/br_nfe/service/simpliss/v1/recepcao_lote_rps_test.rb +6 -3
  253. data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +6 -3
  254. data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +6 -3
  255. data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +6 -3
  256. data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +8 -5
  257. data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +9 -6
  258. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_limitado_test.rb +6 -3
  259. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +6 -3
  260. data/test/factories/person.rb +1 -1
  261. data/test/factories/product/destinatario.rb +11 -0
  262. data/test/factories/product/emitente.rb +1 -1
  263. data/test/factories/product/evento/base.rb +9 -0
  264. data/test/factories/product/evento/cancelamento.rb +10 -0
  265. data/test/factories/product/gateway/web_service_am.rb +5 -0
  266. data/test/factories/product/gateway/web_service_ba.rb +5 -0
  267. data/test/factories/product/nfe/adicao_importacao.rb +7 -0
  268. data/test/factories/product/nfe/cobranca/duplicata.rb +7 -0
  269. data/test/factories/product/nfe/cobranca/fatura.rb +8 -0
  270. data/test/factories/product/nfe/cobranca/pagamento.rb +9 -0
  271. data/test/factories/product/nfe/declaracao_importacao.rb +10 -0
  272. data/test/factories/product/nfe/detalhe_exportacao.rb +5 -0
  273. data/test/factories/product/nfe/item.rb +24 -0
  274. data/test/factories/product/nfe/item_tax/cofins.rb +5 -0
  275. data/test/factories/product/nfe/item_tax/cofins_st.rb +5 -0
  276. data/test/factories/product/nfe/item_tax/icms.rb +9 -0
  277. data/test/factories/product/nfe/item_tax/icms_uf_destino.rb +11 -0
  278. data/test/factories/product/nfe/item_tax/importacao.rb +8 -0
  279. data/test/factories/product/nfe/item_tax/ipi.rb +6 -0
  280. data/test/factories/product/nfe/item_tax/issqn.rb +9 -0
  281. data/test/factories/product/nfe/item_tax/pis.rb +5 -0
  282. data/test/factories/product/nfe/item_tax/pis_st.rb +5 -0
  283. data/test/factories/product/nfe/processo_referencia.rb +6 -0
  284. data/test/factories/product/nfe/transporte/base.rb +5 -0
  285. data/test/factories/product/nfe/transporte/transportador.rb +7 -0
  286. data/test/factories/product/nfe/transporte/veiculo.rb +7 -0
  287. data/test/factories/product/nfe/transporte/volume.rb +5 -0
  288. data/test/factories/product/nota_fiscal.rb +22 -0
  289. data/test/factories/product/{base.rb → operation/base.rb} +1 -1
  290. data/test/factories/product/operation/nfe_autorizacao.rb +590 -0
  291. data/test/factories/product/operation/nfe_consulta_protocolo.rb +13 -0
  292. data/test/factories/product/operation/nfe_download_nf.rb +15 -0
  293. data/test/factories/product/operation/nfe_inutilizacao.rb +19 -0
  294. data/test/factories/product/operation/nfe_recepcao_evento.rb +14 -0
  295. data/test/factories/product/operation/nfe_ret_autorizacao.rb +13 -0
  296. data/test/factories/product/{consulta_status_servico.rb → operation/nfe_status_servico.rb} +1 -1
  297. data/test/factories/product/response/base.rb +12 -0
  298. data/test/factories/product/response/build/base.rb +6 -0
  299. data/test/factories/product/response/nfe_ret_autorizacao.rb +13 -0
  300. data/test/factories/service/emitente.rb +1 -1
  301. data/test/fixtures/product/operation/nfe_autorizacao/nfe_signed.xml +1 -0
  302. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_fail.xml +21 -0
  303. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_success.xml +25 -0
  304. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/with_proc.xml +1 -0
  305. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/without_proc.xml +1 -0
  306. data/test/fixtures/product/response/v3.10/nfe_autorizacao/original_xml.xml +1 -0
  307. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_fail.xml +32 -0
  308. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_success.xml +33 -0
  309. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_1.xml +1 -0
  310. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_2.xml +1 -0
  311. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_3.xml +1 -0
  312. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_cancel.xml +1 -0
  313. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/one_event.xml +1 -0
  314. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/fail.xml +22 -0
  315. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/with_proc.xml +1 -0
  316. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/without_proc.xml +1 -0
  317. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_with_cancel.xml +198 -0
  318. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_without_cancel.xml +199 -0
  319. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_one.xml +89 -0
  320. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_without.xml +34 -0
  321. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/fail.xml +29 -0
  322. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/success.xml +30 -0
  323. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/fail.xml +34 -0
  324. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/success.xml +36 -0
  325. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_fail.xml +22 -0
  326. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail.xml +33 -0
  327. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail_and_one_ok.xml +46 -0
  328. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_ok.xml +34 -0
  329. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_fail.xml +46 -0
  330. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_ok.xml +46 -0
  331. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_with_protocol.xml +1 -0
  332. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_without_protocol.xml +1 -0
  333. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_with_protocol.xml +1 -0
  334. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_without_protocol.xml +1 -0
  335. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/lot.xml +2 -0
  336. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfe.xml +2 -0
  337. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfeProc.xml +4 -0
  338. data/test/fixtures/product/response/v3.10/nfe_status_servico/fail.xml +23 -0
  339. data/test/fixtures/product/response/v3.10/nfe_status_servico/success.xml +22 -0
  340. data/test/fixtures/product/schemas/CCe_v1.00.xsd +11 -0
  341. data/test/fixtures/product/schemas/EPEC_v1.00.xsd +9 -0
  342. data/test/fixtures/product/schemas/LeiauteCadastroEmissorDFe_v1.01.xsd +234 -0
  343. data/test/fixtures/product/schemas/SuframaInternaliza_v1.00.xsd +9 -0
  344. data/test/fixtures/product/schemas/SuframaVistoria_v1.00.xsd +9 -0
  345. data/test/fixtures/product/schemas/atuCadEmiDFe_v1.01.xsd +9 -0
  346. data/test/fixtures/product/schemas/cabecMsg_v1.02.xsd +29 -0
  347. data/test/fixtures/product/schemas/cadEmiDFe_v1.01.xsd +9 -0
  348. data/test/fixtures/product/schemas/cancNFe_v2.00.xsd +9 -0
  349. data/test/fixtures/product/schemas/confRecebto_v1.00.xsd +9 -0
  350. data/test/fixtures/product/schemas/consCad_v2.00.xsd +9 -0
  351. data/test/fixtures/product/schemas/consDPEC_v1.01.xsd +9 -0
  352. data/test/fixtures/product/schemas/consNFeDest_v1.01.xsd +10 -0
  353. data/test/fixtures/product/schemas/consReciNFe_v2.00.xsd +9 -0
  354. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consReciNFe_v3.10.xsd +8 -8
  355. data/test/fixtures/product/schemas/consSitNFe_v2.01.xsd +10 -0
  356. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consSitNFe_v3.10.xsd +8 -8
  357. data/test/fixtures/product/schemas/consStatServ_v2.00.xsd +9 -0
  358. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consStatServ_v3.10.xsd +8 -8
  359. data/test/fixtures/product/schemas/distDFeInt_v1.00.xsd +71 -0
  360. data/test/fixtures/product/schemas/downloadNFe_v1.00.xsd +10 -0
  361. data/test/fixtures/product/schemas/e110110_v1.00.xsd +58 -0
  362. data/test/fixtures/product/schemas/e110111_v1.00.xsd +42 -0
  363. data/test/fixtures/product/schemas/e110140_v1.00.xsd +124 -0
  364. data/test/fixtures/product/schemas/e111500_v1.00.xsd +69 -0
  365. data/test/fixtures/product/schemas/e111501_v1.00.xsd +69 -0
  366. data/test/fixtures/product/schemas/e111502_v1.00.xsd +50 -0
  367. data/test/fixtures/product/schemas/e111503_v1.00.xsd +50 -0
  368. data/test/fixtures/product/schemas/e210200_v1.00.xsd +32 -0
  369. data/test/fixtures/product/schemas/e210210_v1.00.xsd +32 -0
  370. data/test/fixtures/product/schemas/e210220_v1.00.xsd +45 -0
  371. data/test/fixtures/product/schemas/e210240_v1.00.xsd +44 -0
  372. data/test/fixtures/product/schemas/e411500_v1.00.xsd +134 -0
  373. data/test/fixtures/product/schemas/e411501_v1.00.xsd +134 -0
  374. data/test/fixtures/product/schemas/e411502_v1.00.xsd +95 -0
  375. data/test/fixtures/product/schemas/e411503_v1.00.xsd +95 -0
  376. data/test/fixtures/product/schemas/e990900_v1.00.xsd +87 -0
  377. data/test/fixtures/product/schemas/e990910_v1.00.xsd +81 -0
  378. data/test/fixtures/product/schemas/envCCe_v1.00.xsd +10 -0
  379. data/test/fixtures/product/schemas/envCancelPProrrogNFe_v1.0.xsd +50 -0
  380. data/test/fixtures/product/schemas/envConfRecebto_v1.00.xsd +9 -0
  381. data/test/fixtures/product/schemas/envDPEC_v1.01.xsd +9 -0
  382. data/test/fixtures/product/schemas/envEPEC_v1.00.xsd +9 -0
  383. data/test/fixtures/product/schemas/envEventoCancNFe_v1.00.xsd +9 -0
  384. data/test/fixtures/product/schemas/envEvento_v1.00.xsd +9 -0
  385. data/test/fixtures/product/schemas/envFiscoNfe_v1.0.xsd +179 -0
  386. data/test/fixtures/product/schemas/envPProrrogNFe_v1.0.xsd +65 -0
  387. data/test/fixtures/product/schemas/envRemIndus_v1.00.xsd +9 -0
  388. data/test/fixtures/product/schemas/envSuframaInternaliza_v1.00.xsd +10 -0
  389. data/test/fixtures/product/schemas/envSuframaVistoria_v1.00.xsd +10 -0
  390. data/test/fixtures/product/schemas/enviNFe_v2.00.xsd +9 -0
  391. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/enviNFe_v3.10.xsd +8 -8
  392. data/test/fixtures/product/schemas/eventoCancNFe_v1.00.xsd +9 -0
  393. data/test/fixtures/product/schemas/eventoEPEC_v0.01.xsd +267 -0
  394. data/test/fixtures/product/schemas/eventoEPEC_v1.00.xsd +267 -0
  395. data/test/fixtures/product/schemas/eventoRemIndus_v1.00.xsd +9 -0
  396. data/test/fixtures/product/schemas/inutNFe_v2.00.xsd +9 -0
  397. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/inutNFe_v3.10.xsd +8 -8
  398. data/test/fixtures/product/schemas/leiauteCCe_v1.00.xsd +418 -0
  399. data/test/fixtures/product/schemas/leiauteCancNFe_v2.00.xsd +143 -0
  400. data/test/fixtures/product/schemas/leiauteConfRecebto_v1.00.xsd +406 -0
  401. data/test/fixtures/product/schemas/leiauteConsNFeDest_v1.01.xsd +483 -0
  402. data/test/fixtures/product/schemas/leiauteConsSitNFe_v2.01.xsd +548 -0
  403. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsSitNFe_v3.10.xsd +502 -502
  404. data/test/fixtures/product/schemas/leiauteConsStatServ_v2.00.xsd +98 -0
  405. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsStatServ_v3.10.xsd +97 -97
  406. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v1.01.xsd +355 -0
  407. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v2.00.xsd +404 -0
  408. data/test/fixtures/product/schemas/leiauteDPEC_v1.01.xsd +464 -0
  409. data/test/fixtures/product/schemas/leiauteDownloadNFe_v1.00.xsd +149 -0
  410. data/test/fixtures/product/schemas/leiauteEPEC_v1.00.xsd +459 -0
  411. data/test/fixtures/product/schemas/leiauteEventoCancNFe_v1.00.xsd +394 -0
  412. data/test/fixtures/product/schemas/leiauteEvento_v1.00.xsd +373 -0
  413. data/test/fixtures/product/schemas/leiauteInutNFe_v2.00.xsd +193 -0
  414. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteInutNFe_v3.10.xsd +192 -192
  415. data/test/fixtures/product/schemas/leiauteNFe_v2.00.xsd +6661 -0
  416. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteNFe_v3.10.xsd +6060 -6060
  417. data/test/fixtures/product/schemas/leiauteRemIndus_v1.00.xsd +382 -0
  418. data/test/fixtures/product/schemas/leiauteSRE_v1.00.xsd +372 -0
  419. data/test/fixtures/product/schemas/leiauteSuframaInternaliza_v1.00.xsd +642 -0
  420. data/test/fixtures/product/schemas/leiauteSuframaVistoria_v1.00.xsd +648 -0
  421. data/test/fixtures/product/schemas/nfe_v2.00.xsd +9 -0
  422. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/nfe_v3.10.xsd +8 -8
  423. data/test/fixtures/product/schemas/procCCeNFe_v1.00.xsd +10 -0
  424. data/test/fixtures/product/schemas/procCancNFe_v2.00.xsd +9 -0
  425. data/test/fixtures/product/schemas/procConfRecebtoNFe_v1.00.xsd +9 -0
  426. data/test/fixtures/product/schemas/procEPEC_v1.00.xsd +9 -0
  427. data/test/fixtures/product/schemas/procEventoCancNFe_v1.00.xsd +9 -0
  428. data/test/fixtures/product/schemas/procEventoNFe_v1.00.xsd +9 -0
  429. data/test/fixtures/product/schemas/procEventoNFe_v99.99.xsd +37 -0
  430. data/test/fixtures/product/schemas/procInutNFe_v2.00.xsd +9 -0
  431. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procInutNFe_v3.10.xsd +8 -8
  432. data/test/fixtures/product/schemas/procNFe_v2.00.xsd +9 -0
  433. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procNFe_v3.10.xsd +8 -8
  434. data/test/fixtures/product/schemas/procRemIndus_v1.00.xsd +9 -0
  435. data/test/fixtures/product/schemas/resEvento_v1.00.xsd +94 -0
  436. data/test/fixtures/product/schemas/resNFe_v1.00.xsd +110 -0
  437. data/test/fixtures/product/schemas/retAtuCadEmiDFe_v1.01.xsd +9 -0
  438. data/test/fixtures/product/schemas/retCancNFe_v2.00.xsd +9 -0
  439. data/test/fixtures/product/schemas/retConsCad_v2.00.xsd +9 -0
  440. data/test/fixtures/product/schemas/retConsDPEC_v1.01.xsd +9 -0
  441. data/test/fixtures/product/schemas/retConsReciNFe_v2.00.xsd +9 -0
  442. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsReciNFe_v3.10.xsd +8 -8
  443. data/test/fixtures/product/schemas/retConsSitNFe_v2.01.xsd +10 -0
  444. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsSitNFe_v3.10.xsd +8 -8
  445. data/test/fixtures/product/schemas/retConsStatServ_v2.00.xsd +9 -0
  446. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsStatServ_v3.10.xsd +8 -8
  447. data/test/fixtures/product/schemas/retDPEC_v1.01.xsd +9 -0
  448. data/test/fixtures/product/schemas/retDistDFeInt_v1.00.xsd +84 -0
  449. data/test/fixtures/product/schemas/retDownloadNFe_v1.00.xsd +9 -0
  450. data/test/fixtures/product/schemas/retEnvCCe_v1.00.xsd +10 -0
  451. data/test/fixtures/product/schemas/retEnvCancelPProrrogNFe_v1.0.xsd +231 -0
  452. data/test/fixtures/product/schemas/retEnvConfRecebto_v1.00.xsd +9 -0
  453. data/test/fixtures/product/schemas/retEnvEPEC_v1.00.xsd +9 -0
  454. data/test/fixtures/product/schemas/retEnvEventoCancNFe_v1.00.xsd +9 -0
  455. data/test/fixtures/product/schemas/retEnvEvento_v1.00.xsd +9 -0
  456. data/test/fixtures/product/schemas/retEnvFiscoNFe_v1.0.xsd +234 -0
  457. data/test/fixtures/product/schemas/retEnvRemIndus_v1.00.xsd +9 -0
  458. data/test/fixtures/product/schemas/retEnvSuframaInternaliza_v1.00.xsd +9 -0
  459. data/test/fixtures/product/schemas/retEnvSuframaVistoria_v1.00.xsd +9 -0
  460. data/test/fixtures/product/schemas/retEnviNFe_v2.00.xsd +9 -0
  461. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retEnviNFe_v3.10.xsd +8 -8
  462. data/test/fixtures/product/schemas/retEventoEPEC_v0.01.xsd +207 -0
  463. data/test/fixtures/product/schemas/retInutNFe_v2.00.xsd +9 -0
  464. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retInutNFe_v3.10.xsd +8 -8
  465. data/test/fixtures/product/schemas/retPProrrogNFe_v1.0.xsd +233 -0
  466. data/test/fixtures/product/schemas/retconsNFeDest_v1.01.xsd +9 -0
  467. data/test/fixtures/product/schemas/tiposBasico_v1.03.xsd +816 -0
  468. data/test/fixtures/product/schemas/tiposBasico_v1.03_OPENSSL.xsd +816 -0
  469. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/tiposBasico_v3.10.xsd +571 -571
  470. data/test/fixtures/product/schemas/tiposBasico_v3.10_OPENSSL.xsd +877 -0
  471. data/test/fixtures/product/schemas/tiposDistDFe_v1.00.xsd +217 -0
  472. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/xmldsig-core-schema_v1.01.xsd +97 -97
  473. data/test/fixtures/product/wsdl/NFeRetAutorizacao.xml +80 -0
  474. data/test/fixtures/product/wsdl/NfeAutorizacao.xml +107 -0
  475. data/test/fixtures/product/wsdl/NfeConsulta2.xml +80 -0
  476. data/test/fixtures/product/wsdl/NfeStatusServico2.xml +70 -0
  477. data/test/fixtures/product/wsdl/nfeinutilizacao2.xml +80 -0
  478. data/test/fixtures/service/wsdl/betha/v1/cancelar_nfse.xml +178 -0
  479. data/test/fixtures/service/wsdl/betha/v1/consultar_lote_rps.xml +339 -0
  480. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse.xml +348 -0
  481. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse_por_rps.xml +365 -0
  482. data/test/fixtures/service/wsdl/betha/v1/consultar_situacao_lote_rps.xml +74 -0
  483. data/test/fixtures/service/wsdl/betha/v1/recepcionar_lote_rps.xml +299 -0
  484. data/test/fixtures/service/wsdl/simpliss/v1/nfseservice.xml +1 -0
  485. data/test/fixtures/service/wsdl/thema/v1/nfse_cancelamento.xml +82 -0
  486. data/test/fixtures/service/wsdl/thema/v1/nfse_consulta.xml +235 -0
  487. data/test/fixtures/service/wsdl/thema/v1/nfse_remessa.xml +185 -0
  488. data/test/test_helper.rb +369 -1
  489. metadata +711 -33
  490. data/lib/br_nfe/product/base.rb +0 -82
  491. data/lib/br_nfe/product/consulta_status_servico.rb +0 -35
  492. data/lib/br_nfe/product/value_nf.rb +0 -9
  493. data/lib/br_nfe/product/xml/v3_10/consulta_status_servico.xml.slim +0 -4
  494. data/test/br_nfe/product/base_test.rb +0 -150
  495. data/test/br_nfe/product/consulta_status_servico_test.rb +0 -59
@@ -0,0 +1,133 @@
1
+ # o método original_xml deve ter o XML da NF-e
2
+ #
3
+ module BrNfe
4
+ module Product
5
+ module Response
6
+ module Build
7
+ class NfeConsultaProtocolo < Base
8
+ # Responsável por definir qual classe será instânciada para
9
+ # setar os valores de retorno referentes a cada operação.
10
+ #
11
+ # <b>Type: </b> _Class_
12
+ #
13
+ def response_class
14
+ BrNfe::Product::Response::NfeConsultaProtocolo
15
+ end
16
+
17
+ # Responsável por setar os atributos específicos para
18
+ # cada tipo de operação.
19
+ #
20
+ # <b>Type: </b> _Hash_
21
+ #
22
+ def specific_attributes
23
+ attrs = {
24
+ environment: body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:tpAmb', nf: nf_xmlns, ret: url_xmlns_retorno).text,
25
+ app_version: body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:verAplic', nf: nf_xmlns, ret: url_xmlns_retorno).text,
26
+ processed_at: request_processed_at,
27
+ processing_status_code: get_processing_status_code,
28
+ processing_status_motive: get_processing_status_motive,
29
+ }
30
+
31
+ set_events!( attrs )
32
+
33
+ attrs[:nota_fiscal] = build_invoice_by_prot_nfe( prot_nfe_doc ) if prot_nfe_doc
34
+
35
+ set_invoice_situation!( attrs )
36
+
37
+ attrs
38
+ end
39
+
40
+ private
41
+
42
+ def prot_nfe_doc
43
+ return @prot_nfe_doc if @prot_nfe_doc
44
+ if prot_nfe = body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:protNFe', nf: nf_xmlns, ret: url_xmlns_retorno).first
45
+ @prot_nfe_doc = parse_nokogiri_xml( prot_nfe.to_xml )
46
+ end
47
+ end
48
+
49
+ def request_processed_at
50
+ @request_processed_at ||= body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:dhRecbto', nf: nf_xmlns, ret: url_xmlns_retorno).text
51
+ end
52
+ def get_processing_status_code
53
+ @get_processing_status_code ||= body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:cStat', nf: nf_xmlns, ret: url_xmlns_retorno).text
54
+ end
55
+ def get_processing_status_motive
56
+ @get_processing_status_motive ||= body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:xMotivo', nf: nf_xmlns, ret: url_xmlns_retorno).text
57
+ end
58
+
59
+ # Responsável por instanciar e setar os eventos através do XML
60
+ # Percore todas as tags de eventos, instancia o evento e seta o
61
+ # valor na chave do evento
62
+ #
63
+ def set_events! attrs
64
+ attrs[:events] = []
65
+ body_xml.xpath('//ret:nfeConsultaNF2Result/nf:retConsSitNFe/nf:procEventoNFe', nf: nf_xmlns, ret: url_xmlns_retorno).each do |event_node|
66
+ doc_evento = parse_nokogiri_xml( event_node.to_xml )
67
+ attrs[:events] << build_event_by_xml( doc_evento )
68
+ end
69
+ set_main_event!(attrs)
70
+ end
71
+
72
+ # Responsável por setar o evento principal.
73
+ # O evento principal é o que tem a maior sequência. Exceto se
74
+ # tiver algum evento de cancelamento, pois o evento de cancelamento
75
+ # é sempre o último evento, e após o cancelamento não é mais
76
+ # possível registrar eventos.
77
+ #
78
+ def set_main_event!(attrs)
79
+ # CÓDIGO DE CANCELAMENTO
80
+ if ev_cancel = attrs[:events].select{|e| e.code == '110111' }.last
81
+ attrs[:main_event] = ev_cancel
82
+ else
83
+ attrs[:main_event] = attrs[:events].sort_by{|e| [e.sequence.to_i, (e.registred_at||Time.current)] }.last
84
+ end
85
+ end
86
+
87
+ def build_event_by_xml( doc_evento )
88
+ # É feito o dup para setar no evento o XMl com os namespaces
89
+ doc_evento_with_namespaces = doc_evento.dup
90
+
91
+ # Os namespaces são removidos pois as vezes pode vir com namespace
92
+ # e as vezes não.
93
+ doc_evento.remove_namespaces!
94
+
95
+ BrNfe::Product::Response::Event.new do |event|
96
+ event.codigo_orgao = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/cOrgao').text
97
+ event.status_code = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/cStat').text
98
+ event.status_motive = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/xMotivo').text
99
+ event.code = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/tpEvento').text
100
+ event.sequence = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/nSeqEvento').text.to_i
101
+
102
+ if doc_evento.xpath('//procEventoNFe/retEvento/infEvento/CNPJDest').present?
103
+ event.cpf_cnpj_destino = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/CNPJDest').text
104
+ else
105
+ event.cpf_cnpj_destino = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/CPFDest').text
106
+ end
107
+
108
+ event.sent_at = doc_evento.xpath('//procEventoNFe/evento/infEvento/dhEvento').text
109
+ event.registred_at = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/dhRegEvento').text
110
+ event.event_protocol = doc_evento.xpath('//procEventoNFe/evento/infEvento/detEvento/nProt').text
111
+ event.ret_event_protocol = doc_evento.xpath('//procEventoNFe/retEvento/infEvento/nProt').text
112
+ event.description = doc_evento.xpath('//procEventoNFe/evento/infEvento/detEvento/descEvento').text
113
+ event.justification = doc_evento.xpath('//procEventoNFe/evento/infEvento/detEvento/xJust').text
114
+ event.correction_text = doc_evento.xpath('//procEventoNFe/evento/infEvento/detEvento/xCorrecao').text
115
+ event.xml = '<?xml version="1.0" encoding="UTF-8"?>'+canonicalize( doc_evento_with_namespaces.to_xml )
116
+ end
117
+ end
118
+
119
+ def set_invoice_situation!( attrs )
120
+ if attrs[:nota_fiscal].present? && attrs[:main_event].present?
121
+ case attrs[:main_event].code.to_i
122
+ when 110111
123
+ attrs[:nota_fiscal].situation = :canceled
124
+ when 110110
125
+ attrs[:nota_fiscal].situation = :adjusted
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,53 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ module Build
5
+ class NfeInutilizacao < Base
6
+
7
+ # Responsável por definir qual classe será instânciada para
8
+ # setar os valores de retorno referentes a cada operação.
9
+ #
10
+ # <b>Type: </b> _Class_
11
+ #
12
+ def response_class
13
+ BrNfe::Product::Response::NfeInutilizacao
14
+ end
15
+
16
+ # Responsável por pegar a tag XML principal que contém os dados da homologação.
17
+ # Utilizado para facilitar a codificação e para não repetir o
18
+ # código ao buscar as informações da homologação.
19
+ #
20
+ def info_xml
21
+ @info_xml ||= parse_nokogiri_xml( body_xml.xpath('//ret:nfeInutilizacaoNF2Result/nf:retInutNFe/nf:infInut', nf: nf_xmlns, ret: url_xmlns_retorno).to_xml )
22
+ end
23
+
24
+ # Responsável por setar os atributos específicos para
25
+ # cada tipo de operação.
26
+ # Nesse caso irá setar as informações da homologação da inutilização.
27
+ #
28
+ # <b>Type: </b> _Hash_
29
+ #
30
+ def specific_attributes
31
+ {
32
+ environment: info_xml.xpath('//infInut/tpAmb').text,
33
+ app_version: info_xml.xpath('//infInut/verAplic').text,
34
+ processed_at: info_xml.xpath('//infInut/dhRecbto').text,
35
+ protocol: info_xml.xpath('//infInut/nProt').text,
36
+
37
+ processing_status_code: info_xml.xpath('//infInut/cStat').text,
38
+ processing_status_motive: info_xml.xpath('//infInut/xMotivo').text,
39
+
40
+ uf: info_xml.xpath('//infInut/cUF').text,
41
+ year: info_xml.xpath('//infInut/ano').text,
42
+ cnpj: info_xml.xpath('//infInut/CNPJ').text,
43
+ nf_model: info_xml.xpath('//infInut/mod').text,
44
+ nf_series: info_xml.xpath('//infInut/serie').text,
45
+ start_invoice_number: info_xml.xpath('//infInut/nNFIni').text,
46
+ end_invoice_number: info_xml.xpath('//infInut/nNFFin').text,
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,65 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ module Build
5
+ class NfeRetAutorizacao < Base
6
+
7
+ # Responsável por definir qual classe será instânciada para
8
+ # setar os valores de retorno referentes a cada operação.
9
+ #
10
+ # <b>Type: </b> _Class_
11
+ #
12
+ def response_class
13
+ BrNfe::Product::Response::NfeRetAutorizacao
14
+ end
15
+
16
+ # Responsável por setar os atributos específicos para
17
+ # cada tipo de operação.
18
+ # Nesse caso irá setar as notas fiscais com seus respectivos
19
+ # XMLs.
20
+ #
21
+ # <b>Type: </b> _Hash_
22
+ #
23
+ def specific_attributes
24
+ {
25
+ environment: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:tpAmb', nf: nf_xmlns, ret: url_xmlns_retorno).text,
26
+ app_version: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:verAplic', nf: nf_xmlns, ret: url_xmlns_retorno).text,
27
+ processed_at: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:dhRecbto', nf: nf_xmlns, ret: url_xmlns_retorno).text,
28
+ protocol: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:nRec', nf: nf_xmlns, ret: url_xmlns_retorno).text,
29
+
30
+ processing_status_code: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:cStat', nf: nf_xmlns, ret: url_xmlns_retorno).text,
31
+ processing_status_motive: body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:xMotivo', nf: nf_xmlns, ret: url_xmlns_retorno).text,
32
+
33
+ notas_fiscais: get_invoices
34
+ }
35
+ end
36
+
37
+ # Responsável por buscar os protocolos no XML da resposta.
38
+ #
39
+ # <b>Type: </b> _Nokogiri::XML::NodeSet_
40
+ #
41
+ def protocol_nfe_nodes
42
+ @protocol_nfe_nodes ||= body_xml.xpath('//ret:nfeRetAutorizacaoLoteResult/nf:retConsReciNFe/nf:protNFe', nf: nf_xmlns, ret: url_xmlns_retorno)
43
+ end
44
+
45
+ # Responsável por instânciar as notas fiscais presentes na resposta
46
+ # a partir das tags de resposta do xml (protNFe).
47
+ # Também irá ajustar e setar o xml atualizado na nota fiscal, já com o protocolo
48
+ # incluso. Irá setar a tag nfeProc como raiz do XML.
49
+ #
50
+ # <b>Type: </b> _Array_
51
+ #
52
+ def get_invoices
53
+ invoices = []
54
+ protocol_nfe_nodes.each do |prot_nfe|
55
+ prot_nfe = parse_nokogiri_xml(prot_nfe.to_xml)
56
+ invoices << build_invoice_by_prot_nfe(prot_nfe)
57
+ end
58
+ invoices
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,43 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ module Build
5
+ class NfeStatusServico < Base
6
+
7
+ # Responsável por definir qual classe será instânciada para
8
+ # setar os valores de retorno referentes a cada operação.
9
+ #
10
+ # <b>Type: </b> _Class_
11
+ #
12
+ def response_class
13
+ BrNfe::Product::Response::NfeStatusServico
14
+ end
15
+
16
+ # Responsável por setar os atributos específicos para
17
+ # cada tipo de operação.
18
+ # Nesse caso irá setar as notas fiscais com seus respectivos
19
+ # XMLs.
20
+ #
21
+ # <b>Type: </b> _Hash_
22
+ #
23
+ def specific_attributes
24
+ {
25
+ environment: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:tpAmb', nf: nf_xmlns, ret: url_xmlns_retorno).text,
26
+ app_version: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:verAplic', nf: nf_xmlns, ret: url_xmlns_retorno).text,
27
+ processed_at: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:dhRecbto', nf: nf_xmlns, ret: url_xmlns_retorno).text,
28
+
29
+ processing_status_code: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:cStat', nf: nf_xmlns, ret: url_xmlns_retorno).text,
30
+ processing_status_motive: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:xMotivo', nf: nf_xmlns, ret: url_xmlns_retorno).text,
31
+
32
+ uf: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:cUF', nf: nf_xmlns, ret: url_xmlns_retorno).text,
33
+ average_time: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:tMed', nf: nf_xmlns, ret: url_xmlns_retorno).text.to_i,
34
+ observation: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:xObs', nf: nf_xmlns, ret: url_xmlns_retorno).text,
35
+ return_prevision: body_xml.xpath('//ret:nfeStatusServicoNF2Result/nf:retConsStatServ/nf:dhRetorno', nf: nf_xmlns, ret: url_xmlns_retorno).text,
36
+ }
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,89 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class Event < BrNfe::ActiveModelBase
5
+
6
+ # CÓDIGO DA UF QUE REGISTROU O EVENTO
7
+ # Será setado 90 para o Ambiente Nacional.
8
+ #
9
+ attr_accessor :codigo_orgao
10
+ alias_attribute :cOrgao, :codigo_orgao
11
+
12
+ # CÓDIGO DO STATUS DO EVENTO
13
+ #
14
+ attr_accessor :status_code
15
+ alias_attribute :cStat, :status_code
16
+
17
+ # DESCRIÇÃO DO STATUS DO EVENTO
18
+ #
19
+ attr_accessor :status_motive
20
+ alias_attribute :xMotivo, :status_motive
21
+
22
+ # CÓDIGO DO EVENTO
23
+ # Código do Tipo do Evento.
24
+ # 110111: Cancelamento
25
+ # 110110: CCe
26
+ # 110140: EPEC
27
+ # Eventos de manifestação do destinatário
28
+ # 210200: Confirmação da Operação
29
+ # 210210: Ciência da Emissão
30
+ # 210220: Desconhecimento da Operação
31
+ # 210240: Operação não Realizada
32
+ #
33
+ attr_accessor :code
34
+ alias_attribute :tpEvento, :code
35
+
36
+ # SEQUENCIAL DO EVENTO PARA O MESMO TIPO DE EVENTO.
37
+ #
38
+ attr_accessor :sequence
39
+ alias_attribute :nSeqEvento, :sequence
40
+
41
+ # CPF OU CNPJ DO DESTINATÁRIO DA NF-E
42
+ #
43
+ attr_accessor :cpf_cnpj_destino
44
+ alias_attribute :CNPJDest, :cpf_cnpj_destino
45
+ alias_attribute :CPFDest, :cpf_cnpj_destino
46
+
47
+ # DATA E HORA EM QUE O EVENTO FOI ENVIADO
48
+ #
49
+ attr_accessor :sent_at
50
+ def sent_at
51
+ convert_to_time( @sent_at )
52
+ end
53
+ alias_attribute :dhEvento, :sent_at
54
+
55
+ # DATA E HORA EM QUE O EVENTO FOI PROCESSADO PELA SEFAZ
56
+ #
57
+ attr_accessor :registred_at
58
+ def registred_at
59
+ convert_to_time( @registred_at )
60
+ end
61
+ alias_attribute :dhRegEvento, :registred_at
62
+
63
+ # NÚMERO DO PROTOCOLO DO ENVIO DO EVENTO
64
+ attr_accessor :event_protocol
65
+ alias_attribute :evento_nProt, :event_protocol
66
+
67
+ # NÚMERO DO PROTOCOLO DE AUTORIZAÇÃO DO EVENTO
68
+ attr_accessor :ret_event_protocol
69
+ alias_attribute :retEvento_nProt, :ret_event_protocol
70
+
71
+ # DESCRIÇÃO DO EVENTO
72
+ attr_accessor :description
73
+ alias_attribute :descEvento, :description
74
+
75
+ # JUSTIFICATIVA DO EVENTO
76
+ # Utilizado no evento de cancelamento de NF-e
77
+ attr_accessor :justification
78
+ alias_attribute :xJust, :justification
79
+
80
+ # DESCRIÇÃO DA CARTA DE CORREÇÃO
81
+ attr_accessor :correction_text
82
+ alias_attribute :xCorrecao, :correction_text
83
+
84
+ # XML DO EVENTO
85
+ attr_accessor :xml
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,12 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class NfeAutorizacao < Base
5
+ has_many :notas_fiscais, 'BrNfe.nota_fiscal_product_class'
6
+
7
+ attr_accessor :tempo_medio
8
+ alias_attribute :tMed, :tempo_medio
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class NfeConsultaProtocolo < Base
5
+ has_one :nota_fiscal, 'BrNfe.nota_fiscal_product_class'
6
+
7
+ has_many :events, 'BrNfe::Product::Response::Event'
8
+
9
+ has_one :main_event, 'BrNfe::Product::Response::Event'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,89 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class NfeInutilizacao < Base
5
+
6
+ # Código da UF que atendeu a solicitação
7
+ #
8
+ # <b>Type: </b> _String_
9
+ # <b>Required: </b> _Yes_
10
+ # <b>Example: </b> _SC_
11
+ # <b>Length: </b> _2_
12
+ # <b>tag: </b> cUF
13
+ #
14
+ attr_accessor :uf
15
+ alias_attribute :cUF, :uf
16
+
17
+ ####################################################################
18
+ # OS DADOS A SEGUIR APENAS SERÃO PREENCHIDOS SE A #
19
+ # HOMOLOGAÇÃO DA INUTILIZAÇÃO OBTIVER SUCESSO (cStat=102) #
20
+ ####################################################################
21
+ # Ano de inutilização da numeração
22
+ #
23
+ # <b>Type: </b> _String_
24
+ # <b>Required: </b> _No_
25
+ # <b>Example: </b> _SC_
26
+ # <b>Length: </b> _2_
27
+ # <b>tag: </b> cUF
28
+ #
29
+ attr_accessor :year
30
+ alias_attribute :ano, :year
31
+
32
+ # CNPJ do emitente
33
+ #
34
+ # <b>Type: </b> _String_
35
+ # <b>Required: </b> _No_
36
+ # <b>Example: </b> _12345678901234_
37
+ # <b>Length: </b> _14_
38
+ # <b>tag: </b> CNPJ
39
+ #
40
+ attr_accessor :cnpj
41
+ alias_attribute :CNPJ, :cnpj
42
+
43
+ # Modelo da NF-e
44
+ #
45
+ # <b>Type: </b> _Number_
46
+ # <b>Required: </b> _No_
47
+ # <b>Example: </b> _55_
48
+ # <b>Length: </b> _2_
49
+ # <b>tag: </b> mod
50
+ #
51
+ attr_accessor :nf_model
52
+ alias_attribute :mod, :nf_model
53
+
54
+ # Série da NF-e
55
+ #
56
+ # <b>Type: </b> _Number_
57
+ # <b>Required: </b> _No_
58
+ # <b>Example: </b> _1_
59
+ # <b>Length: </b> _min: 1, max: 3_
60
+ # <b>tag: </b> serie
61
+ #
62
+ attr_accessor :nf_series
63
+ alias_attribute :serie, :nf_series
64
+
65
+ # Número da NF-e inicial a ser inutilizada
66
+ #
67
+ # <b>Type: </b> _Number_
68
+ # <b>Required: </b> _No_
69
+ # <b>Example: </b> _1_
70
+ # <b>Length: </b> _min: 1, max: 3_
71
+ # <b>tag: </b> nNFIni
72
+ #
73
+ attr_accessor :start_invoice_number
74
+ alias_attribute :nNFIni, :start_invoice_number
75
+
76
+ # Número da NF-e final a ser inutilizada
77
+ #
78
+ # <b>Type: </b> _Number_
79
+ # <b>Required: </b> _No_
80
+ # <b>Example: </b> _1_
81
+ # <b>Length: </b> _min: 1, max: 3_
82
+ # <b>tag: </b> nNFFin
83
+ #
84
+ attr_accessor :end_invoice_number
85
+ alias_attribute :nNFFin, :end_invoice_number
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,9 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class NfeRetAutorizacao < Base
5
+ has_many :notas_fiscais, 'BrNfe.nota_fiscal_product_class'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ module BrNfe
2
+ module Product
3
+ module Response
4
+ class NfeStatusServico < Base
5
+
6
+ attr_accessor :uf
7
+ alias_attribute :cUF, :uf
8
+
9
+ attr_accessor :average_time
10
+ alias_attribute :tMed, :average_time
11
+
12
+ attr_accessor :observation
13
+ alias_attribute :xObs, :observation
14
+
15
+ attr_accessor :return_prevision
16
+ alias_attribute :dhRetorno, :return_prevision
17
+ def return_prevision
18
+ convert_to_time(@return_prevision)
19
+ end
20
+
21
+ def status
22
+ if processing_status_code == '107'
23
+ :online
24
+ else
25
+ :offline
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"
2
+ CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
3
+ SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"
4
+ Reference URI="##{uri}"
5
+ Transforms
6
+ Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"
7
+ Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
8
+ DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
9
+ DigestValue = remove_quebras Base64.encode64(OpenSSL::Digest::SHA1.digest(data_xml.html_safe))
@@ -0,0 +1,7 @@
1
+ - cpf_cnpj = BrNfe::Helper::CpfCnpj.new(cpf_cnpj)
2
+ - if cpf_cnpj.cnpj?
3
+ CNPJ = nf_xml_value_cnpj(cpf_cnpj.sem_formatacao)
4
+ - elsif cpf_cnpj.cpf?
5
+ CPF = nf_xml_value_cpf( cpf_cnpj.sem_formatacao)
6
+ - else
7
+ idEstrangeiro = nf_xml_value_id_estrangeiro(cpf_cnpj.sem_formatacao)
@@ -0,0 +1,12 @@
1
+ Signature xmlns="http://www.w3.org/2000/09/xmldsig#"
2
+ - info_xml = render_xml('_signed_info_sh1', data_xml: data_xml, uri: uri)
3
+ / o xmlns é necessário apenas para assinar e não deve estar presente no XML
4
+ / e para evitar 2 renderizações foi feito um gsub para tirar o xmlns
5
+ = info_xml.gsub('<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">','<SignedInfo >').html_safe
6
+
7
+ - signature_hash = certificate_key.sign(OpenSSL::Digest::SHA1.new, info_xml.html_safe)
8
+ SignatureValue = remove_quebras( Base64.encode64( signature_hash ) )
9
+
10
+ KeyInfo
11
+ X509Data
12
+ X509Certificate = certificate.to_s.gsub(/\-\-\-\-\-[A-Z]+ CERTIFICATE\-\-\-\-\-/, "").gsub(/\n/,"")
@@ -0,0 +1,19 @@
1
+ |<infEvento xmlns="http://www.portalfiscal.inf.br/nfe" Id="#{cancelamento.chave}">
2
+ cOrgao = nf_xml_value_orgao_emissor( cancelamento )
3
+ tpAmb = nf_xml_value_tipo_ambiente( env )
4
+
5
+ - if "#{emitente.cpf_cnpj}".size > 11
6
+ CNPJ = nf_xml_value_cnpj( emitente.cpf_cnpj )
7
+ - else
8
+ CPF = nf_xml_value_cpf( emitente.cpf_cnpj )
9
+
10
+ chNFe = nf_xml_value_chave_nfe( cancelamento.chave_nfe )
11
+ dhEvento = nf_xml_value_date_time( cancelamento.data_hora )
12
+ tpEvento = cancelamento.codigo_evento
13
+ nSeqEvento = cancelamento.numero_sequencial.to_i
14
+ verEvento = '1.00'
15
+ detEvento versao="1.00"
16
+ descEvento = 'Cancelamento'
17
+ nProt = cancelamento.protocolo_nfe
18
+ xJust = nf_xml_value_text( cancelamento.justificativa, 255 )
19
+ |</infEvento>
@@ -0,0 +1,5 @@
1
+ downloadNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="#{xml_version}"
2
+ tpAmb = nf_xml_value_tipo_ambiente( env )
3
+ xServ = 'DOWNLOAD NFE'
4
+ CNPJ = nf_xml_value_cnpj( emitente.cpf_cnpj )
5
+ chNFe = nf_xml_value_chave_nfe( chave_nfe )
@@ -0,0 +1,7 @@
1
+ envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="#{xml_version}"
2
+ idLote = numero_lote
3
+ - if cancelamento
4
+ evento versao="#{xml_version}"
5
+ - evento_xml = render_xml('evento/infEventoCancelamento')
6
+ = evento_xml.gsub('<infEvento xmlns="http://www.portalfiscal.inf.br/nfe"', '<infEvento ').html_safe
7
+ = render_xml('signature_sh1', data_xml: evento_xml, uri: "#{cancelamento.chave}").html_safe
@@ -0,0 +1,19 @@
1
+ xLgr = nf_xml_value_text( person.endereco.logradouro, 60 )
2
+ nro = nf_xml_value_text( person.endereco.numero, 60 )
3
+
4
+ - if person.endereco.complemento.present?
5
+ xCpl = nf_xml_value_text( person.endereco.complemento, 60 )
6
+
7
+ xBairro = nf_xml_value_text( person.endereco.bairro, 60 )
8
+ cMun = nf_xml_value_codigo_ibge_municipio( person.endereco.codigo_municipio )
9
+ xMun = nf_xml_value_text( person.endereco.nome_municipio, 60 )
10
+ UF = nf_xml_value_UF( person.endereco.uf )
11
+ CEP = nf_xml_value_CEP( person.endereco.cep )
12
+
13
+ / Só é necessário informar o país se não for o Brasil
14
+ - if person.endereco.codigo_pais.to_i != 1058
15
+ cPais = nf_xml_value_codigo_pais( person.endereco.codigo_pais )
16
+ xPais = nf_xml_value_text( person.endereco.nome_pais, 60 )
17
+
18
+ - if person.telefone.present?
19
+ fone = nf_xml_value_fone( person.telefone )
@@ -0,0 +1,39 @@
1
+ ide = render_xml 'infNFe/_tc_ide', nfe: nfe
2
+ emit = render_xml 'infNFe/_tc_emit'
3
+ / avulsa
4
+ dest = render_xml 'infNFe/_tc_dest', nfe: nfe
5
+
6
+ - if nfe.endereco_retirada
7
+ retirada = render_xml 'infNFe/_tc_retirada', nfe: nfe
8
+
9
+ - if nfe.endereco_entrega
10
+ entrega = render_xml 'infNFe/_tc_entrega', nfe: nfe
11
+
12
+ - nfe.autorizados_download_xml.each do |auth|
13
+ autXML
14
+ = render_xml('_tc_cpf_cnpj', cpf_cnpj: auth)
15
+
16
+ - nfe.itens.each_with_index do |item, i|
17
+ det nItem="#{i+1}"
18
+ = render_xml 'infNFe/_tc_det', item: item
19
+
20
+ total
21
+ = render_xml 'infNFe/_tc_total', nfe: nfe
22
+
23
+ transp
24
+ = render_xml('infNFe/_tc_transp', nfe: nfe)
25
+
26
+ - if nfe.fatura
27
+ cobr
28
+ = render_xml 'infNFe/_tc_cobr', nfe: nfe
29
+
30
+ - if nfe.informacoes_fisco.present? || nfe.informacoes_contribuinte.present? || nfe.processos_referenciados.present?
31
+ infAdic
32
+ = render_xml 'infNFe/_tc_infAdic', nfe: nfe
33
+
34
+ - if nfe.exportacao_uf_saida.present? && nfe.exportacao_local_embarque.present?
35
+ exporta
36
+ = render_xml 'infNFe/_tc_exporta', nfe: nfe
37
+
38
+ / compra
39
+ / cana