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
data/lib/br_nfe.rb CHANGED
@@ -12,13 +12,16 @@ require "signer"
12
12
  require "savon"
13
13
  require "slim"
14
14
 
15
- require "br_nfe/helper/have_address"
16
- require "br_nfe/helper/have_rps"
17
- require "br_nfe/helper/have_emitente"
18
- require "br_nfe/helper/have_destinatario"
19
- require "br_nfe/helper/have_intermediario"
20
- require "br_nfe/helper/have_condicao_pagamento"
21
- require "br_nfe/helper/values_ts/service_v1"
15
+ require "br_nfe/association/have_address"
16
+ require "br_nfe/association/have_condicao_pagamento"
17
+ require "br_nfe/association/have_emitente"
18
+ require "br_nfe/association/have_destinatario"
19
+
20
+ require "br_nfe/service/association/have_intermediario"
21
+ require "br_nfe/service/association/have_rps"
22
+
23
+ # Formatação de valores para XML
24
+ require "br_nfe/service/concerns/values_ts/service_v1"
22
25
 
23
26
  # Regras e atributos para as classes
24
27
  require "br_nfe/service/concerns/rules/recepcao_lote_rps"
@@ -26,16 +29,8 @@ require "br_nfe/service/concerns/rules/consulta_nfse"
26
29
  require "br_nfe/service/concerns/rules/consulta_nfs_por_rps"
27
30
  require "br_nfe/service/concerns/rules/cancelamento_nfs"
28
31
 
29
- # Carrega os modules que contém os paths para buildar a resposta das requisições
30
- require 'br_nfe/response/service/paths/base.rb'
31
- require 'br_nfe/response/service/paths/v1/tc_nfse.rb'
32
-
33
- require 'br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta.rb'
34
- require 'br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta.rb'
35
- require 'br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta.rb'
36
- require 'br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta.rb'
37
- require 'br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta.rb'
38
- require 'br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta.rb'
32
+ # Carrega os modules que contém os paths para buildar a nfs
33
+ require 'br_nfe/service/response/paths/v1/tc_nfse.rb'
39
34
 
40
35
  # Copyright (C) 2015 Bruno M. Mergen
41
36
  #
@@ -56,24 +51,42 @@ module BrNfe
56
51
  end
57
52
 
58
53
  extend ActiveSupport::Autoload
54
+ autoload :Constants
59
55
  autoload :ActiveModelBase
60
56
  autoload :Endereco
61
- autoload :Emitente
62
- autoload :Destinatario
57
+ autoload :Person
63
58
  autoload :Base
64
59
  autoload :CondicaoPagamento
65
60
 
66
- module Response
67
- module Service
61
+
62
+ module Service
63
+ extend ActiveSupport::Autoload
64
+ module Response
68
65
  extend ActiveSupport::Autoload
69
66
  autoload :Default
70
67
  autoload :NotaFiscal
71
- autoload :BuildResponse
68
+ autoload :Cancelamento
69
+ autoload :ConsultaLoteRps
70
+ autoload :ConsultaNfsPorRps
71
+ autoload :ConsultaNfse
72
+ autoload :ConsultaSituacaoLoteRps
73
+ autoload :RecepcaoLoteRps
74
+
75
+ module Build
76
+ extend ActiveSupport::Autoload
77
+ autoload :Base
78
+ autoload :InvoiceBuild
79
+ autoload :Cancelamento
80
+ autoload :ConsultaLoteRps
81
+ autoload :ConsultaNfsPorRps
82
+ autoload :ConsultaNfse
83
+ autoload :ConsultaSituacaoLoteRps
84
+ autoload :RecepcaoLoteRps
85
+ end
72
86
  end
73
- end
74
-
75
- module Service
76
- extend ActiveSupport::Autoload
87
+
88
+ autoload :Emitente
89
+ autoload :Destinatario
77
90
  autoload :Intermediario
78
91
  autoload :Item
79
92
  autoload :Rps
@@ -83,29 +96,18 @@ module BrNfe
83
96
  extend ActiveSupport::Autoload
84
97
  autoload :Base
85
98
  module V1
86
- module ResponsePaths
87
- extend ActiveSupport::Autoload
88
- autoload :ServicoConsultarLoteRpsResposta
89
- autoload :ServicoConsultarNfseResposta
90
- autoload :ServicoConsultarNfseRpsResposta
91
- end
92
99
  extend ActiveSupport::Autoload
93
100
  autoload :Gateway
94
101
  autoload :ConsultaLoteRps
95
102
  autoload :ConsultaNfse
96
103
  autoload :ConsultaNfsPorRps
97
- autoload :CancelamentoNfs
104
+ autoload :CancelaNfse
98
105
  autoload :ConsultaSituacaoLoteRps
99
106
  autoload :RecepcaoLoteRps
100
107
  end
101
108
  end
102
109
  module Thema
103
110
  module V1
104
- module ResponsePaths
105
- extend ActiveSupport::Autoload
106
- autoload :ServicoCancelarNfseResposta
107
- autoload :ServicoConsultarNfseRpsResposta
108
- end
109
111
  extend ActiveSupport::Autoload
110
112
  autoload :Base
111
113
  autoload :CancelaNfse
@@ -119,15 +121,6 @@ module BrNfe
119
121
  end
120
122
  module Simpliss
121
123
  module V1
122
- module ResponsePaths
123
- extend ActiveSupport::Autoload
124
- autoload :ServicoCancelarNfseResposta
125
- autoload :ServicoConsultarLoteRpsResposta
126
- autoload :ServicoConsultarNfseRpsResposta
127
- autoload :ServicoConsultarNfseResposta
128
- autoload :ServicoConsultarSituacaoLoteRpsResposta
129
- autoload :ServicoEnviarLoteRpsResposta
130
- end
131
124
  extend ActiveSupport::Autoload
132
125
  autoload :Base
133
126
  autoload :CancelaNfse
@@ -156,8 +149,19 @@ module BrNfe
156
149
  def self.only_number(value)
157
150
  "#{value}".gsub(/[^0-9]/,'')
158
151
  end
152
+ end
159
153
 
160
-
154
+ module Product
155
+ extend ActiveSupport::Autoload
156
+ module Gateway
157
+ extend ActiveSupport::Autoload
158
+ autoload :Base
159
+ autoload :WebServiceSVRS
160
+ end
161
+ autoload :Emitente
162
+ autoload :ValueNf
163
+ autoload :Base
164
+ autoload :ConsultaStatusServico
161
165
  end
162
166
 
163
167
 
@@ -171,14 +175,18 @@ module BrNfe
171
175
  mattr_accessor :endereco_class
172
176
  @@endereco_class = BrNfe::Endereco
173
177
 
174
- mattr_accessor :emitente_class
175
- @@emitente_class = BrNfe::Emitente
178
+ # Define as classes que serão usadas para instanciar o objeto
179
+ # Emitente para as notas de Serviço e Produto
180
+ mattr_accessor :emitente_service_class
181
+ mattr_accessor :emitente_product_class
182
+ @@emitente_service_class = BrNfe::Service::Emitente
183
+ @@emitente_product_class = BrNfe::Product::Emitente
176
184
 
177
- mattr_accessor :destinatario_class
178
- @@destinatario_class = BrNfe::Destinatario
185
+ mattr_accessor :destinatario_service_class
186
+ @@destinatario_service_class = BrNfe::Service::Destinatario
179
187
 
180
- mattr_accessor :intermediario_class
181
- @@intermediario_class = BrNfe::Service::Intermediario
188
+ mattr_accessor :intermediario_service_class
189
+ @@intermediario_service_class = BrNfe::Service::Intermediario
182
190
 
183
191
  mattr_accessor :condicao_pagamento_class
184
192
  @@condicao_pagamento_class = BrNfe::CondicaoPagamento
@@ -189,14 +197,6 @@ module BrNfe
189
197
  mattr_accessor :service_item_class
190
198
  @@service_item_class = BrNfe::Service::Item
191
199
 
192
- # Configurações do Cliente WSDL
193
- mattr_accessor :client_wsdl_ssl_verify_mode
194
- @@client_wsdl_ssl_verify_mode = :none
195
-
196
- mattr_accessor :client_wsdl_ssl_cert_file
197
- mattr_accessor :client_wsdl_ssl_cert_key_file
198
- mattr_accessor :client_wsdl_ssl_cert_key_password
199
-
200
200
  mattr_accessor :client_wsdl_log
201
201
  @@client_wsdl_log = false
202
202
 
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class HaveAddressTest < BrNfe::ActiveModelBase
4
+ include BrNfe::Association::HaveAddress
5
+ end
6
+ class NewClassEndereco < BrNfe::ActiveModelBase
7
+ end
8
+
9
+ describe HaveAddressTest do
10
+ subject { HaveAddressTest.new(endereco: endereco) }
11
+ let(:endereco) { BrNfe::Endereco.new }
12
+
13
+ it 'Já_inicia_com_um_endereco' do
14
+ subject.class.new.endereco.class.must_equal BrNfe::Endereco
15
+ end
16
+
17
+ it 'Mesmo_setando_o_endereço_como_nil_retorna_um_novo_endereco' do
18
+ subject.endereco = nil
19
+ subject.endereco.must_be_kind_of BrNfe::Endereco
20
+ end
21
+
22
+ it 'deve_manter_o_objeto_endereco_se_ja_tiver' do
23
+ subject.endereco.must_equal endereco
24
+ endereco.cep = 'nova-www'
25
+ subject.endereco.cep.must_equal 'nova-www'
26
+ end
27
+
28
+ it 'Se_setar_o_endereco_com_outra_class_deve_ignorar' do
29
+ subject.endereco = 7777
30
+ subject.endereco.must_equal endereco
31
+ end
32
+
33
+ it 'posso_setar_o_endereco_com_um_hash_com_os_parametros_do_endereço' do
34
+ endereco.assign_attributes(cep: '123456', logradouro: :rua_1, uf: :sc)
35
+ subject.endereco = {cep: '99999', logradouro: :rua_2, uf: :rs}
36
+ subject.endereco.cep.must_equal '99999'
37
+ subject.endereco.logradouro.must_equal 'RUA_2'
38
+ subject.endereco.uf.must_equal :rs
39
+ end
40
+
41
+ it 'posso_setar_o_endereco_com_um_bloco' do
42
+ endereco.assign_attributes(cep: '123456', logradouro: :rua_1, uf: :sc)
43
+ subject.endereco do |address|
44
+ address.cep = '99999'
45
+ address.logradouro = :rua_2
46
+ address.uf = :rs
47
+ end
48
+ subject.endereco.cep.must_equal '99999'
49
+ subject.endereco.logradouro.must_equal 'RUA_2'
50
+ subject.endereco.uf.must_equal :rs
51
+ end
52
+
53
+ it 'posso_mudar_o_objeto_endereco' do
54
+ novo_endereco = FactoryGirl.build(:endereco)
55
+ subject.endereco = novo_endereco
56
+ subject.endereco.must_equal novo_endereco
57
+ end
58
+
59
+ it 'posso_modificar_a_class_do_address' do
60
+ BrNfe.endereco_class = NewClassEndereco
61
+ subject.endereco.class.must_equal NewClassEndereco
62
+ BrNfe.endereco_class = BrNfe::Endereco
63
+ end
64
+ end
@@ -0,0 +1,75 @@
1
+ require 'test_helper'
2
+
3
+ class HaveCondicaoPagamentoTest < BrNfe::ActiveModelBase
4
+ include BrNfe::Association::HaveCondicaoPagamento
5
+ end
6
+ class NewClassCondicaoPagamento < BrNfe::ActiveModelBase
7
+ attr_accessor :condicao
8
+ end
9
+
10
+ describe HaveCondicaoPagamentoTest do
11
+ subject { HaveCondicaoPagamentoTest.new(condicao_pagamento: condicao_pagamento) }
12
+ let(:condicao_pagamento) { BrNfe::CondicaoPagamento.new }
13
+
14
+ it 'deve_iniciar_o_condicao_pagamento_com_nil' do
15
+ subject.class.new.condicao_pagamento.must_be_nil
16
+ end
17
+
18
+ it 'se_tiver_condicao_pagamento_posso_setalo_como_nil' do
19
+ subject.condicao_pagamento.wont_be_nil
20
+ subject.condicao_pagamento = nil
21
+ subject.condicao_pagamento.must_be_nil
22
+ end
23
+
24
+ it 'deve_manter_o_objeto_condicao_pagamento_se_ja_tiver' do
25
+ subject.condicao_pagamento.must_equal condicao_pagamento
26
+ condicao_pagamento.condicao = 'nova-www'
27
+ subject.condicao_pagamento.condicao.must_equal 'nova-www'
28
+ end
29
+
30
+ it 'Se_setar_o_condicao_pagamento_com_outra_class_deve_ignorar' do
31
+ subject.condicao_pagamento = 7777
32
+ subject.condicao_pagamento.must_equal condicao_pagamento
33
+ end
34
+
35
+ it 'posso_setar_o_condicao_pagamento_com_um_hash_com_os_parametros_do_condicao_pagamento' do
36
+ condicao_pagamento.assign_attributes(condicao: '123456')
37
+ subject.condicao_pagamento = {condicao: '99999'}
38
+ subject.condicao_pagamento.condicao.must_equal '99999'
39
+ end
40
+
41
+ it 'ao_setar_um_condicao_pagamento_com_um_hash_e_nao_tiver_um_condicao_pagamento_deve_instanciar_um_com_os_parametros' do
42
+ subject.condicao_pagamento = nil
43
+ subject.condicao_pagamento = {condicao: '99999'}
44
+ subject.condicao_pagamento.condicao.must_equal '99999'
45
+ end
46
+
47
+ it 'posso_setar_o_condicao_pagamento_com_um_bloco' do
48
+ condicao_pagamento.assign_attributes(condicao: '123456')
49
+ subject.condicao_pagamento do |address|
50
+ address.condicao = '99999'
51
+ end
52
+ subject.condicao_pagamento.condicao.must_equal '99999'
53
+ end
54
+
55
+ it 'ao_setar_um_condicao_pagamento_com_um_bloco_e_nao_tiver_um_condicao_pagamento_deve_instanciar_um_com_os_parametros' do
56
+ subject.condicao_pagamento = nil
57
+ subject.condicao_pagamento do |address|
58
+ address.condicao = '99999'
59
+ end
60
+ subject.condicao_pagamento.condicao.must_equal '99999'
61
+ end
62
+
63
+ it 'posso_mudar_o_objeto_condicao_pagamento' do
64
+ novo_condicao_pagamento = FactoryGirl.build(:condicao_pagamento)
65
+ subject.condicao_pagamento = novo_condicao_pagamento
66
+ subject.condicao_pagamento.must_equal novo_condicao_pagamento
67
+ end
68
+
69
+ it 'posso_modificar_a_class_do_condicao_pagamento' do
70
+ BrNfe.condicao_pagamento_class = NewClassCondicaoPagamento
71
+ novo_objeto = subject.class.new(condicao_pagamento: {condicao: '123'})
72
+ novo_objeto.condicao_pagamento.class.must_equal NewClassCondicaoPagamento
73
+ BrNfe.condicao_pagamento_class = BrNfe::CondicaoPagamento
74
+ end
75
+ end
@@ -0,0 +1,76 @@
1
+ require 'test_helper'
2
+
3
+ class HaveDestinatarioTest < BrNfe::ActiveModelBase
4
+ include BrNfe::Association::HaveDestinatario
5
+ end
6
+ class NewClassDestinatario < BrNfe::Person
7
+ end
8
+
9
+ describe HaveDestinatarioTest do
10
+ subject { HaveDestinatarioTest.new(destinatario: destinatario) }
11
+ let(:destinatario) { BrNfe::Person.new }
12
+
13
+ before do
14
+ HaveDestinatarioTest.any_instance.stubs(:destinatario_class).returns(BrNfe::Person)
15
+ end
16
+ it 'Já_inicia_com_um_destinatario' do
17
+ subject.class.new.destinatario.class.must_equal BrNfe::Person
18
+ end
19
+
20
+ it 'Mesmo_setando_o_destinatario_como_nil_retorna_um_novo_destinatario' do
21
+ destinatario
22
+ subject.destinatario = nil
23
+ subject.destinatario.class.must_equal BrNfe::Person
24
+ subject.destinatario.wont_equal destinatario
25
+ end
26
+
27
+ it 'deve_manter_o_objeto_destinatario_se_ja_tiver' do
28
+ subject.destinatario.must_equal destinatario
29
+ destinatario.cpf_cnpj = 'nova-www'
30
+ subject.destinatario.cpf_cnpj.must_equal 'nova-www'
31
+ end
32
+
33
+ it 'Se_setar_o_destinatario_com_outra_class_deve_ignorar' do
34
+ subject.destinatario = 7777
35
+ subject.destinatario.must_equal destinatario
36
+ end
37
+
38
+ it 'posso_setar_o_destinatario_com_um_hash_com_os_parametros_do_destinatario' do
39
+ destinatario.assign_attributes(cpf_cnpj: '123456', telefone: '123465', email: 'mail@mail.com')
40
+ subject.destinatario = {cpf_cnpj: '99999', telefone: '654389', email: 'mail2'}
41
+ subject.destinatario.cpf_cnpj.must_equal '99999'
42
+ subject.destinatario.telefone.must_equal '654389'
43
+ subject.destinatario.email.must_equal 'mail2'
44
+ end
45
+
46
+ it 'posso_setar_o_destinatario_com_um_bloco' do
47
+ destinatario.assign_attributes(cpf_cnpj: '123456', telefone: '11111', email: 'mail1')
48
+ subject.destinatario do |address|
49
+ address.cpf_cnpj = '99999'
50
+ address.telefone = '11111'
51
+ address.email = 'mail1'
52
+ end
53
+ subject.destinatario.cpf_cnpj.must_equal '99999'
54
+ subject.destinatario.telefone.must_equal '11111'
55
+ subject.destinatario.email.must_equal 'mail1'
56
+ end
57
+
58
+ it 'posso_mudar_o_objeto_destinatario' do
59
+ novo_destinatario = FactoryGirl.build(:service_destinatario)
60
+ subject.destinatario = novo_destinatario
61
+ subject.destinatario.must_equal novo_destinatario
62
+ end
63
+
64
+ it 'posso_modificar_a_class_do_destinatario através do método destinatario_class' do
65
+ HaveDestinatarioTest.any_instance.stubs(:destinatario_class).returns(NewClassDestinatario)
66
+ novo_objeto = subject.class.new
67
+ novo_objeto.destinatario.class.must_equal NewClassDestinatario
68
+ end
69
+
70
+ it "por padrão a class destinatario_class deve retornar uma exceção" do
71
+ HaveDestinatarioTest.any_instance.unstub(:destinatario_class)
72
+ assert_raises RuntimeError do
73
+ subject.destinatario_class
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,80 @@
1
+ require 'test_helper'
2
+
3
+ class HaveEmitenteTest < BrNfe::ActiveModelBase
4
+ include BrNfe::Association::HaveEmitente
5
+ end
6
+ class NewClassEmitente < BrNfe::Person
7
+ end
8
+
9
+ describe HaveEmitenteTest do
10
+ subject { HaveEmitenteTest.new(emitente: emitente) }
11
+ let(:emitente) { BrNfe::Person.new }
12
+
13
+ before do
14
+ HaveEmitenteTest.any_instance.stubs(:emitente_class).returns(BrNfe::Person)
15
+ end
16
+
17
+ it 'por padrão Já_inicia_com_um_emitente' do
18
+ subject.class.new.emitente.must_be_kind_of BrNfe::Person
19
+ end
20
+
21
+ it 'Mesmo_setando_o_emitente_como_nil_retorna_um_novo_emitente' do
22
+ subject.emitente = nil
23
+ subject.emitente.must_be_kind_of BrNfe::Person
24
+ subject.emitente.wont_equal emitente
25
+ end
26
+
27
+ it 'deve_manter_o_objeto_emitente_se_ja_tiver' do
28
+ subject.emitente.must_equal emitente
29
+ emitente.cnpj = 'nova-www'
30
+ subject.emitente.cnpj.must_equal 'nova-www'
31
+ end
32
+
33
+ it 'Se_setar_o_emitente_com_outra_class_deve_ignorar' do
34
+ subject.emitente = 7777
35
+ subject.emitente.must_equal emitente
36
+ end
37
+
38
+ it 'posso_setar_o_emitente_com_um_hash_com_os_parametros_do_emitente' do
39
+ emitente.assign_attributes(razao_social: 'JOAO', cnpj: '123456', telefone: '123465', email: 'mail@mail.com')
40
+ subject.emitente = {cnpj: '99999', telefone: '654389', email: 'mail2'}
41
+ subject.emitente.cnpj.must_equal '99999'
42
+ subject.emitente.telefone.must_equal '654389'
43
+ subject.emitente.email.must_equal 'mail2'
44
+ subject.emitente.razao_social.must_equal 'JOAO'
45
+ end
46
+
47
+ it 'posso_setar_o_emitente_com_um_bloco' do
48
+ emitente.assign_attributes(razao_social: 'JOAO', cnpj: '123456', telefone: '11111', email: 'mail1')
49
+ subject.emitente do |address|
50
+ address.cnpj = '99999'
51
+ address.telefone = '11111'
52
+ address.email = 'mail1'
53
+ end
54
+ subject.emitente.cnpj.must_equal '99999'
55
+ subject.emitente.telefone.must_equal '11111'
56
+ subject.emitente.email.must_equal 'mail1'
57
+ subject.emitente.razao_social.must_equal 'JOAO'
58
+ end
59
+
60
+ it 'posso_mudar_o_objeto_emitente' do
61
+ subject.emitente.wont_be_nil
62
+ novo_emitente = BrNfe::Person.new
63
+ subject.emitente = novo_emitente
64
+ subject.emitente.must_equal novo_emitente
65
+ end
66
+
67
+ it 'posso_modificar_a_class_do_emitente através do método emitente_class' do
68
+ HaveEmitenteTest.any_instance.stubs(:emitente_class).returns(NewClassEmitente)
69
+ novo_objeto = subject.class.new
70
+ novo_objeto.emitente.class.must_equal NewClassEmitente
71
+ end
72
+
73
+ it "por padrão a class emitente_class deve retornar uma exceção" do
74
+ HaveEmitenteTest.any_instance.unstub(:emitente_class)
75
+ assert_raises RuntimeError do
76
+ subject.emitente_class
77
+ end
78
+ end
79
+
80
+ end