br_nfe 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.travis.yml +8 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +27 -3
- data/LICENSE +1 -1
- data/README.markdown +10 -12
- data/Rakefile +13 -0
- data/br_nfe.gemspec +18 -21
- data/lib/br_nfe/active_model_base.rb +7 -1
- data/lib/br_nfe/base.rb +175 -37
- data/lib/br_nfe/endereco.rb +7 -1
- data/lib/br_nfe/helper/have_rps.rb +1 -1
- data/lib/br_nfe/helper/values_ts/service_v1.rb +313 -0
- data/lib/br_nfe/response/service/build_response.rb +286 -0
- data/lib/br_nfe/response/service/default.rb +185 -0
- data/lib/br_nfe/{servico/response → response/service}/nota_fiscal.rb +11 -10
- data/lib/br_nfe/response/service/paths/base.rb +93 -0
- data/lib/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta.rb +22 -0
- data/lib/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta.rb +25 -0
- data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta.rb +25 -0
- data/lib/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta.rb +25 -0
- data/lib/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta.rb +31 -0
- data/lib/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta.rb +36 -0
- data/lib/br_nfe/response/service/paths/v1/tc_nfse.rb +127 -0
- data/lib/br_nfe/service/base.rb +59 -0
- data/lib/br_nfe/service/betha/base.rb +8 -0
- data/lib/br_nfe/service/betha/v1/cancelamento_nfs.rb +39 -0
- data/lib/br_nfe/service/betha/v1/consulta_lote_rps.rb +34 -0
- data/lib/br_nfe/service/betha/v1/consulta_nfs_por_rps.rb +32 -0
- data/lib/br_nfe/service/betha/v1/consulta_nfse.rb +32 -0
- data/lib/br_nfe/service/betha/v1/consulta_situacao_lote_rps.rb +30 -0
- data/lib/br_nfe/service/betha/v1/gateway.rb +21 -0
- data/lib/br_nfe/service/betha/v1/recepcao_lote_rps.rb +37 -0
- data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta.rb +19 -0
- data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta.rb +17 -0
- data/lib/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta.rb +17 -0
- data/lib/br_nfe/service/concerns/rules/cancelamento_nfs.rb +20 -0
- data/lib/br_nfe/service/concerns/rules/consulta_nfs_por_rps.rb +18 -0
- data/lib/br_nfe/service/concerns/rules/consulta_nfse.rb +29 -0
- data/lib/br_nfe/service/concerns/rules/recepcao_lote_rps.rb +50 -0
- data/lib/br_nfe/{servico → service}/intermediario.rb +1 -1
- data/lib/br_nfe/service/item.rb +70 -0
- data/lib/br_nfe/service/rps.rb +231 -0
- data/lib/br_nfe/service/sc/florianopolis/base.rb +25 -0
- data/lib/br_nfe/service/sc/florianopolis/cancellation.rb +30 -0
- data/lib/br_nfe/service/sc/florianopolis/emission_rps.rb +19 -0
- data/lib/br_nfe/service/sc/florianopolis/xml/_address.xml.slim +21 -0
- data/lib/br_nfe/service/sc/florianopolis/xml/_contact.xml.slim +3 -0
- data/lib/br_nfe/service/sc/florianopolis/xml/_service_item.xml.slim +9 -0
- data/lib/br_nfe/service/sc/florianopolis/xml/cancellation.xml.slim +6 -0
- data/lib/br_nfe/service/sc/florianopolis/xml/inf_requisicao.xml.slim +55 -0
- data/lib/br_nfe/service/sc/gaspar/cancela_nfse.rb +13 -0
- data/lib/br_nfe/service/sc/gaspar/consulta_lote_rps.rb +13 -0
- data/lib/br_nfe/service/sc/gaspar/consulta_nfs_por_rps.rb +13 -0
- data/lib/br_nfe/service/sc/gaspar/consulta_nfse.rb +17 -0
- data/lib/br_nfe/service/sc/gaspar/consulta_situacao_lote_rps.rb +13 -0
- data/lib/br_nfe/service/sc/gaspar/recepcao_lote_rps.rb +13 -0
- data/lib/br_nfe/service/sc/gaspar/recepcao_lote_rps_limitado.rb +13 -0
- data/lib/br_nfe/service/thema/v1/base.rb +55 -0
- data/lib/br_nfe/service/thema/v1/cancela_nfse.rb +48 -0
- data/lib/br_nfe/service/thema/v1/consulta_lote_rps.rb +49 -0
- data/lib/br_nfe/service/thema/v1/consulta_nfs_por_rps.rb +48 -0
- data/lib/br_nfe/service/thema/v1/consulta_nfse.rb +47 -0
- data/lib/br_nfe/service/thema/v1/consulta_situacao_lote_rps.rb +46 -0
- data/lib/br_nfe/service/thema/v1/recepcao_lote_rps.rb +51 -0
- data/lib/br_nfe/service/thema/v1/recepcao_lote_rps_limitado.rb +30 -0
- data/lib/br_nfe/service/xml/v1/_tc_contato.xml.slim +7 -0
- data/lib/br_nfe/service/xml/v1/_tc_cpf_cnpj.xml.slim +5 -0
- data/lib/br_nfe/service/xml/v1/_tc_dados_construcao_civil.xml.slim +2 -0
- data/lib/br_nfe/service/xml/v1/_tc_dados_prestador.xml.slim +15 -0
- data/lib/br_nfe/service/xml/v1/_tc_dados_servico.xml.slim +14 -0
- data/lib/br_nfe/service/xml/v1/_tc_dados_tomador.xml.slim +15 -0
- data/lib/br_nfe/service/xml/v1/_tc_endereco.xml.slim +13 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_intermediario_servico.xml.slim +7 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_nfse.xml.slim +7 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_orgao_gerador.xml.slim +8 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_prestador.xml.slim +3 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_rps.xml.slim +16 -0
- data/lib/br_nfe/service/xml/v1/_tc_identificacao_tomador.xml.slim +4 -0
- data/lib/br_nfe/service/xml/v1/_tc_inf_pedido_cancelamento.xml.slim +4 -0
- data/lib/br_nfe/service/xml/v1/_tc_inf_rps.xml.slim +47 -0
- data/lib/br_nfe/service/xml/v1/_tc_lote_rps.xml.slim +9 -0
- data/lib/br_nfe/service/xml/v1/_tc_pedido_cancelamento.xml.slim +4 -0
- data/lib/br_nfe/service/xml/v1/_tc_rps.xml.slim +8 -0
- data/lib/br_nfe/service/xml/v1/_tc_valores.xml.slim +48 -0
- data/lib/br_nfe/service/xml/v1/servico_cancelar_nfse_envio.xml.slim +9 -0
- data/lib/br_nfe/service/xml/v1/servico_consultar_lote_rps_envio.xml.slim +4 -0
- data/lib/br_nfe/service/xml/v1/servico_consultar_nfse_envio.xml.slim +19 -0
- data/lib/br_nfe/service/xml/v1/servico_consultar_nfse_rps_envio.xml.slim +5 -0
- data/lib/br_nfe/service/xml/v1/servico_consultar_situacao_lote_rps_envio.xml.slim +4 -0
- data/lib/br_nfe/service/xml/v1/servico_enviar_lote_rps_envio.xml.slim +9 -0
- data/lib/br_nfe/version.rb +2 -2
- data/lib/br_nfe/xml/_signed_info_sh1.xml.slim +9 -0
- data/lib/br_nfe/xml/signature_sh1.xml.slim +12 -0
- data/lib/br_nfe/xml/soap_env.xml.slim +3 -0
- data/lib/br_nfe.rb +72 -20
- data/test/br_nfe/base_test.rb +257 -108
- data/test/br_nfe/helper/have_intermediario_test.rb +2 -2
- data/test/br_nfe/helper/have_rps_test.rb +4 -4
- data/test/br_nfe/response/service/build_response_test.rb +377 -0
- data/test/br_nfe/response/service/default_test.rb +218 -0
- data/test/br_nfe/{servico/response → response/service}/nota_fiscal_test.rb +2 -2
- data/test/br_nfe/response/service/paths/base_test.rb +199 -0
- data/test/br_nfe/response/service/paths/v1/servico_cancelar_nfse_resposta_test.rb +25 -0
- data/test/br_nfe/response/service/paths/v1/servico_consultar_lote_rps_resposta_test.rb +30 -0
- data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_resposta_test.rb +30 -0
- data/test/br_nfe/response/service/paths/v1/servico_consultar_nfse_rps_resposta_test.rb +30 -0
- data/test/br_nfe/response/service/paths/v1/servico_consultar_situacao_lote_rps_resposta_test.rb +30 -0
- data/test/br_nfe/response/service/paths/v1/servico_enviar_lote_rps_resposta_test.rb +34 -0
- data/test/br_nfe/response/service/paths/v1/tc_nfse_test.rb +122 -0
- data/test/br_nfe/service/base_test.rb +138 -0
- data/test/br_nfe/service/betha/base_test.rb +9 -0
- data/test/br_nfe/service/betha/v1/cancelamento_nfs_test.rb +60 -0
- data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +55 -0
- data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +55 -0
- data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +53 -0
- data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +49 -0
- data/test/br_nfe/service/betha/v1/gateway_test.rb +35 -0
- data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +84 -0
- data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_lote_rps_resposta_test.rb +16 -0
- data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_resposta_test.rb +16 -0
- data/test/br_nfe/service/betha/v1/response_paths/servico_consultar_nfse_rps_resposta_test.rb +16 -0
- data/test/br_nfe/service/betha/v1/xsd/TiposNFe_v01.xsd +583 -0
- data/test/br_nfe/service/betha/v1/xsd/nfse_v01.xsd +652 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_cancelar_nfse_envio_v01.xsd +17 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_consultar_lote_rps_envio_v01.xsd +16 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_consultar_nfse_envio_v01.xsd +28 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_consultar_nfse_rps_envio_v01.xsd +16 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_consultar_situacao_lote_rps_envio_v01.xsd +16 -0
- data/test/br_nfe/service/betha/v1/xsd/servico_enviar_lote_rps_envio_v01.xsd +17 -0
- data/test/br_nfe/service/betha/v1/xsd/xmldsig-core-schema.xsd +308 -0
- data/test/br_nfe/service/betha/v1/xsd/xmldsig-core-schema_v01.xsd +95 -0
- data/test/br_nfe/service/concerns/rules/cancelamento_nfs_test.rb +15 -0
- data/test/br_nfe/service/concerns/rules/consulta_nfs_por_rps_test.rb +36 -0
- data/test/br_nfe/service/concerns/rules/consulta_nfse_test.rb +42 -0
- data/test/br_nfe/{servico/base_test.rb → service/concerns/rules/recepcao_lote_rps_test.rb} +12 -4
- data/test/br_nfe/{servico → service}/intermediario_test.rb +1 -1
- data/test/br_nfe/service/item_test.rb +34 -0
- data/test/br_nfe/{servico → service}/rps_test.rb +191 -43
- data/test/br_nfe/service/sc/florianopolis/XSD/TiposNFSe_v2.0.xsd +863 -0
- data/test/br_nfe/service/sc/florianopolis/XSD/xmldsig-core-schema.xsd +309 -0
- data/test/br_nfe/service/sc/florianopolis/base_test.rb +20 -0
- data/test/br_nfe/service/sc/florianopolis/cancellation_test.rb +36 -0
- data/test/br_nfe/service/sc/florianopolis/emission_rps_test.rb +145 -0
- data/test/br_nfe/service/sc/gaspar/cancela_nfse_test.rb +21 -0
- data/test/br_nfe/service/sc/gaspar/consulta_nfs_por_rps_test.rb +21 -0
- data/test/br_nfe/service/sc/gaspar/consulta_nfse_test.rb +21 -0
- data/test/br_nfe/service/sc/gaspar/consulta_situacao_lote_rps_test.rb +21 -0
- data/test/br_nfe/service/sc/gaspar/recepcao_lote_rps_limitado_test.rb +22 -0
- data/test/br_nfe/service/sc/gaspar/recepcao_lote_rps_test.rb +22 -0
- data/test/br_nfe/service/thema/v1/base_test.rb +65 -0
- data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +56 -0
- data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +47 -0
- data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +50 -0
- data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +50 -0
- data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +47 -0
- data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +62 -0
- data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test_limitado.rb +50 -0
- data/test/br_nfe/service/thema/v1/xsd/nfse.xsd +656 -0
- data/test/br_nfe/service/thema/v1/xsd/xmldsig-core-schema20020212.xsd +318 -0
- data/test/br_nfe/service/xsd/v1/nfse.xsd +779 -0
- data/test/br_nfe/service/xsd/v1/xmldsig-core-schema20020212.xsd +316 -0
- data/test/cert.pfx +0 -0
- data/test/factories/base.rb +2 -0
- data/test/factories/destinatario.rb +3 -3
- data/test/factories/response/service/build_response.rb +5 -0
- data/test/factories/response/service/default.rb +10 -0
- data/test/factories/{servico/response → response/service}/nota_fiscal.rb +9 -9
- data/test/factories/service/base.rb +6 -0
- data/test/factories/service/betha/base.rb +4 -0
- data/test/factories/service/betha/v1/cancelamento_nfs.rb +9 -0
- data/test/factories/{servico → service}/betha/v1/consulta_lote_rps.rb +2 -2
- data/test/factories/{servico → service}/betha/v1/consulta_nfs_por_rps.rb +1 -1
- data/test/factories/service/betha/v1/consulta_nfse.rb +8 -0
- data/test/factories/{servico → service}/betha/v1/consulta_situacao_lote_rps.rb +2 -2
- data/test/factories/{servico → service}/betha/v1/gateway.rb +1 -1
- data/test/factories/service/betha/v1/recepcao_lote_rps.rb +8 -0
- data/test/factories/{servico → service}/intermediario.rb +2 -2
- data/test/factories/service/item.rb +12 -0
- data/test/factories/service/rps.rb +50 -0
- data/test/factories/service/sc/florianopolis/base.rb +5 -0
- data/test/factories/service/sc/florianopolis/cancellation.rb +7 -0
- data/test/factories/service/sc/florianopolis/emission_rps.rb +7 -0
- data/test/factories/service/sc/gaspar/cancela_nfse.rb +9 -0
- data/test/factories/service/sc/gaspar/consulta_lote_rps.rb +7 -0
- data/test/factories/service/sc/gaspar/consulta_nfs_por_rps.rb +6 -0
- data/test/factories/service/sc/gaspar/consulta_nfse.rb +8 -0
- data/test/factories/service/sc/gaspar/consulta_situacao_lote_rps.rb +6 -0
- data/test/factories/service/sc/gaspar/recepcao_lote_rps.rb +9 -0
- data/test/factories/service/sc/gaspar/recepcao_lote_rps_limitado.rb +9 -0
- data/test/factories/service/thema/v1/base.rb +7 -0
- data/test/factories/service/thema/v1/cancela_nfse.rb +9 -0
- data/test/factories/service/thema/v1/consulta_lote_rps.rb +7 -0
- data/test/factories/service/thema/v1/consulta_nfs_por_rps.rb +6 -0
- data/test/factories/service/thema/v1/consulta_nfse.rb +8 -0
- data/test/factories/service/thema/v1/consulta_situacao_lote_rps.rb +6 -0
- data/test/factories/service/thema/v1/recepcao_lote_rps.rb +9 -0
- data/test/factories/service/thema/v1/recepcao_lote_rps_limitado.rb +8 -0
- data/test/test_helper.rb +42 -0
- metadata +338 -121
- data/lib/br_nfe/servico/base.rb +0 -35
- data/lib/br_nfe/servico/betha/base.rb +0 -85
- data/lib/br_nfe/servico/betha/build_response.rb +0 -141
- data/lib/br_nfe/servico/betha/v1/build_response.rb +0 -121
- data/lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb +0 -52
- data/lib/br_nfe/servico/betha/v1/consulta_lote_rps.rb +0 -33
- data/lib/br_nfe/servico/betha/v1/consulta_nfs_por_rps.rb +0 -37
- data/lib/br_nfe/servico/betha/v1/consulta_nfse.rb +0 -51
- data/lib/br_nfe/servico/betha/v1/consulta_situacao_lote_rps.rb +0 -18
- data/lib/br_nfe/servico/betha/v1/gateway.rb +0 -125
- data/lib/br_nfe/servico/betha/v1/recepcao_lote_rps.rb +0 -97
- data/lib/br_nfe/servico/betha/v2/build_response.rb +0 -159
- data/lib/br_nfe/servico/betha/v2/cancelamento_nfs.rb +0 -30
- data/lib/br_nfe/servico/betha/v2/consulta_lote_rps.rb +0 -30
- data/lib/br_nfe/servico/betha/v2/consulta_nfse_por_rps.rb +0 -27
- data/lib/br_nfe/servico/betha/v2/envio_lote_rps_sincrono.rb +0 -30
- data/lib/br_nfe/servico/betha/v2/gateway.rb +0 -230
- data/lib/br_nfe/servico/betha/v2/gera_nfse.rb +0 -30
- data/lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb +0 -52
- data/lib/br_nfe/servico/betha/v2/substituicao_nfse.rb +0 -43
- data/lib/br_nfe/servico/response/default.rb +0 -34
- data/lib/br_nfe/servico/rps.rb +0 -108
- data/test/br_nfe/servico/betha/base_test.rb +0 -135
- data/test/br_nfe/servico/betha/v1/build_response_test.rb +0 -557
- data/test/br_nfe/servico/betha/v1/cancelamento_nfs_test.rb +0 -72
- data/test/br_nfe/servico/betha/v1/consulta_lote_rps_test.rb +0 -46
- data/test/br_nfe/servico/betha/v1/consulta_nfs_por_rps_test.rb +0 -68
- data/test/br_nfe/servico/betha/v1/consulta_nfse_test.rb +0 -74
- data/test/br_nfe/servico/betha/v1/consulta_situacao_lote_rps_test.rb +0 -27
- data/test/br_nfe/servico/betha/v1/gateway_test.rb +0 -151
- data/test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb +0 -249
- data/test/br_nfe/servico/betha/v2/cancelamento_nfs_test.rb +0 -44
- data/test/br_nfe/servico/betha/v2/consulta_lote_rps_test.rb +0 -38
- data/test/br_nfe/servico/betha/v2/consulta_nfse_por_rps_test.rb +0 -36
- data/test/br_nfe/servico/betha/v2/envio_lote_rps_sincrono_test.rb +0 -51
- data/test/br_nfe/servico/betha/v2/gateway_test.rb +0 -372
- data/test/br_nfe/servico/betha/v2/gera_nfse_test.rb +0 -62
- data/test/br_nfe/servico/betha/v2/recepcao_lote_rps_test.rb +0 -108
- data/test/br_nfe/servico/betha/v2/substituicao_nfse_test.rb +0 -84
- data/test/br_nfe/servico/response/default_test.rb +0 -54
- data/test/factories/servico/base.rb +0 -5
- data/test/factories/servico/betha/base.rb +0 -5
- data/test/factories/servico/betha/v1/build_response.rb +0 -6
- data/test/factories/servico/betha/v1/cancelamento_nfs.rb +0 -7
- data/test/factories/servico/betha/v1/consulta_nfse.rb +0 -8
- data/test/factories/servico/betha/v1/recepcao_lote_rps.rb +0 -6
- data/test/factories/servico/betha/v2/cancelamento_nfs.rb +0 -7
- data/test/factories/servico/betha/v2/consulta_lote_rps.rb +0 -6
- data/test/factories/servico/betha/v2/consulta_nfse_por_rps.rb +0 -6
- data/test/factories/servico/betha/v2/envio_lote_rps_sincrono.rb +0 -5
- data/test/factories/servico/betha/v2/gateway.rb +0 -5
- data/test/factories/servico/betha/v2/gera_nfse.rb +0 -6
- data/test/factories/servico/betha/v2/recepcao_lote_rps.rb +0 -5
- data/test/factories/servico/betha/v2/substituicao_nfse.rb +0 -8
- data/test/factories/servico/response/default.rb +0 -10
- data/test/factories/servico/rps.rb +0 -44
@@ -1,34 +0,0 @@
|
|
1
|
-
module BrNfe
|
2
|
-
module Servico
|
3
|
-
module Response
|
4
|
-
class Default < BrNfe::ActiveModelBase
|
5
|
-
attr_accessor :success
|
6
|
-
attr_accessor :error_messages
|
7
|
-
attr_accessor :notas_fiscais
|
8
|
-
|
9
|
-
attr_accessor :protocolo
|
10
|
-
attr_accessor :data_recebimento
|
11
|
-
attr_accessor :numero_lote
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(attributes = {})
|
15
|
-
self.notas_fiscais = [] # Para poder utilizar o <<
|
16
|
-
self.error_messages = [] # Para poder utilizar o <<
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def notas_fiscais
|
21
|
-
@notas_fiscais = [@notas_fiscais].flatten # Para retornar sempre um vetor
|
22
|
-
end
|
23
|
-
|
24
|
-
def error_messages
|
25
|
-
@error_messages = [@error_messages].flatten
|
26
|
-
end
|
27
|
-
|
28
|
-
def success?
|
29
|
-
success
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/br_nfe/servico/rps.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
module BrNfe
|
2
|
-
module Servico
|
3
|
-
class Rps < BrNfe::ActiveModelBase
|
4
|
-
include BrNfe::Helper::HaveDestinatario
|
5
|
-
include BrNfe::Helper::HaveIntermediario
|
6
|
-
include BrNfe::Helper::HaveCondicaoPagamento
|
7
|
-
|
8
|
-
attr_accessor :validar_recepcao_rps
|
9
|
-
|
10
|
-
# Sempre que houver RPS, essas informações são obrigatórias
|
11
|
-
validates :numero, :serie, :tipo, presence: true
|
12
|
-
|
13
|
-
with_options if: :validar_recepcao_rps do |record|
|
14
|
-
record.validates :data_emissao, :item_lista_servico, :discriminacao, :codigo_municipio,
|
15
|
-
:valor_servicos, :base_calculo, presence: true
|
16
|
-
record.validates :valor_iss, :aliquota, presence: true, unless: :iss_retido?
|
17
|
-
record.validates :municipio_incidencia, presence: true, if: :municipio_incidencia_obrigatorio?
|
18
|
-
|
19
|
-
record.validates :valor_servicos, :valor_deducoes, :valor_pis, :valor_cofins, :valor_inss, :valor_ir,
|
20
|
-
:valor_csll, :outras_retencoes, :valor_iss, :aliquota, :base_calculo,
|
21
|
-
:desconto_incondicionado, :desconto_condicionado, numericality: true, allow_blank: true
|
22
|
-
|
23
|
-
record.validate :validar_intermediario
|
24
|
-
record.validate :validar_destinatario
|
25
|
-
end
|
26
|
-
|
27
|
-
attr_accessor :numero
|
28
|
-
attr_accessor :serie
|
29
|
-
attr_accessor :tipo
|
30
|
-
|
31
|
-
attr_accessor :data_emissao
|
32
|
-
attr_accessor :status
|
33
|
-
attr_accessor :competencia
|
34
|
-
|
35
|
-
attr_accessor :numero_substituicao
|
36
|
-
attr_accessor :serie_substituicao
|
37
|
-
attr_accessor :tipo_substituicao
|
38
|
-
|
39
|
-
#Para construção civil
|
40
|
-
attr_accessor :codigo_obra
|
41
|
-
attr_accessor :codigo_art
|
42
|
-
|
43
|
-
attr_accessor :valor_servicos
|
44
|
-
attr_accessor :valor_deducoes
|
45
|
-
attr_accessor :valor_pis
|
46
|
-
attr_accessor :valor_cofins
|
47
|
-
attr_accessor :valor_inss
|
48
|
-
attr_accessor :valor_ir
|
49
|
-
attr_accessor :valor_csll
|
50
|
-
attr_accessor :outras_retencoes
|
51
|
-
attr_accessor :iss_retido
|
52
|
-
attr_accessor :valor_iss
|
53
|
-
attr_accessor :aliquota
|
54
|
-
attr_accessor :base_calculo
|
55
|
-
attr_accessor :desconto_incondicionado
|
56
|
-
attr_accessor :desconto_condicionado
|
57
|
-
|
58
|
-
attr_accessor :responsavel_retencao
|
59
|
-
attr_accessor :item_lista_servico
|
60
|
-
attr_accessor :codigo_tributacao_municipio
|
61
|
-
attr_accessor :discriminacao
|
62
|
-
attr_accessor :exigibilidade_iss
|
63
|
-
attr_accessor :codigo_municipio
|
64
|
-
attr_accessor :municipio_incidencia
|
65
|
-
attr_accessor :codigo_pais
|
66
|
-
attr_accessor :numero_processo
|
67
|
-
attr_accessor :codigo_cnae
|
68
|
-
attr_accessor :outras_informacoes
|
69
|
-
|
70
|
-
def contem_substituicao?
|
71
|
-
numero_substituicao.present? && serie_substituicao.present? && tipo_substituicao.present?
|
72
|
-
end
|
73
|
-
|
74
|
-
def iss_retido?
|
75
|
-
BrNfe.true_values.include?(iss_retido)
|
76
|
-
end
|
77
|
-
|
78
|
-
def competencia
|
79
|
-
@competencia || data_emissao
|
80
|
-
end
|
81
|
-
|
82
|
-
def default_values
|
83
|
-
{
|
84
|
-
codigo_pais: '1058',
|
85
|
-
validar_recepcao_rps: false
|
86
|
-
}
|
87
|
-
end
|
88
|
-
private
|
89
|
-
|
90
|
-
def validar_intermediario
|
91
|
-
return true unless intermediario
|
92
|
-
if intermediario.invalid?
|
93
|
-
intermediario.errors.full_messages.map{|msg| errors.add(:base, "Intermediário: #{msg}") }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def validar_destinatario
|
98
|
-
if destinatario.invalid?
|
99
|
-
destinatario.errors.full_messages.map{|msg| errors.add(:base, "Destinatário: #{msg}") }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def municipio_incidencia_obrigatorio?
|
104
|
-
"#{exigibilidade_iss}".in?(['1','01','6','06','7','07'])
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe BrNfe::Servico::Betha::Base do
|
4
|
-
subject { FactoryGirl.build(:br_nfe_servico_betha_base) }
|
5
|
-
let(:rps) { FactoryGirl.build(:br_nfe_rps) }
|
6
|
-
let(:destinatario) { FactoryGirl.build(:destinatario) }
|
7
|
-
let(:endereco) { FactoryGirl.build(:endereco) }
|
8
|
-
|
9
|
-
describe "#xml_identificacao_rps" do
|
10
|
-
it "deve vir com a estrutura adecuada" do
|
11
|
-
xml = subject.send(:xml_identificacao_rps, rps).doc
|
12
|
-
|
13
|
-
xml.xpath('IdentificacaoRps/Numero').first.text.must_equal "#{rps.numero}"
|
14
|
-
xml.xpath('IdentificacaoRps/Serie').first.text.must_equal "#{rps.serie}"
|
15
|
-
xml.xpath('IdentificacaoRps/Tipo').first.text.must_equal "#{rps.tipo}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#xml_rps_substituido" do
|
20
|
-
before do
|
21
|
-
rps.numero_substituicao = 333
|
22
|
-
rps.serie_substituicao = 5
|
23
|
-
rps.tipo_substituicao = 9
|
24
|
-
end
|
25
|
-
it "deve vir com a estrutura adecuada" do
|
26
|
-
xml = subject.send(:xml_rps_substituido, rps).doc
|
27
|
-
|
28
|
-
xml.xpath('RpsSubstituido/Numero').first.text.must_equal "333"
|
29
|
-
xml.xpath('RpsSubstituido/Serie').first.text.must_equal "5"
|
30
|
-
xml.xpath('RpsSubstituido/Tipo').first.text.must_equal "9"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "se rps contem_substituicao deve retornar um html vazio" do
|
34
|
-
rps.expects(:contem_substituicao?).returns(false)
|
35
|
-
xml = subject.send(:xml_rps_substituido, rps).doc.root.to_s.must_equal ''
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#xml_endereco" do
|
40
|
-
before do
|
41
|
-
endereco.assign_attributes({
|
42
|
-
logradouro: 'á'.rjust(130, 'á'),
|
43
|
-
numero: '2'.rjust(100, '2'),
|
44
|
-
complemento: 'õ'.rjust(100, 'õ'),
|
45
|
-
bairro: 'ê'.rjust(100, 'ê'),
|
46
|
-
codigo_municipio: '123456789'.rjust(100, 'A'),
|
47
|
-
uf: 'ABCDE',
|
48
|
-
cep: '123-4567-89-60',
|
49
|
-
codigo_pais: '123456AAAA'
|
50
|
-
})
|
51
|
-
end
|
52
|
-
it "valores padroes" do
|
53
|
-
xml = subject.send(:xml_endereco, endereco).doc
|
54
|
-
xml.xpath('Endereco/Endereco').first.text.must_equal "A".rjust(125, 'A')
|
55
|
-
xml.xpath('Endereco/Numero').first.text.must_equal "2".rjust(10, '2')
|
56
|
-
xml.xpath('Endereco/Complemento').first.text.must_equal "O".rjust(60, 'O')
|
57
|
-
xml.xpath('Endereco/Bairro').first.text.must_equal "E".rjust(60, 'E')
|
58
|
-
xml.xpath('Endereco/CodigoMunicipio').first.text.must_equal "1234567"
|
59
|
-
xml.xpath('Endereco/Uf').first.text.must_equal "AB"
|
60
|
-
xml.xpath('Endereco/Cep').first.text.must_equal '12345678'
|
61
|
-
xml.xpath('Endereco/CodigoPais').first.must_be_nil
|
62
|
-
end
|
63
|
-
|
64
|
-
it "se for versao 1 e mandar o codigo_pais como true deve ignorar" do
|
65
|
-
subject.stubs(:version).returns(:v1)
|
66
|
-
xml = subject.send(:xml_endereco, endereco, true).doc
|
67
|
-
xml.xpath('Endereco/CodigoPais').first.must_be_nil
|
68
|
-
end
|
69
|
-
|
70
|
-
it "se for versao 2 e mandar o codigo_pais como true deve trazer junto o codigo do pais" do
|
71
|
-
subject.stubs(:version).returns(:v2)
|
72
|
-
xml = subject.send(:xml_endereco, endereco, true).doc
|
73
|
-
xml.xpath('Endereco/CodigoPais').first.text.must_equal '1234'
|
74
|
-
end
|
75
|
-
|
76
|
-
it "se for versao 2 e mandar o codigo_pais como false não deve trazer o codigo do pais" do
|
77
|
-
subject.stubs(:version).returns(:v2)
|
78
|
-
xml = subject.send(:xml_endereco, endereco, false).doc
|
79
|
-
xml.xpath('Endereco/CodigoPais').first.must_be_nil
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#xml_dados_tomador" do
|
84
|
-
it "Valores padrões indiferentemente da versao" do
|
85
|
-
xml = subject.send(:xml_dados_tomador, destinatario).doc
|
86
|
-
|
87
|
-
xml.xpath('Tomador/RazaoSocial').first.text.must_equal destinatario.razao_social
|
88
|
-
xml.xpath('Tomador/IdentificacaoTomador/CpfCnpj/Cpf').first.text.must_equal BrNfe::Helper::CpfCnpj.new(destinatario.cpf_cnpj).sem_formatacao
|
89
|
-
xml.xpath('Tomador/IdentificacaoTomador/InscricaoMunicipal').first.text.must_equal destinatario.inscricao_municipal
|
90
|
-
xml.xpath('Tomador/IdentificacaoTomador/InscricaoEstadual').first.must_be_nil
|
91
|
-
|
92
|
-
xml.xpath('Tomador/Endereco/Endereco').first.text.must_equal destinatario.endereco.logradouro
|
93
|
-
xml.xpath('Tomador/Endereco/Numero').first.text.must_equal destinatario.endereco.numero
|
94
|
-
xml.xpath('Tomador/Endereco/Complemento').first.text.must_equal destinatario.endereco.complemento
|
95
|
-
xml.xpath('Tomador/Endereco/Bairro').first.text.must_equal destinatario.endereco.bairro
|
96
|
-
xml.xpath('Tomador/Endereco/CodigoMunicipio').first.text.must_equal destinatario.endereco.codigo_municipio
|
97
|
-
xml.xpath('Tomador/Endereco/Uf').first.text.must_equal destinatario.endereco.uf
|
98
|
-
xml.xpath('Tomador/Endereco/Cep').first.text.must_equal destinatario.endereco.cep.gsub(/[^0-9]/,'')
|
99
|
-
xml.xpath('Tomador/Endereco/CodigoPais').first.must_be_nil
|
100
|
-
|
101
|
-
|
102
|
-
xml.xpath('Tomador/Contato/Telefone').first.text.must_equal destinatario.telefone
|
103
|
-
xml.xpath('Tomador/Contato/Email').first.text.must_equal destinatario.email
|
104
|
-
end
|
105
|
-
|
106
|
-
context "tags da versão 1" do
|
107
|
-
before do
|
108
|
-
subject.stubs(:version).returns(:v1)
|
109
|
-
end
|
110
|
-
it "inscricao_estadual" do
|
111
|
-
xml = subject.send(:xml_dados_tomador, destinatario).doc
|
112
|
-
xml.xpath('Tomador/IdentificacaoTomador/InscricaoEstadual').first.text.must_equal destinatario.inscricao_estadual
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "#xml_dados_construcao_civil" do
|
118
|
-
it "quando rps não tem codigo_obra" do
|
119
|
-
rps.assign_attributes(codigo_obra: '', codigo_art: '366')
|
120
|
-
xml = subject.send(:xml_dados_construcao_civil, rps).doc.root.to_s.must_equal ''
|
121
|
-
end
|
122
|
-
it "quando rps não tem codigo_art" do
|
123
|
-
rps.assign_attributes(codigo_obra: '13', codigo_art: '')
|
124
|
-
xml = subject.send(:xml_dados_construcao_civil, rps).doc.root.to_s.must_equal ''
|
125
|
-
end
|
126
|
-
|
127
|
-
it "quando rps tem codigo_art e codigo_obra" do
|
128
|
-
rps.assign_attributes(codigo_obra: '13', codigo_art: '555')
|
129
|
-
xml = subject.send(:xml_dados_construcao_civil, rps).doc
|
130
|
-
xml.xpath('ConstrucaoCivil/CodigoObra').first.text.must_equal '13'
|
131
|
-
xml.xpath('ConstrucaoCivil/Art').first.text.must_equal '555'
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
@@ -1,557 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe BrNfe::Servico::Betha::V1::BuildResponse do
|
4
|
-
subject { FactoryGirl.build(:betha_v1_build_response) }
|
5
|
-
|
6
|
-
describe "#messages" do
|
7
|
-
it "deve retornar o resultado da key do hash conforme o atributo nfe_method com _resposta no fim" do
|
8
|
-
subject.nfe_method = :algo
|
9
|
-
subject.hash = {algo_resposta: {valor_a: 1}}
|
10
|
-
subject.messages.must_equal({valor_a: 1})
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#success?" do
|
15
|
-
it "deve ser true quanto não tem mensagem de retorno" do
|
16
|
-
subject.stubs(:error_messages).returns([])
|
17
|
-
subject.success?.must_equal true
|
18
|
-
end
|
19
|
-
|
20
|
-
it "deve ser false quanto tem alguma mensagem de retorno" do
|
21
|
-
subject.stubs(:error_messages).returns([{codigo: '1'}])
|
22
|
-
subject.success?.must_equal false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#error_messages" do
|
27
|
-
before do
|
28
|
-
subject.nfe_method = :key
|
29
|
-
subject.hash = {key_resposta: {
|
30
|
-
lista_mensagem_retorno: {mensagem_retorno: {
|
31
|
-
codigo: "999",
|
32
|
-
mensagem: "A mensagem",
|
33
|
-
correcao: "A correcao"
|
34
|
-
}}
|
35
|
-
}}
|
36
|
-
end
|
37
|
-
it "se ja tem valor na variavel @error_messages deve retornar o conteudo da variavel" do
|
38
|
-
subject.instance_variable_set(:@error_messages, [123])
|
39
|
-
subject.error_messages.must_equal([123])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "deve retornar um vetor com um hash com as mensagens quando houver apenas 1 mensagem em um hash" do
|
43
|
-
subject.error_messages.size.must_equal 1
|
44
|
-
subject.error_messages.class.must_equal Array
|
45
|
-
|
46
|
-
subject.error_messages[0][:codigo].must_equal '999'
|
47
|
-
subject.error_messages[0][:mensagem].must_equal 'A mensagem'
|
48
|
-
subject.error_messages[0][:correcao].must_equal 'A correcao'
|
49
|
-
end
|
50
|
-
|
51
|
-
it "deve retornar todas as mensagens quando houver mais que uma" do
|
52
|
-
subject.hash = {key_resposta: {
|
53
|
-
lista_mensagem_retorno: {mensagem_retorno: [
|
54
|
-
{codigo: "111", mensagem: "A mensagem 1", correcao: "A correcao 1"},
|
55
|
-
{codigo: "222", mensagem: "A mensagem 2", correcao: "A correcao 2"},
|
56
|
-
]}
|
57
|
-
}}
|
58
|
-
|
59
|
-
subject.error_messages[0][:codigo].must_equal '111'
|
60
|
-
subject.error_messages[0][:mensagem].must_equal 'A mensagem 1'
|
61
|
-
subject.error_messages[0][:correcao].must_equal 'A correcao 1'
|
62
|
-
|
63
|
-
subject.error_messages[1][:codigo].must_equal '222'
|
64
|
-
subject.error_messages[1][:mensagem].must_equal 'A mensagem 2'
|
65
|
-
subject.error_messages[1][:correcao].must_equal 'A correcao 2'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
describe "#response" do
|
71
|
-
context "deve instanciar um objeto Response Default" do
|
72
|
-
it "com o hash completo" do
|
73
|
-
subject.nfe_method = :key
|
74
|
-
subject.hash ={ key_resposta: hash_resposta_completa}
|
75
|
-
|
76
|
-
response = subject.response
|
77
|
-
response.success.must_equal false
|
78
|
-
response.error_messages.size.must_equal 2
|
79
|
-
response.error_messages[0][:codigo].must_equal '111'
|
80
|
-
response.error_messages[0][:mensagem].must_equal 'Msg 1'
|
81
|
-
response.error_messages[0][:correcao].must_equal 'corr 1'
|
82
|
-
response.error_messages[1][:codigo].must_equal '222'
|
83
|
-
response.error_messages[1][:mensagem].must_equal 'Msg 2'
|
84
|
-
response.error_messages[1][:correcao].must_equal 'corr 2'
|
85
|
-
|
86
|
-
response.numero_lote.must_equal "333332"
|
87
|
-
response.protocolo.must_equal "5566633548"
|
88
|
-
response.data_recebimento.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
89
|
-
|
90
|
-
response.notas_fiscais.size.must_equal 1
|
91
|
-
nota_fiscal = response.notas_fiscais.first
|
92
|
-
|
93
|
-
nota_fiscal.numero_nf.must_equal "1111"
|
94
|
-
nota_fiscal.codigo_verificacao.must_equal "ASDAD"
|
95
|
-
nota_fiscal.data_emissao.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
96
|
-
nota_fiscal.rps_numero.must_equal "11111"
|
97
|
-
nota_fiscal.rps_serie.must_equal "SN"
|
98
|
-
nota_fiscal.rps_tipo.must_equal "1"
|
99
|
-
nota_fiscal.rps_situacao.must_be_nil
|
100
|
-
nota_fiscal.data_emissao_rps.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300")
|
101
|
-
nota_fiscal.competencia.must_equal DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300")
|
102
|
-
nota_fiscal.outras_informacoes.must_equal "http://e-gov.betha.com.br/e-nota"
|
103
|
-
nota_fiscal.url_nf.must_equal "http://e-gov.betha.com.br/e-nota"
|
104
|
-
nota_fiscal.item_lista_servico.must_equal "111"
|
105
|
-
nota_fiscal.codigo_cnae.must_equal "6202300"
|
106
|
-
nota_fiscal.discriminacao.must_equal "discriminacao"
|
107
|
-
nota_fiscal.codigo_municipio.must_equal "4204202"
|
108
|
-
nota_fiscal.valor_servicos.must_equal "111"
|
109
|
-
nota_fiscal.valor_deducoes.must_equal "0"
|
110
|
-
nota_fiscal.valor_pis.must_equal "0.00"
|
111
|
-
nota_fiscal.valor_cofins.must_equal "0.00"
|
112
|
-
nota_fiscal.valor_inss.must_equal "0.00"
|
113
|
-
nota_fiscal.valor_ir.must_equal "0.00"
|
114
|
-
nota_fiscal.valor_csll.must_equal "0.00"
|
115
|
-
nota_fiscal.iss_retido.must_equal "2"
|
116
|
-
nota_fiscal.valor_iss.must_equal "0"
|
117
|
-
nota_fiscal.base_calculo.must_equal "111"
|
118
|
-
nota_fiscal.aliquota.must_equal "1.0000"
|
119
|
-
nota_fiscal.desconto_condicionado.must_equal "desconto_condicionado"
|
120
|
-
nota_fiscal.desconto_incondicionado.must_equal "desconto_incondicionado"
|
121
|
-
nota_fiscal.orgao_gerador_municipio.must_equal "0"
|
122
|
-
nota_fiscal.orgao_gerador_uf.must_equal "SC"
|
123
|
-
nota_fiscal.cancelamento_codigo.must_equal "123"
|
124
|
-
nota_fiscal.cancelamento_numero_nf.must_equal "123"
|
125
|
-
nota_fiscal.cancelamento_cnpj.must_equal "12345678901234"
|
126
|
-
nota_fiscal.cancelamento_inscricao_municipal.must_equal "INSCRICAO CANCELAMENTO"
|
127
|
-
nota_fiscal.cancelamento_municipio.must_equal "99999999"
|
128
|
-
nota_fiscal.cancelamento_sucesso.must_equal true
|
129
|
-
nota_fiscal.cancelamento_data_hora.must_equal DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
130
|
-
nota_fiscal.nfe_substituidora.must_equal "663322"
|
131
|
-
nota_fiscal.codigo_obra.must_equal "3333"
|
132
|
-
nota_fiscal.codigo_art.must_equal "4444"
|
133
|
-
|
134
|
-
#Intermediario
|
135
|
-
nota_fiscal.intermediario.razao_social.must_equal "RAZAO_SOCIAL INTERMEDIARIO"
|
136
|
-
nota_fiscal.intermediario.cpf_cnpj.must_equal "cpf intermediario"
|
137
|
-
nota_fiscal.intermediario.inscricao_municipal.must_equal "inscricao_municipal intermediario"
|
138
|
-
|
139
|
-
# Emitente / prestador
|
140
|
-
nota_fiscal.emitente.cnpj.must_equal "18113831000135"
|
141
|
-
nota_fiscal.emitente.inscricao_municipal.must_equal "inscricao_municipal prestador"
|
142
|
-
nota_fiscal.emitente.razao_social.must_equal "EMPRESA NACIONAL LTDA - ME"
|
143
|
-
nota_fiscal.emitente.nome_fantasia.must_equal "EMPRESA NACIONAL"
|
144
|
-
nota_fiscal.emitente.telefone.must_equal "123456"
|
145
|
-
nota_fiscal.emitente.email.must_equal "email@prestador"
|
146
|
-
nota_fiscal.emitente.regime_especial_tributacao.must_be_nil
|
147
|
-
nota_fiscal.emitente.optante_simples_nacional.must_equal "emitente optante_simples_nacional"
|
148
|
-
nota_fiscal.emitente.incentivo_fiscal.must_be_nil
|
149
|
-
nota_fiscal.emitente.natureza_operacao.must_equal "1"
|
150
|
-
|
151
|
-
# Destinatario / Tomador
|
152
|
-
nota_fiscal.destinatario.cpf_cnpj.must_equal "12345678901"
|
153
|
-
nota_fiscal.destinatario.inscricao_estadual.must_equal "tomador inscricao_estadual"
|
154
|
-
nota_fiscal.destinatario.inscricao_municipal.must_equal "tomador inscricao_municipal"
|
155
|
-
nota_fiscal.destinatario.razao_social.must_equal "TOMADOR SERVICO"
|
156
|
-
nota_fiscal.destinatario.telefone.must_equal "336644557"
|
157
|
-
nota_fiscal.destinatario.email.must_equal "mail@prestador.com"
|
158
|
-
end
|
159
|
-
|
160
|
-
it "com o hash parcial e mais de uma nota" do
|
161
|
-
subject.nfe_method = :key
|
162
|
-
subject.hash ={ key_resposta: hash_resposta_parcial}
|
163
|
-
|
164
|
-
response = subject.response
|
165
|
-
response.success.must_equal true
|
166
|
-
response.error_messages.size.must_equal 0
|
167
|
-
|
168
|
-
response.numero_lote.must_be_nil
|
169
|
-
response.protocolo.must_be_nil
|
170
|
-
response.data_recebimento.must_be_nil
|
171
|
-
|
172
|
-
response.notas_fiscais.size.must_equal 2
|
173
|
-
nota_fiscal_1 = response.notas_fiscais.first
|
174
|
-
nota_fiscal_2 = response.notas_fiscais.last
|
175
|
-
|
176
|
-
nota_fiscal_1.numero_nf.must_equal "1111"
|
177
|
-
nota_fiscal_1.codigo_verificacao.must_equal "ASDAD"
|
178
|
-
nota_fiscal_1.data_emissao.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
179
|
-
nota_fiscal_1.rps_numero.must_equal "11111"
|
180
|
-
nota_fiscal_1.rps_serie.must_equal "SN"
|
181
|
-
nota_fiscal_1.rps_tipo.must_equal "1"
|
182
|
-
nota_fiscal_1.rps_situacao.must_be_nil
|
183
|
-
nota_fiscal_1.data_emissao_rps.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300")
|
184
|
-
nota_fiscal_1.competencia.must_equal DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300")
|
185
|
-
nota_fiscal_1.outras_informacoes.must_equal "http://e-gov.betha.com.br/e-nota"
|
186
|
-
nota_fiscal_1.url_nf.must_equal "http://e-gov.betha.com.br/e-nota"
|
187
|
-
nota_fiscal_1.item_lista_servico.must_equal "111"
|
188
|
-
nota_fiscal_1.codigo_cnae.must_equal "6202300"
|
189
|
-
nota_fiscal_1.discriminacao.must_equal "discriminacao"
|
190
|
-
nota_fiscal_1.codigo_municipio.must_equal "4204202"
|
191
|
-
nota_fiscal_1.valor_servicos.must_equal "111"
|
192
|
-
nota_fiscal_1.valor_deducoes.must_equal "0"
|
193
|
-
nota_fiscal_1.valor_pis.must_equal "0.00"
|
194
|
-
nota_fiscal_1.valor_cofins.must_equal "0.00"
|
195
|
-
nota_fiscal_1.valor_inss.must_equal "0.00"
|
196
|
-
nota_fiscal_1.valor_ir.must_equal "0.00"
|
197
|
-
nota_fiscal_1.valor_csll.must_equal "0.00"
|
198
|
-
nota_fiscal_1.iss_retido.must_equal "2"
|
199
|
-
nota_fiscal_1.valor_iss.must_equal "0"
|
200
|
-
nota_fiscal_1.base_calculo.must_equal "111"
|
201
|
-
nota_fiscal_1.aliquota.must_equal "1.0000"
|
202
|
-
nota_fiscal_1.desconto_condicionado.must_equal "desconto_condicionado"
|
203
|
-
nota_fiscal_1.desconto_incondicionado.must_equal "desconto_incondicionado"
|
204
|
-
nota_fiscal_1.orgao_gerador_municipio.must_equal "0"
|
205
|
-
nota_fiscal_1.orgao_gerador_uf.must_equal "SC"
|
206
|
-
nota_fiscal_1.cancelamento_codigo.must_equal "123"
|
207
|
-
nota_fiscal_1.cancelamento_numero_nf.must_equal "123"
|
208
|
-
nota_fiscal_1.cancelamento_cnpj.must_equal "12345678901234"
|
209
|
-
nota_fiscal_1.cancelamento_inscricao_municipal.must_equal "INSCRICAO CANCELAMENTO"
|
210
|
-
nota_fiscal_1.cancelamento_municipio.must_equal "99999999"
|
211
|
-
nota_fiscal_1.cancelamento_sucesso.must_equal true
|
212
|
-
nota_fiscal_1.cancelamento_data_hora.must_equal DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
213
|
-
nota_fiscal_1.nfe_substituidora.must_equal "663322"
|
214
|
-
nota_fiscal_1.codigo_obra.must_equal "3333"
|
215
|
-
nota_fiscal_1.codigo_art.must_equal "4444"
|
216
|
-
|
217
|
-
nota_fiscal_2.numero_nf.must_equal "NOTA2 numero_nf"
|
218
|
-
nota_fiscal_2.codigo_verificacao.must_equal "NOTA2 codigo_verificacao"
|
219
|
-
nota_fiscal_2.data_emissao.must_equal "NOTA2 data_emissao"
|
220
|
-
nota_fiscal_2.rps_numero.must_equal "NOTA2 rps_numero"
|
221
|
-
nota_fiscal_2.rps_serie.must_equal "NOTA2 rps_serie"
|
222
|
-
nota_fiscal_2.rps_tipo.must_equal "NOTA2 rps_tipo"
|
223
|
-
nota_fiscal_2.data_emissao_rps.must_equal "NOTA2 data_emissao_rps"
|
224
|
-
nota_fiscal_2.competencia.must_equal "NOTA2 competencia"
|
225
|
-
nota_fiscal_2.outras_informacoes.must_equal "NOTA2 outras_informacoes"
|
226
|
-
nota_fiscal_2.url_nf.must_equal "NOTA2 outras_informacoes"
|
227
|
-
nota_fiscal_2.item_lista_servico.must_equal "NOTA2 item_lista_servico"
|
228
|
-
nota_fiscal_2.discriminacao.must_equal "NOTA2 discriminacao"
|
229
|
-
nota_fiscal_2.codigo_municipio.must_equal "NOTA2 codigo_municipio"
|
230
|
-
nota_fiscal_2.valor_servicos.must_equal "NOTA2 valor_servicos"
|
231
|
-
nota_fiscal_2.base_calculo.must_equal "NOTA2 base_calculo"
|
232
|
-
nota_fiscal_2.aliquota.must_equal "NOTA2 aliquota"
|
233
|
-
nota_fiscal_2.codigo_cnae.must_be_nil
|
234
|
-
nota_fiscal_2.valor_deducoes.must_be_nil
|
235
|
-
nota_fiscal_2.valor_pis.must_be_nil
|
236
|
-
nota_fiscal_2.valor_cofins.must_be_nil
|
237
|
-
nota_fiscal_2.valor_inss.must_be_nil
|
238
|
-
nota_fiscal_2.valor_ir.must_be_nil
|
239
|
-
nota_fiscal_2.valor_csll.must_be_nil
|
240
|
-
nota_fiscal_2.iss_retido.must_be_nil
|
241
|
-
nota_fiscal_2.valor_iss.must_be_nil
|
242
|
-
nota_fiscal_2.desconto_condicionado.must_be_nil
|
243
|
-
nota_fiscal_2.desconto_incondicionado.must_be_nil
|
244
|
-
nota_fiscal_2.orgao_gerador_municipio.must_be_nil
|
245
|
-
nota_fiscal_2.orgao_gerador_uf.must_be_nil
|
246
|
-
nota_fiscal_2.cancelamento_codigo.must_be_nil
|
247
|
-
nota_fiscal_2.cancelamento_numero_nf.must_be_nil
|
248
|
-
nota_fiscal_2.cancelamento_cnpj.must_be_nil
|
249
|
-
nota_fiscal_2.cancelamento_inscricao_municipal.must_be_nil
|
250
|
-
nota_fiscal_2.cancelamento_municipio.must_be_nil
|
251
|
-
nota_fiscal_2.cancelamento_sucesso.must_be_nil
|
252
|
-
nota_fiscal_2.cancelamento_data_hora.must_be_nil
|
253
|
-
nota_fiscal_2.nfe_substituidora.must_be_nil
|
254
|
-
nota_fiscal_2.codigo_obra.must_be_nil
|
255
|
-
nota_fiscal_2.codigo_art.must_be_nil
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
|
262
|
-
def hash_resposta_completa
|
263
|
-
{
|
264
|
-
protocolo: "5566633548",
|
265
|
-
data_recebimento: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
266
|
-
numero_lote: '333332',
|
267
|
-
lista_nfse: {
|
268
|
-
compl_nfse: {
|
269
|
-
nfse: {
|
270
|
-
inf_nfse: {
|
271
|
-
numero: "1111",
|
272
|
-
codigo_verificacao: "ASDAD",
|
273
|
-
data_emissao: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
274
|
-
identificacao_rps: {
|
275
|
-
numero: "11111",
|
276
|
-
serie: "SN",
|
277
|
-
tipo: "1"
|
278
|
-
},
|
279
|
-
data_emissao_rps: DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300"),
|
280
|
-
natureza_operacao: "1",
|
281
|
-
optante_simples_nacional: "emitente optante_simples_nacional",
|
282
|
-
competencia: DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300"),
|
283
|
-
outras_informacoes: "http://e-gov.betha.com.br/e-nota",
|
284
|
-
servico: {
|
285
|
-
valores: {
|
286
|
-
valor_servicos: "111",
|
287
|
-
valor_deducoes: "0",
|
288
|
-
valor_pis: "0.00",
|
289
|
-
valor_cofins: "0.00",
|
290
|
-
valor_inss: "0.00",
|
291
|
-
valor_ir: "0.00",
|
292
|
-
valor_csll: "0.00",
|
293
|
-
iss_retido: "2",
|
294
|
-
valor_iss: "0",
|
295
|
-
base_calculo: "111",
|
296
|
-
aliquota: "1.0000",
|
297
|
-
desconto_condicionado: "desconto_condicionado",
|
298
|
-
desconto_incondicionado: "desconto_incondicionado"
|
299
|
-
},
|
300
|
-
item_lista_servico: "111",
|
301
|
-
codigo_cnae: "6202300",
|
302
|
-
discriminacao: "discriminacao",
|
303
|
-
codigo_municipio: "4204202"
|
304
|
-
},
|
305
|
-
intermediario_servico: {
|
306
|
-
razao_social: "razao_social intermediario",
|
307
|
-
cpf_cnpj: {cpf: 'cpf intermediario'},
|
308
|
-
inscricao_municipal: "inscricao_municipal intermediario"
|
309
|
-
|
310
|
-
},
|
311
|
-
prestador_servico: {
|
312
|
-
identificacao_prestador: {
|
313
|
-
cnpj: "18113831000135",
|
314
|
-
inscricao_municipal: "inscricao_municipal prestador",
|
315
|
-
},
|
316
|
-
razao_social: "EMPRESA NACIONAL LTDA - ME",
|
317
|
-
nome_fantasia: "EMPRESA NACIONAL",
|
318
|
-
endereco: {
|
319
|
-
endereco: "RUA PRESTADOR",
|
320
|
-
numero: "111",
|
321
|
-
complemento: "COMPLEMENTO PRESTADOR",
|
322
|
-
bairro: "BAIRRO PRESTADOR",
|
323
|
-
codigo_municipio: "4204202",
|
324
|
-
uf: "SC",
|
325
|
-
cep: "89805675"
|
326
|
-
},
|
327
|
-
contato: {
|
328
|
-
telefone: "123456",
|
329
|
-
email: "email@prestador",
|
330
|
-
}
|
331
|
-
},
|
332
|
-
tomador_servico: {
|
333
|
-
identificacao_tomador: {
|
334
|
-
cpf_cnpj: {
|
335
|
-
cpf: "12345678901",
|
336
|
-
},
|
337
|
-
inscricao_estadual: "tomador inscricao_estadual",
|
338
|
-
inscricao_municipal: "tomador inscricao_municipal"
|
339
|
-
},
|
340
|
-
razao_social: "TOMADOR SERVIcO",
|
341
|
-
endereco: {
|
342
|
-
endereco: "RUA TOMADOR",
|
343
|
-
numero: "99999",
|
344
|
-
complemento: "COMPLEMENTO TOMADOR",
|
345
|
-
bairro: "BAIRRO TOMADOR",
|
346
|
-
codigo_municipio: "4204202",
|
347
|
-
uf: "SC",
|
348
|
-
cep: "89805675"
|
349
|
-
},
|
350
|
-
contato: {
|
351
|
-
telefone: "336644557",
|
352
|
-
email: "mail@prestador.com"
|
353
|
-
}
|
354
|
-
},
|
355
|
-
orgao_gerador: {
|
356
|
-
codigo_municipio: "0",
|
357
|
-
uf: "SC"
|
358
|
-
},
|
359
|
-
construcao_civil: {
|
360
|
-
codigo_obra: '3333',
|
361
|
-
art: '4444'
|
362
|
-
}
|
363
|
-
}
|
364
|
-
},
|
365
|
-
nfse_cancelamento: {
|
366
|
-
confirmacao: {
|
367
|
-
pedido: {
|
368
|
-
inf_pedido_cancelamento: {
|
369
|
-
codigo_cancelamento: '123',
|
370
|
-
identificacao_nfse: {
|
371
|
-
numero: '123',
|
372
|
-
cnpj: '12345678901234',
|
373
|
-
inscricao_municipal: 'INSCRICAO CANCELAMENTO',
|
374
|
-
codigo_municipio: '99999999'
|
375
|
-
}
|
376
|
-
},
|
377
|
-
signature: nil
|
378
|
-
},
|
379
|
-
inf_confirmacao_cancelamento: {
|
380
|
-
sucesso: true,
|
381
|
-
data_hora: DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
382
|
-
}
|
383
|
-
}
|
384
|
-
},
|
385
|
-
nfse_substituicao: {
|
386
|
-
substituicao_nfse: {
|
387
|
-
nfse_substituidora: '663322'
|
388
|
-
}
|
389
|
-
}
|
390
|
-
}
|
391
|
-
},
|
392
|
-
lista_mensagem_retorno: {
|
393
|
-
mensagem_retorno: [
|
394
|
-
{codigo: '111', mensagem: 'Msg 1', correcao: 'corr 1'},
|
395
|
-
{codigo: '222', mensagem: 'Msg 2', correcao: 'corr 2'}
|
396
|
-
]
|
397
|
-
}
|
398
|
-
}
|
399
|
-
end
|
400
|
-
|
401
|
-
def hash_resposta_parcial
|
402
|
-
{
|
403
|
-
lista_nfse: {
|
404
|
-
compl_nfse: [
|
405
|
-
{
|
406
|
-
nfse: {
|
407
|
-
inf_nfse: {
|
408
|
-
numero: "1111",
|
409
|
-
codigo_verificacao: "ASDAD",
|
410
|
-
data_emissao: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
411
|
-
identificacao_rps: {
|
412
|
-
numero: "11111",
|
413
|
-
serie: "SN",
|
414
|
-
tipo: "1"
|
415
|
-
},
|
416
|
-
data_emissao_rps: DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300"),
|
417
|
-
natureza_operacao: "1",
|
418
|
-
optante_simples_nacional: "1",
|
419
|
-
competencia: DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300"),
|
420
|
-
outras_informacoes: "http://e-gov.betha.com.br/e-nota",
|
421
|
-
servico: {
|
422
|
-
valores: {
|
423
|
-
valor_servicos: "111",
|
424
|
-
valor_deducoes: "0",
|
425
|
-
valor_pis: "0.00",
|
426
|
-
valor_cofins: "0.00",
|
427
|
-
valor_inss: "0.00",
|
428
|
-
valor_ir: "0.00",
|
429
|
-
valor_csll: "0.00",
|
430
|
-
iss_retido: "2",
|
431
|
-
valor_iss: "0",
|
432
|
-
base_calculo: "111",
|
433
|
-
aliquota: "1.0000",
|
434
|
-
desconto_condicionado: "desconto_condicionado",
|
435
|
-
desconto_incondicionado: "desconto_incondicionado"
|
436
|
-
},
|
437
|
-
item_lista_servico: "111",
|
438
|
-
codigo_cnae: "6202300",
|
439
|
-
discriminacao: "discriminacao",
|
440
|
-
codigo_municipio: "4204202"
|
441
|
-
},
|
442
|
-
prestador_servico: {
|
443
|
-
identificacao_prestador: {
|
444
|
-
cnpj: "18113831000135"
|
445
|
-
},
|
446
|
-
razao_social: "EMPRESA NACIONAL LTDA - ME",
|
447
|
-
nome_fantasia: "EMPRESA NACIONAL",
|
448
|
-
endereco: {
|
449
|
-
endereco: "RUA PRESTADOR",
|
450
|
-
numero: "111",
|
451
|
-
complemento: "COMPLEMENTO PRESTADOR",
|
452
|
-
bairro: "BAIRRO PRESTADOR",
|
453
|
-
codigo_municipio: "4204202",
|
454
|
-
uf: "SC",
|
455
|
-
cep: "89805675"
|
456
|
-
},
|
457
|
-
contato: {
|
458
|
-
email: "email@prestador",
|
459
|
-
telefone: "123456"
|
460
|
-
}
|
461
|
-
},
|
462
|
-
tomador_servico: {
|
463
|
-
identificacao_tomador: {
|
464
|
-
cpf_cnpj: {
|
465
|
-
cnpj: "12345678901234"
|
466
|
-
}
|
467
|
-
},
|
468
|
-
razao_social: "TOMADOR SERVIÇO",
|
469
|
-
endereco: {
|
470
|
-
endereco: "RUA TOMADOR",
|
471
|
-
numero: "99999",
|
472
|
-
complemento: "COMPLEMENTO TOMADOR",
|
473
|
-
bairro: "BAIRRO TOMADOR",
|
474
|
-
codigo_municipio: "4204202",
|
475
|
-
uf: "SC",
|
476
|
-
cep: "89805675"
|
477
|
-
},
|
478
|
-
contato: {
|
479
|
-
telefone: "336644557",
|
480
|
-
email: "mail@prestador.com"
|
481
|
-
}
|
482
|
-
},
|
483
|
-
orgao_gerador: {
|
484
|
-
codigo_municipio: "0",
|
485
|
-
uf: "SC"
|
486
|
-
},
|
487
|
-
construcao_civil: {
|
488
|
-
codigo_obra: '3333',
|
489
|
-
art: '4444'
|
490
|
-
}
|
491
|
-
}
|
492
|
-
},
|
493
|
-
nfse_cancelamento: {
|
494
|
-
confirmacao: {
|
495
|
-
pedido: {
|
496
|
-
inf_pedido_cancelamento: {
|
497
|
-
codigo_cancelamento: '123',
|
498
|
-
identificacao_nfse: {
|
499
|
-
numero: '123',
|
500
|
-
cnpj: '12345678901234',
|
501
|
-
inscricao_municipal: 'INSCRICAO CANCELAMENTO',
|
502
|
-
codigo_municipio: '99999999'
|
503
|
-
}
|
504
|
-
},
|
505
|
-
signature: nil
|
506
|
-
},
|
507
|
-
inf_confirmacao_cancelamento: {
|
508
|
-
sucesso: true,
|
509
|
-
data_hora: DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
510
|
-
}
|
511
|
-
}
|
512
|
-
},
|
513
|
-
nfse_substituicao: {
|
514
|
-
substituicao_nfse: {
|
515
|
-
nfse_substituidora: '663322'
|
516
|
-
}
|
517
|
-
}
|
518
|
-
},
|
519
|
-
{
|
520
|
-
nfse: {
|
521
|
-
inf_nfse: {
|
522
|
-
numero: "NOTA2 numero_nf",
|
523
|
-
codigo_verificacao: "NOTA2 codigo_verificacao",
|
524
|
-
data_emissao: "NOTA2 data_emissao",
|
525
|
-
identificacao_rps: {
|
526
|
-
numero: "NOTA2 rps_numero",
|
527
|
-
serie: "NOTA2 rps_serie",
|
528
|
-
tipo: "NOTA2 rps_tipo"
|
529
|
-
},
|
530
|
-
data_emissao_rps: "NOTA2 data_emissao_rps",
|
531
|
-
natureza_operacao: "NOTA2 natureza_operacao",
|
532
|
-
optante_simples_nacional: "NOTA2 optante_simples_nacional",
|
533
|
-
competencia: "NOTA2 competencia",
|
534
|
-
outras_informacoes: "NOTA2 outras_informacoes",
|
535
|
-
servico: {
|
536
|
-
valores: {
|
537
|
-
valor_servicos: "NOTA2 valor_servicos",
|
538
|
-
base_calculo: "NOTA2 base_calculo",
|
539
|
-
aliquota: "NOTA2 aliquota"
|
540
|
-
},
|
541
|
-
item_lista_servico: "NOTA2 item_lista_servico",
|
542
|
-
discriminacao: "NOTA2 discriminacao",
|
543
|
-
codigo_municipio: "NOTA2 codigo_municipio"
|
544
|
-
},
|
545
|
-
}
|
546
|
-
},
|
547
|
-
nfse_cancelamento: {
|
548
|
-
confirmacao: nil
|
549
|
-
},
|
550
|
-
nfse_substituicao: nil
|
551
|
-
}
|
552
|
-
]
|
553
|
-
},
|
554
|
-
lista_mensagem_retorno: nil
|
555
|
-
}
|
556
|
-
end
|
557
|
-
end
|