br_nfe 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +0 -1
  4. data/Gemfile.lock +1 -1
  5. data/README.markdown +264 -106
  6. data/lib/br_nfe/{helper → association}/have_address.rb +1 -1
  7. data/lib/br_nfe/{helper → association}/have_condicao_pagamento.rb +1 -1
  8. data/lib/br_nfe/association/have_destinatario.rb +22 -0
  9. data/lib/br_nfe/association/have_emitente.rb +24 -0
  10. data/lib/br_nfe/base.rb +37 -27
  11. data/lib/br_nfe/condicao_pagamento.rb +2 -0
  12. data/lib/br_nfe/constants.rb +33 -0
  13. data/lib/br_nfe/endereco.rb +10 -0
  14. data/lib/br_nfe/helper/string_methods.rb +4 -0
  15. data/lib/br_nfe/{emitente.rb → person.rb} +11 -7
  16. data/lib/br_nfe/product/base.rb +82 -0
  17. data/lib/br_nfe/product/consulta_status_servico.rb +35 -0
  18. data/lib/br_nfe/product/emitente.rb +8 -0
  19. data/lib/br_nfe/product/gateway/base.rb +62 -0
  20. data/lib/br_nfe/product/gateway/web_service_svrs.rb +39 -0
  21. data/lib/br_nfe/product/value_nf.rb +9 -0
  22. data/lib/br_nfe/product/xml/soap_env.xml.slim +8 -0
  23. data/lib/br_nfe/product/xml/v3_10/XSD/consReciNFe_v3.10.xsd +9 -0
  24. data/lib/br_nfe/product/xml/v3_10/XSD/consSitNFe_v3.10.xsd +9 -0
  25. data/lib/br_nfe/product/xml/v3_10/XSD/consStatServ_v3.10.xsd +9 -0
  26. data/lib/br_nfe/product/xml/v3_10/XSD/enviNFe_v3.10.xsd +9 -0
  27. data/lib/br_nfe/product/xml/v3_10/XSD/inutNFe_v3.10.xsd +9 -0
  28. data/lib/br_nfe/product/xml/v3_10/XSD/leiauteConsSitNFe_v3.10.xsd +502 -0
  29. data/lib/br_nfe/product/xml/v3_10/XSD/leiauteConsStatServ_v3.10.xsd +98 -0
  30. data/lib/br_nfe/product/xml/v3_10/XSD/leiauteInutNFe_v3.10.xsd +193 -0
  31. data/lib/br_nfe/product/xml/v3_10/XSD/leiauteNFe_v3.10.xsd +6060 -0
  32. data/lib/br_nfe/product/xml/v3_10/XSD/nfe_v3.10.xsd +9 -0
  33. data/lib/br_nfe/product/xml/v3_10/XSD/procInutNFe_v3.10.xsd +9 -0
  34. data/lib/br_nfe/product/xml/v3_10/XSD/procNFe_v3.10.xsd +9 -0
  35. data/lib/br_nfe/product/xml/v3_10/XSD/retConsReciNFe_v3.10.xsd +9 -0
  36. data/lib/br_nfe/product/xml/v3_10/XSD/retConsSitNFe_v3.10.xsd +9 -0
  37. data/lib/br_nfe/product/xml/v3_10/XSD/retConsStatServ_v3.10.xsd +9 -0
  38. data/lib/br_nfe/product/xml/v3_10/XSD/retEnviNFe_v3.10.xsd +9 -0
  39. data/lib/br_nfe/product/xml/v3_10/XSD/retInutNFe_v3.10.xsd +9 -0
  40. data/lib/br_nfe/product/xml/v3_10/XSD/tiposBasico_v3.10.xsd +571 -0
  41. data/lib/br_nfe/product/xml/v3_10/XSD/xmldsig-core-schema_v1.01.xsd +98 -0
  42. data/lib/br_nfe/product/xml/v3_10/consulta_status_servico.xml.slim +4 -0
  43. data/lib/br_nfe/service/association/have_intermediario.rb +26 -0
  44. data/lib/br_nfe/service/association/have_rps.rb +36 -0
  45. data/lib/br_nfe/service/base.rb +24 -20
  46. data/lib/br_nfe/service/betha/v1/cancela_nfse.rb +43 -0
  47. data/lib/br_nfe/service/betha/v1/consulta_lote_rps.rb +20 -6
  48. data/lib/br_nfe/service/betha/v1/consulta_nfs_por_rps.rb +17 -6
  49. data/lib/br_nfe/service/betha/v1/consulta_nfse.rb +16 -5
  50. data/lib/br_nfe/service/betha/v1/consulta_situacao_lote_rps.rb +15 -6
  51. data/lib/br_nfe/service/betha/v1/gateway.rb +4 -0
  52. data/lib/br_nfe/service/betha/v1/recepcao_lote_rps.rb +13 -5
  53. data/lib/br_nfe/service/betha/v1/xml/_tc_identificacao_prestador.xml.slim +3 -0
  54. data/lib/br_nfe/service/betha/v1/xml/_tc_pedido_cancelamento.xml.slim +4 -0
  55. data/lib/br_nfe/service/concerns/rules/cancelamento_nfs.rb +8 -0
  56. data/lib/br_nfe/service/concerns/rules/consulta_nfs_por_rps.rb +1 -1
  57. data/lib/br_nfe/service/concerns/rules/consulta_nfse.rb +5 -2
  58. data/lib/br_nfe/service/concerns/values_ts/service_v1.rb +319 -0
  59. data/lib/br_nfe/service/destinatario.rb +7 -0
  60. data/lib/br_nfe/service/emitente.rb +8 -0
  61. data/lib/br_nfe/service/intermediario.rb +1 -12
  62. data/lib/br_nfe/service/item.rb +7 -7
  63. data/lib/br_nfe/service/response/build/base.rb +166 -0
  64. data/lib/br_nfe/service/response/build/cancelamento.rb +62 -0
  65. data/lib/br_nfe/service/response/build/consulta_lote_rps.rb +25 -0
  66. data/lib/br_nfe/service/response/build/consulta_nfs_por_rps.rb +25 -0
  67. data/lib/br_nfe/service/response/build/consulta_nfse.rb +24 -0
  68. data/lib/br_nfe/service/response/build/consulta_situacao_lote_rps.rb +56 -0
  69. data/lib/br_nfe/service/response/build/invoice_build.rb +359 -0
  70. data/lib/br_nfe/service/response/build/recepcao_lote_rps.rb +69 -0
  71. data/lib/br_nfe/service/response/cancelamento.rb +22 -0
  72. data/lib/br_nfe/service/response/consulta_lote_rps.rb +18 -0
  73. data/lib/br_nfe/service/response/consulta_nfs_por_rps.rb +10 -0
  74. data/lib/br_nfe/service/response/consulta_nfse.rb +10 -0
  75. data/lib/br_nfe/service/response/consulta_situacao_lote_rps.rb +74 -0
  76. data/lib/br_nfe/service/response/default.rb +93 -0
  77. data/lib/br_nfe/{response/service → service/response}/nota_fiscal.rb +19 -12
  78. data/lib/br_nfe/service/response/paths/v1/tc_nfse.rb +275 -0
  79. data/lib/br_nfe/service/response/recepcao_lote_rps.rb +35 -0
  80. data/lib/br_nfe/service/rps.rb +30 -27
  81. data/lib/br_nfe/service/sc/florianopolis/xml/_service_item.xml.slim +4 -4
  82. data/lib/br_nfe/service/sc/florianopolis/xml/inf_requisicao.xml.slim +4 -4
  83. data/lib/br_nfe/service/simpliss/v1/cancela_nfse.rb +16 -6
  84. data/lib/br_nfe/service/simpliss/v1/consulta_lote_rps.rb +20 -12
  85. data/lib/br_nfe/service/simpliss/v1/consulta_nfs_por_rps.rb +21 -6
  86. data/lib/br_nfe/service/simpliss/v1/consulta_nfse.rb +20 -6
  87. data/lib/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps.rb +17 -6
  88. data/lib/br_nfe/service/simpliss/v1/recepcao_lote_rps.rb +16 -4
  89. data/lib/br_nfe/service/simpliss/v1/xml/_tc_item_servico.xml.slim +2 -2
  90. data/lib/br_nfe/service/thema/v1/cancela_nfse.rb +21 -19
  91. data/lib/br_nfe/service/thema/v1/consulta_lote_rps.rb +21 -19
  92. data/lib/br_nfe/service/thema/v1/consulta_nfs_por_rps.rb +25 -18
  93. data/lib/br_nfe/service/thema/v1/consulta_nfse.rb +20 -20
  94. data/lib/br_nfe/service/thema/v1/consulta_situacao_lote_rps.rb +14 -20
  95. data/lib/br_nfe/service/thema/v1/recepcao_lote_rps.rb +11 -16
  96. data/lib/br_nfe/service/thema/v1/recepcao_lote_rps_limitado.rb +8 -6
  97. data/lib/br_nfe/service/xml/v1/_tc_identificacao_nfse.xml.slim +1 -1
  98. data/lib/br_nfe/service/xml/v1/_tc_pedido_cancelamento.xml.slim +1 -1
  99. data/lib/br_nfe/service/xml/v1/_tc_valores.xml.slim +11 -11
  100. data/lib/br_nfe/version.rb +1 -1
  101. data/lib/br_nfe.rb +62 -62
  102. data/test/br_nfe/association/have_address_test.rb +64 -0
  103. data/test/br_nfe/association/have_condicao_pagamento_test.rb +75 -0
  104. data/test/br_nfe/association/have_destinatario_test.rb +76 -0
  105. data/test/br_nfe/association/have_emitente_test.rb +80 -0
  106. data/test/br_nfe/base_test.rb +96 -61
  107. data/test/br_nfe/endereco_test.rb +21 -0
  108. data/test/br_nfe/person_test.rb +55 -0
  109. data/test/br_nfe/product/base_test.rb +150 -0
  110. data/test/br_nfe/product/consulta_status_servico_test.rb +59 -0
  111. data/test/br_nfe/product/emitente_test.rb +29 -0
  112. data/test/br_nfe/product/gateway/base_test.rb +16 -0
  113. data/test/br_nfe/product/gateway/web_service_svrs_test.rb +36 -0
  114. data/test/br_nfe/service/association/have_intermediario_test.rb +80 -0
  115. data/test/br_nfe/service/association/have_rps_test.rb +62 -0
  116. data/test/br_nfe/service/base_test.rb +42 -42
  117. data/test/br_nfe/service/betha/v1/cancela_nfse_test.rb +90 -0
  118. data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +105 -5
  119. data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +103 -5
  120. data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +114 -5
  121. data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +118 -5
  122. data/test/br_nfe/service/betha/v1/gateway_test.rb +1 -1
  123. data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +51 -5
  124. data/test/br_nfe/service/concerns/rules/cancelamento_nfs_test.rb +2 -2
  125. data/test/br_nfe/service/concerns/rules/consulta_nfs_por_rps_test.rb +2 -7
  126. data/test/br_nfe/service/concerns/rules/consulta_nfse_test.rb +24 -3
  127. data/test/br_nfe/service/concerns/rules/recepcao_lote_rps_test.rb +1 -1
  128. data/test/br_nfe/{helper → service/concerns}/values_ts/service_v1_test.rb +2 -2
  129. data/test/br_nfe/{destinatario_test.rb → service/destinatario_test.rb} +3 -4
  130. data/test/br_nfe/service/emitente_test.rb +29 -0
  131. data/test/br_nfe/service/item_test.rb +14 -14
  132. data/test/br_nfe/service/response/build/base_test.rb +80 -0
  133. data/test/br_nfe/{response/service → service/response}/default_test.rb +1 -82
  134. data/test/br_nfe/service/response/nota_fiscal_test.rb +59 -0
  135. data/test/br_nfe/{response/service → service/response}/paths/v1/tc_nfse_test.rb +10 -10
  136. data/test/br_nfe/service/rps_test.rb +107 -138
  137. data/test/br_nfe/service/sc/florianopolis/emission_rps_test.rb +9 -9
  138. data/test/br_nfe/service/simpliss/v1/base_test.rb +1 -1
  139. data/test/br_nfe/service/simpliss/v1/cancela_nfse_test.rb +7 -10
  140. data/test/br_nfe/service/simpliss/v1/consulta_lote_rps_test.rb +11 -18
  141. data/test/br_nfe/service/simpliss/v1/consulta_nfs_por_rps_test.rb +11 -18
  142. data/test/br_nfe/service/simpliss/v1/consulta_nfse_test.rb +11 -18
  143. data/test/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps_test.rb +7 -11
  144. data/test/br_nfe/service/simpliss/v1/recepcao_lote_rps_test.rb +3 -9
  145. data/test/br_nfe/service/thema/v1/base_test.rb +1 -1
  146. data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +7 -14
  147. data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +6 -17
  148. data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +6 -13
  149. data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +11 -18
  150. data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +7 -11
  151. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_limitado_test.rb +1 -5
  152. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +3 -9
  153. data/test/factories/base.rb +0 -1
  154. data/test/factories/{emitente.rb → person.rb} +1 -1
  155. data/test/factories/product/base.rb +12 -0
  156. data/test/factories/product/consulta_status_servico.rb +12 -0
  157. data/test/factories/product/emitente.rb +15 -0
  158. data/test/factories/product/gateway/base.rb +5 -0
  159. data/test/factories/product/gateway/web_service_svrs.rb +5 -0
  160. data/test/factories/service/betha/v1/{cancelamento_nfs.rb → cancela_nfse.rb} +2 -1
  161. data/test/factories/service/betha/v1/consulta_lote_rps.rb +1 -1
  162. data/test/factories/service/betha/v1/consulta_nfs_por_rps.rb +1 -1
  163. data/test/factories/service/betha/v1/consulta_nfse.rb +1 -1
  164. data/test/factories/service/betha/v1/consulta_situacao_lote_rps.rb +1 -1
  165. data/test/factories/{destinatario.rb → service/destinatario.rb} +1 -1
  166. data/test/factories/service/emitente.rb +15 -0
  167. data/test/factories/service/item.rb +4 -4
  168. data/test/factories/service/response/build_response.rb +5 -0
  169. data/test/factories/service/response/default.rb +6 -0
  170. data/test/factories/{response/service → service/response}/nota_fiscal.rb +8 -8
  171. data/test/factories/service/rps.rb +11 -11
  172. data/test/factories/service/sc/florianopolis/base.rb +1 -1
  173. data/test/factories/service/sc/florianopolis/cancellation.rb +1 -1
  174. data/test/factories/service/sc/florianopolis/emission_rps.rb +1 -1
  175. data/test/factories/service/simpliss/v1/base.rb +1 -1
  176. data/test/factories/service/simpliss/v1/cancela_nfse.rb +1 -1
  177. data/test/factories/service/simpliss/v1/consulta_lote_rps.rb +1 -1
  178. data/test/factories/service/simpliss/v1/consulta_nfs_por_rps.rb +1 -1
  179. data/test/factories/service/simpliss/v1/consulta_nfse.rb +1 -1
  180. data/test/factories/service/simpliss/v1/consulta_situacao_lote_rps.rb +1 -1
  181. data/test/factories/service/simpliss/v1/recepcao_lote_rps.rb +1 -1
  182. data/test/factories/service/thema/v1/base.rb +1 -1
  183. data/test/factories/service/thema/v1/cancela_nfse.rb +1 -1
  184. data/test/factories/service/thema/v1/consulta_lote_rps.rb +1 -1
  185. data/test/factories/service/thema/v1/consulta_nfs_por_rps.rb +1 -1
  186. data/test/factories/service/thema/v1/consulta_nfse.rb +1 -1
  187. data/test/factories/service/thema/v1/consulta_situacao_lote_rps.rb +1 -1
  188. data/test/factories/service/thema/v1/recepcao_lote_rps.rb +1 -1
  189. data/test/fixtures/service/response/betha/v1/cancela_nfse/fault.xml +17 -0
  190. data/test/fixtures/service/response/betha/v1/cancela_nfse/success.xml +48 -0
  191. data/test/fixtures/service/response/betha/v1/consulta_lote_rps/fault.xml +18 -0
  192. data/test/fixtures/service/response/betha/v1/consulta_lote_rps/success.xml +108 -0
  193. data/test/fixtures/service/response/betha/v1/consulta_nfse/fault.xml +18 -0
  194. data/test/fixtures/service/response/betha/v1/consulta_nfse/nfs_empty.xml +12 -0
  195. data/test/fixtures/service/response/betha/v1/consulta_nfse/success.xml +115 -0
  196. data/test/fixtures/service/response/betha/v1/consulta_nfse_por_rps/fault.xml +18 -0
  197. data/test/fixtures/service/response/betha/v1/consulta_nfse_por_rps/success.xml +103 -0
  198. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/error.xml +13 -0
  199. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/fault.xml +17 -0
  200. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/success.xml +13 -0
  201. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/unprocessed.xml +13 -0
  202. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/unprocessed_by_code_error.xml +17 -0
  203. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/unreceived.xml +13 -0
  204. data/test/fixtures/service/response/betha/v1/consulta_situacao_lote_rps/unreceived_by_code_error.xml +17 -0
  205. data/test/fixtures/service/response/betha/v1/recepcao_lote_rps/error.xml +17 -0
  206. data/test/fixtures/service/response/betha/v1/recepcao_lote_rps/success.xml +14 -0
  207. metadata +160 -94
  208. data/lib/br_nfe/destinatario.rb +0 -26
  209. data/lib/br_nfe/helper/have_destinatario.rb +0 -18
  210. data/lib/br_nfe/helper/have_emitente.rb +0 -20
  211. data/lib/br_nfe/helper/have_intermediario.rb +0 -24
  212. data/lib/br_nfe/helper/have_rps.rb +0 -34
  213. data/lib/br_nfe/helper/values_ts/service_v1.rb +0 -317
  214. data/lib/br_nfe/response/service/build_response.rb +0 -463
  215. data/lib/br_nfe/response/service/default.rb +0 -185
  216. data/lib/br_nfe/response/service/paths/base.rb +0 -127
  217. data/lib/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta.rb +0 -22
  218. data/lib/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta.rb +0 -25
  219. data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta.rb +0 -25
  220. data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta.rb +0 -25
  221. data/lib/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta.rb +0 -31
  222. data/lib/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta.rb +0 -36
  223. data/lib/br_nfe/response/service/paths/v1/tc_nfse.rb +0 -271
  224. data/lib/br_nfe/service/betha/v1/cancelamento_nfs.rb +0 -36
  225. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta.rb +0 -23
  226. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta.rb +0 -21
  227. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta.rb +0 -21
  228. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_cancelar_nfse_resposta.rb +0 -22
  229. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_consultar_lote_rps_resposta.rb +0 -25
  230. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_consultar_nfse_resposta.rb +0 -25
  231. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_consultar_nfse_rps_resposta.rb +0 -25
  232. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_consultar_situacao_lote_rps_resposta.rb +0 -31
  233. data/lib/br_nfe/service/simpliss/v1/response_paths/servico_enviar_lote_rps_resposta.rb +0 -36
  234. data/lib/br_nfe/service/thema/v1/response_paths/servico_cancelar_nfse_resposta.rb +0 -17
  235. data/lib/br_nfe/service/thema/v1/response_paths/servico_consultar_nfse_rps_resposta.rb +0 -19
  236. data/test/br_nfe/emitente_test.rb +0 -46
  237. data/test/br_nfe/helper/have_address_test.rb +0 -62
  238. data/test/br_nfe/helper/have_condicao_pagamento_test.rb +0 -71
  239. data/test/br_nfe/helper/have_destinatario_test.rb +0 -64
  240. data/test/br_nfe/helper/have_emitente_test.rb +0 -63
  241. data/test/br_nfe/helper/have_intermediario_test.rb +0 -77
  242. data/test/br_nfe/helper/have_rps_test.rb +0 -59
  243. data/test/br_nfe/response/service/build_response_test.rb +0 -205
  244. data/test/br_nfe/response/service/nota_fiscal_test.rb +0 -41
  245. data/test/br_nfe/response/service/paths/base_test.rb +0 -196
  246. data/test/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta_test.rb +0 -25
  247. data/test/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta_test.rb +0 -30
  248. data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta_test.rb +0 -30
  249. data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta_test.rb +0 -30
  250. data/test/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta_test.rb +0 -30
  251. data/test/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta_test.rb +0 -34
  252. data/test/br_nfe/service/betha/v1/cancelamento_nfs_test.rb +0 -54
  253. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta_test.rb +0 -16
  254. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta_test.rb +0 -16
  255. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta_test.rb +0 -16
  256. data/test/factories/response/service/build_response.rb +0 -5
  257. data/test/factories/response/service/default.rb +0 -10
@@ -0,0 +1,98 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- ***************************************************-->
3
+ <!-- *** Schema específico para assinaturas XML ***-->
4
+ <!-- *** a partir de certificados do padrão (X509) ***-->
5
+ <!-- *** ICP-Brasil - Projeto Nota Fiscal Eletrônica ***-->
6
+ <!-- ***************************************************-->
7
+ <!-- Schema for XML Signatures-->
8
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.1">
9
+ <element name="Signature" type="ds:SignatureType"/>
10
+ <complexType name="SignatureType">
11
+ <sequence>
12
+ <element name="SignedInfo" type="ds:SignedInfoType"/>
13
+ <element name="SignatureValue" type="ds:SignatureValueType"/>
14
+ <element name="KeyInfo" type="ds:KeyInfoType"/>
15
+ </sequence>
16
+ <attribute name="Id" type="ID" use="optional"/>
17
+ </complexType>
18
+ <complexType name="SignatureValueType">
19
+ <simpleContent>
20
+ <extension base="base64Binary">
21
+ <attribute name="Id" type="ID" use="optional"/>
22
+ </extension>
23
+ </simpleContent>
24
+ </complexType>
25
+ <complexType name="SignedInfoType">
26
+ <sequence>
27
+ <element name="CanonicalizationMethod">
28
+ <complexType>
29
+ <attribute name="Algorithm" type="anyURI" use="required" fixed="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
30
+ </complexType>
31
+ </element>
32
+ <element name="SignatureMethod">
33
+ <complexType>
34
+ <attribute name="Algorithm" type="anyURI" use="required" fixed="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
35
+ </complexType>
36
+ </element>
37
+ <element name="Reference" type="ds:ReferenceType"/>
38
+ </sequence>
39
+ <attribute name="Id" type="ID" use="optional"/>
40
+ </complexType>
41
+ <complexType name="ReferenceType">
42
+ <sequence>
43
+ <element name="Transforms" type="ds:TransformsType">
44
+ <!-- Garante a unicidade do atributo -->
45
+ <unique name="unique_Transf_Alg">
46
+ <selector xpath="./*"/>
47
+ <field xpath="@Algorithm"/>
48
+ </unique>
49
+ </element>
50
+ <element name="DigestMethod">
51
+ <complexType>
52
+ <attribute name="Algorithm" type="anyURI" use="required" fixed="http://www.w3.org/2000/09/xmldsig#sha1"/>
53
+ </complexType>
54
+ </element>
55
+ <element name="DigestValue" type="ds:DigestValueType"/>
56
+ </sequence>
57
+ <attribute name="Id" type="ID" use="optional"/>
58
+ <attribute name="URI" use="required">
59
+ <simpleType>
60
+ <restriction base="anyURI">
61
+ <minLength value="2"/>
62
+ </restriction>
63
+ </simpleType>
64
+ </attribute>
65
+ <attribute name="Type" type="anyURI" use="optional"/>
66
+ </complexType>
67
+ <complexType name="TransformsType">
68
+ <sequence>
69
+ <element name="Transform" type="ds:TransformType" minOccurs="2" maxOccurs="2"/>
70
+ </sequence>
71
+ </complexType>
72
+ <complexType name="TransformType">
73
+ <sequence minOccurs="0" maxOccurs="unbounded">
74
+ <element name="XPath" type="string"/>
75
+ </sequence>
76
+ <attribute name="Algorithm" type="ds:TTransformURI" use="required"/>
77
+ </complexType>
78
+ <complexType name="KeyInfoType">
79
+ <sequence>
80
+ <element name="X509Data" type="ds:X509DataType"/>
81
+ </sequence>
82
+ <attribute name="Id" type="ID" use="optional"/>
83
+ </complexType>
84
+ <complexType name="X509DataType">
85
+ <sequence>
86
+ <element name="X509Certificate" type="base64Binary"/>
87
+ </sequence>
88
+ </complexType>
89
+ <simpleType name="DigestValueType">
90
+ <restriction base="base64Binary"/>
91
+ </simpleType>
92
+ <simpleType name="TTransformURI">
93
+ <restriction base="anyURI">
94
+ <enumeration value="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
95
+ <enumeration value="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
96
+ </restriction>
97
+ </simpleType>
98
+ </schema>
@@ -0,0 +1,4 @@
1
+ consStatServ versao="#{xml_version}" xmlns="http://www.portalfiscal.inf.br/nfe"
2
+ tpAmb = value_nf_tp_amb(env)
3
+ cUF = ibge_code_of_issuer_uf
4
+ xServ = 'STATUS'
@@ -0,0 +1,26 @@
1
+ module BrNfe
2
+ module Service
3
+ module Association
4
+ module HaveIntermediario
5
+ def intermediario
6
+ yield(intermediario || new_intermediario) if block_given?
7
+ @intermediario.is_a?(BrNfe.intermediario_service_class) ? @intermediario : nil
8
+ end
9
+
10
+ def intermediario=(value)
11
+ if value.is_a?(BrNfe.intermediario_service_class) || value.nil?
12
+ @intermediario = value
13
+ elsif value.is_a?(Hash)
14
+ intermediario ? intermediario.assign_attributes(value) : new_intermediario(value)
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def new_intermediario(params={})
21
+ @intermediario = BrNfe.intermediario_service_class.new(params)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ module BrNfe
2
+ module Service
3
+ module Association
4
+ module HaveRps
5
+ def rps
6
+ yield rps if block_given?
7
+ @rps.is_a?(BrNfe.rps_class) ? @rps : @rps = BrNfe.rps_class.new
8
+ end
9
+
10
+ def rps=(value)
11
+ if value.is_a?(BrNfe.rps_class) || value.nil?
12
+ @rps = value
13
+ elsif value.is_a?(Hash)
14
+ rps.assign_attributes(value)
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def validate_rps
21
+ if rps.invalid?
22
+ rps.errors.full_messages.map{|msg| errors.add(:rps, msg) }
23
+ end
24
+ end
25
+
26
+ def valida_rps_recepcao
27
+ rps.validar_recepcao_rps = true
28
+ if rps.invalid?
29
+ rps.errors.full_messages.map{|msg| errors.add(:base, "RPS: #{msg}") }
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,7 +1,7 @@
1
1
  module BrNfe
2
2
  module Service
3
3
  class Base < BrNfe::Base
4
- include BrNfe::Helper::ValuesTs::ServiceV1
4
+ include BrNfe::Service::Concerns::ValuesTs::ServiceV1
5
5
 
6
6
  # Alguns orgãos emissores necessitam que seja
7
7
  # passado junto ao XML o Usuário e Senha do acesso do sistema
@@ -10,12 +10,6 @@ module BrNfe
10
10
  attr_accessor :username
11
11
  attr_accessor :password
12
12
 
13
- # Código IBGE da cidade emitente
14
- attr_accessor :ibge_code_of_issuer_city
15
- def ibge_code_of_issuer_city
16
- "#{@ibge_code_of_issuer_city ||= emitente.endereco.codigo_municipio}"
17
- end
18
-
19
13
  # Declaro que o método `render_xml` irá verificar os arquivos também presentes
20
14
  # no diretório especificado
21
15
  #
@@ -43,19 +37,29 @@ module BrNfe
43
37
  end
44
38
 
45
39
  def request
46
- set_response( client_wsdl.call(method_wsdl, xml: soap_xml) )
40
+ @original_response = client_wsdl.call(method_wsdl, xml: soap_xml)
41
+ set_response
47
42
  rescue Savon::SOAPFault => error
48
- return @response = BrNfe::Response::Service::Default.new(status: :soap_error, error_messages: [error.message])
43
+ return @response = response_class.new(status: :soap_error, error_messages: [error.message])
49
44
  rescue Savon::HTTPError => error
50
- return @response = BrNfe::Response::Service::Default.new(status: :http_error, error_messages: [error.message])
45
+ return @response = response_class.new(status: :http_error, error_messages: [error.message])
51
46
  rescue Exception => error
52
- return @response = BrNfe::Response::Service::Default.new(status: :unknown_error, error_messages: [error.message])
47
+ return @response = response_class.new(status: :unknown_error, error_messages: [error.message])
48
+ end
49
+
50
+ private
51
+
52
+ def emitente_class
53
+ BrNfe.emitente_service_class
54
+ end
55
+
56
+ def response_class
57
+ BrNfe::Service::Response::Default
53
58
  end
54
59
 
55
- def set_response(resp)
56
- @original_response = resp
57
- @response = BrNfe::Response::Service::BuildResponse.new(
58
- savon_response: resp, # Rsposta da requisição SOAP
60
+ def set_response
61
+ @response = BrNfe::Service::Response::Build::Base.new(
62
+ savon_response: @original_response, # Rsposta da requisição SOAP
59
63
  keys_root_path: response_root_path, # Caminho inicial da resposta / Chave pai principal
60
64
  nfe_xml_path: nfse_xml_path, # Caminho para encontrar a NF dentro do XML
61
65
  body_xml_path: body_xml_path,
@@ -93,18 +97,18 @@ module BrNfe
93
97
  invoice_cnae_code_path: response_invoice_cnae_code_path,
94
98
  invoice_description_path: response_invoice_description_path,
95
99
  invoice_codigo_municipio_path: response_invoice_codigo_municipio_path,
96
- invoice_total_services_path: response_invoice_total_services_path,
97
- invoice_deductions_path: response_invoice_deductions_path,
100
+ invoice_valor_total_servicos_path: response_invoice_valor_total_servicos_path,
101
+ invoice_deducoes_path: response_invoice_deducoes_path,
98
102
  invoice_valor_pis_path: response_invoice_valor_pis_path,
99
103
  invoice_valor_cofins_path: response_invoice_valor_cofins_path,
100
104
  invoice_valor_inss_path: response_invoice_valor_inss_path,
101
105
  invoice_valor_ir_path: response_invoice_valor_ir_path,
102
106
  invoice_valor_csll_path: response_invoice_valor_csll_path,
103
- invoice_iss_retained_path: response_invoice_iss_retained_path,
107
+ invoice_iss_retido_path: response_invoice_iss_retido_path,
104
108
  invoice_outras_retencoes_path: response_invoice_outras_retencoes_path,
105
109
  invoice_total_iss_path: response_invoice_total_iss_path,
106
- invoice_base_calculation_path: response_invoice_base_calculation_path,
107
- invoice_iss_tax_rate_path: response_invoice_iss_tax_rate_path,
110
+ invoice_base_calculo_path: response_invoice_base_calculo_path,
111
+ invoice_iss_aliquota_path: response_invoice_iss_aliquota_path,
108
112
  invoice_valor_liquido_path: response_invoice_valor_liquido_path,
109
113
  invoice_desconto_condicionado_path: response_invoice_desconto_condicionado_path,
110
114
  invoice_desconto_incondicionado_path: response_invoice_desconto_incondicionado_path,
@@ -0,0 +1,43 @@
1
+ module BrNfe
2
+ module Service
3
+ module Betha
4
+ module V1
5
+ class CancelaNfse < BrNfe::Service::Betha::V1::Gateway
6
+ include BrNfe::Service::Concerns::Rules::CancelamentoNfs
7
+
8
+ def certificado_obrigatorio?
9
+ true
10
+ end
11
+
12
+ def wsdl
13
+ "http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/cancelarNfseV02?wsdl"
14
+ end
15
+
16
+ def method_wsdl
17
+ :cancelar_nfse_envio
18
+ end
19
+
20
+ def xml_builder
21
+ render_xml 'servico_cancelar_nfse_envio'
22
+ end
23
+
24
+ private
25
+
26
+ def set_response
27
+ @response = BrNfe::Service::Response::Build::Cancelamento.new(
28
+ savon_response: @original_response, # Rsposta da requisição SOAP
29
+ keys_root_path: [:cancelar_nfse_envio_response], # Caminho inicial da resposta / Chave pai principal
30
+ body_xml_path: nil,
31
+ xml_encode: response_encoding, # Codificação do xml de resposta
32
+ data_hora_cancelamento_path: [:cancelar_nfse_resposta, :cancelamento, :confirmacao, :inf_confirmacao_cancelamento, :data_hora],
33
+ codigo_cancelamento_path: [:cancelar_nfse_resposta, :cancelamento, :confirmacao, :pedido, :inf_pedido_cancelamento, :codigo_cancelamento],
34
+ numero_nfs_path: [:cancelar_nfse_resposta, :cancelamento, :confirmacao, :pedido, :inf_pedido_cancelamento, :identificacao_nfse, :numero],
35
+ message_errors_path: [:cancelar_nfse_resposta, :lista_mensagem_retorno, :mensagem_retorno]
36
+ ).response
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -3,8 +3,7 @@ module BrNfe
3
3
  module Betha
4
4
  module V1
5
5
  class ConsultaLoteRps < BrNfe::Service::Betha::V1::Gateway
6
- include BrNfe::Service::Betha::V1::ResponsePaths::ServicoConsultarLoteRpsResposta
7
-
6
+
8
7
  attr_accessor :protocolo
9
8
 
10
9
  validates :protocolo, presence: true
@@ -17,13 +16,28 @@ module BrNfe
17
16
  :consultar_lote_rps_envio
18
17
  end
19
18
 
20
- def response_root_path
21
- [:consultar_lote_rps_envio_response]
22
- end
23
-
24
19
  def xml_builder
25
20
  render_xml 'servico_consultar_lote_rps_envio'
26
21
  end
22
+
23
+ private
24
+ def set_response
25
+ @response = BrNfe::Service::Response::Build::ConsultaLoteRps.new(
26
+ savon_response: @original_response, # Rsposta da requisição SOAP
27
+ keys_root_path: [:consultar_lote_rps_envio_response], # Caminho inicial da resposta / Chave pai principal
28
+ body_xml_path: nil,
29
+ xml_encode: response_encoding, # Codificação do xml de resposta
30
+
31
+ #//Envelope/Body/ConsultarLoteRpsEnvioResponse/ConsultarLoteRpsResposta
32
+ nfe_xml_path: '//*/*/*/*',
33
+
34
+ invoices_path: [:consultar_lote_rps_resposta, :lista_nfse, :compl_nfse],
35
+ invoice_url_nf_path: [:nfse, :inf_nfse, :outras_informacoes]
36
+ ).response
37
+ end
38
+ def response_class
39
+ BrNfe::Service::Response::ConsultaLoteRps
40
+ end
27
41
  end
28
42
  end
29
43
  end
@@ -4,8 +4,7 @@ module BrNfe
4
4
  module V1
5
5
  class ConsultaNfsPorRps < BrNfe::Service::Betha::V1::Gateway
6
6
  include BrNfe::Service::Concerns::Rules::ConsultaNfsPorRps
7
- include BrNfe::Service::Betha::V1::ResponsePaths::ServicoConsultarNfseRpsResposta
8
-
7
+
9
8
  def wsdl
10
9
  "http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarNfsePorRps?wsdl"
11
10
  end
@@ -14,13 +13,25 @@ module BrNfe
14
13
  :consultar_nfse_por_rps_envio
15
14
  end
16
15
 
17
- def response_root_path
18
- [:consultar_nfse_rps_envio_response]
19
- end
20
-
21
16
  def xml_builder
22
17
  render_xml 'servico_consultar_nfse_rps_envio'
23
18
  end
19
+ private
20
+
21
+ def set_response
22
+ @response = BrNfe::Service::Response::Build::ConsultaNfsPorRps.new(
23
+ savon_response: @original_response, # Rsposta da requisição SOAP
24
+ keys_root_path: [:consultar_nfse_rps_envio_response], # Caminho inicial da resposta / Chave pai principal
25
+ body_xml_path: nil,
26
+ xml_encode: response_encoding, # Codificação do xml de resposta
27
+ #//Envelope/Body/ConsultarLoteRpsEnvioResponse/ConsultarLoteRpsResposta
28
+ nfe_xml_path: '//*/*/*/*',
29
+ invoice_url_nf_path: [:nfse, :inf_nfse, :outras_informacoes]
30
+ ).response
31
+ end
32
+ def response_class
33
+ BrNfe::Service::Response::ConsultaNfsPorRps
34
+ end
24
35
 
25
36
  end
26
37
  end
@@ -4,7 +4,6 @@ module BrNfe
4
4
  module V1
5
5
  class ConsultaNfse < BrNfe::Service::Betha::V1::Gateway
6
6
  include BrNfe::Service::Concerns::Rules::ConsultaNfse
7
- include BrNfe::Service::Betha::V1::ResponsePaths::ServicoConsultarNfseResposta
8
7
 
9
8
  def wsdl
10
9
  "http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarNfse?wsdl"
@@ -14,14 +13,26 @@ module BrNfe
14
13
  :consultar_nfse_envio
15
14
  end
16
15
 
17
- def response_root_path
18
- [:consultar_nfse_envio_response]
19
- end
20
-
21
16
  def xml_builder
22
17
  render_xml 'servico_consultar_nfse_envio'
23
18
  end
19
+ private
24
20
 
21
+ def set_response
22
+ @response = BrNfe::Service::Response::Build::ConsultaNfse.new(
23
+ savon_response: @original_response, # Rsposta da requisição SOAP
24
+ keys_root_path: [:consultar_nfse_envio_response], # Caminho inicial da resposta / Chave pai principal
25
+ body_xml_path: nil,
26
+ xml_encode: response_encoding, # Codificação do xml de resposta
27
+
28
+ #//Envelope/Body/ConsultarLoteRpsEnvioResponse/ConsultarLoteRpsResposta
29
+ nfe_xml_path: '//*/*/*/*',
30
+ invoice_url_nf_path: [:nfse, :inf_nfse, :outras_informacoes]
31
+ ).response
32
+ end
33
+ def response_class
34
+ BrNfe::Service::Response::ConsultaNfse
35
+ end
25
36
  end
26
37
  end
27
38
  end
@@ -3,8 +3,6 @@ module BrNfe
3
3
  module Betha
4
4
  module V1
5
5
  class ConsultaSituacaoLoteRps < BrNfe::Service::Betha::V1::ConsultaLoteRps
6
- include BrNfe::Service::Response::Paths::V1::ServicoConsultarSituacaoLoteRpsResposta
7
-
8
6
  def wsdl
9
7
  "http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarSituacaoLoteRps?wsdl"
10
8
  end
@@ -13,14 +11,25 @@ module BrNfe
13
11
  :consultar_situacao_lote_rps_envio
14
12
  end
15
13
 
16
- def response_root_path
17
- [:consultar_situacao_lote_rps_envio_response]
18
- end
19
-
20
14
  def xml_builder
21
15
  render_xml 'servico_consultar_situacao_lote_rps_envio'
22
16
  end
23
17
 
18
+ private
19
+
20
+ def response_class
21
+ BrNfe::Service::Response::ConsultaSituacaoLoteRps
22
+ end
23
+
24
+ def set_response
25
+ @response = BrNfe::Service::Response::Build::ConsultaSituacaoLoteRps.new(
26
+ savon_response: @original_response, # Rsposta da requisição SOAP
27
+ keys_root_path: [:consultar_situacao_lote_rps_envio_response],
28
+ body_xml_path: nil,
29
+ xml_encode: response_encoding, # Codificação do xml de resposta
30
+ ).response
31
+ end
32
+
24
33
  end
25
34
  end
26
35
  end
@@ -14,6 +14,10 @@ module BrNfe
14
14
  def namespace_identifier
15
15
  'ns1:'
16
16
  end
17
+
18
+ def xml_current_dir_path
19
+ ["#{BrNfe.root}/lib/br_nfe/service/betha/v1/xml"]+super
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -4,7 +4,6 @@ module BrNfe
4
4
  module V1
5
5
  class RecepcaoLoteRps < BrNfe::Service::Betha::V1::Gateway
6
6
  include BrNfe::Service::Concerns::Rules::RecepcaoLoteRps
7
- include BrNfe::Service::Response::Paths::V1::ServicoEnviarLoteRpsResposta
8
7
 
9
8
  def certificado_obrigatorio?
10
9
  true
@@ -17,10 +16,6 @@ module BrNfe
17
16
  :enviar_lote_rps_envio
18
17
  end
19
18
 
20
- def response_root_path
21
- [:enviar_lote_rps_envio_response]
22
- end
23
-
24
19
  def id_attribute?
25
20
  false
26
21
  end
@@ -28,6 +23,19 @@ module BrNfe
28
23
  def xml_builder
29
24
  render_xml 'servico_enviar_lote_rps_envio'
30
25
  end
26
+ private
27
+ def response_class
28
+ BrNfe::Service::Response::RecepcaoLoteRps
29
+ end
30
+
31
+ def set_response
32
+ @response = BrNfe::Service::Response::Build::RecepcaoLoteRps.new(
33
+ savon_response: @original_response, # Rsposta da requisição SOAP
34
+ keys_root_path: [:enviar_lote_rps_envio_response],
35
+ body_xml_path: nil,
36
+ xml_encode: response_encoding, # Codificação do xml de resposta
37
+ ).response
38
+ end
31
39
  end
32
40
  end
33
41
  end
@@ -0,0 +1,3 @@
1
+ *{tag: "#{namespace_for_tags}Cnpj"} = ts_cnpj(emitente.cnpj)
2
+ - if emitente.inscricao_municipal.present? && self.is_a?(BrNfe::Service::Betha::V1::RecepcaoLoteRps)
3
+ *{tag: "#{namespace_for_tags}InscricaoMunicipal"} = ts_inscricao_municipal(emitente.inscricao_municipal)
@@ -0,0 +1,4 @@
1
+ / Alguns órgãos emissores não aceitam o atributo ID na tag
2
+ - attributes = id_attribute? ? {Id: "#{id_cancelamento}"} : {}
3
+ *{tag: "#{namespace_for_tags}InfPedidoCancelamento"} *attributes
4
+ = render_xml '_tc_inf_pedido_cancelamento'
@@ -11,11 +11,19 @@ module BrNfe
11
11
  attr_accessor :codigo_cancelamento
12
12
  attr_accessor :id_cancelamento
13
13
 
14
+ # Código do município na qual o serviço foi prestado
15
+ attr_accessor :codigo_ibge_municipio_prestacao
16
+
17
+ validates :codigo_ibge_municipio_prestacao, presence: true
14
18
  validates :nfe_number, :codigo_cancelamento, presence: true
15
19
 
16
20
  def id_cancelamento
17
21
  @id_cancelamento ||= Time.now.strftime('%Y%m%d%H%M%S%9N')
18
22
  end
23
+
24
+ def response_class
25
+ BrNfe::Service::Response::Cancelamento
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -6,7 +6,7 @@ module BrNfe
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- include BrNfe::Helper::HaveRps
9
+ include BrNfe::Service::Association::HaveRps
10
10
 
11
11
  validate :validate_rps # metodo definido no module BrNfe::Helper::HaveRps
12
12
  end
@@ -6,8 +6,8 @@ module BrNfe
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- include BrNfe::Helper::HaveDestinatario
10
- include BrNfe::Helper::HaveIntermediario
9
+ include BrNfe::Association::HaveDestinatario
10
+ include BrNfe::Service::Association::HaveIntermediario
11
11
 
12
12
  attr_accessor :nfe_number
13
13
  attr_accessor :start_date
@@ -20,6 +20,9 @@ module BrNfe
20
20
  def end_date
21
21
  value_date(@end_date)
22
22
  end
23
+ def destinatario_class
24
+ BrNfe.destinatario_service_class
25
+ end
23
26
  end
24
27
 
25
28
  end