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,62 @@
1
+ require 'test_helper'
2
+
3
+ class HaveRpsTest < BrNfe::ActiveModelBase
4
+ include BrNfe::Service::Association::HaveRps
5
+ end
6
+ class NewClassRps < BrNfe::Person
7
+ end
8
+
9
+ describe HaveRpsTest do
10
+ subject { HaveRpsTest.new(rps: rps) }
11
+ let(:rps) { BrNfe::Service::Rps.new }
12
+
13
+ it 'Já_inicia_com_um_rps' do
14
+ subject.class.new.rps.must_be_kind_of BrNfe::Service::Rps
15
+ end
16
+
17
+ it 'Mesmo_setando_o_endereço_como_nil_retorna_um_novo_rps' do
18
+ subject.rps = nil
19
+ subject.rps.must_be_kind_of BrNfe::Service::Rps
20
+ subject.rps.class.wont_equal rps
21
+ end
22
+
23
+ it 'deve_manter_o_objeto_rps_se_ja_tiver' do
24
+ subject.rps.must_equal rps
25
+ rps.numero = 'nova-www'
26
+ subject.rps.numero.must_equal 'nova-www'
27
+ end
28
+
29
+ it 'Se_setar_o_rps_com_outra_class_deve_ignorar' do
30
+ subject.rps = 7777
31
+ subject.rps.must_equal rps
32
+ end
33
+
34
+ it 'posso_setar_o_rps_com_um_hash_com_os_parametros_do_endereço' do
35
+ rps.assign_attributes(numero: '123456', serie: 'SN')
36
+ subject.rps = {numero: '99999', serie: 'sss'}
37
+ subject.rps.numero.must_equal '99999'
38
+ subject.rps.serie.must_equal 'sss'
39
+ end
40
+
41
+ it 'posso_setar_o_rps_com_um_bloco' do
42
+ rps.assign_attributes(numero: '123456', serie: 'SN')
43
+ subject.rps do |obj_rps|
44
+ obj_rps.numero = '99999'
45
+ obj_rps.serie = 'sss'
46
+ end
47
+ subject.rps.numero.must_equal '99999'
48
+ subject.rps.serie.must_equal 'sss'
49
+ end
50
+
51
+ it 'posso_mudar_o_objeto_rps' do
52
+ novo_rps = FactoryGirl.build(:br_nfe_rps)
53
+ subject.rps = novo_rps
54
+ subject.rps.must_equal novo_rps
55
+ end
56
+
57
+ it 'posso_modificar_a_class_do_rps' do
58
+ BrNfe.rps_class = NewClassRps
59
+ subject.rps.must_be_kind_of NewClassRps
60
+ BrNfe.rps_class = BrNfe::Service::Rps
61
+ end
62
+ end
@@ -34,18 +34,18 @@ module ResponsePathTest
34
34
  def response_invoice_cnae_code_path; :response_invoice_cnae_code_path end
35
35
  def response_invoice_description_path; :response_invoice_description_path end
36
36
  def response_invoice_codigo_municipio_path; :response_invoice_codigo_municipio_path end
37
- def response_invoice_total_services_path; :response_invoice_total_services_path end
38
- def response_invoice_deductions_path; :response_invoice_deductions_path end
37
+ def response_invoice_valor_total_servicos_path; :response_invoice_valor_total_servicos_path end
38
+ def response_invoice_deducoes_path; :response_invoice_deducoes_path end
39
39
  def response_invoice_valor_pis_path; :response_invoice_valor_pis_path end
40
40
  def response_invoice_valor_cofins_path; :response_invoice_valor_cofins_path end
41
41
  def response_invoice_valor_inss_path; :response_invoice_valor_inss_path end
42
42
  def response_invoice_valor_ir_path; :response_invoice_valor_ir_path end
43
43
  def response_invoice_valor_csll_path; :response_invoice_valor_csll_path end
44
- def response_invoice_iss_retained_path; :response_invoice_iss_retained_path end
44
+ def response_invoice_iss_retido_path; :response_invoice_iss_retido_path end
45
45
  def response_invoice_outras_retencoes_path; :response_invoice_outras_retencoes_path end
46
46
  def response_invoice_total_iss_path; :response_invoice_total_iss_path end
47
- def response_invoice_base_calculation_path; :response_invoice_base_calculation_path end
48
- def response_invoice_iss_tax_rate_path; :response_invoice_iss_tax_rate_path end
47
+ def response_invoice_base_calculo_path; :response_invoice_base_calculo_path end
48
+ def response_invoice_iss_aliquota_path; :response_invoice_iss_aliquota_path end
49
49
  def response_invoice_valor_liquido_path; :response_invoice_valor_liquido_path end
50
50
  def response_invoice_desconto_condicionado_path; :response_invoice_desconto_condicionado_path end
51
51
  def response_invoice_desconto_incondicionado_path; :response_invoice_desconto_incondicionado_path end
@@ -97,8 +97,8 @@ describe BrNfe::Service::Base do
97
97
  subject { FactoryGirl.build(:br_nfe_servico_base) }
98
98
 
99
99
  describe "Included modules" do
100
- it "deve ter o module BrNfe::Helper::ValuesTs::ServiceV1 incluso" do
101
- subject.class.included_modules.must_include(BrNfe::Helper::ValuesTs::ServiceV1)
100
+ it "deve ter o module BrNfe::Service::Concerns::ValuesTs::ServiceV1 incluso" do
101
+ subject.class.included_modules.must_include(BrNfe::Service::Concerns::ValuesTs::ServiceV1)
102
102
  end
103
103
  end
104
104
 
@@ -128,6 +128,26 @@ describe BrNfe::Service::Base do
128
128
  end
129
129
  end
130
130
 
131
+ describe "#emitente" do
132
+ class OtherClassEmitente < BrNfe::ActiveModelBase
133
+ end
134
+ it "deve ter incluso o module HaveEmitente" do
135
+ subject.class.included_modules.must_include BrNfe::Association::HaveEmitente
136
+ end
137
+ it "o método #emitente_class deve ter por padrão a class BrNfe::Service::Emitente" do
138
+ subject.emitente.must_be_kind_of BrNfe::Service::Emitente
139
+ subject.send(:emitente_class).must_equal BrNfe::Service::Emitente
140
+ end
141
+ it "a class do emitente pode ser modificada através da configuração emitente_service_class" do
142
+ BrNfe.emitente_service_class = OtherClassEmitente
143
+ subject.emitente.must_be_kind_of OtherClassEmitente
144
+ subject.send(:emitente_class).must_equal OtherClassEmitente
145
+
146
+ # É necessário voltar a configuração original para não falhar outros testes
147
+ BrNfe.emitente_service_class = BrNfe::Service::Emitente
148
+ end
149
+ end
150
+
131
151
  describe "#soap_xml" do
132
152
  it "deve trazer a tag_xml e a renderização para o soap_env concatenados" do
133
153
  subject.expects(:tag_xml).returns('<?xml?>')
@@ -160,13 +180,14 @@ describe BrNfe::Service::Base do
160
180
 
161
181
  it "deve fazer a requisição para o WS passando a resposta para o metodo set_response" do
162
182
  subject.client_wsdl.expects(:call).with(:operation, xml: soap_xml).returns(:savon_response)
163
- subject.expects(:set_response).with(:savon_response).returns(:result)
183
+ subject.expects(:set_response).returns(:result)
164
184
  subject.request.must_equal :result
185
+ subject.instance_variable_get(:@original_response).must_equal :savon_response
165
186
  end
166
187
 
167
188
  it "Se ocorrer erro Savon::SOAPFault deve ser tratado e setar o status da resposta com :soap_error" do
168
- subject.client_wsdl.expects(:call).with(:operation, xml: soap_xml).returns(:savon_response)
169
- subject.expects(:set_response).with(:savon_response).raises(soap_fault)
189
+ subject.client_wsdl.expects(:call).with(:operation, xml: soap_xml).raises(soap_fault)
190
+ subject.expects(:set_response).never
170
191
 
171
192
  subject.request
172
193
  subject.response.error_messages.must_equal(['Message Error'])
@@ -196,17 +217,7 @@ describe BrNfe::Service::Base do
196
217
  end
197
218
 
198
219
  describe "#set_response" do
199
- let(:build_response) { BrNfe::Response::Service::BuildResponse.new() }
200
- it "Deve setar a variavel @original_response com a resposta original do savon" do
201
- subject.class.send(:include, ResponsePathTest)
202
- BrNfe::Response::Service::BuildResponse.any_instance.stubs(:response).returns(:response)
203
- subject.stubs(:response_root_path).returns(:response_root_path)
204
- subject.stubs(:nfse_xml_path).returns(:nfse_xml_path)
205
- subject.stubs(:body_xml_path).returns(:body_xml_path)
206
-
207
- subject.set_response(:original).must_equal :response
208
- subject.instance_variable_get(:@original_response).must_equal(:original)
209
- end
220
+ let(:build_response) { BrNfe::Service::Response::Build::Base.new() }
210
221
  it "deve instanciar o build_response e retornar a resposta" do
211
222
  build_response
212
223
  subject.class.send(:include, ResponsePathTest)
@@ -214,7 +225,7 @@ describe BrNfe::Service::Base do
214
225
  subject.expects(:nfse_xml_path).returns(:nfse_xml_path)
215
226
  subject.expects(:body_xml_path).returns(:body_xml_path)
216
227
  subject.expects(:response_encoding).returns('ENCODE')
217
- BrNfe::Response::Service::BuildResponse.expects(:new).with({
228
+ BrNfe::Service::Response::Build::Base.expects(:new).with({
218
229
  savon_response: :savon_response,
219
230
  keys_root_path: :response_root_path,
220
231
  nfe_xml_path: :nfse_xml_path,
@@ -253,18 +264,18 @@ describe BrNfe::Service::Base do
253
264
  invoice_cnae_code_path: :response_invoice_cnae_code_path,
254
265
  invoice_description_path: :response_invoice_description_path,
255
266
  invoice_codigo_municipio_path: :response_invoice_codigo_municipio_path,
256
- invoice_total_services_path: :response_invoice_total_services_path,
257
- invoice_deductions_path: :response_invoice_deductions_path,
267
+ invoice_valor_total_servicos_path: :response_invoice_valor_total_servicos_path,
268
+ invoice_deducoes_path: :response_invoice_deducoes_path,
258
269
  invoice_valor_pis_path: :response_invoice_valor_pis_path,
259
270
  invoice_valor_cofins_path: :response_invoice_valor_cofins_path,
260
271
  invoice_valor_inss_path: :response_invoice_valor_inss_path,
261
272
  invoice_valor_ir_path: :response_invoice_valor_ir_path,
262
273
  invoice_valor_csll_path: :response_invoice_valor_csll_path,
263
- invoice_iss_retained_path: :response_invoice_iss_retained_path,
274
+ invoice_iss_retido_path: :response_invoice_iss_retido_path,
264
275
  invoice_outras_retencoes_path: :response_invoice_outras_retencoes_path,
265
276
  invoice_total_iss_path: :response_invoice_total_iss_path,
266
- invoice_base_calculation_path: :response_invoice_base_calculation_path,
267
- invoice_iss_tax_rate_path: :response_invoice_iss_tax_rate_path,
277
+ invoice_base_calculo_path: :response_invoice_base_calculo_path,
278
+ invoice_iss_aliquota_path: :response_invoice_iss_aliquota_path,
268
279
  invoice_valor_liquido_path: :response_invoice_valor_liquido_path,
269
280
  invoice_desconto_condicionado_path: :response_invoice_desconto_condicionado_path,
270
281
  invoice_desconto_incondicionado_path: :response_invoice_desconto_incondicionado_path,
@@ -313,21 +324,10 @@ describe BrNfe::Service::Base do
313
324
  }).returns(build_response)
314
325
  build_response.expects(:response).returns('resposta')
315
326
 
316
- subject.set_response(:savon_response).must_equal 'resposta'
317
- subject.instance_variable_get(:@response).must_equal('resposta')
318
- end
319
- end
327
+ subject.instance_variable_set(:@original_response, :savon_response)
320
328
 
321
- describe "#ibge_code_of_issuer_city" do
322
- it "se não setar um valor deve pegar o valor do codigo IBGE do endereço do emitente" do
323
- subject.emitente.endereco.codigo_municipio = '12345678'
324
- subject.ibge_code_of_issuer_city = nil
325
- subject.ibge_code_of_issuer_city.must_equal '12345678'
326
- end
327
- it "se setar o valor em ibge_code_of_issuer_city não deve pegar do endereço do emitente" do
328
- subject.emitente.endereco.codigo_municipio = '12345678'
329
- subject.ibge_code_of_issuer_city = 78978945
330
- subject.ibge_code_of_issuer_city.must_equal '78978945'
329
+ subject.send(:set_response).must_equal 'resposta'
330
+ subject.instance_variable_get(:@response).must_equal('resposta')
331
331
  end
332
- end
332
+ end
333
333
  end
@@ -0,0 +1,90 @@
1
+ require 'test_helper'
2
+
3
+ describe BrNfe::Service::Betha::V1::CancelaNfse do
4
+ subject { FactoryGirl.build(:servico_betha_cancela_nfse, emitente: emitente) }
5
+ let(:emitente) { FactoryGirl.build(:service_emitente) }
6
+
7
+ describe "superclass" do
8
+ it { subject.class.superclass.must_equal BrNfe::Service::Betha::V1::Gateway }
9
+ end
10
+
11
+ it "deve conter as regras de BrNfe::Service::Concerns::Rules::CancelamentoNfs inclusas" do
12
+ subject.class.included_modules.must_include BrNfe::Service::Concerns::Rules::CancelamentoNfs
13
+ end
14
+
15
+ it "o certificado deve ser obrigatório" do
16
+ subject.certificado_obrigatorio?.must_equal true
17
+ end
18
+
19
+ describe "#wsdl" do
20
+ context "for env production" do
21
+ it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/cancelarNfseV02?wsdl' }
22
+ end
23
+ context "for env test" do
24
+ before do
25
+ subject.env = :test
26
+ end
27
+ it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/cancelarNfseV02?wsdl' }
28
+ end
29
+ end
30
+
31
+ describe "#method_wsdl" do
32
+ it { subject.method_wsdl.must_equal :cancelar_nfse_envio }
33
+ end
34
+
35
+ describe "Validação do XML através do XSD" do
36
+ let(:schemas_dir) { BrNfe.root+'/test/br_nfe/service/betha/v1/xsd' }
37
+
38
+ describe "Validações a partir do arquivo XSD" do
39
+ it "Deve ser válido com 1 RPS com todas as informações preenchidas" do
40
+ Dir.chdir(schemas_dir) do
41
+ schema = Nokogiri::XML::Schema(IO.read('servico_cancelar_nfse_envio_v01.xsd'))
42
+ document = Nokogiri::XML(subject.content_xml)
43
+ errors = schema.validate(document)
44
+ errors.must_be_empty
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#request and set response" do
51
+ before { savon.mock! }
52
+ after { savon.unmock! }
53
+
54
+ it "Quando cancelou a NF com sucesso" do
55
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/cancela_nfse/success.xml')
56
+
57
+ savon.expects(:cancelar_nfse_envio).returns(fixture)
58
+ subject.request
59
+ response = subject.response
60
+
61
+ response.must_be_kind_of BrNfe::Service::Response::Cancelamento
62
+ response.data_hora_cancelamento.must_equal Time.parse('2016-09-21T17:33:45.718-03:00')
63
+ response.codigo_cancelamento.must_equal '2'
64
+ response.numero_nfs.must_equal '3188'
65
+
66
+ response.status.must_equal :success
67
+ response.successful_request?.must_equal true
68
+ end
69
+
70
+ it "Quando a requisição voltar com erro deve setar os erros corretamente" do
71
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/cancela_nfse/fault.xml')
72
+
73
+ savon.expects(:cancelar_nfse_envio).returns(fixture)
74
+ subject.request
75
+ response = subject.response
76
+
77
+ response.data_hora_cancelamento.must_be_nil
78
+
79
+ response.status.must_equal :falied
80
+
81
+ response.error_messages.size.must_equal 1
82
+ response.error_messages[0][:code].must_equal 'E42'
83
+ response.error_messages[0][:message].must_equal 'Código do município da prestação do serviço inválido.'
84
+ response.error_messages[0][:solution].must_equal 'Informe o código do município onde foi prestado o serviço, conforme Tabela de Municípios do IBGE.'
85
+
86
+ response.successful_request?.must_equal true
87
+ end
88
+ end
89
+
90
+ end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  describe BrNfe::Service::Betha::V1::ConsultaLoteRps do
4
4
  subject { FactoryGirl.build(:servico_betha_consulta_lote_rps, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
5
+ let(:emitente) { FactoryGirl.build(:service_emitente) }
6
6
 
7
7
  describe "superclass" do
8
8
  it { subject.class.superclass.must_equal BrNfe::Service::Betha::V1::Gateway }
@@ -24,12 +24,22 @@ describe BrNfe::Service::Betha::V1::ConsultaLoteRps do
24
24
  end
25
25
  end
26
26
 
27
- describe "#method_wsdl" do
28
- it { subject.method_wsdl.must_equal :consultar_lote_rps_envio }
27
+ it "não deve adicionar a tag InscricaoMunicipal no XML" do
28
+ # Se emitir uma NFS com InscricaoMunicipal 1234 e no cadastro da prefeitura
29
+ # a InscricaoMunicipal estiver cadastrada como 123-4, a nota vai emitir porém
30
+ # no momento de consultar da erro dizendo que a inscrição municipal não existe
31
+ # para o municipio.
32
+ subject.emitente.inscricao_municipal = '12345'
33
+ subject.emitente.cpf_cnpj = '12345678901234'
34
+ content_xml = Nori.new.parse(subject.content_xml).deep_transform_keys!{|k| k.to_s.underscore.to_sym}
35
+ prestador = content_xml[:'ns1:consultar_lote_rps_envio'][:prestador]
36
+
37
+ prestador[:cnpj].must_equal '12345678901234'
38
+ prestador[:inscricao_municipal].must_be_nil
29
39
  end
30
40
 
31
- it "#response_root_path" do
32
- subject.response_root_path.must_equal [:consultar_lote_rps_envio_response]
41
+ describe "#method_wsdl" do
42
+ it { subject.method_wsdl.must_equal :consultar_lote_rps_envio }
33
43
  end
34
44
 
35
45
  describe "Validação do XML através do XSD" do
@@ -46,4 +56,94 @@ describe BrNfe::Service::Betha::V1::ConsultaLoteRps do
46
56
  end
47
57
  end
48
58
  end
59
+
60
+ describe "#request and set response" do
61
+ before { savon.mock! }
62
+ after { savon.unmock! }
63
+
64
+ it "Quando a requisição voltar com erro deve setar os erros corretamente" do
65
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/consulta_lote_rps/fault.xml')
66
+
67
+ savon.expects(:consultar_lote_rps_envio).returns(fixture)
68
+ subject.request
69
+ response = subject.response
70
+
71
+ response.must_be_kind_of BrNfe::Service::Response::ConsultaLoteRps
72
+ response.status.must_equal :falied
73
+ response.error_messages.size.must_equal 1
74
+ response.error_messages[0][:code].must_equal 'E10'
75
+ response.error_messages[0][:message].must_equal 'RPS já informado.'
76
+ response.error_messages[0][:solution].must_equal 'Para essa Inscrição Municipal/CNPJ já existe um RPS informado com o mesmo número, série e tipo.'
77
+ response.successful_request?.must_equal true
78
+ end
79
+
80
+ it "Quando encontrar uma nota fiscal com as informações preenchidas" do
81
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/consulta_lote_rps/success.xml')
82
+ savon.expects(:consultar_lote_rps_envio).returns(fixture)
83
+ subject.request
84
+ response = subject.response
85
+
86
+ response.must_be_kind_of BrNfe::Service::Response::ConsultaLoteRps
87
+ response.notas_fiscais.size.must_equal 1
88
+ response.status.must_equal :success
89
+ response.successful_request?.must_equal true
90
+
91
+ nf = response.notas_fiscais[0]
92
+ nf.numero_nf.must_equal '4'
93
+ nf.codigo_verificacao.must_equal 'E6E7686366'
94
+ nf.data_emissao.must_equal DateTime.parse('2016-09-08T10:03:16.850-03:00')
95
+ nf.url_nf.must_equal 'http://e-gov.betha.com.br/e-nota/visualizarnotaeletronica?link=XXXXXXXXXXXXX'
96
+ nf.xml_nf[0..89].must_equal '<ConsultarLoteRpsResposta><ListaNfse><ComplNfse><Nfse><InfNfse><Numero>4</Numero><CodigoVe'
97
+ nf.rps_numero.must_equal '3146'
98
+ nf.rps_serie.must_equal 'SN'
99
+ nf.rps_tipo.must_equal '1'
100
+ nf.rps_situacao.must_be_nil
101
+ nf.rps_substituido_numero.must_be_nil
102
+ nf.rps_substituido_serie.must_be_nil
103
+ nf.rps_substituido_tipo.must_be_nil
104
+ nf.data_emissao_rps.must_equal DateTime.parse('2016-09-08T10:02:00-03:00')
105
+ nf.competencia.must_equal DateTime.parse('2016-09-01T00:00:00-03:00')
106
+ nf.natureza_operacao.must_equal '1'
107
+ nf.regime_especial_tributacao.must_be_nil
108
+ nf.optante_simples_nacional.must_equal '1'
109
+ nf.incentivador_cultural.must_be_nil
110
+ nf.outras_informacoes.must_equal 'http://e-gov.betha.com.br/e-nota/visualizarnotaeletronica?link=XXXXXXXXXXXXX'
111
+ nf.item_lista_servico.must_equal '0107'
112
+ nf.cnae_code.must_equal '6202300'
113
+ nf.description.must_equal '1 TESTE WEBSERVICE: R$ 5,00'
114
+ nf.codigo_municipio.must_equal '4204202'
115
+ nf.valor_total_servicos.must_equal '349'
116
+ nf.iss_retido.must_equal '2'
117
+ nf.total_iss.must_equal '0'
118
+ nf.base_calculo.must_equal '349'
119
+ nf.iss_aliquota.must_equal '2.0000'
120
+ nf.valor_liquido.must_be_nil
121
+ nf.deducoes.must_equal '0'
122
+ nf.valor_pis.must_be_nil
123
+ nf.valor_cofins.must_be_nil
124
+ nf.valor_inss.must_be_nil
125
+ nf.valor_ir.must_be_nil
126
+ nf.valor_csll.must_be_nil
127
+ nf.outras_retencoes.must_be_nil
128
+ nf.desconto_condicionado.must_equal '0'
129
+ nf.desconto_incondicionado.must_equal '0'
130
+ nf.responsavel_retencao.must_be_nil
131
+ nf.numero_processo.must_be_nil
132
+ nf.municipio_incidencia.must_be_nil
133
+ nf.orgao_gerador_municipio.must_equal '4204202'
134
+ nf.orgao_gerador_uf.must_equal 'SC'
135
+ nf.cancelamento_codigo.must_be_nil
136
+ nf.cancelamento_numero_nf.must_be_nil
137
+ nf.cancelamento_cnpj.must_be_nil
138
+ nf.cancelamento_inscricao_municipal.must_be_nil
139
+ nf.cancelamento_municipio.must_be_nil
140
+ nf.cancelamento_sucesso.must_equal false
141
+ nf.cancelamento_data_hora.must_be_nil
142
+ nf.nfe_substituidora.must_be_nil
143
+ nf.codigo_obra.must_be_nil
144
+ nf.codigo_art.must_be_nil
145
+
146
+ nf.destinatario.cpf_cnpj.must_equal '12345678901234'
147
+ end
148
+ end
49
149
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  describe BrNfe::Service::Betha::V1::ConsultaNfsPorRps do
4
4
  subject { FactoryGirl.build(:servico_betha_consulta_nfs_por_rps, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
5
+ let(:emitente) { FactoryGirl.build(:service_emitente) }
6
6
  let(:rps) { subject.rps }
7
7
 
8
8
  describe "superclass" do
@@ -29,10 +29,6 @@ describe BrNfe::Service::Betha::V1::ConsultaNfsPorRps do
29
29
  it { subject.method_wsdl.must_equal :consultar_nfse_por_rps_envio }
30
30
  end
31
31
 
32
- it "#response_root_path" do
33
- subject.response_root_path.must_equal [:consultar_nfse_rps_envio_response]
34
- end
35
-
36
32
  describe "Validação do XML através do XSD" do
37
33
  let(:schemas_dir) { BrNfe.root+'/test/br_nfe/service/betha/v1/xsd' }
38
34
 
@@ -48,4 +44,106 @@ describe BrNfe::Service::Betha::V1::ConsultaNfsPorRps do
48
44
  end
49
45
  end
50
46
 
47
+ it "não deve adicionar a tag InscricaoMunicipal no XML" do
48
+ # Se emitir uma NFS com InscricaoMunicipal 1234 e no cadastro da prefeitura
49
+ # a InscricaoMunicipal estiver cadastrada como 123-4, a nota vai emitir porém
50
+ # no momento de consultar da erro dizendo que a inscrição municipal não existe
51
+ # para o municipio.
52
+ subject.emitente.inscricao_municipal = '12345'
53
+ subject.emitente.cpf_cnpj = '12345678901234'
54
+ content_xml = Nori.new.parse(subject.content_xml).deep_transform_keys!{|k| k.to_s.underscore.to_sym}
55
+ prestador = content_xml[:'ns1:consultar_nfse_rps_envio'][:prestador]
56
+
57
+ prestador[:cnpj].must_equal '12345678901234'
58
+ prestador[:inscricao_municipal].must_be_nil
59
+ end
60
+
61
+ describe "#request and set response" do
62
+ before { savon.mock! }
63
+ after { savon.unmock! }
64
+
65
+ it "Quando a requisição voltar com erro deve setar os erros corretamente" do
66
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/consulta_nfse_por_rps/fault.xml')
67
+
68
+ savon.expects(:consultar_nfse_por_rps_envio).returns(fixture)
69
+ subject.request
70
+ response = subject.response
71
+
72
+ response.status.must_equal :falied
73
+ response.error_messages.size.must_equal 1
74
+ response.error_messages[0][:code].must_equal 'E10'
75
+ response.error_messages[0][:message].must_equal 'Esse RPS não foi enviado para a nossa base de dados.'
76
+ response.error_messages[0][:solution].must_equal 'Envie o RPS para emissão da Nfs-e.'
77
+ response.successful_request?.must_equal true
78
+ end
79
+
80
+ it "Quando encontrar uma nota fiscal com as informações preenchidas" do
81
+ fixture = File.read(BrNfe.root+'/test/fixtures/service/response/betha/v1/consulta_nfse_por_rps/success.xml')
82
+ savon.expects(:consultar_nfse_por_rps_envio).returns(fixture)
83
+ subject.request
84
+ response = subject.response
85
+
86
+ response.notas_fiscais.size.must_equal 1
87
+ response.status.must_equal :success
88
+ response.successful_request?.must_equal true
89
+
90
+ nf = response.notas_fiscais[0]
91
+ nf.numero_nf.must_equal '3186'
92
+ nf.codigo_verificacao.must_equal 'CKT4JFKQT'
93
+ nf.data_emissao.must_equal DateTime.parse('2016-09-08T10:29:13.330-03:00')
94
+ nf.url_nf.must_equal 'http://e-gov.betha.com.br/e-nota/visualizarnotaeletronica?link=45646546'
95
+ nf.xml_nf[0..89].must_equal '<ConsultarNfseRpsResposta><ComplNfse><Nfse><InfNfse><Numero>3186</Numero><CodigoVerificaca'
96
+ nf.rps_numero.must_equal '3148'
97
+ nf.rps_serie.must_equal 'SN'
98
+ nf.rps_tipo.must_equal '1'
99
+ nf.rps_situacao.must_be_nil
100
+ nf.rps_substituido_numero.must_be_nil
101
+ nf.rps_substituido_serie.must_be_nil
102
+ nf.rps_substituido_tipo.must_be_nil
103
+ nf.data_emissao_rps.must_equal DateTime.parse('2016-09-08T10:29:00-03:00')
104
+ nf.competencia.must_equal DateTime.parse('2016-09-01T00:00:00-03:00')
105
+ nf.natureza_operacao.must_equal '1'
106
+ nf.regime_especial_tributacao.must_be_nil
107
+ nf.optante_simples_nacional.must_equal '1'
108
+ nf.incentivador_cultural.must_be_nil
109
+ nf.outras_informacoes.must_equal 'http://e-gov.betha.com.br/e-nota/visualizarnotaeletronica?link=45646546'
110
+ nf.item_lista_servico.must_equal '0107'
111
+ nf.cnae_code.must_equal '6202300'
112
+ nf.description.must_equal 'Descrição: 1 MENSALIDADE WEBSITE: R$ 49,00'
113
+ nf.codigo_municipio.must_equal '4204202'
114
+ nf.valor_total_servicos.must_equal '49'
115
+ nf.iss_retido.must_equal '2'
116
+ nf.total_iss.must_equal '0'
117
+ nf.base_calculo.must_equal '49'
118
+ nf.iss_aliquota.must_equal '2.0000'
119
+ nf.valor_liquido.must_equal '49'
120
+ nf.deducoes.must_equal '0'
121
+ nf.valor_pis.must_be_nil
122
+ nf.valor_cofins.must_be_nil
123
+ nf.valor_inss.must_be_nil
124
+ nf.valor_ir.must_be_nil
125
+ nf.valor_csll.must_be_nil
126
+ nf.outras_retencoes.must_be_nil
127
+ nf.desconto_condicionado.must_equal '0'
128
+ nf.desconto_incondicionado.must_equal '0'
129
+ nf.responsavel_retencao.must_be_nil
130
+ nf.numero_processo.must_be_nil
131
+ nf.municipio_incidencia.must_be_nil
132
+ nf.orgao_gerador_municipio.must_equal '4204202'
133
+ nf.orgao_gerador_uf.must_equal 'SC'
134
+ nf.cancelamento_codigo.must_be_nil
135
+ nf.cancelamento_numero_nf.must_be_nil
136
+ nf.cancelamento_cnpj.must_be_nil
137
+ nf.cancelamento_inscricao_municipal.must_be_nil
138
+ nf.cancelamento_municipio.must_be_nil
139
+ nf.cancelamento_sucesso.must_equal false
140
+ nf.cancelamento_data_hora.must_be_nil
141
+ nf.nfe_substituidora.must_be_nil
142
+ nf.codigo_obra.must_be_nil
143
+ nf.codigo_art.must_be_nil
144
+
145
+ nf.destinatario.cpf_cnpj.must_equal '11111111111111'
146
+ end
147
+ end
148
+
51
149
  end