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