br_nfe 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (495) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +12 -2
  5. data/README.markdown +3 -1
  6. data/Rakefile +20 -1
  7. data/lib/br_nfe/active_model/associations.rb +11 -0
  8. data/lib/br_nfe/active_model/has_many.rb +65 -0
  9. data/lib/br_nfe/active_model/has_one.rb +57 -0
  10. data/lib/br_nfe/active_model_base.rb +38 -1
  11. data/lib/br_nfe/base.rb +9 -0
  12. data/lib/br_nfe/calculos/fatores_de_multiplicacao.rb +67 -0
  13. data/lib/br_nfe/calculos/modulo11.rb +54 -0
  14. data/lib/br_nfe/calculos/modulo11_fator_de2a9.rb +83 -0
  15. data/lib/br_nfe/calculos/modulo11_fator_de2a9_resto_zero.rb +29 -0
  16. data/lib/br_nfe/constants.rb +46 -1
  17. data/lib/br_nfe/endereco.rb +6 -2
  18. data/lib/br_nfe/helper/cpf_cnpj.rb +8 -1
  19. data/lib/br_nfe/person.rb +32 -3
  20. data/lib/br_nfe/product/destinatario.rb +45 -0
  21. data/lib/br_nfe/product/emitente.rb +14 -1
  22. data/lib/br_nfe/product/evento/base.rb +146 -0
  23. data/lib/br_nfe/product/evento/cancelamento.rb +46 -0
  24. data/lib/br_nfe/product/gateway/base.rb +16 -43
  25. data/lib/br_nfe/product/gateway/web_service_am.rb +140 -0
  26. data/lib/br_nfe/product/gateway/web_service_ba.rb +140 -0
  27. data/lib/br_nfe/product/gateway/web_service_ce.rb +162 -0
  28. data/lib/br_nfe/product/gateway/web_service_go.rb +140 -0
  29. data/lib/br_nfe/product/gateway/web_service_mg.rb +140 -0
  30. data/lib/br_nfe/product/gateway/web_service_ms.rb +140 -0
  31. data/lib/br_nfe/product/gateway/web_service_mt.rb +140 -0
  32. data/lib/br_nfe/product/gateway/web_service_pe.rb +140 -0
  33. data/lib/br_nfe/product/gateway/web_service_pr.rb +140 -0
  34. data/lib/br_nfe/product/gateway/web_service_rs.rb +140 -0
  35. data/lib/br_nfe/product/gateway/web_service_sp.rb +140 -0
  36. data/lib/br_nfe/product/gateway/web_service_svan.rb +162 -0
  37. data/lib/br_nfe/product/gateway/web_service_svc_an.rb +131 -0
  38. data/lib/br_nfe/product/gateway/web_service_svc_rs.rb +20 -0
  39. data/lib/br_nfe/product/gateway/web_service_svrs.rb +111 -10
  40. data/lib/br_nfe/product/nf_xml_value.rb +278 -0
  41. data/lib/br_nfe/product/nfe/adicao_importacao.rb +76 -0
  42. data/lib/br_nfe/product/nfe/cobranca/duplicata.rb +44 -0
  43. data/lib/br_nfe/product/nfe/cobranca/fatura.rb +64 -0
  44. data/lib/br_nfe/product/nfe/cobranca/pagamento.rb +99 -0
  45. data/lib/br_nfe/product/nfe/declaracao_importacao.rb +221 -0
  46. data/lib/br_nfe/product/nfe/detalhe_exportacao.rb +89 -0
  47. data/lib/br_nfe/product/nfe/item.rb +678 -0
  48. data/lib/br_nfe/product/nfe/item_tax/cofins.rb +138 -0
  49. data/lib/br_nfe/product/nfe/item_tax/cofins_st.rb +68 -0
  50. data/lib/br_nfe/product/nfe/item_tax/icms.rb +593 -0
  51. data/lib/br_nfe/product/nfe/item_tax/icms_uf_destino.rb +169 -0
  52. data/lib/br_nfe/product/nfe/item_tax/importacao.rb +62 -0
  53. data/lib/br_nfe/product/nfe/item_tax/ipi.rb +179 -0
  54. data/lib/br_nfe/product/nfe/item_tax/issqn.rb +256 -0
  55. data/lib/br_nfe/product/nfe/item_tax/pis.rb +138 -0
  56. data/lib/br_nfe/product/nfe/item_tax/pis_st.rb +68 -0
  57. data/lib/br_nfe/product/nfe/processo_referencia.rb +48 -0
  58. data/lib/br_nfe/product/nfe/transporte/base.rb +264 -0
  59. data/lib/br_nfe/product/nfe/transporte/transportador.rb +15 -0
  60. data/lib/br_nfe/product/nfe/transporte/veiculo.rb +53 -0
  61. data/lib/br_nfe/product/nfe/transporte/volume.rb +89 -0
  62. data/lib/br_nfe/product/nota_fiscal.rb +1173 -0
  63. data/lib/br_nfe/product/operation/base.rb +255 -0
  64. data/lib/br_nfe/product/operation/nfe_autorizacao.rb +118 -0
  65. data/lib/br_nfe/product/operation/nfe_consulta_protocolo.rb +61 -0
  66. data/lib/br_nfe/product/operation/nfe_download_nf.rb +86 -0
  67. data/lib/br_nfe/product/operation/nfe_inutilizacao.rb +168 -0
  68. data/lib/br_nfe/product/operation/nfe_recepcao_evento.rb +70 -0
  69. data/lib/br_nfe/product/operation/nfe_ret_autorizacao.rb +63 -0
  70. data/lib/br_nfe/product/operation/nfe_status_servico.rb +46 -0
  71. data/lib/br_nfe/product/response/base.rb +97 -0
  72. data/lib/br_nfe/product/response/build/base.rb +287 -0
  73. data/lib/br_nfe/product/response/build/nfe_autorizacao.rb +102 -0
  74. data/lib/br_nfe/product/response/build/nfe_consulta_protocolo.rb +133 -0
  75. data/lib/br_nfe/product/response/build/nfe_inutilizacao.rb +53 -0
  76. data/lib/br_nfe/product/response/build/nfe_ret_autorizacao.rb +65 -0
  77. data/lib/br_nfe/product/response/build/nfe_status_servico.rb +43 -0
  78. data/lib/br_nfe/product/response/event.rb +89 -0
  79. data/lib/br_nfe/product/response/nfe_autorizacao.rb +12 -0
  80. data/lib/br_nfe/product/response/nfe_consulta_protocolo.rb +13 -0
  81. data/lib/br_nfe/product/response/nfe_inutilizacao.rb +89 -0
  82. data/lib/br_nfe/product/response/nfe_ret_autorizacao.rb +9 -0
  83. data/lib/br_nfe/product/response/nfe_status_servico.rb +31 -0
  84. data/lib/br_nfe/product/xml/_signed_info_sh1.xml.slim +9 -0
  85. data/lib/br_nfe/product/xml/_tc_cpf_cnpj.xml.slim +7 -0
  86. data/lib/br_nfe/product/xml/signature_sh1.xml.slim +12 -0
  87. data/lib/br_nfe/product/xml/v1_00/evento/infEventoCancelamento.xml.slim +19 -0
  88. data/lib/br_nfe/product/xml/v1_00/root/NfeDownloadNf.xml.slim +5 -0
  89. data/lib/br_nfe/product/xml/v1_00/root/NfeRecepcaoEvento.xml.slim +7 -0
  90. data/lib/br_nfe/product/xml/v2_00/_tc_endereco.xml.slim +19 -0
  91. data/lib/br_nfe/product/xml/v2_00/_tc_infNFe.xml.slim +39 -0
  92. data/lib/br_nfe/product/xml/v2_00/infInut.xml.slim +12 -0
  93. data/lib/br_nfe/product/xml/v2_00/infNFe/NFe.xml.slim +4 -0
  94. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_cobr.xml.slim +19 -0
  95. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_dest.xml.slim +14 -0
  96. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_det.xml.slim +7 -0
  97. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_emit.xml.slim +19 -0
  98. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_entrega.xml.slim +11 -0
  99. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_exporta.xml.slim +2 -0
  100. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_ide.xml.slim +24 -0
  101. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_infAdic.xml.slim +13 -0
  102. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_retirada.xml.slim +11 -0
  103. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_total.xml.slim +50 -0
  104. data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_transp.xml.slim +35 -0
  105. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_imposto.xml.slim +31 -0
  106. data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_prod.xml.slim +37 -0
  107. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS00.xml.slim +6 -0
  108. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS10.xml.slim +16 -0
  109. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS101.xml.slim +4 -0
  110. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS102.xml.slim +3 -0
  111. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +6 -0
  112. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS201.xml.slim +15 -0
  113. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS202.xml.slim +14 -0
  114. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +12 -0
  115. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  116. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS500.xml.slim +6 -0
  117. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +13 -0
  118. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS60.xml.slim +5 -0
  119. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +18 -0
  120. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +21 -0
  121. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS900.xml.slim +25 -0
  122. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS.xml.slim +26 -0
  123. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS_ST.xml.slim +7 -0
  124. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_ICMS.xml.slim +45 -0
  125. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_II.xml.slim +4 -0
  126. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_IPI.xml.slim +30 -0
  127. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS.xml.slim +26 -0
  128. data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS_ST.xml.slim +7 -0
  129. data/lib/br_nfe/product/xml/v2_00/infNFe/det/prod/_tc_di.xml.slim +13 -0
  130. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_retTransp.xml.slim +6 -0
  131. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_transporta.xml.slim +17 -0
  132. data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_vol.xml.slim +15 -0
  133. data/lib/br_nfe/product/xml/v2_00/infNFe.xml.slim +3 -0
  134. data/lib/br_nfe/product/xml/v2_00/root/NfeAutorizacao.xml.slim +5 -0
  135. data/lib/br_nfe/product/xml/v2_00/root/NfeInutilizacao.xml.slim +4 -0
  136. data/lib/br_nfe/product/xml/v2_00/root/NfeRetAutorizacao.xml.slim +3 -0
  137. data/lib/br_nfe/product/xml/v2_00/root/NfeStatusServico.xml.slim +4 -0
  138. data/lib/br_nfe/product/xml/v2_01/root/NfeConsultaProtocolo.xml.slim +4 -0
  139. data/lib/br_nfe/product/xml/v3_10/_tc_infNFe.xml.slim +44 -0
  140. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_dest.xml.slim +25 -0
  141. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_det.xml.slim +14 -0
  142. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_exporta.xml.slim +4 -0
  143. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_ide.xml.slim +26 -0
  144. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_pag.xml.slim +7 -0
  145. data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_total.xml.slim +78 -0
  146. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_imposto.xml.slim +37 -0
  147. data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_prod.xml.slim +48 -0
  148. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +12 -0
  149. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +17 -0
  150. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
  151. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +19 -0
  152. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +23 -0
  153. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +26 -0
  154. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +8 -0
  155. data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ISSQN.xml.slim +35 -0
  156. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_det_export.xml.slim +8 -0
  157. data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_di.xml.slim +28 -0
  158. data/lib/br_nfe/product/xml/v3_10/root/NfeAutorizacao.xml.slim +6 -0
  159. data/lib/br_nfe/service/base.rb +1 -105
  160. data/lib/br_nfe/service/betha/v1/cancela_nfse.rb +1 -1
  161. data/lib/br_nfe/service/response/default.rb +1 -1
  162. data/lib/br_nfe/service/simpliss/v1/base.rb +2 -0
  163. data/lib/br_nfe/version.rb +2 -2
  164. data/lib/br_nfe.rb +180 -22
  165. data/lib/config/locales/br_nfe/en/product/nfe/cobranca/fatura.yml +6 -0
  166. data/lib/config/locales/br_nfe/en/product/nfe/declaracao_importacao.yml +10 -0
  167. data/lib/config/locales/br_nfe/en/product/nfe/item.yml +20 -0
  168. data/lib/config/locales/br_nfe/en/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  169. data/lib/config/locales/br_nfe/en/product/nfe/transporte/base.yml +9 -0
  170. data/lib/config/locales/br_nfe/en/product/nota_fiscal.yml +21 -0
  171. data/lib/config/locales/br_nfe/en/product/operation/nfe_autorizacao.yml +10 -0
  172. data/lib/config/locales/br_nfe/en/product/operation/nfe_recepcao_evento.yml +6 -0
  173. data/lib/config/locales/br_nfe/pt-BR/product/nfe/cobranca/fatura.yml +6 -0
  174. data/lib/config/locales/br_nfe/pt-BR/product/nfe/declaracao_importacao.yml +10 -0
  175. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item.yml +20 -0
  176. data/lib/config/locales/br_nfe/pt-BR/product/nfe/item_tax/icms_uf_destino.yml +8 -0
  177. data/lib/config/locales/br_nfe/pt-BR/product/nfe/transporte/base.yml +9 -0
  178. data/lib/config/locales/br_nfe/pt-BR/product/nota_fiscal.yml +21 -0
  179. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_autorizacao.yml +10 -0
  180. data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_recepcao_evento.yml +6 -0
  181. data/test/br_nfe/association/have_destinatario_test.rb +8 -8
  182. data/test/br_nfe/association/have_emitente_test.rb +6 -6
  183. data/test/br_nfe/base_test.rb +15 -4
  184. data/test/br_nfe/endereco_test.rb +15 -0
  185. data/test/br_nfe/person_test.rb +55 -6
  186. data/test/br_nfe/product/destinatario_test.rb +26 -0
  187. data/test/br_nfe/product/emitente_test.rb +1 -2
  188. data/test/br_nfe/product/evento/base_test.rb +58 -0
  189. data/test/br_nfe/product/evento/cancelamento_test.rb +32 -0
  190. data/test/br_nfe/product/gateway/web_service_am_test.rb +242 -0
  191. data/test/br_nfe/product/gateway/web_service_ba_test.rb +242 -0
  192. data/test/br_nfe/product/gateway/web_service_ce_test.rb +242 -0
  193. data/test/br_nfe/product/gateway/web_service_go_test.rb +242 -0
  194. data/test/br_nfe/product/gateway/web_service_mg_test.rb +242 -0
  195. data/test/br_nfe/product/gateway/web_service_ms_test.rb +242 -0
  196. data/test/br_nfe/product/gateway/web_service_mt_test.rb +408 -0
  197. data/test/br_nfe/product/gateway/web_service_pe_test.rb +408 -0
  198. data/test/br_nfe/product/gateway/web_service_pr_test.rb +408 -0
  199. data/test/br_nfe/product/gateway/web_service_rs_test.rb +407 -0
  200. data/test/br_nfe/product/gateway/web_service_sp_test.rb +408 -0
  201. data/test/br_nfe/product/gateway/web_service_svan_test.rb +242 -0
  202. data/test/br_nfe/product/gateway/web_service_svc_an_test.rb +185 -0
  203. data/test/br_nfe/product/gateway/web_service_svc_rs_test.rb +185 -0
  204. data/test/br_nfe/product/gateway/web_service_svrs_test.rb +208 -2
  205. data/test/br_nfe/product/nfe/adicao_importacao_test.rb +19 -0
  206. data/test/br_nfe/product/nfe/cobranca/duplicata_test.rb +19 -0
  207. data/test/br_nfe/product/nfe/cobranca/fatura_test.rb +32 -0
  208. data/test/br_nfe/product/nfe/cobranca/pagamento_test.rb +105 -0
  209. data/test/br_nfe/product/nfe/declaracao_importacao_test.rb +116 -0
  210. data/test/br_nfe/product/nfe/detalhe_exportacao_test.rb +97 -0
  211. data/test/br_nfe/product/nfe/item_tax/cofins_st_test.rb +22 -0
  212. data/test/br_nfe/product/nfe/item_tax/cofins_test.rb +113 -0
  213. data/test/br_nfe/product/nfe/item_tax/icms_test.rb +1011 -0
  214. data/test/br_nfe/product/nfe/item_tax/icms_uf_destino_test.rb +99 -0
  215. data/test/br_nfe/product/nfe/item_tax/importacao_test.rb +23 -0
  216. data/test/br_nfe/product/nfe/item_tax/ipi_test.rb +160 -0
  217. data/test/br_nfe/product/nfe/item_tax/issqn_test.rb +84 -0
  218. data/test/br_nfe/product/nfe/item_tax/pis_st_test.rb +22 -0
  219. data/test/br_nfe/product/nfe/item_tax/pis_test.rb +113 -0
  220. data/test/br_nfe/product/nfe/item_test.rb +381 -0
  221. data/test/br_nfe/product/nfe/processo_referencia_test.rb +30 -0
  222. data/test/br_nfe/product/nfe/transporte/base_test.rb +182 -0
  223. data/test/br_nfe/product/nfe/transporte/transportador_test.rb +13 -0
  224. data/test/br_nfe/product/nfe/transporte/veiculo_test.rb +13 -0
  225. data/test/br_nfe/product/nfe/transporte/volume_test.rb +42 -0
  226. data/test/br_nfe/product/nota_fiscal_test.rb +662 -0
  227. data/test/br_nfe/product/operation/base_test.rb +538 -0
  228. data/test/br_nfe/product/operation/nfe_autorizacao_test.rb +378 -0
  229. data/test/br_nfe/product/operation/nfe_consulta_protocolo_test.rb +349 -0
  230. data/test/br_nfe/product/operation/nfe_download_nf_test.rb +93 -0
  231. data/test/br_nfe/product/operation/nfe_inutilizacao_test.rb +210 -0
  232. data/test/br_nfe/product/operation/nfe_recepcao_evento_test.rb +84 -0
  233. data/test/br_nfe/product/operation/nfe_ret_autorizacao_test.rb +309 -0
  234. data/test/br_nfe/product/operation/nfe_status_servico_test.rb +122 -0
  235. data/test/br_nfe/product/response/base_test.rb +75 -0
  236. data/test/br_nfe/product/response/build/base_test.rb +34 -0
  237. data/test/br_nfe/product/response/nfe_ret_autorizacao_test.rb +14 -0
  238. data/test/br_nfe/service/association/have_intermediario_test.rb +10 -10
  239. data/test/br_nfe/service/base_test.rb +9 -206
  240. data/test/br_nfe/service/betha/v1/cancela_nfse_test.rb +8 -6
  241. data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +6 -3
  242. data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +6 -3
  243. data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +7 -4
  244. data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +12 -9
  245. data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +6 -3
  246. data/test/br_nfe/service/rps_test.rb +2 -2
  247. data/test/br_nfe/service/simpliss/v1/cancela_nfse_test.rb +6 -3
  248. data/test/br_nfe/service/simpliss/v1/consulta_lote_rps_test.rb +7 -4
  249. data/test/br_nfe/service/simpliss/v1/consulta_nfs_por_rps_test.rb +7 -4
  250. data/test/br_nfe/service/simpliss/v1/consulta_nfse_test.rb +8 -5
  251. data/test/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps_test.rb +9 -6
  252. data/test/br_nfe/service/simpliss/v1/recepcao_lote_rps_test.rb +6 -3
  253. data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +6 -3
  254. data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +6 -3
  255. data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +6 -3
  256. data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +8 -5
  257. data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +9 -6
  258. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_limitado_test.rb +6 -3
  259. data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +6 -3
  260. data/test/factories/person.rb +1 -1
  261. data/test/factories/product/destinatario.rb +11 -0
  262. data/test/factories/product/emitente.rb +1 -1
  263. data/test/factories/product/evento/base.rb +9 -0
  264. data/test/factories/product/evento/cancelamento.rb +10 -0
  265. data/test/factories/product/gateway/web_service_am.rb +5 -0
  266. data/test/factories/product/gateway/web_service_ba.rb +5 -0
  267. data/test/factories/product/nfe/adicao_importacao.rb +7 -0
  268. data/test/factories/product/nfe/cobranca/duplicata.rb +7 -0
  269. data/test/factories/product/nfe/cobranca/fatura.rb +8 -0
  270. data/test/factories/product/nfe/cobranca/pagamento.rb +9 -0
  271. data/test/factories/product/nfe/declaracao_importacao.rb +10 -0
  272. data/test/factories/product/nfe/detalhe_exportacao.rb +5 -0
  273. data/test/factories/product/nfe/item.rb +24 -0
  274. data/test/factories/product/nfe/item_tax/cofins.rb +5 -0
  275. data/test/factories/product/nfe/item_tax/cofins_st.rb +5 -0
  276. data/test/factories/product/nfe/item_tax/icms.rb +9 -0
  277. data/test/factories/product/nfe/item_tax/icms_uf_destino.rb +11 -0
  278. data/test/factories/product/nfe/item_tax/importacao.rb +8 -0
  279. data/test/factories/product/nfe/item_tax/ipi.rb +6 -0
  280. data/test/factories/product/nfe/item_tax/issqn.rb +9 -0
  281. data/test/factories/product/nfe/item_tax/pis.rb +5 -0
  282. data/test/factories/product/nfe/item_tax/pis_st.rb +5 -0
  283. data/test/factories/product/nfe/processo_referencia.rb +6 -0
  284. data/test/factories/product/nfe/transporte/base.rb +5 -0
  285. data/test/factories/product/nfe/transporte/transportador.rb +7 -0
  286. data/test/factories/product/nfe/transporte/veiculo.rb +7 -0
  287. data/test/factories/product/nfe/transporte/volume.rb +5 -0
  288. data/test/factories/product/nota_fiscal.rb +22 -0
  289. data/test/factories/product/{base.rb → operation/base.rb} +1 -1
  290. data/test/factories/product/operation/nfe_autorizacao.rb +590 -0
  291. data/test/factories/product/operation/nfe_consulta_protocolo.rb +13 -0
  292. data/test/factories/product/operation/nfe_download_nf.rb +15 -0
  293. data/test/factories/product/operation/nfe_inutilizacao.rb +19 -0
  294. data/test/factories/product/operation/nfe_recepcao_evento.rb +14 -0
  295. data/test/factories/product/operation/nfe_ret_autorizacao.rb +13 -0
  296. data/test/factories/product/{consulta_status_servico.rb → operation/nfe_status_servico.rb} +1 -1
  297. data/test/factories/product/response/base.rb +12 -0
  298. data/test/factories/product/response/build/base.rb +6 -0
  299. data/test/factories/product/response/nfe_ret_autorizacao.rb +13 -0
  300. data/test/factories/service/emitente.rb +1 -1
  301. data/test/fixtures/product/operation/nfe_autorizacao/nfe_signed.xml +1 -0
  302. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_fail.xml +21 -0
  303. data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_success.xml +25 -0
  304. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/with_proc.xml +1 -0
  305. data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/without_proc.xml +1 -0
  306. data/test/fixtures/product/response/v3.10/nfe_autorizacao/original_xml.xml +1 -0
  307. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_fail.xml +32 -0
  308. data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_success.xml +33 -0
  309. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_1.xml +1 -0
  310. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_2.xml +1 -0
  311. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_3.xml +1 -0
  312. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_cancel.xml +1 -0
  313. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/one_event.xml +1 -0
  314. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/fail.xml +22 -0
  315. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/with_proc.xml +1 -0
  316. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/without_proc.xml +1 -0
  317. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_with_cancel.xml +198 -0
  318. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_without_cancel.xml +199 -0
  319. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_one.xml +89 -0
  320. data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_without.xml +34 -0
  321. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/fail.xml +29 -0
  322. data/test/fixtures/product/response/v3.10/nfe_inutilizacao/success.xml +30 -0
  323. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/fail.xml +34 -0
  324. data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/success.xml +36 -0
  325. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_fail.xml +22 -0
  326. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail.xml +33 -0
  327. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail_and_one_ok.xml +46 -0
  328. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_ok.xml +34 -0
  329. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_fail.xml +46 -0
  330. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_ok.xml +46 -0
  331. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_with_protocol.xml +1 -0
  332. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_without_protocol.xml +1 -0
  333. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_with_protocol.xml +1 -0
  334. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_without_protocol.xml +1 -0
  335. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/lot.xml +2 -0
  336. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfe.xml +2 -0
  337. data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfeProc.xml +4 -0
  338. data/test/fixtures/product/response/v3.10/nfe_status_servico/fail.xml +23 -0
  339. data/test/fixtures/product/response/v3.10/nfe_status_servico/success.xml +22 -0
  340. data/test/fixtures/product/schemas/CCe_v1.00.xsd +11 -0
  341. data/test/fixtures/product/schemas/EPEC_v1.00.xsd +9 -0
  342. data/test/fixtures/product/schemas/LeiauteCadastroEmissorDFe_v1.01.xsd +234 -0
  343. data/test/fixtures/product/schemas/SuframaInternaliza_v1.00.xsd +9 -0
  344. data/test/fixtures/product/schemas/SuframaVistoria_v1.00.xsd +9 -0
  345. data/test/fixtures/product/schemas/atuCadEmiDFe_v1.01.xsd +9 -0
  346. data/test/fixtures/product/schemas/cabecMsg_v1.02.xsd +29 -0
  347. data/test/fixtures/product/schemas/cadEmiDFe_v1.01.xsd +9 -0
  348. data/test/fixtures/product/schemas/cancNFe_v2.00.xsd +9 -0
  349. data/test/fixtures/product/schemas/confRecebto_v1.00.xsd +9 -0
  350. data/test/fixtures/product/schemas/consCad_v2.00.xsd +9 -0
  351. data/test/fixtures/product/schemas/consDPEC_v1.01.xsd +9 -0
  352. data/test/fixtures/product/schemas/consNFeDest_v1.01.xsd +10 -0
  353. data/test/fixtures/product/schemas/consReciNFe_v2.00.xsd +9 -0
  354. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consReciNFe_v3.10.xsd +8 -8
  355. data/test/fixtures/product/schemas/consSitNFe_v2.01.xsd +10 -0
  356. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consSitNFe_v3.10.xsd +8 -8
  357. data/test/fixtures/product/schemas/consStatServ_v2.00.xsd +9 -0
  358. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consStatServ_v3.10.xsd +8 -8
  359. data/test/fixtures/product/schemas/distDFeInt_v1.00.xsd +71 -0
  360. data/test/fixtures/product/schemas/downloadNFe_v1.00.xsd +10 -0
  361. data/test/fixtures/product/schemas/e110110_v1.00.xsd +58 -0
  362. data/test/fixtures/product/schemas/e110111_v1.00.xsd +42 -0
  363. data/test/fixtures/product/schemas/e110140_v1.00.xsd +124 -0
  364. data/test/fixtures/product/schemas/e111500_v1.00.xsd +69 -0
  365. data/test/fixtures/product/schemas/e111501_v1.00.xsd +69 -0
  366. data/test/fixtures/product/schemas/e111502_v1.00.xsd +50 -0
  367. data/test/fixtures/product/schemas/e111503_v1.00.xsd +50 -0
  368. data/test/fixtures/product/schemas/e210200_v1.00.xsd +32 -0
  369. data/test/fixtures/product/schemas/e210210_v1.00.xsd +32 -0
  370. data/test/fixtures/product/schemas/e210220_v1.00.xsd +45 -0
  371. data/test/fixtures/product/schemas/e210240_v1.00.xsd +44 -0
  372. data/test/fixtures/product/schemas/e411500_v1.00.xsd +134 -0
  373. data/test/fixtures/product/schemas/e411501_v1.00.xsd +134 -0
  374. data/test/fixtures/product/schemas/e411502_v1.00.xsd +95 -0
  375. data/test/fixtures/product/schemas/e411503_v1.00.xsd +95 -0
  376. data/test/fixtures/product/schemas/e990900_v1.00.xsd +87 -0
  377. data/test/fixtures/product/schemas/e990910_v1.00.xsd +81 -0
  378. data/test/fixtures/product/schemas/envCCe_v1.00.xsd +10 -0
  379. data/test/fixtures/product/schemas/envCancelPProrrogNFe_v1.0.xsd +50 -0
  380. data/test/fixtures/product/schemas/envConfRecebto_v1.00.xsd +9 -0
  381. data/test/fixtures/product/schemas/envDPEC_v1.01.xsd +9 -0
  382. data/test/fixtures/product/schemas/envEPEC_v1.00.xsd +9 -0
  383. data/test/fixtures/product/schemas/envEventoCancNFe_v1.00.xsd +9 -0
  384. data/test/fixtures/product/schemas/envEvento_v1.00.xsd +9 -0
  385. data/test/fixtures/product/schemas/envFiscoNfe_v1.0.xsd +179 -0
  386. data/test/fixtures/product/schemas/envPProrrogNFe_v1.0.xsd +65 -0
  387. data/test/fixtures/product/schemas/envRemIndus_v1.00.xsd +9 -0
  388. data/test/fixtures/product/schemas/envSuframaInternaliza_v1.00.xsd +10 -0
  389. data/test/fixtures/product/schemas/envSuframaVistoria_v1.00.xsd +10 -0
  390. data/test/fixtures/product/schemas/enviNFe_v2.00.xsd +9 -0
  391. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/enviNFe_v3.10.xsd +8 -8
  392. data/test/fixtures/product/schemas/eventoCancNFe_v1.00.xsd +9 -0
  393. data/test/fixtures/product/schemas/eventoEPEC_v0.01.xsd +267 -0
  394. data/test/fixtures/product/schemas/eventoEPEC_v1.00.xsd +267 -0
  395. data/test/fixtures/product/schemas/eventoRemIndus_v1.00.xsd +9 -0
  396. data/test/fixtures/product/schemas/inutNFe_v2.00.xsd +9 -0
  397. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/inutNFe_v3.10.xsd +8 -8
  398. data/test/fixtures/product/schemas/leiauteCCe_v1.00.xsd +418 -0
  399. data/test/fixtures/product/schemas/leiauteCancNFe_v2.00.xsd +143 -0
  400. data/test/fixtures/product/schemas/leiauteConfRecebto_v1.00.xsd +406 -0
  401. data/test/fixtures/product/schemas/leiauteConsNFeDest_v1.01.xsd +483 -0
  402. data/test/fixtures/product/schemas/leiauteConsSitNFe_v2.01.xsd +548 -0
  403. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsSitNFe_v3.10.xsd +502 -502
  404. data/test/fixtures/product/schemas/leiauteConsStatServ_v2.00.xsd +98 -0
  405. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsStatServ_v3.10.xsd +97 -97
  406. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v1.01.xsd +355 -0
  407. data/test/fixtures/product/schemas/leiauteConsultaCadastro_v2.00.xsd +404 -0
  408. data/test/fixtures/product/schemas/leiauteDPEC_v1.01.xsd +464 -0
  409. data/test/fixtures/product/schemas/leiauteDownloadNFe_v1.00.xsd +149 -0
  410. data/test/fixtures/product/schemas/leiauteEPEC_v1.00.xsd +459 -0
  411. data/test/fixtures/product/schemas/leiauteEventoCancNFe_v1.00.xsd +394 -0
  412. data/test/fixtures/product/schemas/leiauteEvento_v1.00.xsd +373 -0
  413. data/test/fixtures/product/schemas/leiauteInutNFe_v2.00.xsd +193 -0
  414. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteInutNFe_v3.10.xsd +192 -192
  415. data/test/fixtures/product/schemas/leiauteNFe_v2.00.xsd +6661 -0
  416. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteNFe_v3.10.xsd +6060 -6060
  417. data/test/fixtures/product/schemas/leiauteRemIndus_v1.00.xsd +382 -0
  418. data/test/fixtures/product/schemas/leiauteSRE_v1.00.xsd +372 -0
  419. data/test/fixtures/product/schemas/leiauteSuframaInternaliza_v1.00.xsd +642 -0
  420. data/test/fixtures/product/schemas/leiauteSuframaVistoria_v1.00.xsd +648 -0
  421. data/test/fixtures/product/schemas/nfe_v2.00.xsd +9 -0
  422. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/nfe_v3.10.xsd +8 -8
  423. data/test/fixtures/product/schemas/procCCeNFe_v1.00.xsd +10 -0
  424. data/test/fixtures/product/schemas/procCancNFe_v2.00.xsd +9 -0
  425. data/test/fixtures/product/schemas/procConfRecebtoNFe_v1.00.xsd +9 -0
  426. data/test/fixtures/product/schemas/procEPEC_v1.00.xsd +9 -0
  427. data/test/fixtures/product/schemas/procEventoCancNFe_v1.00.xsd +9 -0
  428. data/test/fixtures/product/schemas/procEventoNFe_v1.00.xsd +9 -0
  429. data/test/fixtures/product/schemas/procEventoNFe_v99.99.xsd +37 -0
  430. data/test/fixtures/product/schemas/procInutNFe_v2.00.xsd +9 -0
  431. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procInutNFe_v3.10.xsd +8 -8
  432. data/test/fixtures/product/schemas/procNFe_v2.00.xsd +9 -0
  433. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procNFe_v3.10.xsd +8 -8
  434. data/test/fixtures/product/schemas/procRemIndus_v1.00.xsd +9 -0
  435. data/test/fixtures/product/schemas/resEvento_v1.00.xsd +94 -0
  436. data/test/fixtures/product/schemas/resNFe_v1.00.xsd +110 -0
  437. data/test/fixtures/product/schemas/retAtuCadEmiDFe_v1.01.xsd +9 -0
  438. data/test/fixtures/product/schemas/retCancNFe_v2.00.xsd +9 -0
  439. data/test/fixtures/product/schemas/retConsCad_v2.00.xsd +9 -0
  440. data/test/fixtures/product/schemas/retConsDPEC_v1.01.xsd +9 -0
  441. data/test/fixtures/product/schemas/retConsReciNFe_v2.00.xsd +9 -0
  442. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsReciNFe_v3.10.xsd +8 -8
  443. data/test/fixtures/product/schemas/retConsSitNFe_v2.01.xsd +10 -0
  444. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsSitNFe_v3.10.xsd +8 -8
  445. data/test/fixtures/product/schemas/retConsStatServ_v2.00.xsd +9 -0
  446. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsStatServ_v3.10.xsd +8 -8
  447. data/test/fixtures/product/schemas/retDPEC_v1.01.xsd +9 -0
  448. data/test/fixtures/product/schemas/retDistDFeInt_v1.00.xsd +84 -0
  449. data/test/fixtures/product/schemas/retDownloadNFe_v1.00.xsd +9 -0
  450. data/test/fixtures/product/schemas/retEnvCCe_v1.00.xsd +10 -0
  451. data/test/fixtures/product/schemas/retEnvCancelPProrrogNFe_v1.0.xsd +231 -0
  452. data/test/fixtures/product/schemas/retEnvConfRecebto_v1.00.xsd +9 -0
  453. data/test/fixtures/product/schemas/retEnvEPEC_v1.00.xsd +9 -0
  454. data/test/fixtures/product/schemas/retEnvEventoCancNFe_v1.00.xsd +9 -0
  455. data/test/fixtures/product/schemas/retEnvEvento_v1.00.xsd +9 -0
  456. data/test/fixtures/product/schemas/retEnvFiscoNFe_v1.0.xsd +234 -0
  457. data/test/fixtures/product/schemas/retEnvRemIndus_v1.00.xsd +9 -0
  458. data/test/fixtures/product/schemas/retEnvSuframaInternaliza_v1.00.xsd +9 -0
  459. data/test/fixtures/product/schemas/retEnvSuframaVistoria_v1.00.xsd +9 -0
  460. data/test/fixtures/product/schemas/retEnviNFe_v2.00.xsd +9 -0
  461. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retEnviNFe_v3.10.xsd +8 -8
  462. data/test/fixtures/product/schemas/retEventoEPEC_v0.01.xsd +207 -0
  463. data/test/fixtures/product/schemas/retInutNFe_v2.00.xsd +9 -0
  464. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retInutNFe_v3.10.xsd +8 -8
  465. data/test/fixtures/product/schemas/retPProrrogNFe_v1.0.xsd +233 -0
  466. data/test/fixtures/product/schemas/retconsNFeDest_v1.01.xsd +9 -0
  467. data/test/fixtures/product/schemas/tiposBasico_v1.03.xsd +816 -0
  468. data/test/fixtures/product/schemas/tiposBasico_v1.03_OPENSSL.xsd +816 -0
  469. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/tiposBasico_v3.10.xsd +571 -571
  470. data/test/fixtures/product/schemas/tiposBasico_v3.10_OPENSSL.xsd +877 -0
  471. data/test/fixtures/product/schemas/tiposDistDFe_v1.00.xsd +217 -0
  472. data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/xmldsig-core-schema_v1.01.xsd +97 -97
  473. data/test/fixtures/product/wsdl/NFeRetAutorizacao.xml +80 -0
  474. data/test/fixtures/product/wsdl/NfeAutorizacao.xml +107 -0
  475. data/test/fixtures/product/wsdl/NfeConsulta2.xml +80 -0
  476. data/test/fixtures/product/wsdl/NfeStatusServico2.xml +70 -0
  477. data/test/fixtures/product/wsdl/nfeinutilizacao2.xml +80 -0
  478. data/test/fixtures/service/wsdl/betha/v1/cancelar_nfse.xml +178 -0
  479. data/test/fixtures/service/wsdl/betha/v1/consultar_lote_rps.xml +339 -0
  480. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse.xml +348 -0
  481. data/test/fixtures/service/wsdl/betha/v1/consultar_nfse_por_rps.xml +365 -0
  482. data/test/fixtures/service/wsdl/betha/v1/consultar_situacao_lote_rps.xml +74 -0
  483. data/test/fixtures/service/wsdl/betha/v1/recepcionar_lote_rps.xml +299 -0
  484. data/test/fixtures/service/wsdl/simpliss/v1/nfseservice.xml +1 -0
  485. data/test/fixtures/service/wsdl/thema/v1/nfse_cancelamento.xml +82 -0
  486. data/test/fixtures/service/wsdl/thema/v1/nfse_consulta.xml +235 -0
  487. data/test/fixtures/service/wsdl/thema/v1/nfse_remessa.xml +185 -0
  488. data/test/test_helper.rb +369 -1
  489. metadata +711 -33
  490. data/lib/br_nfe/product/base.rb +0 -82
  491. data/lib/br_nfe/product/consulta_status_servico.rb +0 -35
  492. data/lib/br_nfe/product/value_nf.rb +0 -9
  493. data/lib/br_nfe/product/xml/v3_10/consulta_status_servico.xml.slim +0 -4
  494. data/test/br_nfe/product/base_test.rb +0 -150
  495. data/test/br_nfe/product/consulta_status_servico_test.rb +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d1320a14fd1cfd5849a39a3a44a214c94aa8e0f
4
- data.tar.gz: 25a0a4d8eea87e877f791e728ecc30b8cda3fe67
3
+ metadata.gz: f0e77a5cbdff4cafded676663364ef6f68055f3b
4
+ data.tar.gz: d0c49b3af3527a18a4d26c55659a69304cfdd11d
5
5
  SHA512:
6
- metadata.gz: de121c683a16f145d1f05309e1b24071339033ef0e7e5b5ac0600206ec4d79aead4c884ef3b8e9329c674747489a8ec24e945d88fb3edeebf13ed129f89e7b0a
7
- data.tar.gz: 2e48ba4c89749380ba4e63b74028b987581507c712983fad01550d74d610c109a4efbfaa1f99ba3305f6328ba197d4db25fd9111f16966b6789f59f1c0d03295
6
+ metadata.gz: 7977655fcf845fb598ec32104ba446c616de4373fd4e8e753b03fa40c046e939f32055ef0a89cbfccb5171c27c1a42107b9d366534f610a8570040e1ec7989e5
7
+ data.tar.gz: 288138b94569b0d53a03d6cf2fdcce21b765369ad01587fc56f9326c4ceba11aefb7b5887e2c2859f524b7eda0085870fa37196e642891373704ae6ffd9465f6
data/.gitignore CHANGED
@@ -2,5 +2,5 @@ coverage/
2
2
  .dropbox
3
3
  **/*.subl*
4
4
  **/*.~lock.*
5
- dev_load_data.rb
5
+ dev/*
6
6
  br_nfe*.gem
data/Gemfile CHANGED
@@ -13,4 +13,5 @@ group :test do
13
13
  gem 'shoulda-matchers', require: false
14
14
  gem "minitest-matchers_vaccine"
15
15
  gem 'simplecov'
16
+ gem 'webmock', require: false
16
17
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_nfe (2.1.1)
4
+ br_nfe (2.2.0)
5
5
  activemodel (~> 4)
6
6
  activesupport (~> 4)
7
7
  nokogiri (~> 1.6)
@@ -49,6 +49,7 @@ GEM
49
49
  minitest (~> 5.1)
50
50
  thread_safe (~> 0.3, >= 0.3.4)
51
51
  tzinfo (~> 1.1)
52
+ addressable (2.4.0)
52
53
  akami (1.3.1)
53
54
  gyoku (>= 0.4.0)
54
55
  nokogiri
@@ -58,6 +59,8 @@ GEM
58
59
  codeclimate-test-reporter (0.4.8)
59
60
  simplecov (>= 0.7.1, < 1.0.0)
60
61
  coderay (1.1.1)
62
+ crack (0.4.3)
63
+ safe_yaml (~> 1.0.0)
61
64
  docile (1.1.5)
62
65
  erubis (2.7.0)
63
66
  factory_girl (4.5.0)
@@ -69,6 +72,7 @@ GEM
69
72
  activesupport (>= 4.1.0)
70
73
  gyoku (1.3.1)
71
74
  builder (>= 2.1.2)
75
+ hashdiff (0.3.0)
72
76
  httpi (2.4.2)
73
77
  rack
74
78
  socksify
@@ -134,6 +138,7 @@ GEM
134
138
  thor (>= 0.18.1, < 2.0)
135
139
  rake (10.4.2)
136
140
  ruby-progressbar (1.7.5)
141
+ safe_yaml (1.0.4)
137
142
  savon (2.11.1)
138
143
  akami (~> 1.2)
139
144
  builder (>= 2.1.2)
@@ -154,7 +159,7 @@ GEM
154
159
  slim (3.0.7)
155
160
  temple (~> 0.7.6)
156
161
  tilt (>= 1.3.3, < 2.1)
157
- slim-rails (3.1.0)
162
+ slim-rails (3.1.1)
158
163
  actionpack (>= 3.1)
159
164
  railties (>= 3.1)
160
165
  slim (~> 3.0)
@@ -175,6 +180,10 @@ GEM
175
180
  wasabi (3.5.0)
176
181
  httpi (~> 2.0)
177
182
  nokogiri (>= 1.4.2)
183
+ webmock (2.1.0)
184
+ addressable (>= 2.3.6)
185
+ crack (>= 0.3.2)
186
+ hashdiff
178
187
 
179
188
  PLATFORMS
180
189
  ruby
@@ -191,6 +200,7 @@ DEPENDENCIES
191
200
  pry (~> 0.10)
192
201
  shoulda-matchers
193
202
  simplecov
203
+ webmock
194
204
 
195
205
  BUNDLED WITH
196
206
  1.11.2
data/README.markdown CHANGED
@@ -7,6 +7,8 @@ Gem para emissão de notas fiscais eletrônicas.
7
7
 
8
8
  Devido a falta de padronização dos parâmetros e a forma de envio e resposta na transmissão de Notas Fiscais de Serviços (NFS-e), esta gem vem com o objetivo de obter uma forma padronizada dessa tarefa, e assim, facilitando a vida de muitos desenvolvedores.
9
9
 
10
+ A Nota Fiscal eletrônica de produto está em desenvolvimento e pode ser acompanhada através da issue [#4](https://github.com/Brunomm/br_nfe/issues/4)
11
+
10
12
  **O que essa gem faz?**
11
13
 
12
14
  - Assina digitalmente a nota fiscal eletrônica.
@@ -231,7 +233,7 @@ Também é possível fazer o `merge` dos atributos através do método `assign_a
231
233
  telefone: '4933665577',
232
234
  email: 'emitente@mail.com',
233
235
  regime_especial_tributacao: '1',
234
- optante_simples_nacional: true,
236
+ codigo_regime_tributario: '1', # 1: Simples Nacional, 2: Simples Nacional(sublimite), 3: Reg. Normal
235
237
  incentivo_fiscal: false,
236
238
  endereco: @endereco
237
239
  })
data/Rakefile CHANGED
@@ -10,4 +10,23 @@ task :console do
10
10
  sh "irb -rubygems -I lib -r br_nfe.rb"
11
11
  end
12
12
 
13
- task :default => :test
13
+ task :default => :test
14
+
15
+ namespace :test do
16
+ desc "Test lib source"
17
+ Rake::TestTask.new(:product) do |t|
18
+ t.libs << "test"
19
+ t.pattern = 'test/br_nfe/product/**/*_test.rb'
20
+ t.verbose = true
21
+ end
22
+
23
+ end
24
+
25
+ namespace :test do
26
+ desc "Test lib source"
27
+ Rake::TestTask.new(:service) do |t|
28
+ t.libs << "test"
29
+ t.pattern = 'test/br_nfe/service/**/*_test.rb'
30
+ t.verbose = true
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ require 'br_nfe/active_model/has_many.rb'
2
+ require 'br_nfe/active_model/has_one.rb'
3
+ module BrNfe
4
+ module ActiveModel
5
+ module Associations
6
+ extend ActiveSupport::Concern
7
+ include HasMany
8
+ include HasOne
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ module BrNfe
2
+ module ActiveModel
3
+ module HasMany
4
+ extend ActiveSupport::Concern
5
+ module ClassMethods
6
+
7
+ # Método utilziado para definir uma associação 'has_many'.
8
+ # Parâmetros para configuração:
9
+ # 1° - Nome do atributo
10
+ # 2° - Class que será utilizada para que considere apenas objetos dessa classe
11
+ # Exemplo:
12
+ # class MyCustomClass
13
+ # include ::ActiveModel::Model
14
+ # include BrNfe::ActiveModel::Associations
15
+ #
16
+ # has_many :books, 'Book'
17
+ # end
18
+ #
19
+ def has_many attr_name, class_name_str, *args
20
+ options = {inverse_of: :reference}.merge(args.extract_options!)
21
+ attr_accessor attr_name
22
+ define_method attr_name do
23
+ arry = [instance_variable_get("@#{attr_name}")].flatten.reject(&:blank?)
24
+ arry_ok = arry.select{|v| v.is_a?(eval(class_name_str)) }
25
+ arry.select!{|v| v.is_a?(Hash) }
26
+ arry.map{ |hash| arry_ok.push(eval(class_name_str).new(hash)) }
27
+ add_reference_to_has_many(arry_ok, options[:inverse_of]) if options[:inverse_of]
28
+ instance_variable_set("@#{attr_name}", arry_ok)
29
+ instance_variable_get("@#{attr_name}")
30
+ end
31
+
32
+ define_method :add_reference_to_has_many do |collection, inverse_of|
33
+ collection.map{|obj| obj.send("#{inverse_of}=", self)}
34
+ end
35
+ end
36
+
37
+ def validate_has_many attr_name, *args
38
+ options = {
39
+ message: "invalid_#{attr_name.to_s.singularize}".to_sym
40
+ }.merge(args.extract_options!)
41
+ if options[:if]
42
+ validate "#{attr_name}_validations", if: options[:if]
43
+ elsif options[:unless]
44
+ validate "#{attr_name}_validations", unless: options[:unless]
45
+ else
46
+ validate "#{attr_name}_validations"
47
+ end
48
+
49
+ define_method "#{attr_name}_validations" do
50
+ send(attr_name).each_with_index do |obj, i|
51
+ index = if options[:index_attr] then obj.send(options[:index_attr]) else i+1 end
52
+ send("add_#{attr_name}_errors", obj, index) if obj.invalid?
53
+ end
54
+ end
55
+
56
+ define_method "add_#{attr_name}_errors" do |obj, index|
57
+ obj.errors.full_messages.each do |message|
58
+ errors.add(:base, options[:message], {index: index, error_message: message})
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,57 @@
1
+ module BrNfe
2
+ module ActiveModel
3
+ module HasOne
4
+ extend ActiveSupport::Concern
5
+ module ClassMethods
6
+ def has_one attr_name, class_name, *args
7
+ options = {null: true, inverse_of: :reference}.merge(args.extract_options!)
8
+
9
+ define_method attr_name do |&block|
10
+ block.call(send("#{attr_name}_force_instance")) if block
11
+ if instance_variable_get("@#{attr_name}").is_a?(eval(class_name))
12
+ instance_variable_get("@#{attr_name}").instance_variable_set("@#{options[:inverse_of]}", self) if instance_variable_get("@#{attr_name}").send(options[:inverse_of]).blank?
13
+ instance_variable_get("@#{attr_name}")
14
+ else
15
+ if options[:null] then nil else send("#{attr_name}_force_instance") end
16
+ end
17
+ end
18
+
19
+ define_method "#{attr_name}=" do |value|
20
+ if value.is_a?(eval(class_name))
21
+ instance_variable_set("@#{attr_name}", value)
22
+ elsif value.is_a?(Hash)
23
+ send("#{attr_name}_force_instance").assign_attributes(value)
24
+ elsif value.blank?
25
+ instance_variable_set("@#{attr_name}", nil)
26
+ end
27
+ end
28
+
29
+ define_method "#{attr_name}_force_instance" do
30
+ instance_variable_set("@#{attr_name}", eval(class_name).new) unless instance_variable_get("@#{attr_name}").is_a?(eval(class_name))
31
+ instance_variable_get("@#{attr_name}").instance_variable_set("@#{options[:inverse_of]}", self) if instance_variable_get("@#{attr_name}").send(options[:inverse_of]).blank?
32
+ instance_variable_get("@#{attr_name}")
33
+ end
34
+ end
35
+
36
+ def validate_has_one attr_name, *args
37
+ options = {message: "invalid_#{attr_name}".to_sym}
38
+ options.merge!(args.extract_options!)
39
+ if options[:if]
40
+ if options[:if].is_a?(Proc)
41
+ validate "#{attr_name}_validation", if: lambda{|rec| rec.send(attr_name) && options[:if].call(rec) }
42
+ else
43
+ validate "#{attr_name}_validation", if: lambda{|rec| rec.send(attr_name) && rec.send(options[:if]) }
44
+ end
45
+ else
46
+ validate "#{attr_name}_validation", if: attr_name
47
+ end
48
+ define_method "#{attr_name}_validation" do
49
+ if send(attr_name).invalid?
50
+ send(attr_name).errors.full_messages.each { |msg| errors.add(:base, options[:message], {error_message: msg}) }
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,6 +1,17 @@
1
1
  module BrNfe
2
2
  class ActiveModelBase
3
- include ActiveModel::Model
3
+ include ::ActiveModel::Model
4
+ include BrNfe::ActiveModel::Associations
5
+
6
+ # Utilizado para referenciar o objeto que utiliza a informação.
7
+ # Setado automaticamnete no has_one e has_many;
8
+ # Exemplo:
9
+ # ~$ endereco = Endereco.new
10
+ # ~$ pessoa = Pessoa.new(endereco: endereco)
11
+ # ~$ endereco.reference
12
+ # ~$ => pessoa
13
+ #
14
+ attr_accessor :reference
4
15
 
5
16
  def initialize(attributes = {})
6
17
  attributes = default_values.merge!(attributes)
@@ -59,5 +70,31 @@ module BrNfe
59
70
  xml.canonicalize(Nokogiri::XML::XML_C14N_EXCLUSIVE_1_0)
60
71
  end
61
72
 
73
+ def convert_to_time(value)
74
+ return if value.blank?
75
+ if value.class.in?([Time, DateTime])
76
+ value.to_time.in_time_zone
77
+ else
78
+ Time.zone ? Time.zone.parse(value.to_s) : Time.parse(value.to_s)
79
+ end
80
+ rescue
81
+ nil
82
+ end
83
+
84
+ def convert_to_date(value)
85
+ return if value.blank?
86
+ if value.is_a?(Date)
87
+ value
88
+ else
89
+ Date.parse(value.to_s)
90
+ end
91
+ rescue
92
+ nil
93
+ end
94
+
95
+ def convert_to_boolean(value)
96
+ BrNfe.true_values.include?(value)
97
+ end
98
+
62
99
  end
63
100
  end
data/lib/br_nfe/base.rb CHANGED
@@ -35,6 +35,10 @@ module BrNfe
35
35
  @env ||= :production
36
36
  end
37
37
 
38
+ def env_test?
39
+ env == :test
40
+ end
41
+
38
42
  def original_response
39
43
  @original_response
40
44
  end
@@ -49,6 +53,11 @@ module BrNfe
49
53
  :soapenv
50
54
  end
51
55
 
56
+ # Para saber se deve add o attr id na assinatura
57
+ def id_attribute?
58
+ true
59
+ end
60
+
52
61
  # Deve conter o LINK do webservice a ser chamado
53
62
  #
54
63
  def wsdl
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+ module BrNfe
3
+ module Calculos
4
+ # Classe responsável por multiplicar cada dígito pelos fatores de multiplicação passado como argumento.
5
+ #
6
+ # Imagine que temos o número <b>'2468'</b> e os fatores de multiplicação <b>[2, 1]</b>.
7
+ #
8
+ # Será calculado da seguinte maneira:
9
+ #
10
+ # 2 4 6 8
11
+ # * * * * ===> Multiplicação
12
+ # 1 2 1 2
13
+ #
14
+ # #=> [2, 8, 6, 16]
15
+ #
16
+ # Você pode passar outros fatores de multiplicação se você precisar.
17
+ # Por exemplo, dado o número '1234567890' e os fatores de multiplicação: <b>[2, 3, 4, 5, 6, 7, 8, 9]</b>.
18
+ # Será calculado da seguinte maneira:
19
+ #
20
+ # 1 2 3 4 5 6 7 8 9 0
21
+ # * * * * * * * * * *
22
+ # 3 2 9 8 7 6 5 4 3 2
23
+ #
24
+ # #=> [3, 4, 27, 32, 35, 36, 35, 32, 27, 0]
25
+ #
26
+ # @param [String] O número que será usado para multiplicar cada dígito.
27
+ # @param [Hash] Os fatores de multiplicação que irão ser calculados na ordem reversa.
28
+ #
29
+ # @example Calculo
30
+ #
31
+ # BrBoleto::Calculos::FatoresDeMultiplicacao.new(123, fatores: [2, 1])
32
+ # # => [1, 2, 6]
33
+ #
34
+ # BrBoleto::Calculos::FatoresDeMultiplicacao.new(123, fatores: [2, 3, 4, 5, 6, 7, 8, 9])
35
+ # # => [4, 6, 6]
36
+ #
37
+ # BrBoleto::Calculos::FatoresDeMultiplicacao.new(809070608090, fatores: [9, 8, 7, 6, 5, 4, 3, 2])
38
+ # # => [48, 0, 72, 0, 14, 0, 24, 0, 48, 0, 72, 0]
39
+ #
40
+ class FatoresDeMultiplicacao < Array
41
+ # @param [String || Integer] number
42
+ # @param [Hash] options
43
+ # @option options [Array] :fatores
44
+ # @return [Array]
45
+ # @example
46
+ #
47
+ # FatoresDeMultiplicacao.new(12, fatores: [2, 1])
48
+ # # => [1, 4]
49
+ #
50
+ # FatoresDeMultiplicacao.new(1864, fatores: [2, 3, 4, 5, 6, 7, 8, 9])
51
+ # # => [5, 32, 18, 8]
52
+ #
53
+ def initialize(number, options)
54
+ @number = number.to_s.reverse.split('')
55
+ @factors = options.fetch(:fatores).cycle.take(@number.size)
56
+ super(calculate)
57
+ end
58
+
59
+ # Para cada número realiza a multiplicação para cada dígito.
60
+ # @return [Array]
61
+ #
62
+ def calculate
63
+ @number.collect.each_with_index { |n, index| n.to_i * @factors[index] }.reverse
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,54 @@
1
+ module BrNfe
2
+ module Calculos
3
+ # Classe que possue a convenção de calculo do modulo 11.
4
+ # O que muda para cada classe é a forma de verificar o total do cálculo.
5
+ #
6
+ # @abstract Precisa implementar { #fatores, #calculate } nas subclasses.
7
+ #
8
+ class Modulo11 < String
9
+ # Número que será feito o cálculo do módulo 11.
10
+ #
11
+ attr_reader :number
12
+
13
+ # @param [String ou Integer] number (Corresponde ao número a ser calculado pelo Módulo 11)
14
+ # @return [String]
15
+ #
16
+ def initialize(number)
17
+ @number = number
18
+
19
+ super(calculate.to_s)
20
+ end
21
+
22
+ # @return [Array] Fatores que serão multiplicados por cada digito do
23
+ # número passado como argumento no initialize.
24
+ # @raise [NotImplementedError] Precisa implementar na subclasse
25
+ #
26
+ def fatores
27
+ raise NotImplementedError, "Not implemented #fatores in subclass."
28
+ end
29
+
30
+ # @return [Fixnum]
31
+ # @raise [NotImplementedError] Precisa implementar na subclasse
32
+ #
33
+ def calculate
34
+ raise NotImplementedError, "Not implemented #calculate in subclass."
35
+ end
36
+
37
+ # Realiza o cálculo retornando o resto da divisão do cálculo dos fatores por 11.
38
+ #
39
+ # @return [Fixnum] Resto da divisão por 11.
40
+ #
41
+ def mod_division
42
+ @mod_division ||= FatoresDeMultiplicacao.new(@number, fatores: fatores).sum % 11
43
+ end
44
+
45
+ # Subtrai 11 do resto da divisão para se ter o total do módulo 11.
46
+ #
47
+ # @return [Fixnum]
48
+ #
49
+ def total
50
+ @total ||= 11 - mod_division
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+ module BrNfe
3
+ module Calculos
4
+ # === Módulo 11 Fator de 2 a 9
5
+ #
6
+ # === Passos
7
+ #
8
+ # 1) Tomando-se os algarismos multiplique-os, iniciando-se da direita para a esquerda,
9
+ # pela seqüência numérica de 2 a 9 (2, 3, 4, 5, 6, 7, 8, 9 ... e assim por diante).
10
+ #
11
+ # 2) Some o resultado de cada produto efetuado e determine o total como (N).
12
+ #
13
+ # 3) Divida o total (N) por 11 e determine o resto obtido da divisão como Mod 11(N).
14
+ #
15
+ # 4) Calcule o dígito verificador (DAC) através da expressão:
16
+ #
17
+ # DIGIT = 11 - Mod 11 (n)
18
+ #
19
+ # <b>OBS.:</b> Se o resultado desta expressão for igual a 0, 1, 10 ou 11, considere DAC = 1.
20
+ #
21
+ # ==== Exemplo
22
+ #
23
+ # Considerando o seguinte número: '89234560'.
24
+ #
25
+ # 1) Multiplicando a seqüência de multiplicadores:
26
+ #
27
+ # 8 9 2 3 4 5 6 0
28
+ # * * * * * * * *
29
+ # 9 8 7 6 5 4 3 2
30
+ #
31
+ # 2) Soma-se o resultado dos produtos obtidos no item “1” acima:
32
+ #
33
+ # 72 + 72 + 14 + 18 + 20 + 20 + 18 + 0
34
+ # # => 234
35
+ #
36
+ # 3) Determina-se o resto da Divisão:
37
+ #
38
+ # 234 % 11
39
+ # # => 3
40
+ #
41
+ # 4) Calcula-se o DAC:
42
+ #
43
+ # 11 - 3
44
+ # # => 8 =============> Resultado final retornado.
45
+ #
46
+ # @param [String]: Corresponde ao número a ser calculado o Módulo 11 no fator de 2 a 9.
47
+ # @return [String] Retorna o resultado do cálculo descrito acima.
48
+ #
49
+ # @example
50
+ #
51
+ # BrBoleto::Calculos::Modulo11FatorDe2a9.new('1')
52
+ # # => '9'
53
+ #
54
+ # BrBoleto::Calculos::Modulo11FatorDe2a9.new('91')
55
+ # # => '4'
56
+ #
57
+ # BrBoleto::Calculos::Modulo11FatorDe2a9.new('189')
58
+ # # => '9'
59
+ #
60
+ class Modulo11FatorDe2a9 < Modulo11
61
+ # Sequência numérica de 2 a 9 que será feito a multiplicação de cada dígito
62
+ # do número passado no #initialize.
63
+ #
64
+ # @return [Array] Sequência numérica
65
+ #
66
+ def fatores
67
+ [2, 3, 4, 5, 6, 7, 8, 9]
68
+ end
69
+
70
+ # Calcula o número pelos fatores de multiplicação de 2 a 9.
71
+ # Depois calcula o resto da divisão por 11 e subtrai por 11.
72
+ # Se o resultado desse cálculo for igual a 0, 1, 10 ou 11, considere DAC = 1.
73
+ #
74
+ # @return [Fixnum]
75
+ #
76
+ def calculate
77
+ return 1 if total > 9
78
+
79
+ total
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,29 @@
1
+ module BrNfe
2
+ module Calculos
3
+ # Classe responsável por calcular o módulo 11 com fatores de 2 a 9.
4
+ # <b>Essa classe difere da outra com Modulo11FatorDe2a9, no momento de verificar o resto da divisão por 11.</b>
5
+ #
6
+ # <b>Para mais detalhes veja a classe Modulo11FatorDe2a9.</b>
7
+ #
8
+ class Modulo11FatorDe2a9RestoZero < Modulo11FatorDe2a9
9
+ # Realiza o cálculo do módulo 11 com fatores de 2 a 9.
10
+ #
11
+ # === Resto Da divisão por 11
12
+ #
13
+ # * Se o resto da divisão por 11 for igual a 10, o digito será '1' (um),
14
+ # * Se o resto da divisão por 11 for igual a 1 (um) ou 0 (zero) o digito será 0 (zero).
15
+ #
16
+ # Qualquer “RESTO” diferente de “0, 1 ou 10”, subtrair o resto de 11 para obter o digíto.
17
+ #
18
+ # @return [Fixnum] Resultado da subtração ou resultado da verificação do resto da divisão.
19
+ #
20
+ def calculate
21
+ if mod_division.equal?(1) or mod_division.equal?(0)
22
+ 0
23
+ else
24
+ total
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -28,6 +28,51 @@ module BrNfe
28
28
  '51', # Mato Grosso
29
29
  '52', # Goiás
30
30
  '53', # Distrito Federal
31
- ]
31
+ ]
32
+ SIGLAS_UF = [
33
+ 'AC', # Acre
34
+ 'AL', # Alagoas
35
+ 'AP', # Amapá
36
+ 'AM', # Amazonas
37
+ 'BA', # Bahia
38
+ 'CE', # Ceará
39
+ 'DF', # Distrito Federal
40
+ 'ES', # Espírito Santo
41
+ 'GO', # Goiás
42
+ 'MA', # Maranhão
43
+ 'MT', # Mato Grosso
44
+ 'MS', # Mato Grosso do Sul
45
+ 'MG', # Minas Gerais
46
+ 'PA', # Pará
47
+ 'PB', # Paraíba
48
+ 'PR', # Paraná
49
+ 'PE', # Pernambuco
50
+ 'PI', # Piauí
51
+ 'RJ', # Rio de Janeiro
52
+ 'RN', # Rio Grande do Norte
53
+ 'RS', # Rio Grande do Sul
54
+ 'RO', # Rondônia
55
+ 'RR', # Roraima
56
+ 'SC', # Santa Catarina
57
+ 'SP', # São Paulo
58
+ 'SE', # Sergipe
59
+ 'TO', # Tocantins
60
+ 'EX' # Exterior
61
+ ]
62
+
63
+ FORMAS_PAGAMENTO = [1, 2, 3, 4, 5, 10, 11, 12, 13, 99, '1', '2', '3', '4', '5', '01', '02', '03', '04', '05', '10', '11', '12', '13', '99']
64
+
65
+ NFE_STATUS_SUCCESS = %w[100 101 102 103 104 107 111 112 124 128 135 138 139 140 150 151]
66
+ NFE_STATUS_PROCESSING = %w[105]
67
+ NFE_STATUS_OFFLINE = %w[108 109]
68
+ NFE_STATUS_DENIED = %w[110 205 301 302 303]
69
+
70
+ NFE_SITUATION_AUTORIZED = %w[100 124 139 140 150]
71
+ NFE_SITUATION_ADJUSTED = %w[128 135 136]
72
+ NFE_SITUATION_CANCELED = %w[101 151 218]
73
+ NFE_SITUATION_DENIED = %w[110 205 301 302 303]
74
+ NFE_SITUATION_DRAFT = %w[105 106 108 109 137 142]
75
+
76
+
32
77
  end
33
78
  end
@@ -4,7 +4,7 @@ module BrNfe
4
4
  def default_values
5
5
  {
6
6
  codigo_pais: '1058',
7
- nome_pais: 'BRASIL'
7
+ nome_pais: 'BRASIL'
8
8
  }
9
9
  end
10
10
 
@@ -54,7 +54,11 @@ module BrNfe
54
54
  end
55
55
 
56
56
  def nome_pais
57
- "#{@nome_pais}".to_valid_format_nf
57
+ "#{@nome_pais}".to_valid_format_nf
58
+ end
59
+
60
+ def exterior?
61
+ codigo_pais.to_i != 1058
58
62
  end
59
63
  end
60
64
  end
@@ -15,7 +15,14 @@ module BrNfe
15
15
  end
16
16
 
17
17
  def cpf_ou_cnpj?
18
- sem_formatacao.size > 11 ? :cnpj : :cpf
18
+ case sem_formatacao.size
19
+ when 11
20
+ :cpf
21
+ when 14
22
+ :cnpj
23
+ else
24
+ :id_estrangeiro
25
+ end
19
26
  end
20
27
 
21
28
  def sem_formatacao