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,56 @@
1
+ #encoding UTF-8
2
+ module BrNfe
3
+ module Service
4
+ module Response
5
+ module Build
6
+ class ConsultaSituacaoLoteRps < BrNfe::Service::Response::Build::Base
7
+ ##############################################################################################################
8
+ ####################### CAMINHOS PARA ENCONTRAR OS VALORES NA RESPOSTA DA REQUISIÇÃO #####################
9
+ # o numero do lote
10
+ attr_accessor :lot_number_path
11
+
12
+ # a situação do lote rps
13
+ attr_accessor :situation_path
14
+
15
+ attr_accessor :situation_key_values
16
+ def situation_key_values
17
+ @situation_key_values.is_a?(Hash) ? @situation_key_values : {
18
+ '1' => :unreceived, # Não Recebido
19
+ '2' => :unprocessed,# Não Processado
20
+ '3' => :error, # Processado com Erro
21
+ '4' => :success, # Processado com Sucesso
22
+ }
23
+ end
24
+
25
+ def default_values
26
+ super.merge({
27
+ message_errors_path: [:consultar_situacao_lote_rps_resposta, :lista_mensagem_retorno, :mensagem_retorno],
28
+ lot_number_path: [:consultar_situacao_lote_rps_resposta, :numero_lote],
29
+ situation_path: [:consultar_situacao_lote_rps_resposta, :situacao],
30
+ })
31
+ end
32
+ ####################### FIM DA DEFINIÇÃO DOS CAMINHOS ############################
33
+ ######################################################################################
34
+ def response
35
+ @response ||= BrNfe::Service::Response::ConsultaSituacaoLoteRps.new({
36
+ error_messages: get_message_for_path(message_errors_path),
37
+ numero_lote: get_lot_number,
38
+ situation: get_situation,
39
+ original_xml: savon_response.xml.force_encoding('UTF-8'),
40
+ })
41
+ end
42
+
43
+ # Método utilizado para pegar a situação do RPS
44
+ #
45
+ # <b>Tipo de retorno: </b> _Symbol_
46
+ #
47
+ def get_situation
48
+ situation_value = find_value_for_keys(savon_body, path_with_root(situation_path))
49
+ situation_value = situation_key_values[situation_value.to_s.strip] if situation_value.present?
50
+ situation_value
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,359 @@
1
+ #encoding UTF-8
2
+ module BrNfe
3
+ module Service
4
+ module Response
5
+ module Build
6
+ class InvoiceBuild < BrNfe::Service::Response::Build::Base
7
+
8
+ # Módule que contém o caminho padrão para pegar os dados da NFS-e.
9
+ # O Padrão dos caminhos obedece a documentação da ABRASF
10
+ include BrNfe::Service::Response::Paths::V1::TcNfse
11
+
12
+ # Caminho para encontrar o XML da NF-e
13
+ attr_accessor :nfe_xml_path
14
+
15
+ ##############################################################################################################
16
+ ####################### CAMINHOS PARA ENCONTRAR OS VALORES NA RESPOSTA DA REQUISIÇÃO #####################
17
+ # Caminho para encontrar
18
+ attr_accessor :invoices_path # o caminho para listar as notas fiscais
19
+ attr_accessor :invoice_numero_nf_path # numero da nota fiscal
20
+ attr_accessor :invoice_codigo_verificacao_path # código de verificação
21
+ attr_accessor :invoice_data_emissao_path # Data de emissão da NF
22
+ attr_accessor :invoice_url_nf_path # URL para visualizar a DANFE (apenas alguns emissores disponibilizam isso)
23
+ attr_accessor :invoice_rps_numero_path # Número do RPS da nota
24
+ attr_accessor :invoice_rps_serie_path # Número da série do RPS da nota
25
+ attr_accessor :invoice_rps_tipo_path # Tipo do RPS
26
+ attr_accessor :invoice_rps_situacao_path # Situação da NF
27
+ attr_accessor :invoice_rps_substituido_numero_path # Número do RPS da nota substituido
28
+ attr_accessor :invoice_rps_substituido_serie_path # Número da série do RPS da nota substituido
29
+ attr_accessor :invoice_rps_substituido_tipo_path # Tipo do RPS substituido
30
+ attr_accessor :invoice_data_emissao_rps_path # Data de emissão do RPS
31
+ attr_accessor :invoice_competencia_path # Competência da nf
32
+ attr_accessor :invoice_natureza_operacao_path # natureza de operação
33
+ attr_accessor :invoice_regime_especial_tributacao_path # Regime especial de tributação
34
+ attr_accessor :invoice_optante_simples_nacional_path # Se é optante do simples
35
+ attr_accessor :invoice_incentivador_cultural_path # Incentivo cultural
36
+ attr_accessor :invoice_outras_informacoes_path # Outras informações da nf
37
+ attr_accessor :invoice_item_lista_servico_path # Código do serviço prestado
38
+ attr_accessor :invoice_cnae_code_path # CNAE utilizado na nf
39
+ attr_accessor :invoice_description_path # Descrição da nf
40
+ attr_accessor :invoice_codigo_municipio_path # Código do municipio prestador do serviço
41
+ attr_accessor :invoice_valor_total_servicos_path # Valor total dos serviços
42
+ attr_accessor :invoice_deducoes_path # Valor das deduções
43
+ attr_accessor :invoice_valor_pis_path # Valor do PIS
44
+ attr_accessor :invoice_valor_cofins_path # Valor do COFINS
45
+ attr_accessor :invoice_valor_inss_path # Valor do INSS
46
+ attr_accessor :invoice_valor_ir_path # Valor do IR
47
+ attr_accessor :invoice_valor_csll_path # Valor da CSLL
48
+ attr_accessor :invoice_iss_retido_path # Se o ISS está retido
49
+ attr_accessor :invoice_outras_retencoes_path # Valor Outras retenções
50
+ attr_accessor :invoice_total_iss_path # Valor total de ISS
51
+ attr_accessor :invoice_base_calculo_path # Valor da base de cálculo
52
+ attr_accessor :invoice_iss_aliquota_path # Percentual do imposto de ISS
53
+ attr_accessor :invoice_valor_liquido_path # Valor liquido da NFS
54
+ attr_accessor :invoice_desconto_condicionado_path # Valor do desconto condicionado
55
+ attr_accessor :invoice_desconto_incondicionado_path # Valor do desconto incondicionado
56
+ attr_accessor :invoice_responsavel_retencao_path # Responsável pela retenção
57
+ attr_accessor :invoice_numero_processo_path # Número do processo da NF
58
+ attr_accessor :invoice_municipio_incidencia_path # Código do municipio em que o serviço foi prestado
59
+ attr_accessor :invoice_orgao_gerador_municipio_path # Órgão gerador municipal da NFS
60
+ attr_accessor :invoice_orgao_gerador_uf_path # Órgão gerador estadual da NFS
61
+ attr_accessor :invoice_cancelamento_codigo_path # Código do cancelamento da NFS
62
+ attr_accessor :invoice_cancelamento_numero_nf_path # Número da NFS cancelada
63
+ attr_accessor :invoice_cancelamento_cnpj_path # CNPJ da NF cancelada
64
+ attr_accessor :invoice_cancelamento_municipio_path # Municipo da nota cancelada
65
+ attr_accessor :invoice_cancelamento_data_hora_path # Data e hora do cancelamento
66
+ attr_accessor :invoice_cancelamento_inscricao_municipal_path # Inscrição municipal da nota cancelada
67
+ attr_accessor :invoice_nfe_substituidora_path # Número da NFS substituidora
68
+ attr_accessor :invoice_codigo_obra_path # Código obra
69
+ attr_accessor :invoice_codigo_art_path # Código art
70
+ attr_accessor :invoice_emitente_cnpj_path # Cnpj do emitente da NFS
71
+ attr_accessor :invoice_emitente_inscricao_municipal_path # Inscricao municipal do emitente da NFS
72
+ attr_accessor :invoice_emitente_razao_social_path # Razao social do emitente da NFS
73
+ attr_accessor :invoice_emitente_nome_fantasia_path # Nome fantasia do emitente da NFS
74
+ attr_accessor :invoice_emitente_telefone_path # Telefone do emitente da NFS
75
+ attr_accessor :invoice_emitente_email_path # Email do emitente da NFS
76
+ attr_accessor :invoice_emitente_endereco_logradouro_path # Logradouro do emitente da NFS
77
+ attr_accessor :invoice_emitente_endereco_numero_path # Numero do emitente da NFS
78
+ attr_accessor :invoice_emitente_endereco_complemento_path # Complemento do emitente da NFS
79
+ attr_accessor :invoice_emitente_endereco_bairro_path # Bairro do emitente da NFS
80
+ attr_accessor :invoice_emitente_endereco_codigo_municipio_path # Codigo_municipio do emitente da NFS
81
+ attr_accessor :invoice_emitente_endereco_uf_path # Uf do emitente da NFS
82
+ attr_accessor :invoice_emitente_endereco_cep_path # Cep do emitente da NFS
83
+ attr_accessor :invoice_destinatario_cpf_path # Cpf do destinatário da NFS
84
+ attr_accessor :invoice_destinatario_cnpj_path # Cnpj do destinatário da NFS
85
+ attr_accessor :invoice_destinatario_inscricao_municipal_path # Inscricao municipal do destinatário da NFS
86
+ attr_accessor :invoice_destinatario_inscricao_estadual_path # Inscricao estadual do destinatário da NFS
87
+ attr_accessor :invoice_destinatario_inscricao_suframa_path # Inscricao suframa do destinatário da NFS
88
+ attr_accessor :invoice_destinatario_razao_social_path # Razao social do destinatário da NFS
89
+ attr_accessor :invoice_destinatario_telefone_path # Telefone do destinatário da NFS
90
+ attr_accessor :invoice_destinatario_email_path # Email do destinatário da NFS
91
+ attr_accessor :invoice_destinatario_endereco_logradouro_path # Logradouro do destinatário da NFS
92
+ attr_accessor :invoice_destinatario_endereco_numero_path # Numero do destinatário da NFS
93
+ attr_accessor :invoice_destinatario_endereco_complemento_path # Complemento do destinatário da NFS
94
+ attr_accessor :invoice_destinatario_endereco_bairro_path # Bairro do destinatário da NFS
95
+ attr_accessor :invoice_destinatario_endereco_codigo_municipio_path # Codigo_municipio do destinatário da NFS
96
+ attr_accessor :invoice_destinatario_endereco_uf_path # Uf do destinatário da NFS
97
+ attr_accessor :invoice_destinatario_endereco_cep_path # Cep do destinatário da NFS
98
+
99
+ ####################### FIM DA DEFINIÇÃO DOS CAMINHOS ############################
100
+ ######################################################################################
101
+
102
+ ######################################################################################
103
+ ############### DEFINIÇÃO DOS VALORES PADRÕES PARA O CAMINHO DA NFSE ###############
104
+ def default_values
105
+ super.merge({
106
+ # invoices_path: response_invoices_path,
107
+ invoice_numero_nf_path: response_invoice_numero_nf_path,
108
+ invoice_codigo_verificacao_path: response_invoice_codigo_verificacao_path,
109
+ invoice_data_emissao_path: response_invoice_data_emissao_path,
110
+ # invoice_url_nf_path: response_invoice_url_nf_path,
111
+ invoice_rps_numero_path: response_invoice_rps_numero_path,
112
+ invoice_rps_serie_path: response_invoice_rps_serie_path,
113
+ invoice_rps_tipo_path: response_invoice_rps_tipo_path,
114
+ # invoice_rps_situacao_path: response_invoice_rps_situacao_path,
115
+ # invoice_rps_substituido_numero_path: response_invoice_rps_substituido_numero_path,
116
+ # invoice_rps_substituido_serie_path: response_invoice_rps_substituido_serie_path,
117
+ # invoice_rps_substituido_tipo_path: response_invoice_rps_substituido_tipo_path,
118
+ invoice_data_emissao_rps_path: response_invoice_data_emissao_rps_path,
119
+ invoice_competencia_path: response_invoice_competencia_path,
120
+ invoice_natureza_operacao_path: response_invoice_natureza_operacao_path,
121
+ invoice_regime_especial_tributacao_path: response_invoice_regime_especial_tributacao_path,
122
+ invoice_optante_simples_nacional_path: response_invoice_optante_simples_nacional_path,
123
+ invoice_incentivador_cultural_path: response_invoice_incentivador_cultural_path,
124
+ invoice_outras_informacoes_path: response_invoice_outras_informacoes_path,
125
+ invoice_item_lista_servico_path: response_invoice_item_lista_servico_path,
126
+ invoice_cnae_code_path: response_invoice_cnae_code_path,
127
+ invoice_description_path: response_invoice_description_path,
128
+ invoice_codigo_municipio_path: response_invoice_codigo_municipio_path,
129
+ invoice_valor_total_servicos_path: response_invoice_valor_total_servicos_path,
130
+ invoice_deducoes_path: response_invoice_deducoes_path,
131
+ invoice_valor_pis_path: response_invoice_valor_pis_path,
132
+ invoice_valor_cofins_path: response_invoice_valor_cofins_path,
133
+ invoice_valor_inss_path: response_invoice_valor_inss_path,
134
+ invoice_valor_ir_path: response_invoice_valor_ir_path,
135
+ invoice_valor_csll_path: response_invoice_valor_csll_path,
136
+ invoice_iss_retido_path: response_invoice_iss_retido_path,
137
+ invoice_outras_retencoes_path: response_invoice_outras_retencoes_path,
138
+ invoice_total_iss_path: response_invoice_total_iss_path,
139
+ invoice_base_calculo_path: response_invoice_base_calculo_path,
140
+ invoice_iss_aliquota_path: response_invoice_iss_aliquota_path,
141
+ invoice_valor_liquido_path: response_invoice_valor_liquido_path,
142
+ invoice_desconto_condicionado_path: response_invoice_desconto_condicionado_path,
143
+ invoice_desconto_incondicionado_path: response_invoice_desconto_incondicionado_path,
144
+ # invoice_responsavel_retencao_path: response_invoice_responsavel_retencao_path,
145
+ # invoice_numero_processo_path: response_invoice_numero_processo_path,
146
+ # invoice_municipio_incidencia_path: response_invoice_municipio_incidencia_path,
147
+ invoice_orgao_gerador_municipio_path: response_invoice_orgao_gerador_municipio_path,
148
+ invoice_orgao_gerador_uf_path: response_invoice_orgao_gerador_uf_path,
149
+ invoice_cancelamento_codigo_path: response_invoice_cancelamento_codigo_path,
150
+ invoice_cancelamento_numero_nf_path: response_invoice_cancelamento_numero_nf_path,
151
+ invoice_cancelamento_cnpj_path: response_invoice_cancelamento_cnpj_path,
152
+ invoice_cancelamento_municipio_path: response_invoice_cancelamento_municipio_path,
153
+ invoice_cancelamento_data_hora_path: response_invoice_cancelamento_data_hora_path,
154
+ invoice_cancelamento_inscricao_municipal_path: response_invoice_cancelamento_inscricao_municipal_path,
155
+ invoice_nfe_substituidora_path: response_invoice_nfe_substituidora_path,
156
+ invoice_codigo_obra_path: response_invoice_codigo_obra_path,
157
+ invoice_codigo_art_path: response_invoice_codigo_art_path,
158
+ invoice_emitente_cnpj_path: response_invoice_emitente_cnpj_path,
159
+ invoice_emitente_inscricao_municipal_path: response_invoice_emitente_inscricao_municipal_path,
160
+ invoice_emitente_razao_social_path: response_invoice_emitente_razao_social_path,
161
+ invoice_emitente_nome_fantasia_path: response_invoice_emitente_nome_fantasia_path,
162
+ invoice_emitente_telefone_path: response_invoice_emitente_telefone_path,
163
+ invoice_emitente_email_path: response_invoice_emitente_email_path,
164
+ invoice_emitente_endereco_logradouro_path: response_invoice_emitente_endereco_logradouro_path,
165
+ invoice_emitente_endereco_numero_path: response_invoice_emitente_endereco_numero_path,
166
+ invoice_emitente_endereco_complemento_path: response_invoice_emitente_endereco_complemento_path,
167
+ invoice_emitente_endereco_bairro_path: response_invoice_emitente_endereco_bairro_path,
168
+ invoice_emitente_endereco_codigo_municipio_path: response_invoice_emitente_endereco_codigo_municipio_path,
169
+ invoice_emitente_endereco_uf_path: response_invoice_emitente_endereco_uf_path,
170
+ invoice_emitente_endereco_cep_path: response_invoice_emitente_endereco_cep_path,
171
+ invoice_destinatario_cpf_path: response_invoice_destinatario_cpf_path,
172
+ invoice_destinatario_cnpj_path: response_invoice_destinatario_cnpj_path,
173
+ invoice_destinatario_inscricao_municipal_path: response_invoice_destinatario_inscricao_municipal_path,
174
+ invoice_destinatario_inscricao_estadual_path: response_invoice_destinatario_inscricao_estadual_path,
175
+ invoice_destinatario_inscricao_suframa_path: response_invoice_destinatario_inscricao_suframa_path,
176
+ invoice_destinatario_razao_social_path: response_invoice_destinatario_razao_social_path,
177
+ invoice_destinatario_telefone_path: response_invoice_destinatario_telefone_path,
178
+ invoice_destinatario_email_path: response_invoice_destinatario_email_path,
179
+ invoice_destinatario_endereco_logradouro_path: response_invoice_destinatario_endereco_logradouro_path,
180
+ invoice_destinatario_endereco_numero_path: response_invoice_destinatario_endereco_numero_path,
181
+ invoice_destinatario_endereco_complemento_path: response_invoice_destinatario_endereco_complemento_path,
182
+ invoice_destinatario_endereco_bairro_path: response_invoice_destinatario_endereco_bairro_path,
183
+ invoice_destinatario_endereco_codigo_municipio_path: response_invoice_destinatario_endereco_codigo_municipio_path,
184
+ invoice_destinatario_endereco_uf_path: response_invoice_destinatario_endereco_uf_path,
185
+ invoice_destinatario_endereco_cep_path: response_invoice_destinatario_endereco_cep_path,
186
+ })
187
+ end
188
+ ############## FIM DEFINIÇÃO DOS VALORES PADRÕES PARA O CAMINHO DA NFSE #############
189
+ ######################################################################################
190
+
191
+ # Método que retorna as notas fiscais emitidas.
192
+ # Como pode ser que retorne mais de uma NF, a busca pela NF
193
+ # pode retornar um Array ou um Hash.
194
+ # Se retornar um array é porque existe mais de uma NFE, então é necessario
195
+ # percorer com um loop e instanciar cada nota com seus valores.
196
+ # Se retornar um Hash é porque tem apenas uma NFe, e nesse caso
197
+ # irá instanciar apenas a nfe encontrada.
198
+ #
199
+ # <b>Tipo de retorno: </b> _Array_
200
+ #
201
+ def get_invoices
202
+ invoices = []
203
+ _invoices = find_value_for_keys(savon_body, path_with_root(invoices_path))
204
+ if _invoices.is_a?(Hash)
205
+ invoices << instance_invoice(_invoices)
206
+ elsif _invoices.is_a?(Array)
207
+ _invoices.map{|inv| invoices << instance_invoice(inv) }
208
+ end
209
+ invoices
210
+ end
211
+
212
+ # Método utilizado para pegar o XML da NF
213
+ # É necessário canonicalizar o document para que seja colocado os
214
+ # namespaces nas tags corretas. Caso contrário o XML não irá abrir.
215
+ #
216
+ # <b>Tipo de retorno: </b> _String_
217
+ #
218
+ def get_xml_nf
219
+ if body_xml_path.present?
220
+ canonicalize(Nokogiri::XML.parse( body_converted_to_xml , nil, 'UTF-8').xpath(nfe_xml_path).to_xml)
221
+ else
222
+ canonicalize(Nokogiri::XML.parse(canonicalize(savon_response.doc.to_s), nil, 'UTF-8').xpath(nfe_xml_path).to_xml)
223
+ end
224
+ rescue
225
+ savon_response.xml
226
+ end
227
+
228
+ # Método responsável por instanciar a nota fiscal de acordo com o hash
229
+ # passado por parêmetro
230
+ # O parâmetro recebido deve ser o Hash representado pelo tipo de dados tcCompNfse(do manual NFS-e v1)
231
+ #
232
+ def instance_invoice(invoice_hash)
233
+ nfe = BrNfe::Service::Response::NotaFiscal.new({
234
+ xml_nf: get_xml_nf.force_encoding('UTF-8'),
235
+ numero_nf: find_value_for_keys(invoice_hash, invoice_numero_nf_path ),
236
+ codigo_verificacao: find_value_for_keys(invoice_hash, invoice_codigo_verificacao_path ),
237
+ data_emissao: find_value_for_keys(invoice_hash, invoice_data_emissao_path ),
238
+ url_nf: find_value_for_keys(invoice_hash, invoice_url_nf_path ),
239
+ competencia: find_value_for_keys(invoice_hash, invoice_competencia_path ),
240
+ natureza_operacao: find_value_for_keys(invoice_hash, invoice_natureza_operacao_path ),
241
+ regime_especial_tributacao: find_value_for_keys(invoice_hash, invoice_regime_especial_tributacao_path ),
242
+ optante_simples_nacional: find_value_for_keys(invoice_hash, invoice_optante_simples_nacional_path ),
243
+ incentivador_cultural: find_value_for_keys(invoice_hash, invoice_incentivador_cultural_path ),
244
+ outras_informacoes: find_value_for_keys(invoice_hash, invoice_outras_informacoes_path ),
245
+ item_lista_servico: find_value_for_keys(invoice_hash, invoice_item_lista_servico_path ),
246
+ cnae_code: find_value_for_keys(invoice_hash, invoice_cnae_code_path ),
247
+ description: find_value_for_keys(invoice_hash, invoice_description_path ),
248
+ codigo_municipio: find_value_for_keys(invoice_hash, invoice_codigo_municipio_path ),
249
+ responsavel_retencao: find_value_for_keys(invoice_hash, invoice_responsavel_retencao_path ),
250
+ numero_processo: find_value_for_keys(invoice_hash, invoice_numero_processo_path ),
251
+ municipio_incidencia: find_value_for_keys(invoice_hash, invoice_municipio_incidencia_path ),
252
+ orgao_gerador_municipio: find_value_for_keys(invoice_hash, invoice_orgao_gerador_municipio_path ),
253
+ orgao_gerador_uf: find_value_for_keys(invoice_hash, invoice_orgao_gerador_uf_path ),
254
+ codigo_obra: find_value_for_keys(invoice_hash, invoice_codigo_obra_path ),
255
+ codigo_art: find_value_for_keys(invoice_hash, invoice_codigo_art_path ),
256
+ })
257
+
258
+ build_rps_fields_nfe(nfe, invoice_hash)
259
+ build_cancelation_fields_nfe(nfe, invoice_hash)
260
+ build_values_nfe(nfe, invoice_hash)
261
+ build_emitente_nfe(nfe, invoice_hash)
262
+ build_destinatario_nfe(nfe, invoice_hash)
263
+ nfe
264
+ end
265
+
266
+ def build_rps_fields_nfe(nfe, invoice_hash)
267
+ nfe.assign_attributes({
268
+ rps_numero: find_value_for_keys(invoice_hash, invoice_rps_numero_path ),
269
+ rps_serie: find_value_for_keys(invoice_hash, invoice_rps_serie_path ),
270
+ rps_tipo: find_value_for_keys(invoice_hash, invoice_rps_tipo_path ),
271
+ rps_situacao: find_value_for_keys(invoice_hash, invoice_rps_situacao_path ),
272
+ rps_substituido_numero: find_value_for_keys(invoice_hash, invoice_rps_substituido_numero_path ),
273
+ rps_substituido_serie: find_value_for_keys(invoice_hash, invoice_rps_substituido_serie_path ),
274
+ rps_substituido_tipo: find_value_for_keys(invoice_hash, invoice_rps_substituido_tipo_path ),
275
+ data_emissao_rps: find_value_for_keys(invoice_hash, invoice_data_emissao_rps_path ),
276
+ })
277
+ end
278
+
279
+ def build_cancelation_fields_nfe(nfe, invoice_hash)
280
+ nfe.assign_attributes({
281
+ cancelamento_codigo: find_value_for_keys(invoice_hash, invoice_cancelamento_codigo_path ),
282
+ cancelamento_numero_nf: find_value_for_keys(invoice_hash, invoice_cancelamento_numero_nf_path ),
283
+ cancelamento_cnpj: find_value_for_keys(invoice_hash, invoice_cancelamento_cnpj_path ),
284
+ cancelamento_inscricao_municipal: find_value_for_keys(invoice_hash, invoice_cancelamento_inscricao_municipal_path),
285
+ cancelamento_municipio: find_value_for_keys(invoice_hash, invoice_cancelamento_municipio_path ),
286
+ cancelamento_data_hora: find_value_for_keys(invoice_hash, invoice_cancelamento_data_hora_path ),
287
+ nfe_substituidora: find_value_for_keys(invoice_hash, invoice_nfe_substituidora_path ),
288
+ })
289
+ end
290
+
291
+ def build_values_nfe(nfe, invoice_hash)
292
+ nfe.assign_attributes({
293
+ valor_total_servicos: find_value_for_keys(invoice_hash, invoice_valor_total_servicos_path ),
294
+ deducoes: find_value_for_keys(invoice_hash, invoice_deducoes_path ),
295
+ valor_pis: find_value_for_keys(invoice_hash, invoice_valor_pis_path ),
296
+ valor_cofins: find_value_for_keys(invoice_hash, invoice_valor_cofins_path ),
297
+ valor_inss: find_value_for_keys(invoice_hash, invoice_valor_inss_path ),
298
+ valor_ir: find_value_for_keys(invoice_hash, invoice_valor_ir_path ),
299
+ valor_csll: find_value_for_keys(invoice_hash, invoice_valor_csll_path ),
300
+ iss_retido: find_value_for_keys(invoice_hash, invoice_iss_retido_path ),
301
+ outras_retencoes: find_value_for_keys(invoice_hash, invoice_outras_retencoes_path ),
302
+ total_iss: find_value_for_keys(invoice_hash, invoice_total_iss_path ),
303
+ base_calculo: find_value_for_keys(invoice_hash, invoice_base_calculo_path ),
304
+ iss_aliquota: find_value_for_keys(invoice_hash, invoice_iss_aliquota_path ),
305
+ valor_liquido: find_value_for_keys(invoice_hash, invoice_valor_liquido_path ),
306
+ desconto_condicionado: find_value_for_keys(invoice_hash, invoice_desconto_condicionado_path ),
307
+ desconto_incondicionado: find_value_for_keys(invoice_hash, invoice_desconto_incondicionado_path ),
308
+ })
309
+ end
310
+
311
+ def build_emitente_nfe(nfe, invoice_hash)
312
+ nfe.assign_attributes({
313
+ emitente: {
314
+ cnpj: find_value_for_keys(invoice_hash, invoice_emitente_cnpj_path ),
315
+ inscricao_municipal: find_value_for_keys(invoice_hash, invoice_emitente_inscricao_municipal_path ),
316
+ razao_social: find_value_for_keys(invoice_hash, invoice_emitente_razao_social_path ),
317
+ nome_fantasia: find_value_for_keys(invoice_hash, invoice_emitente_nome_fantasia_path ),
318
+ telefone: find_value_for_keys(invoice_hash, invoice_emitente_telefone_path ),
319
+ email: find_value_for_keys(invoice_hash, invoice_emitente_email_path ),
320
+ endereco: {
321
+ logradouro: find_value_for_keys(invoice_hash, invoice_emitente_endereco_logradouro_path ),
322
+ numero: find_value_for_keys(invoice_hash, invoice_emitente_endereco_numero_path ),
323
+ complemento: find_value_for_keys(invoice_hash, invoice_emitente_endereco_complemento_path ),
324
+ bairro: find_value_for_keys(invoice_hash, invoice_emitente_endereco_bairro_path ),
325
+ codigo_municipio: find_value_for_keys(invoice_hash, invoice_emitente_endereco_codigo_municipio_path ),
326
+ uf: find_value_for_keys(invoice_hash, invoice_emitente_endereco_uf_path ),
327
+ cep: find_value_for_keys(invoice_hash, invoice_emitente_endereco_cep_path ),
328
+ }
329
+ }
330
+ })
331
+ end
332
+
333
+ def build_destinatario_nfe(nfe, invoice_hash)
334
+ nfe.assign_attributes({
335
+ destinatario: {
336
+ cpf_cnpj: (find_value_for_keys(invoice_hash, invoice_destinatario_cpf_path) || find_value_for_keys(invoice_hash, invoice_destinatario_cnpj_path)),
337
+ inscricao_municipal: find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_municipal_path),
338
+ inscricao_estadual: find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_estadual_path),
339
+ inscricao_suframa: find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_suframa_path),
340
+ razao_social: find_value_for_keys(invoice_hash, invoice_destinatario_razao_social_path),
341
+ telefone: find_value_for_keys(invoice_hash, invoice_destinatario_telefone_path),
342
+ email: find_value_for_keys(invoice_hash, invoice_destinatario_email_path),
343
+ endereco: {
344
+ logradouro: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_logradouro_path),
345
+ numero: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_numero_path),
346
+ complemento: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_complemento_path),
347
+ bairro: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_bairro_path),
348
+ codigo_municipio: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_codigo_municipio_path),
349
+ uf: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_uf_path),
350
+ cep: find_value_for_keys(invoice_hash, invoice_destinatario_endereco_cep_path),
351
+ }
352
+ }
353
+ })
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end
359
+ end
@@ -0,0 +1,69 @@
1
+ #encoding UTF-8
2
+ module BrNfe
3
+ module Service
4
+ module Response
5
+ module Build
6
+ class RecepcaoLoteRps < BrNfe::Service::Response::Build::Base
7
+ ##############################################################################################################
8
+ ####################### CAMINHOS PARA ENCONTRAR OS VALORES NA RESPOSTA DA REQUISIÇÃO #####################
9
+ # o numero do lote
10
+ attr_accessor :lot_number_path
11
+
12
+ # o protocolo
13
+ attr_accessor :protocol_path
14
+
15
+ # a data de recebimento do xml
16
+ attr_accessor :received_date_path
17
+
18
+ def default_values
19
+ super.merge({
20
+ lot_number_path: [:enviar_lote_rps_resposta, :numero_lote],
21
+ protocol_path: [:enviar_lote_rps_resposta, :protocolo],
22
+ received_date_path: [:enviar_lote_rps_resposta, :data_recebimento],
23
+ message_errors_path: [:enviar_lote_rps_resposta, :lista_mensagem_retorno, :mensagem_retorno]
24
+ })
25
+ end
26
+
27
+ ####################### FIM DA DEFINIÇÃO DOS CAMINHOS ############################
28
+ ######################################################################################
29
+ def response
30
+ @response ||= BrNfe::Service::Response::RecepcaoLoteRps.new({
31
+ original_xml: savon_response.xml.force_encoding('UTF-8'),
32
+ error_messages: get_message_for_path(message_errors_path),
33
+ protocolo: get_protocol,
34
+ data_recebimento: get_received_date,
35
+ numero_lote: get_lot_number,
36
+ })
37
+ end
38
+
39
+ # Método utilizado para pegar protocolo de solicitação de
40
+ # processamento do RPS.
41
+ # Esse protocolo é utilizado posteriormente para consultar se
42
+ # o RPS já foi processado
43
+ #
44
+ # <b>Tipo de retorno: </b> _String_
45
+ #
46
+ def get_protocol
47
+ find_value_for_keys(savon_body, path_with_root(protocol_path))
48
+ end
49
+
50
+ # Método utilizado para pegar a data de recebimento do lote
51
+ #
52
+ # <b>Tipo de retorno: </b> _String_
53
+ #
54
+ def get_received_date
55
+ find_value_for_keys(savon_body, path_with_root(received_date_path))
56
+ end
57
+
58
+ # Método utilizado para pegar o número do lote RPS
59
+ #
60
+ # <b>Tipo de retorno: </b> _String_
61
+ #
62
+ def get_lot_number
63
+ find_value_for_keys(savon_body, path_with_root(lot_number_path))
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,22 @@
1
+ module BrNfe
2
+ module Service
3
+ module Response
4
+ class Cancelamento < Default
5
+
6
+ # Data e hora do cancelamento da NF-e
7
+ # utilizado apenas para o Cancelamento da NF
8
+ #
9
+ # <b>Tipo de retorno: </b> _DateTime_
10
+ #
11
+ attr_accessor :data_hora_cancelamento
12
+
13
+ # Codigo do Cancelamento
14
+ #
15
+ attr_accessor :codigo_cancelamento
16
+
17
+ # Número da nota fiscal cancelada
18
+ attr_accessor :numero_nfs
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ module BrNfe
2
+ module Service
3
+ module Response
4
+ class ConsultaLoteRps < Default
5
+ # Número do protocolo de recebimento do XML
6
+ # Setado normalmente quando é enviado um lote RPS
7
+ # para processamento.
8
+ # O valor desse atributo é utilizado para posteriormente
9
+ # fazer a consulta para saber se o RPS já foi processado
10
+ #
11
+ # <b>Tipo de retorno: </b> _Integer_ ou _String_
12
+ #
13
+ attr_accessor :protocolo
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module BrNfe
2
+ module Service
3
+ module Response
4
+ class ConsultaNfsPorRps < Default
5
+
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module BrNfe
2
+ module Service
3
+ module Response
4
+ class ConsultaNfse < Default
5
+
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,74 @@
1
+ module BrNfe
2
+ module Service
3
+ module Response
4
+ class ConsultaSituacaoLoteRps < Default
5
+
6
+ # Número do lote RPS
7
+ # Nesse atributo é setado o número do lote RPS
8
+ # quando o mesmo for retornado na resposta
9
+ #
10
+ # <b>Tipo de retorno: </b> _Integer_
11
+ #
12
+ attr_accessor :numero_lote
13
+
14
+ # Código da situação do lote RPS
15
+ # Utilizado para saber se o Lote RPS já foi processado
16
+ # e se foi processado com sucesso ou teve algum erro
17
+ #
18
+ # <b>Tipo de retorno: </b> _Integer_ ou _String_
19
+ #
20
+ attr_accessor :situation
21
+ def situation
22
+ @situation ||= get_situation_by_message_codes if error_messages.present?
23
+ @situation
24
+ end
25
+
26
+ def situation_unreceived_code_errors
27
+ @situation_unreceived_code_errors ||= []
28
+ @situation_unreceived_code_errors+['E4']
29
+ end
30
+ def situation_unreceived_code_errors=(value)
31
+ @situation_unreceived_code_errors = [value].flatten
32
+ end
33
+
34
+ def situation_unprocessed_code_errors
35
+ @situation_unprocessed_code_errors ||= []
36
+ @situation_unprocessed_code_errors+['E92']
37
+ end
38
+ def situation_unprocessed_code_errors=(value)
39
+ @situation_unprocessed_code_errors = [value].flatten
40
+ end
41
+
42
+ def situation_success_code_errors
43
+ @situation_success_code_errors ||= []
44
+ @situation_success_code_errors#+[]
45
+ end
46
+ def situation_success_code_errors=(value)
47
+ @situation_success_code_errors = [value].flatten
48
+ end
49
+
50
+ # Como alguns orgãos emissores (como a Betha) não tem a capacidade
51
+ # de programar para colocar o codigo da situação em determinados momentos
52
+ # e simplesmente colocam uma mensagem de erro na resposta sem setar a situação
53
+ # foi necessário construir esse método para que a partir dos códigos das mensagens
54
+ # seja possível distinguir qual a situação atual do lote enviado.
55
+ # Por exemplo: Quando retornar o erro com código 'E92' quer dizer que a situação
56
+ # do lote é :unprocessed. Equivalente ao código de situação 2
57
+ #
58
+ # <b>Tipo de retorno: </b> _Symbol_
59
+ #
60
+ def get_situation_by_message_codes
61
+ if (situation_unprocessed_code_errors & message_codes).any?
62
+ :unprocessed
63
+ elsif (situation_unreceived_code_errors & message_codes).any?
64
+ :unreceived
65
+ elsif (situation_success_code_errors & message_codes).any?
66
+ :success
67
+ elsif message_codes.any?
68
+ :error
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end