br_nfe 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +16 -0
  5. data/Gemfile.lock +27 -3
  6. data/LICENSE +1 -1
  7. data/README.markdown +10 -12
  8. data/Rakefile +13 -0
  9. data/br_nfe.gemspec +18 -21
  10. data/lib/br_nfe/active_model_base.rb +7 -1
  11. data/lib/br_nfe/base.rb +175 -37
  12. data/lib/br_nfe/endereco.rb +7 -1
  13. data/lib/br_nfe/helper/have_rps.rb +1 -1
  14. data/lib/br_nfe/helper/values_ts/service_v1.rb +313 -0
  15. data/lib/br_nfe/response/service/build_response.rb +286 -0
  16. data/lib/br_nfe/response/service/default.rb +185 -0
  17. data/lib/br_nfe/{servico/response → response/service}/nota_fiscal.rb +11 -10
  18. data/lib/br_nfe/response/service/paths/base.rb +93 -0
  19. data/lib/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta.rb +22 -0
  20. data/lib/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta.rb +25 -0
  21. data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta.rb +25 -0
  22. data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta.rb +25 -0
  23. data/lib/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta.rb +31 -0
  24. data/lib/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta.rb +36 -0
  25. data/lib/br_nfe/response/service/paths/v1/tc_nfse.rb +127 -0
  26. data/lib/br_nfe/service/base.rb +59 -0
  27. data/lib/br_nfe/service/betha/base.rb +8 -0
  28. data/lib/br_nfe/service/betha/v1/cancelamento_nfs.rb +39 -0
  29. data/lib/br_nfe/service/betha/v1/consulta_lote_rps.rb +34 -0
  30. data/lib/br_nfe/service/betha/v1/consulta_nfs_por_rps.rb +32 -0
  31. data/lib/br_nfe/service/betha/v1/consulta_nfse.rb +32 -0
  32. data/lib/br_nfe/service/betha/v1/consulta_situacao_lote_rps.rb +30 -0
  33. data/lib/br_nfe/service/betha/v1/gateway.rb +21 -0
  34. data/lib/br_nfe/service/betha/v1/recepcao_lote_rps.rb +37 -0
  35. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta.rb +19 -0
  36. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta.rb +17 -0
  37. data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta.rb +17 -0
  38. data/lib/br_nfe/service/concerns/rules/cancelamento_nfs.rb +20 -0
  39. data/lib/br_nfe/service/concerns/rules/consulta_nfs_por_rps.rb +18 -0
  40. data/lib/br_nfe/service/concerns/rules/consulta_nfse.rb +29 -0
  41. data/lib/br_nfe/service/concerns/rules/recepcao_lote_rps.rb +50 -0
  42. data/lib/br_nfe/{servico → service}/intermediario.rb +1 -1
  43. data/lib/br_nfe/service/item.rb +70 -0
  44. data/lib/br_nfe/service/rps.rb +231 -0
  45. data/lib/br_nfe/service/sc/florianopolis/base.rb +25 -0
  46. data/lib/br_nfe/service/sc/florianopolis/cancellation.rb +30 -0
  47. data/lib/br_nfe/service/sc/florianopolis/emission_rps.rb +19 -0
  48. data/lib/br_nfe/service/sc/florianopolis/xml/_address.xml.slim +21 -0
  49. data/lib/br_nfe/service/sc/florianopolis/xml/_contact.xml.slim +3 -0
  50. data/lib/br_nfe/service/sc/florianopolis/xml/_service_item.xml.slim +9 -0
  51. data/lib/br_nfe/service/sc/florianopolis/xml/cancellation.xml.slim +6 -0
  52. data/lib/br_nfe/service/sc/florianopolis/xml/inf_requisicao.xml.slim +55 -0
  53. data/lib/br_nfe/service/sc/gaspar/cancela_nfse.rb +13 -0
  54. data/lib/br_nfe/service/sc/gaspar/consulta_lote_rps.rb +13 -0
  55. data/lib/br_nfe/service/sc/gaspar/consulta_nfs_por_rps.rb +13 -0
  56. data/lib/br_nfe/service/sc/gaspar/consulta_nfse.rb +17 -0
  57. data/lib/br_nfe/service/sc/gaspar/consulta_situacao_lote_rps.rb +13 -0
  58. data/lib/br_nfe/service/sc/gaspar/recepcao_lote_rps.rb +13 -0
  59. data/lib/br_nfe/service/sc/gaspar/recepcao_lote_rps_limitado.rb +13 -0
  60. data/lib/br_nfe/service/thema/v1/base.rb +55 -0
  61. data/lib/br_nfe/service/thema/v1/cancela_nfse.rb +48 -0
  62. data/lib/br_nfe/service/thema/v1/consulta_lote_rps.rb +49 -0
  63. data/lib/br_nfe/service/thema/v1/consulta_nfs_por_rps.rb +48 -0
  64. data/lib/br_nfe/service/thema/v1/consulta_nfse.rb +47 -0
  65. data/lib/br_nfe/service/thema/v1/consulta_situacao_lote_rps.rb +46 -0
  66. data/lib/br_nfe/service/thema/v1/recepcao_lote_rps.rb +51 -0
  67. data/lib/br_nfe/service/thema/v1/recepcao_lote_rps_limitado.rb +30 -0
  68. data/lib/br_nfe/service/xml/v1/_tc_contato.xml.slim +7 -0
  69. data/lib/br_nfe/service/xml/v1/_tc_cpf_cnpj.xml.slim +5 -0
  70. data/lib/br_nfe/service/xml/v1/_tc_dados_construcao_civil.xml.slim +2 -0
  71. data/lib/br_nfe/service/xml/v1/_tc_dados_prestador.xml.slim +15 -0
  72. data/lib/br_nfe/service/xml/v1/_tc_dados_servico.xml.slim +14 -0
  73. data/lib/br_nfe/service/xml/v1/_tc_dados_tomador.xml.slim +15 -0
  74. data/lib/br_nfe/service/xml/v1/_tc_endereco.xml.slim +13 -0
  75. data/lib/br_nfe/service/xml/v1/_tc_identificacao_intermediario_servico.xml.slim +7 -0
  76. data/lib/br_nfe/service/xml/v1/_tc_identificacao_nfse.xml.slim +7 -0
  77. data/lib/br_nfe/service/xml/v1/_tc_identificacao_orgao_gerador.xml.slim +8 -0
  78. data/lib/br_nfe/service/xml/v1/_tc_identificacao_prestador.xml.slim +3 -0
  79. data/lib/br_nfe/service/xml/v1/_tc_identificacao_rps.xml.slim +16 -0
  80. data/lib/br_nfe/service/xml/v1/_tc_identificacao_tomador.xml.slim +4 -0
  81. data/lib/br_nfe/service/xml/v1/_tc_inf_pedido_cancelamento.xml.slim +4 -0
  82. data/lib/br_nfe/service/xml/v1/_tc_inf_rps.xml.slim +47 -0
  83. data/lib/br_nfe/service/xml/v1/_tc_lote_rps.xml.slim +9 -0
  84. data/lib/br_nfe/service/xml/v1/_tc_pedido_cancelamento.xml.slim +4 -0
  85. data/lib/br_nfe/service/xml/v1/_tc_rps.xml.slim +8 -0
  86. data/lib/br_nfe/service/xml/v1/_tc_valores.xml.slim +48 -0
  87. data/lib/br_nfe/service/xml/v1/servico_cancelar_nfse_envio.xml.slim +9 -0
  88. data/lib/br_nfe/service/xml/v1/servico_consultar_lote_rps_envio.xml.slim +4 -0
  89. data/lib/br_nfe/service/xml/v1/servico_consultar_nfse_envio.xml.slim +19 -0
  90. data/lib/br_nfe/service/xml/v1/servico_consultar_nfse_rps_envio.xml.slim +5 -0
  91. data/lib/br_nfe/service/xml/v1/servico_consultar_situacao_lote_rps_envio.xml.slim +4 -0
  92. data/lib/br_nfe/service/xml/v1/servico_enviar_lote_rps_envio.xml.slim +9 -0
  93. data/lib/br_nfe/version.rb +2 -2
  94. data/lib/br_nfe/xml/_signed_info_sh1.xml.slim +9 -0
  95. data/lib/br_nfe/xml/signature_sh1.xml.slim +12 -0
  96. data/lib/br_nfe/xml/soap_env.xml.slim +3 -0
  97. data/lib/br_nfe.rb +72 -20
  98. data/test/br_nfe/base_test.rb +257 -108
  99. data/test/br_nfe/helper/have_intermediario_test.rb +2 -2
  100. data/test/br_nfe/helper/have_rps_test.rb +4 -4
  101. data/test/br_nfe/response/service/build_response_test.rb +377 -0
  102. data/test/br_nfe/response/service/default_test.rb +218 -0
  103. data/test/br_nfe/{servico/response → response/service}/nota_fiscal_test.rb +2 -2
  104. data/test/br_nfe/response/service/paths/base_test.rb +199 -0
  105. data/test/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta_test.rb +25 -0
  106. data/test/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta_test.rb +30 -0
  107. data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta_test.rb +30 -0
  108. data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta_test.rb +30 -0
  109. data/test/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta_test.rb +30 -0
  110. data/test/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta_test.rb +34 -0
  111. data/test/br_nfe/response/service/paths/v1/tc_nfse_test.rb +122 -0
  112. data/test/br_nfe/service/base_test.rb +138 -0
  113. data/test/br_nfe/service/betha/base_test.rb +9 -0
  114. data/test/br_nfe/service/betha/v1/cancelamento_nfs_test.rb +60 -0
  115. data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +55 -0
  116. data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +55 -0
  117. data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +53 -0
  118. data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +49 -0
  119. data/test/br_nfe/service/betha/v1/gateway_test.rb +35 -0
  120. data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +84 -0
  121. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta_test.rb +16 -0
  122. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta_test.rb +16 -0
  123. data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta_test.rb +16 -0
  124. data/test/br_nfe/service/betha/v1/xsd/TiposNFe_v01.xsd +583 -0
  125. data/test/br_nfe/service/betha/v1/xsd/nfse_v01.xsd +652 -0
  126. data/test/br_nfe/service/betha/v1/xsd/servico_cancelar_nfse_envio_v01.xsd +17 -0
  127. data/test/br_nfe/service/betha/v1/xsd/servico_consultar_lote_rps_envio_v01.xsd +16 -0
  128. data/test/br_nfe/service/betha/v1/xsd/servico_consultar_nfse_envio_v01.xsd +28 -0
  129. data/test/br_nfe/service/betha/v1/xsd/servico_consultar_nfse_rps_envio_v01.xsd +16 -0
  130. data/test/br_nfe/service/betha/v1/xsd/servico_consultar_situacao_lote_rps_envio_v01.xsd +16 -0
  131. data/test/br_nfe/service/betha/v1/xsd/servico_enviar_lote_rps_envio_v01.xsd +17 -0
  132. data/test/br_nfe/service/betha/v1/xsd/xmldsig-core-schema.xsd +308 -0
  133. data/test/br_nfe/service/betha/v1/xsd/xmldsig-core-schema_v01.xsd +95 -0
  134. data/test/br_nfe/service/concerns/rules/cancelamento_nfs_test.rb +15 -0
  135. data/test/br_nfe/service/concerns/rules/consulta_nfs_por_rps_test.rb +36 -0
  136. data/test/br_nfe/service/concerns/rules/consulta_nfse_test.rb +42 -0
  137. data/test/br_nfe/{servico/base_test.rb → service/concerns/rules/recepcao_lote_rps_test.rb} +12 -4
  138. data/test/br_nfe/{servico → service}/intermediario_test.rb +1 -1
  139. data/test/br_nfe/service/item_test.rb +34 -0
  140. data/test/br_nfe/{servico → service}/rps_test.rb +191 -43
  141. data/test/br_nfe/service/sc/florianopolis/XSD/TiposNFSe_v2.0.xsd +863 -0
  142. data/test/br_nfe/service/sc/florianopolis/XSD/xmldsig-core-schema.xsd +309 -0
  143. data/test/br_nfe/service/sc/florianopolis/base_test.rb +20 -0
  144. data/test/br_nfe/service/sc/florianopolis/cancellation_test.rb +36 -0
  145. data/test/br_nfe/service/sc/florianopolis/emission_rps_test.rb +145 -0
  146. data/test/br_nfe/service/sc/gaspar/cancela_nfse_test.rb +21 -0
  147. data/test/br_nfe/service/sc/gaspar/consulta_nfs_por_rps_test.rb +21 -0
  148. data/test/br_nfe/service/sc/gaspar/consulta_nfse_test.rb +21 -0
  149. data/test/br_nfe/service/sc/gaspar/consulta_situacao_lote_rps_test.rb +21 -0
  150. data/test/br_nfe/service/sc/gaspar/recepcao_lote_rps_limitado_test.rb +22 -0
  151. data/test/br_nfe/service/sc/gaspar/recepcao_lote_rps_test.rb +22 -0
  152. data/test/br_nfe/service/thema/v1/base_test.rb +65 -0
  153. data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +56 -0
  154. data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +47 -0
  155. data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +50 -0
  156. data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +50 -0
  157. data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +47 -0
  158. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +62 -0
  159. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test_limitado.rb +50 -0
  160. data/test/br_nfe/service/thema/v1/xsd/nfse.xsd +656 -0
  161. data/test/br_nfe/service/thema/v1/xsd/xmldsig-core-schema20020212.xsd +318 -0
  162. data/test/br_nfe/service/xsd/v1/nfse.xsd +779 -0
  163. data/test/br_nfe/service/xsd/v1/xmldsig-core-schema20020212.xsd +316 -0
  164. data/test/cert.pfx +0 -0
  165. data/test/factories/base.rb +2 -0
  166. data/test/factories/destinatario.rb +3 -3
  167. data/test/factories/response/service/build_response.rb +5 -0
  168. data/test/factories/response/service/default.rb +10 -0
  169. data/test/factories/{servico/response → response/service}/nota_fiscal.rb +9 -9
  170. data/test/factories/service/base.rb +6 -0
  171. data/test/factories/service/betha/base.rb +4 -0
  172. data/test/factories/service/betha/v1/cancelamento_nfs.rb +9 -0
  173. data/test/factories/{servico → service}/betha/v1/consulta_lote_rps.rb +2 -2
  174. data/test/factories/{servico → service}/betha/v1/consulta_nfs_por_rps.rb +1 -1
  175. data/test/factories/service/betha/v1/consulta_nfse.rb +8 -0
  176. data/test/factories/{servico → service}/betha/v1/consulta_situacao_lote_rps.rb +2 -2
  177. data/test/factories/{servico → service}/betha/v1/gateway.rb +1 -1
  178. data/test/factories/service/betha/v1/recepcao_lote_rps.rb +8 -0
  179. data/test/factories/{servico → service}/intermediario.rb +2 -2
  180. data/test/factories/service/item.rb +12 -0
  181. data/test/factories/service/rps.rb +50 -0
  182. data/test/factories/service/sc/florianopolis/base.rb +5 -0
  183. data/test/factories/service/sc/florianopolis/cancellation.rb +7 -0
  184. data/test/factories/service/sc/florianopolis/emission_rps.rb +7 -0
  185. data/test/factories/service/sc/gaspar/cancela_nfse.rb +9 -0
  186. data/test/factories/service/sc/gaspar/consulta_lote_rps.rb +7 -0
  187. data/test/factories/service/sc/gaspar/consulta_nfs_por_rps.rb +6 -0
  188. data/test/factories/service/sc/gaspar/consulta_nfse.rb +8 -0
  189. data/test/factories/service/sc/gaspar/consulta_situacao_lote_rps.rb +6 -0
  190. data/test/factories/service/sc/gaspar/recepcao_lote_rps.rb +9 -0
  191. data/test/factories/service/sc/gaspar/recepcao_lote_rps_limitado.rb +9 -0
  192. data/test/factories/service/thema/v1/base.rb +7 -0
  193. data/test/factories/service/thema/v1/cancela_nfse.rb +9 -0
  194. data/test/factories/service/thema/v1/consulta_lote_rps.rb +7 -0
  195. data/test/factories/service/thema/v1/consulta_nfs_por_rps.rb +6 -0
  196. data/test/factories/service/thema/v1/consulta_nfse.rb +8 -0
  197. data/test/factories/service/thema/v1/consulta_situacao_lote_rps.rb +6 -0
  198. data/test/factories/service/thema/v1/recepcao_lote_rps.rb +9 -0
  199. data/test/factories/service/thema/v1/recepcao_lote_rps_limitado.rb +8 -0
  200. data/test/test_helper.rb +42 -0
  201. metadata +338 -121
  202. data/lib/br_nfe/servico/base.rb +0 -35
  203. data/lib/br_nfe/servico/betha/base.rb +0 -85
  204. data/lib/br_nfe/servico/betha/build_response.rb +0 -141
  205. data/lib/br_nfe/servico/betha/v1/build_response.rb +0 -121
  206. data/lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb +0 -52
  207. data/lib/br_nfe/servico/betha/v1/consulta_lote_rps.rb +0 -33
  208. data/lib/br_nfe/servico/betha/v1/consulta_nfs_por_rps.rb +0 -37
  209. data/lib/br_nfe/servico/betha/v1/consulta_nfse.rb +0 -51
  210. data/lib/br_nfe/servico/betha/v1/consulta_situacao_lote_rps.rb +0 -18
  211. data/lib/br_nfe/servico/betha/v1/gateway.rb +0 -125
  212. data/lib/br_nfe/servico/betha/v1/recepcao_lote_rps.rb +0 -97
  213. data/lib/br_nfe/servico/betha/v2/build_response.rb +0 -159
  214. data/lib/br_nfe/servico/betha/v2/cancelamento_nfs.rb +0 -30
  215. data/lib/br_nfe/servico/betha/v2/consulta_lote_rps.rb +0 -30
  216. data/lib/br_nfe/servico/betha/v2/consulta_nfse_por_rps.rb +0 -27
  217. data/lib/br_nfe/servico/betha/v2/envio_lote_rps_sincrono.rb +0 -30
  218. data/lib/br_nfe/servico/betha/v2/gateway.rb +0 -230
  219. data/lib/br_nfe/servico/betha/v2/gera_nfse.rb +0 -30
  220. data/lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb +0 -52
  221. data/lib/br_nfe/servico/betha/v2/substituicao_nfse.rb +0 -43
  222. data/lib/br_nfe/servico/response/default.rb +0 -34
  223. data/lib/br_nfe/servico/rps.rb +0 -108
  224. data/test/br_nfe/servico/betha/base_test.rb +0 -135
  225. data/test/br_nfe/servico/betha/v1/build_response_test.rb +0 -557
  226. data/test/br_nfe/servico/betha/v1/cancelamento_nfs_test.rb +0 -72
  227. data/test/br_nfe/servico/betha/v1/consulta_lote_rps_test.rb +0 -46
  228. data/test/br_nfe/servico/betha/v1/consulta_nfs_por_rps_test.rb +0 -68
  229. data/test/br_nfe/servico/betha/v1/consulta_nfse_test.rb +0 -74
  230. data/test/br_nfe/servico/betha/v1/consulta_situacao_lote_rps_test.rb +0 -27
  231. data/test/br_nfe/servico/betha/v1/gateway_test.rb +0 -151
  232. data/test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb +0 -249
  233. data/test/br_nfe/servico/betha/v2/cancelamento_nfs_test.rb +0 -44
  234. data/test/br_nfe/servico/betha/v2/consulta_lote_rps_test.rb +0 -38
  235. data/test/br_nfe/servico/betha/v2/consulta_nfse_por_rps_test.rb +0 -36
  236. data/test/br_nfe/servico/betha/v2/envio_lote_rps_sincrono_test.rb +0 -51
  237. data/test/br_nfe/servico/betha/v2/gateway_test.rb +0 -372
  238. data/test/br_nfe/servico/betha/v2/gera_nfse_test.rb +0 -62
  239. data/test/br_nfe/servico/betha/v2/recepcao_lote_rps_test.rb +0 -108
  240. data/test/br_nfe/servico/betha/v2/substituicao_nfse_test.rb +0 -84
  241. data/test/br_nfe/servico/response/default_test.rb +0 -54
  242. data/test/factories/servico/base.rb +0 -5
  243. data/test/factories/servico/betha/base.rb +0 -5
  244. data/test/factories/servico/betha/v1/build_response.rb +0 -6
  245. data/test/factories/servico/betha/v1/cancelamento_nfs.rb +0 -7
  246. data/test/factories/servico/betha/v1/consulta_nfse.rb +0 -8
  247. data/test/factories/servico/betha/v1/recepcao_lote_rps.rb +0 -6
  248. data/test/factories/servico/betha/v2/cancelamento_nfs.rb +0 -7
  249. data/test/factories/servico/betha/v2/consulta_lote_rps.rb +0 -6
  250. data/test/factories/servico/betha/v2/consulta_nfse_por_rps.rb +0 -6
  251. data/test/factories/servico/betha/v2/envio_lote_rps_sincrono.rb +0 -5
  252. data/test/factories/servico/betha/v2/gateway.rb +0 -5
  253. data/test/factories/servico/betha/v2/gera_nfse.rb +0 -6
  254. data/test/factories/servico/betha/v2/recepcao_lote_rps.rb +0 -5
  255. data/test/factories/servico/betha/v2/substituicao_nfse.rb +0 -8
  256. data/test/factories/servico/response/default.rb +0 -10
  257. data/test/factories/servico/rps.rb +0 -44
@@ -1,72 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::CancelamentoNfs do
4
- subject { FactoryGirl.build(:servico_betha_cancelamento_nfs, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
6
-
7
- describe "superclass" do
8
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
9
- end
10
-
11
- describe "validations" do
12
- it { must validate_presence_of(:numero_nfse) }
13
- it { must validate_presence_of(:codigo_cancelamento) }
14
- context "validações do certificado" do
15
- before { subject.certificate_pkcs12 = nil }
16
- it { must validate_presence_of(:certificate) }
17
- it { must validate_presence_of(:certificate_key) }
18
- end
19
- end
20
-
21
- describe "#wsdl" do
22
- context "for env production" do
23
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/cancelarNfseV02?wsdl' }
24
- end
25
- context "for env test" do
26
- before do
27
- subject.env = :test
28
- end
29
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/cancelarNfseV02?wsdl' }
30
- end
31
- end
32
-
33
- describe "#method_wsdl" do
34
- it { subject.method_wsdl.must_equal :cancelar_nfse }
35
- end
36
-
37
-
38
- describe "#xml_inf_pedido_cancelamento" do
39
- it "estrutura" do
40
- xml = subject.send(:xml_inf_pedido_cancelamento).doc
41
-
42
- xml.xpath('InfPedidoCancelamento/CodigoCancelamento').first.text.must_equal subject.codigo_cancelamento
43
-
44
- xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/Numero').first.text.must_equal subject.numero_nfse
45
-
46
- xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/Cnpj').first.text.must_equal emitente.cnpj
47
- xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
48
- xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/CodigoMunicipio').first.text.must_equal emitente.endereco.codigo_municipio
49
- end
50
- end
51
-
52
-
53
- describe "#xml_builder" do
54
- let(:info_pedido) do
55
- Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
56
- xml.InfPedidoCancelamento 'Valor'
57
- end
58
- end
59
-
60
- it "deve adicionar o valor do xml_inf_pedido_cancelamento e assinar o xml" do
61
- subject.stubs(:xml_inf_pedido_cancelamento).returns(info_pedido)
62
- subject.expects(:assinatura_xml).with(info_pedido.doc.root.to_s).returns("<Signature>Val</Signature>")
63
- xml = subject.xml_builder
64
- xml = Nokogiri::XML xml
65
-
66
- xml.xpath('Pedido/InfPedidoCancelamento').first.text.must_equal 'Valor'
67
- xml.xpath('Pedido/Signature').first.text.must_equal 'Val'
68
-
69
- end
70
- end
71
-
72
- end
@@ -1,46 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::ConsultaLoteRps do
4
- subject { FactoryGirl.build(:servico_betha_consulta_lote_rps, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
6
-
7
- describe "superclass" do
8
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
9
- end
10
-
11
- describe "validations" do
12
- it { must validate_presence_of(:protocolo) }
13
- end
14
-
15
- describe "#wsdl" do
16
- context "for env production" do
17
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/consultarLoteRps?wsdl' }
18
- end
19
- context "for env test" do
20
- before do
21
- subject.env = :test
22
- end
23
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/consultarLoteRps?wsdl' }
24
- end
25
- end
26
-
27
- describe "#method_wsdl" do
28
- it { subject.method_wsdl.must_equal :consultar_lote_rps }
29
- end
30
-
31
-
32
- describe "#xml_builder" do
33
- it "deve adicionar o valor do xml_inf_pedido_cancelamento e assinar o xml" do
34
- subject.protocolo = '6654898765131'
35
-
36
- xml = subject.xml_builder.to_s
37
- xml = Nokogiri::XML xml
38
-
39
- xml.xpath('Temp/Prestador/Cnpj').first.text.must_equal emitente.cnpj
40
- xml.xpath('Temp/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
41
- xml.xpath('Temp/Protocolo').first.text.must_equal '6654898765131'
42
-
43
- end
44
- end
45
-
46
- end
@@ -1,68 +0,0 @@
1
- require 'test_helper'
2
- require 'br_nfe/helper/have_rps'
3
-
4
- describe BrNfe::Servico::Betha::V1::ConsultaNfsPorRps do
5
- subject { FactoryGirl.build(:servico_betha_consulta_nfs_por_rps, emitente: emitente) }
6
- let(:emitente) { FactoryGirl.build(:emitente) }
7
- let(:rps) { subject.rps }
8
-
9
- describe "superclass" do
10
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
11
- end
12
-
13
- describe "#wsdl" do
14
- context "for env production" do
15
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/consultarNfsePorRps?wsdl' }
16
- end
17
- context "for env test" do
18
- before do
19
- subject.env = :test
20
- end
21
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/consultarNfsePorRps?wsdl' }
22
- end
23
- end
24
-
25
- describe "#method_wsdl" do
26
- it { subject.method_wsdl.must_equal :consultar_nfse_por_rps }
27
- end
28
-
29
- describe "rps" do
30
- include BrNfeTest::HelperTest::HaveRpsTest
31
- end
32
-
33
- describe "#xml_builder" do
34
- it "deve adicionar o valor do xml_inf_pedido_cancelamento e assinar o xml" do
35
- xml = subject.xml_builder.to_s
36
- xml = Nokogiri::XML xml
37
-
38
- xml.xpath('Temp/Prestador/Cnpj').first.text.must_equal emitente.cnpj
39
- xml.xpath('Temp/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
40
-
41
- xml.xpath('Temp/IdentificacaoRps/Numero').first.text.must_equal rps.numero.to_s
42
- xml.xpath('Temp/IdentificacaoRps/Serie').first.text.must_equal rps.serie.to_s
43
- xml.xpath('Temp/IdentificacaoRps/Tipo').first.text.must_equal rps.tipo.to_s
44
- end
45
- end
46
-
47
- describe "#set_response" do
48
- let(:hash_response) { {envelope: {body: {consultar_nfse_por_rps_envio_response: 'valor_hash'} } } }
49
- let(:response) { FactoryGirl.build(:response_default) }
50
- let(:build_response) { FactoryGirl.build(:betha_v1_build_response) }
51
-
52
- it "deve instanciar um objeto response pelo build_response" do
53
- res = Object.new
54
- res.stubs(:hash).returns( hash_response )
55
- build_response.stubs(:response).returns(response)
56
-
57
- BrNfe::Servico::Betha::V1::BuildResponse.expects(:new).
58
- with({hash: 'valor_hash', nfe_method: :consultar_nfse_rps}).
59
- returns(build_response)
60
-
61
- subject.instance_variable_get(:@response).must_be_nil
62
-
63
- subject.set_response(res).must_equal response
64
- subject.instance_variable_get(:@response).must_equal response
65
- end
66
- end
67
-
68
- end
@@ -1,74 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::ConsultaNfse do
4
- subject { FactoryGirl.build(:servico_betha_consulta_nfse, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
6
-
7
- describe "superclass" do
8
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
9
- end
10
-
11
- describe "validations" do
12
- it { must validate_presence_of(:data_inicial) }
13
- it { must validate_presence_of(:data_final) }
14
- end
15
-
16
- context "data inicial e final sempre deve retornar uma data na formatação adequada" do
17
- it "data_inicial" do
18
- subject.data_inicial = '12/05/2015'
19
- subject.data_inicial.must_equal '2015-05-12'
20
- end
21
-
22
- it "data_final" do
23
- subject.data_inicial = Date.parse '12/05/2010'
24
- subject.data_inicial.must_equal '2010-05-12'
25
- end
26
- end
27
-
28
- describe "#wsdl" do
29
- context "for env production" do
30
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/consultarNfse?wsdl' }
31
- end
32
- context "for env test" do
33
- before do
34
- subject.env = :test
35
- end
36
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/consultarNfse?wsdl' }
37
- end
38
- end
39
-
40
- describe "#method_wsdl" do
41
- it { subject.method_wsdl.must_equal :consultar_nfse }
42
- end
43
-
44
- describe "#xml_builder" do
45
- before do
46
- subject.assign_attributes(data_inicial: Date.parse('01/09/2015'), data_final: Date.parse('10/09/2015'))
47
- end
48
- it "estrutura com numero da nfse" do
49
- xml = subject.xml_builder.to_s
50
- xml = Nokogiri::XML xml
51
-
52
- xml.xpath('Temp/Prestador/Cnpj').first.text.must_equal emitente.cnpj
53
- xml.xpath('Temp/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
54
-
55
- xml.xpath('Temp/NumeroNfse').first.text.must_equal subject.numero_nfse
56
- xml.xpath('Temp/PeriodoEmissao/DataInicial').first.text.must_equal '2015-09-01'
57
- xml.xpath('Temp/PeriodoEmissao/DataFinal').first.text.must_equal '2015-09-10'
58
- end
59
-
60
- it "estrutura sem numero da nfse" do
61
- subject.numero_nfse = ''
62
-
63
- xml = subject.xml_builder.to_s
64
- xml = Nokogiri::XML xml
65
-
66
- xml.xpath('Temp/Prestador/Cnpj').first.text.must_equal emitente.cnpj
67
- xml.xpath('Temp/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
68
-
69
- xml.xpath('Temp/NumeroNfse').first.must_be_nil
70
- xml.xpath('Temp/PeriodoEmissao/DataInicial').first.text.must_equal '2015-09-01'
71
- xml.xpath('Temp/PeriodoEmissao/DataFinal').first.text.must_equal '2015-09-10'
72
- end
73
- end
74
- end
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::ConsultaSituacaoLoteRps do
4
- subject { FactoryGirl.build(:servico_betha_consulta_situacao_lote_rps, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
6
-
7
- describe "superclass" do
8
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::ConsultaLoteRps }
9
- end
10
-
11
- describe "#wsdl" do
12
- context "for env production" do
13
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/consultarSituacaoLoteRps?wsdl' }
14
- end
15
- context "for env test" do
16
- before do
17
- subject.env = :test
18
- end
19
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/consultarSituacaoLoteRps?wsdl' }
20
- end
21
- end
22
-
23
- describe "#method_wsdl" do
24
- it { subject.method_wsdl.must_equal :consultar_situacao_lote_rps }
25
- end
26
-
27
- end
@@ -1,151 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::Gateway do
4
- subject { FactoryGirl.build(:br_nfe_servico_betha_v1_gateway, emitente: emitente) }
5
- let(:rps) { FactoryGirl.build(:br_nfe_rps, :completo) }
6
- let(:emitente) { FactoryGirl.build(:emitente) }
7
- let(:intermediario) { FactoryGirl.build(:intermediario) }
8
-
9
- describe "inheritance class" do
10
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::Base }
11
- end
12
-
13
- describe "#namespaces" do
14
- it "deve ter um valor" do
15
- subject.namespaces.must_equal({"xmlns:ns1" => "http://www.betha.com.br/e-nota-contribuinte-ws"})
16
- end
17
- end
18
-
19
- describe "#namespace_identifier" do
20
- it "deve ter o valor ns1" do
21
- subject.namespace_identifier.must_equal :ns1
22
- end
23
- end
24
-
25
- describe "#version" do
26
- it { subject.version.must_equal :v1 }
27
- end
28
-
29
- describe "#content_xml" do
30
- it "canonicaliza o xml_builder e remove as tags <Temp>" do
31
- subject.expects(:xml_builder).returns('<?xml version="1.0" encoding="UTF-8"?>'+"\n<Temp>\n\t <AlgumaTag>ValorXXX</AlgumaTag>\n</Temp>")
32
- subject.content_xml.must_equal "<AlgumaTag>ValorXXX</AlgumaTag>"
33
- end
34
- end
35
-
36
- describe "#xml_dados_servico" do
37
- it "deve vir com a estrutura adecuada com todos os valores preenchidos" do
38
- xml = subject.send(:xml_dados_servico, rps).doc
39
-
40
- xml.xpath('Servico/ItemListaServico').first.text.must_equal rps.item_lista_servico
41
- xml.xpath('Servico/CodigoCnae').first.text.must_equal rps.codigo_cnae
42
- xml.xpath('Servico/CodigoTributacaoMunicipio').first.text.must_equal rps.codigo_tributacao_municipio
43
- xml.xpath('Servico/Discriminacao').first.text.must_equal rps.discriminacao
44
- xml.xpath('Servico/CodigoMunicipio').first.text.must_equal rps.codigo_municipio
45
-
46
- xml.xpath('Servico/Valores/ValorServicos').first.text.must_equal rps.valor_servicos.to_f.round(2).to_s
47
- xml.xpath('Servico/Valores/IssRetido').first.text.must_equal '2'
48
- xml.xpath('Servico/Valores/BaseCalculo').first.text.must_equal rps.base_calculo.to_f.round(2).to_s
49
- xml.xpath('Servico/Valores/ValorDeducoes').first.text.must_equal rps.valor_deducoes.to_f.round(2).to_s
50
- xml.xpath('Servico/Valores/ValorPis').first.text.must_equal rps.valor_pis.to_f.round(2).to_s
51
- xml.xpath('Servico/Valores/ValorCofins').first.text.must_equal rps.valor_cofins.to_f.round(2).to_s
52
- xml.xpath('Servico/Valores/ValorInss').first.text.must_equal rps.valor_inss.to_f.round(2).to_s
53
- xml.xpath('Servico/Valores/ValorIr').first.text.must_equal rps.valor_ir.to_f.round(2).to_s
54
- xml.xpath('Servico/Valores/ValorCsll').first.text.must_equal rps.valor_csll.to_f.round(2).to_s
55
- xml.xpath('Servico/Valores/ValorIss').first.text.must_equal rps.valor_iss.to_f.round(2).to_s
56
- xml.xpath('Servico/Valores/OutrasRetencoes').first.text.must_equal rps.outras_retencoes.to_f.round(2).to_s
57
- xml.xpath('Servico/Valores/Aliquota').first.text.must_equal rps.aliquota.to_f.round(2).to_s
58
- end
59
-
60
- it "sem os valores não obrigatórios" do
61
- rps.assign_attributes({valor_deducoes: '', valor_pis: '', valor_cofins: '',
62
- valor_inss: '', valor_ir: '', valor_csll: '', valor_iss: '', outras_retencoes: '',
63
- aliquota: '', codigo_cnae: '', codigo_tributacao_municipio: ''
64
- })
65
-
66
- xml = subject.send(:xml_dados_servico, rps).doc
67
-
68
-
69
- xml.xpath('Servico/CodigoCnae').first.must_be_nil
70
- xml.xpath('Servico/CodigoTributacaoMunicipio').first.must_be_nil
71
- xml.xpath('Servico/Valores/ValorDeducoes').first.must_be_nil
72
- xml.xpath('Servico/Valores/ValorPis').first.must_be_nil
73
- xml.xpath('Servico/Valores/ValorCofins').first.must_be_nil
74
- xml.xpath('Servico/Valores/ValorInss').first.must_be_nil
75
- xml.xpath('Servico/Valores/ValorIr').first.must_be_nil
76
- xml.xpath('Servico/Valores/ValorCsll').first.must_be_nil
77
- xml.xpath('Servico/Valores/ValorIss').first.must_be_nil
78
- xml.xpath('Servico/Valores/OutrasRetencoes').first.must_be_nil
79
- xml.xpath('Servico/Valores/Aliquota').first.must_be_nil
80
- end
81
- end
82
-
83
- context "#xml_prestador" do
84
- it "estrutura com todos os atributos" do
85
- xml = subject.send(:xml_prestador).doc
86
-
87
- xml.xpath('Prestador/Cnpj').first.text.must_equal emitente.cnpj
88
- xml.xpath('Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
89
- end
90
- it "estrutura sem os atributos não obrigatorios" do
91
- emitente.inscricao_municipal = ''
92
- xml = subject.send(:xml_prestador).doc
93
-
94
- xml.xpath('Prestador/InscricaoMunicipal').first.must_be_nil
95
- end
96
- end
97
-
98
- context "#xml_intermediario_servico" do
99
- it "estrutura com todos os atributos" do
100
- xml = subject.send(:xml_intermediario_servico, intermediario).doc
101
- xml.xpath('IntermediarioServico/RazaoSocial').first.text.must_equal intermediario.razao_social
102
- xml.xpath('IntermediarioServico/CpfCnpj/Cnpj').first.text.must_equal BrNfe::Helper::CpfCnpj.new(intermediario.cpf_cnpj).sem_formatacao
103
- xml.xpath('IntermediarioServico/InscricaoMunicipal').first.text.must_equal intermediario.inscricao_municipal
104
- end
105
- it "estrutura sem os atributos não obrigatorios" do
106
- intermediario.assign_attributes({cpf_cnpj: '132.456.789-01', inscricao_municipal: ''})
107
- xml = subject.send(:xml_intermediario_servico, intermediario).doc
108
-
109
- xml.xpath('IntermediarioServico/CpfCnpj/Cpf').first.text.must_equal BrNfe::Helper::CpfCnpj.new(intermediario.cpf_cnpj).sem_formatacao
110
- xml.xpath('IntermediarioServico/InscricaoMunicipal').first.must_be_nil
111
- end
112
- it "se não tiver intermediario não monta o xml" do
113
- xml = subject.send(:xml_intermediario_servico, nil).doc
114
- xml.root.to_s.must_equal ''
115
- end
116
- end
117
-
118
- describe "#xml_condicao_pagamento" do
119
- it "estrutura a prazo" do
120
- xml = subject.send(:xml_condicao_pagamento, rps).doc
121
-
122
- xml.xpath('CondicaoPagamento/Condicao').first.text.must_equal rps.condicao_pagamento.condicao
123
- xml.xpath('CondicaoPagamento/QtdParcela').first.text.must_equal '2'
124
-
125
- xml.xpath('CondicaoPagamento/Parcelas/Parcela').first.text.must_equal '1'
126
- xml.xpath('CondicaoPagamento/Parcelas/DataVencimento').first.text.must_equal '15/10/2015'
127
- xml.xpath('CondicaoPagamento/Parcelas/Valor').first.text.must_equal '10.0'
128
-
129
- xml.xpath('CondicaoPagamento/Parcelas/Parcela').last.text.must_equal '2'
130
- xml.xpath('CondicaoPagamento/Parcelas/DataVencimento').last.text.must_equal '15/11/2015'
131
- xml.xpath('CondicaoPagamento/Parcelas/Valor').last.text.must_equal '20.0'
132
- end
133
-
134
- it "estrutura a vista" do
135
- rps.condicao_pagamento.assign_attributes(condicao: 'A_VISTA', parcelas: [])
136
- xml = subject.send(:xml_condicao_pagamento, rps).doc
137
-
138
- xml.xpath('CondicaoPagamento/Condicao').first.text.must_equal 'A_VISTA'
139
- xml.xpath('CondicaoPagamento/QtdParcela').first.must_be_nil
140
-
141
- xml.xpath('CondicaoPagamento/Parcelas').first.must_be_nil
142
- end
143
-
144
- it "quando não tem condicao_pagamento" do
145
- rps.condicao_pagamento = nil
146
- xml = subject.send(:xml_condicao_pagamento, rps).doc
147
- xml.root.to_s.must_equal ''
148
- end
149
- end
150
-
151
- end
@@ -1,249 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe BrNfe::Servico::Betha::V1::RecepcaoLoteRps do
4
- subject { FactoryGirl.build(:br_nfe_servico_betha_recepcao_lote_rps, emitente: emitente) }
5
- let(:emitente) { FactoryGirl.build(:emitente) }
6
- let(:rps_1) { FactoryGirl.build(:br_nfe_rps, valor_pis: '', valor_cofins: nil, valor_inss: nil, valor_ir: nil, valor_csll: nil) }
7
- let(:rps_2) { FactoryGirl.build(:br_nfe_rps, :completo) }
8
-
9
- describe "superclass" do
10
- it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
11
- end
12
-
13
- describe "validations" do
14
- it { must validate_presence_of(:numero_lote_rps) }
15
- context "validações do certificado" do
16
- before { subject.certificate_pkcs12 = nil }
17
- it { must validate_presence_of(:certificate) }
18
- it { must validate_presence_of(:certificate_key) }
19
- end
20
-
21
- it "deve chamar o metodo validar_lote_rps" do
22
- subject.expects(:validar_lote_rps)
23
- subject.valid?
24
- end
25
- end
26
-
27
- describe "#wsdl" do
28
- context "for env production" do
29
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/recepcionarLoteRps?wsdl' }
30
- end
31
- context "for env test" do
32
- before do
33
- subject.env = :test
34
- end
35
- it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/recepcionarLoteRps?wsdl' }
36
- end
37
- end
38
-
39
- describe "#method_wsdl" do
40
- it { subject.method_wsdl.must_equal :enviar_lote_rps }
41
- end
42
-
43
- describe "#xml_inf_rps" do
44
- it "estrutura com informações do rps parcialmente preenchidas" do
45
- xml = subject.xml_inf_rps(rps_1).doc
46
-
47
- xml.xpath('InfRps').first.attr("Id").must_equal "rps#{rps_1.numero}"
48
- xml.xpath('InfRps/IdentificacaoRps/Numero').first.text.must_equal rps_1.numero.to_s
49
- xml.xpath('InfRps/IdentificacaoRps/Serie').first.text.must_equal rps_1.serie
50
- xml.xpath('InfRps/IdentificacaoRps/Tipo').first.text.must_equal rps_1.tipo
51
-
52
- xml.xpath('InfRps/RpsSubstituido/Numero').first.must_be_nil
53
- xml.xpath('InfRps/RpsSubstituido/Serie').first.must_be_nil
54
- xml.xpath('InfRps/RpsSubstituido/Tipo').first.must_be_nil
55
-
56
- xml.xpath('InfRps/DataEmissao').first.text.must_equal rps_1.data_emissao.to_s(:br_nfe)
57
- xml.xpath('InfRps/NaturezaOperacao').first.text.must_equal emitente.natureza_operacao
58
- xml.xpath('InfRps/RegimeEspecialTributacao').first.text.must_equal emitente.regime_especial_tributacao
59
- xml.xpath('InfRps/OptanteSimplesNacional').first.text.must_equal emitente.optante_simples_nacional
60
- xml.xpath('InfRps/IncentivadorCultural').first.text.must_equal emitente.incentivo_fiscal
61
- xml.xpath('InfRps/Status').first.text.must_equal rps_1.status
62
-
63
- # Serviço
64
- xml.xpath('InfRps/Servico/ItemListaServico').first.text.must_equal rps_1.item_lista_servico
65
- xml.xpath('InfRps/Servico/CodigoCnae').first.text.must_equal rps_1.codigo_cnae
66
- xml.xpath('InfRps/Servico/CodigoTributacaoMunicipio').first.must_be_nil
67
- xml.xpath('InfRps/Servico/Discriminacao').first.text.must_equal rps_1.discriminacao
68
- xml.xpath('InfRps/Servico/CodigoMunicipio').first.text.must_equal rps_1.codigo_municipio
69
- # Valores dos serviços
70
- xml.xpath('InfRps/Servico/Valores/ValorServicos').first.text.must_equal rps_1.valor_servicos.to_f.round(2).to_s
71
- xml.xpath('InfRps/Servico/Valores/IssRetido').first.text.must_equal '2'
72
- xml.xpath('InfRps/Servico/Valores/BaseCalculo').first.text.must_equal rps_1.base_calculo.to_f.round(2).to_s
73
- xml.xpath('InfRps/Servico/Valores/ValorDeducoes').first.text.must_equal rps_1.valor_deducoes.to_f.round(2).to_s
74
- xml.xpath('InfRps/Servico/Valores/ValorPis').first.must_be_nil
75
- xml.xpath('InfRps/Servico/Valores/ValorCofins').first.must_be_nil
76
- xml.xpath('InfRps/Servico/Valores/ValorInss').first.must_be_nil
77
- xml.xpath('InfRps/Servico/Valores/ValorIr').first.must_be_nil
78
- xml.xpath('InfRps/Servico/Valores/ValorCsll').first.must_be_nil
79
- xml.xpath('InfRps/Servico/Valores/ValorIss').first.text.must_equal rps_1.valor_iss
80
- xml.xpath('InfRps/Servico/Valores/OutrasRetencoes').first.text.must_equal rps_1.outras_retencoes
81
- xml.xpath('InfRps/Servico/Valores/Aliquota').first.text.must_equal rps_1.aliquota
82
-
83
- # Prestador
84
- xml.xpath('InfRps/Prestador/Cnpj').first.text.must_equal emitente.cnpj
85
- xml.xpath('InfRps/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
86
-
87
- # Tomador
88
- xml.xpath('InfRps/Tomador/RazaoSocial').first.text.must_equal rps_1.destinatario.razao_social
89
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/CpfCnpj/Cpf').first.text.must_equal BrNfe::Helper::CpfCnpj.new(rps_1.destinatario.cpf_cnpj).sem_formatacao
90
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/InscricaoMunicipal').first.text.must_equal rps_1.destinatario.inscricao_municipal
91
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/InscricaoEstadual').first.text.must_equal rps_1.destinatario.inscricao_estadual
92
- xml.xpath('InfRps/Tomador/Endereco/Endereco').first.text.must_equal rps_1.destinatario.endereco.logradouro
93
- xml.xpath('InfRps/Tomador/Endereco/Numero').first.text.must_equal rps_1.destinatario.endereco.numero
94
- xml.xpath('InfRps/Tomador/Endereco/Complemento').first.text.must_equal rps_1.destinatario.endereco.complemento
95
- xml.xpath('InfRps/Tomador/Endereco/Bairro').first.text.must_equal rps_1.destinatario.endereco.bairro
96
- xml.xpath('InfRps/Tomador/Endereco/CodigoMunicipio').first.text.must_equal rps_1.destinatario.endereco.codigo_municipio
97
- xml.xpath('InfRps/Tomador/Endereco/Uf').first.text.must_equal rps_1.destinatario.endereco.uf
98
- xml.xpath('InfRps/Tomador/Endereco/Cep').first.text.must_equal rps_1.destinatario.endereco.cep.gsub(/[^0-9]/,'')
99
- xml.xpath('InfRps/Tomador/Contato/Telefone').first.text.must_equal rps_1.destinatario.telefone
100
- xml.xpath('InfRps/Tomador/Contato/Email').first.text.must_equal rps_1.destinatario.email
101
-
102
- xml.xpath('InfRps/IntermediarioServico').first.must_be_nil
103
- xml.xpath('InfRps/ConstrucaoCivil').first.must_be_nil
104
- xml.xpath('InfRps/OutrasInformacoes').first.must_be_nil
105
- xml.xpath('InfRps/CondicaoPagamento').first.must_be_nil
106
- end
107
- it "estrutura com toas informações do rps preenchidas" do
108
- rps_2.destinatario.cpf_cnpj = '12345678901234'
109
- xml = subject.xml_inf_rps(rps_2).doc
110
-
111
- xml.xpath('InfRps').first.attr("Id").must_equal "rps#{rps_2.numero}"
112
- xml.xpath('InfRps/IdentificacaoRps/Numero').first.text.must_equal rps_2.numero.to_s
113
- xml.xpath('InfRps/IdentificacaoRps/Serie').first.text.must_equal rps_2.serie
114
- xml.xpath('InfRps/IdentificacaoRps/Tipo').first.text.must_equal rps_2.tipo
115
-
116
- xml.xpath('InfRps/RpsSubstituido/Numero').first.text.must_equal rps_2.numero_substituicao
117
- xml.xpath('InfRps/RpsSubstituido/Serie').first.text.must_equal rps_2.serie_substituicao
118
- xml.xpath('InfRps/RpsSubstituido/Tipo').first.text.must_equal rps_2.tipo_substituicao
119
-
120
- xml.xpath('InfRps/DataEmissao').first.text.must_equal rps_2.data_emissao.to_s(:br_nfe)
121
- xml.xpath('InfRps/NaturezaOperacao').first.text.must_equal emitente.natureza_operacao
122
- xml.xpath('InfRps/RegimeEspecialTributacao').first.text.must_equal emitente.regime_especial_tributacao
123
- xml.xpath('InfRps/OptanteSimplesNacional').first.text.must_equal emitente.optante_simples_nacional
124
- xml.xpath('InfRps/IncentivadorCultural').first.text.must_equal emitente.incentivo_fiscal
125
- xml.xpath('InfRps/Status').first.text.must_equal rps_2.status
126
-
127
- # Serviço
128
- xml.xpath('InfRps/Servico/ItemListaServico').first.text.must_equal rps_2.item_lista_servico
129
- xml.xpath('InfRps/Servico/CodigoCnae').first.text.must_equal rps_2.codigo_cnae
130
- xml.xpath('InfRps/Servico/CodigoTributacaoMunicipio').first.text.must_equal rps_2.codigo_tributacao_municipio
131
- xml.xpath('InfRps/Servico/Discriminacao').first.text.must_equal rps_2.discriminacao
132
- xml.xpath('InfRps/Servico/CodigoMunicipio').first.text.must_equal rps_2.codigo_municipio
133
- # Valores dos serviços
134
- xml.xpath('InfRps/Servico/Valores/ValorServicos').first.text.must_equal rps_2.valor_servicos.to_f.round(4).to_s
135
- xml.xpath('InfRps/Servico/Valores/IssRetido').first.text.must_equal '2'
136
- xml.xpath('InfRps/Servico/Valores/BaseCalculo').first.text.must_equal rps_2.base_calculo.to_f.round(4).to_s
137
- xml.xpath('InfRps/Servico/Valores/ValorDeducoes').first.text.must_equal rps_2.valor_deducoes.to_f.round(4).to_s
138
- xml.xpath('InfRps/Servico/Valores/ValorPis').first.text.must_equal rps_2.valor_pis.to_f.round(4).to_s
139
- xml.xpath('InfRps/Servico/Valores/ValorCofins').first.text.must_equal rps_2.valor_cofins.to_f.round(4).to_s
140
- xml.xpath('InfRps/Servico/Valores/ValorInss').first.text.must_equal rps_2.valor_inss.to_f.round(4).to_s
141
- xml.xpath('InfRps/Servico/Valores/ValorIr').first.text.must_equal rps_2.valor_ir.to_f.round(4).to_s
142
- xml.xpath('InfRps/Servico/Valores/ValorCsll').first.text.must_equal rps_2.valor_csll.to_f.round(4).to_s
143
- xml.xpath('InfRps/Servico/Valores/ValorIss').first.text.must_equal rps_2.valor_iss.to_f.round(4).to_s
144
- xml.xpath('InfRps/Servico/Valores/OutrasRetencoes').first.text.must_equal rps_2.outras_retencoes.to_f.round(4).to_s
145
- xml.xpath('InfRps/Servico/Valores/Aliquota').first.text.must_equal rps_2.aliquota.to_f.round(4).to_s
146
-
147
- # Prestador
148
- xml.xpath('InfRps/Prestador/Cnpj').first.text.must_equal emitente.cnpj
149
- xml.xpath('InfRps/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
150
-
151
- # Tomador
152
- xml.xpath('InfRps/Tomador/RazaoSocial').first.text.must_equal rps_2.destinatario.razao_social
153
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/CpfCnpj/Cnpj').first.text.must_equal BrNfe::Helper::CpfCnpj.new(rps_2.destinatario.cpf_cnpj).sem_formatacao
154
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/InscricaoMunicipal').first.text.must_equal rps_2.destinatario.inscricao_municipal
155
- xml.xpath('InfRps/Tomador/IdentificacaoTomador/InscricaoEstadual').first.text.must_equal rps_2.destinatario.inscricao_estadual
156
- xml.xpath('InfRps/Tomador/Endereco/Endereco').first.text.must_equal rps_2.destinatario.endereco.logradouro
157
- xml.xpath('InfRps/Tomador/Endereco/Numero').first.text.must_equal rps_2.destinatario.endereco.numero
158
- xml.xpath('InfRps/Tomador/Endereco/Complemento').first.text.must_equal rps_2.destinatario.endereco.complemento
159
- xml.xpath('InfRps/Tomador/Endereco/Bairro').first.text.must_equal rps_2.destinatario.endereco.bairro
160
- xml.xpath('InfRps/Tomador/Endereco/CodigoMunicipio').first.text.must_equal rps_2.destinatario.endereco.codigo_municipio
161
- xml.xpath('InfRps/Tomador/Endereco/Uf').first.text.must_equal rps_2.destinatario.endereco.uf
162
- xml.xpath('InfRps/Tomador/Endereco/Cep').first.text.must_equal rps_2.destinatario.endereco.cep.gsub(/[^0-9]/,'')
163
- xml.xpath('InfRps/Tomador/Contato/Telefone').first.text.must_equal rps_2.destinatario.telefone
164
- xml.xpath('InfRps/Tomador/Contato/Email').first.text.must_equal rps_2.destinatario.email
165
-
166
- xml.xpath('InfRps/IntermediarioServico/RazaoSocial').first.text.must_equal rps_2.intermediario.razao_social
167
- xml.xpath('InfRps/IntermediarioServico/CpfCnpj/Cnpj').first.text.must_equal BrNfe::Helper::CpfCnpj.new(rps_2.intermediario.cpf_cnpj).sem_formatacao
168
- xml.xpath('InfRps/IntermediarioServico/InscricaoMunicipal').first.text.must_equal rps_2.intermediario.inscricao_municipal
169
-
170
- xml.xpath('InfRps/ConstrucaoCivil/CodigoObra').first.text.must_equal rps_2.codigo_obra
171
- xml.xpath('InfRps/ConstrucaoCivil/Art').first.text.must_equal rps_2.codigo_art
172
-
173
- xml.xpath('InfRps/OutrasInformacoes').first.text.must_equal rps_2.outras_informacoes
174
-
175
- xml.xpath('InfRps/CondicaoPagamento/Condicao').first.text.must_equal rps_2.condicao_pagamento.condicao
176
- xml.xpath('InfRps/CondicaoPagamento/QtdParcela').first.text.must_equal '2'
177
- xml.xpath('InfRps/CondicaoPagamento/Parcelas').count.must_equal 2
178
-
179
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/Parcela').first.text.must_equal '1'
180
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/DataVencimento').first.text.must_equal '15/10/2015'
181
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/Valor').first.text.must_equal '10.0'
182
-
183
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/Parcela').last.text.must_equal '2'
184
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/DataVencimento').last.text.must_equal '15/11/2015'
185
- xml.xpath('InfRps/CondicaoPagamento/Parcelas/Valor').last.text.must_equal '20.0'
186
- end
187
- end
188
-
189
- describe "#lote_rps_xml" do
190
- let(:info_rps_1) do
191
- Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
192
- xml.InfRps "RPS1"
193
- end
194
- end
195
- let(:info_rps_2) do
196
- Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
197
- xml.InfRps "RPS2"
198
- end
199
- end
200
-
201
- before do
202
- rps_1.numero = '1'
203
- rps_2.numero = '2'
204
- subject.lote_rps = [rps_1, rps_2]
205
- end
206
-
207
- it "estrutura deve conter as informações assinadas de todos os RPSs do lote" do
208
- subject.expects(:xml_inf_rps).with(rps_1).returns(info_rps_1)
209
- subject.expects(:xml_inf_rps).with(rps_2).returns(info_rps_2)
210
-
211
- subject.expects(:assinatura_xml).with(info_rps_1.doc.root.to_s, '#rps1').returns('<Signature>RPS_1</Signature>')
212
- subject.expects(:assinatura_xml).with(info_rps_2.doc.root.to_s, '#rps2').returns('<Signature>RPS_2</Signature>')
213
-
214
- xml = subject.lote_rps_xml.doc
215
-
216
- xml.xpath('LoteRps/NumeroLote').first.text.must_equal subject.numero_lote_rps
217
- xml.xpath('LoteRps/Cnpj').first.text.must_equal emitente.cnpj
218
- xml.xpath('LoteRps/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
219
- xml.xpath('LoteRps/QuantidadeRps').first.text.must_equal '2'
220
-
221
- xml.xpath('LoteRps/ListaRps/Rps/InfRps').first.text.must_equal 'RPS1'
222
- xml.xpath('LoteRps/ListaRps/Rps/Signature').first.text.must_equal 'RPS_1'
223
-
224
- xml.xpath('LoteRps/ListaRps/Rps/InfRps').last.text.must_equal 'RPS2'
225
- xml.xpath('LoteRps/ListaRps/Rps/Signature').last.text.must_equal 'RPS_2'
226
-
227
- end
228
- end
229
-
230
- describe "#xml_builder" do
231
- let(:xml_lote_rps) do
232
- Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
233
- xml.LoteRps "Valor lote rps"
234
- end
235
- end
236
-
237
- it "estrutura" do
238
- subject.numero_lote_rps = '8899'
239
- subject.expects(:lote_rps_xml).returns(xml_lote_rps)
240
- subject.expects(:assinatura_xml).with(xml_lote_rps.doc.root.to_s, '#lote8899').returns('<Signature>SIGN</Signature>')
241
-
242
- xml = Nokogiri::XML(subject.xml_builder)
243
-
244
- xml.xpath("Temp/LoteRps").first.text.must_equal "Valor lote rps"
245
- xml.xpath("Temp/Signature").first.text.must_equal "SIGN"
246
- end
247
- end
248
-
249
- end