br_nfe 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +12 -2
- data/README.markdown +3 -1
- data/Rakefile +20 -1
- data/lib/br_nfe/active_model/associations.rb +11 -0
- data/lib/br_nfe/active_model/has_many.rb +65 -0
- data/lib/br_nfe/active_model/has_one.rb +57 -0
- data/lib/br_nfe/active_model_base.rb +38 -1
- data/lib/br_nfe/base.rb +9 -0
- data/lib/br_nfe/calculos/fatores_de_multiplicacao.rb +67 -0
- data/lib/br_nfe/calculos/modulo11.rb +54 -0
- data/lib/br_nfe/calculos/modulo11_fator_de2a9.rb +83 -0
- data/lib/br_nfe/calculos/modulo11_fator_de2a9_resto_zero.rb +29 -0
- data/lib/br_nfe/constants.rb +46 -1
- data/lib/br_nfe/endereco.rb +6 -2
- data/lib/br_nfe/helper/cpf_cnpj.rb +8 -1
- data/lib/br_nfe/person.rb +32 -3
- data/lib/br_nfe/product/destinatario.rb +45 -0
- data/lib/br_nfe/product/emitente.rb +14 -1
- data/lib/br_nfe/product/evento/base.rb +146 -0
- data/lib/br_nfe/product/evento/cancelamento.rb +46 -0
- data/lib/br_nfe/product/gateway/base.rb +16 -43
- data/lib/br_nfe/product/gateway/web_service_am.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_ba.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_ce.rb +162 -0
- data/lib/br_nfe/product/gateway/web_service_go.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_mg.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_ms.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_mt.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_pe.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_pr.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_rs.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_sp.rb +140 -0
- data/lib/br_nfe/product/gateway/web_service_svan.rb +162 -0
- data/lib/br_nfe/product/gateway/web_service_svc_an.rb +131 -0
- data/lib/br_nfe/product/gateway/web_service_svc_rs.rb +20 -0
- data/lib/br_nfe/product/gateway/web_service_svrs.rb +111 -10
- data/lib/br_nfe/product/nf_xml_value.rb +278 -0
- data/lib/br_nfe/product/nfe/adicao_importacao.rb +76 -0
- data/lib/br_nfe/product/nfe/cobranca/duplicata.rb +44 -0
- data/lib/br_nfe/product/nfe/cobranca/fatura.rb +64 -0
- data/lib/br_nfe/product/nfe/cobranca/pagamento.rb +99 -0
- data/lib/br_nfe/product/nfe/declaracao_importacao.rb +221 -0
- data/lib/br_nfe/product/nfe/detalhe_exportacao.rb +89 -0
- data/lib/br_nfe/product/nfe/item.rb +678 -0
- data/lib/br_nfe/product/nfe/item_tax/cofins.rb +138 -0
- data/lib/br_nfe/product/nfe/item_tax/cofins_st.rb +68 -0
- data/lib/br_nfe/product/nfe/item_tax/icms.rb +593 -0
- data/lib/br_nfe/product/nfe/item_tax/icms_uf_destino.rb +169 -0
- data/lib/br_nfe/product/nfe/item_tax/importacao.rb +62 -0
- data/lib/br_nfe/product/nfe/item_tax/ipi.rb +179 -0
- data/lib/br_nfe/product/nfe/item_tax/issqn.rb +256 -0
- data/lib/br_nfe/product/nfe/item_tax/pis.rb +138 -0
- data/lib/br_nfe/product/nfe/item_tax/pis_st.rb +68 -0
- data/lib/br_nfe/product/nfe/processo_referencia.rb +48 -0
- data/lib/br_nfe/product/nfe/transporte/base.rb +264 -0
- data/lib/br_nfe/product/nfe/transporte/transportador.rb +15 -0
- data/lib/br_nfe/product/nfe/transporte/veiculo.rb +53 -0
- data/lib/br_nfe/product/nfe/transporte/volume.rb +89 -0
- data/lib/br_nfe/product/nota_fiscal.rb +1173 -0
- data/lib/br_nfe/product/operation/base.rb +255 -0
- data/lib/br_nfe/product/operation/nfe_autorizacao.rb +118 -0
- data/lib/br_nfe/product/operation/nfe_consulta_protocolo.rb +61 -0
- data/lib/br_nfe/product/operation/nfe_download_nf.rb +86 -0
- data/lib/br_nfe/product/operation/nfe_inutilizacao.rb +168 -0
- data/lib/br_nfe/product/operation/nfe_recepcao_evento.rb +70 -0
- data/lib/br_nfe/product/operation/nfe_ret_autorizacao.rb +63 -0
- data/lib/br_nfe/product/operation/nfe_status_servico.rb +46 -0
- data/lib/br_nfe/product/response/base.rb +97 -0
- data/lib/br_nfe/product/response/build/base.rb +287 -0
- data/lib/br_nfe/product/response/build/nfe_autorizacao.rb +102 -0
- data/lib/br_nfe/product/response/build/nfe_consulta_protocolo.rb +133 -0
- data/lib/br_nfe/product/response/build/nfe_inutilizacao.rb +53 -0
- data/lib/br_nfe/product/response/build/nfe_ret_autorizacao.rb +65 -0
- data/lib/br_nfe/product/response/build/nfe_status_servico.rb +43 -0
- data/lib/br_nfe/product/response/event.rb +89 -0
- data/lib/br_nfe/product/response/nfe_autorizacao.rb +12 -0
- data/lib/br_nfe/product/response/nfe_consulta_protocolo.rb +13 -0
- data/lib/br_nfe/product/response/nfe_inutilizacao.rb +89 -0
- data/lib/br_nfe/product/response/nfe_ret_autorizacao.rb +9 -0
- data/lib/br_nfe/product/response/nfe_status_servico.rb +31 -0
- data/lib/br_nfe/product/xml/_signed_info_sh1.xml.slim +9 -0
- data/lib/br_nfe/product/xml/_tc_cpf_cnpj.xml.slim +7 -0
- data/lib/br_nfe/product/xml/signature_sh1.xml.slim +12 -0
- data/lib/br_nfe/product/xml/v1_00/evento/infEventoCancelamento.xml.slim +19 -0
- data/lib/br_nfe/product/xml/v1_00/root/NfeDownloadNf.xml.slim +5 -0
- data/lib/br_nfe/product/xml/v1_00/root/NfeRecepcaoEvento.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v2_00/_tc_endereco.xml.slim +19 -0
- data/lib/br_nfe/product/xml/v2_00/_tc_infNFe.xml.slim +39 -0
- data/lib/br_nfe/product/xml/v2_00/infInut.xml.slim +12 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/NFe.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_cobr.xml.slim +19 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_dest.xml.slim +14 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_det.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_emit.xml.slim +19 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_entrega.xml.slim +11 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_exporta.xml.slim +2 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_ide.xml.slim +24 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_infAdic.xml.slim +13 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_retirada.xml.slim +11 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_total.xml.slim +50 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/_tc_transp.xml.slim +35 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_imposto.xml.slim +31 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/_tc_prod.xml.slim +37 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS00.xml.slim +6 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS10.xml.slim +16 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS101.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS102.xml.slim +3 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +6 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS201.xml.slim +15 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS202.xml.slim +14 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +12 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS500.xml.slim +6 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +13 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS60.xml.slim +5 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +18 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +21 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/ICMS/_tc_ICMS900.xml.slim +25 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS.xml.slim +26 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_COFINS_ST.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_ICMS.xml.slim +45 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_II.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_IPI.xml.slim +30 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS.xml.slim +26 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/imposto/_tc_PIS_ST.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/det/prod/_tc_di.xml.slim +13 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_retTransp.xml.slim +6 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_transporta.xml.slim +17 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe/transp/_tc_vol.xml.slim +15 -0
- data/lib/br_nfe/product/xml/v2_00/infNFe.xml.slim +3 -0
- data/lib/br_nfe/product/xml/v2_00/root/NfeAutorizacao.xml.slim +5 -0
- data/lib/br_nfe/product/xml/v2_00/root/NfeInutilizacao.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v2_00/root/NfeRetAutorizacao.xml.slim +3 -0
- data/lib/br_nfe/product/xml/v2_00/root/NfeStatusServico.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v2_01/root/NfeConsultaProtocolo.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v3_10/_tc_infNFe.xml.slim +44 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_dest.xml.slim +25 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_det.xml.slim +14 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_exporta.xml.slim +4 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_ide.xml.slim +26 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_pag.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/_tc_total.xml.slim +78 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_imposto.xml.slim +37 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/_tc_prod.xml.slim +48 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS20.xml.slim +12 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS30.xml.slim +17 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS40.xml.slim +7 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS51.xml.slim +19 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS70.xml.slim +23 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/ICMS/_tc_ICMS90.xml.slim +26 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ICMSUFDest.xml.slim +8 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/imposto/_tc_ISSQN.xml.slim +35 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_det_export.xml.slim +8 -0
- data/lib/br_nfe/product/xml/v3_10/infNFe/det/prod/_tc_di.xml.slim +28 -0
- data/lib/br_nfe/product/xml/v3_10/root/NfeAutorizacao.xml.slim +6 -0
- data/lib/br_nfe/service/base.rb +1 -105
- data/lib/br_nfe/service/betha/v1/cancela_nfse.rb +1 -1
- data/lib/br_nfe/service/response/default.rb +1 -1
- data/lib/br_nfe/service/simpliss/v1/base.rb +2 -0
- data/lib/br_nfe/version.rb +2 -2
- data/lib/br_nfe.rb +180 -22
- data/lib/config/locales/br_nfe/en/product/nfe/cobranca/fatura.yml +6 -0
- data/lib/config/locales/br_nfe/en/product/nfe/declaracao_importacao.yml +10 -0
- data/lib/config/locales/br_nfe/en/product/nfe/item.yml +20 -0
- data/lib/config/locales/br_nfe/en/product/nfe/item_tax/icms_uf_destino.yml +8 -0
- data/lib/config/locales/br_nfe/en/product/nfe/transporte/base.yml +9 -0
- data/lib/config/locales/br_nfe/en/product/nota_fiscal.yml +21 -0
- data/lib/config/locales/br_nfe/en/product/operation/nfe_autorizacao.yml +10 -0
- data/lib/config/locales/br_nfe/en/product/operation/nfe_recepcao_evento.yml +6 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nfe/cobranca/fatura.yml +6 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nfe/declaracao_importacao.yml +10 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nfe/item.yml +20 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nfe/item_tax/icms_uf_destino.yml +8 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nfe/transporte/base.yml +9 -0
- data/lib/config/locales/br_nfe/pt-BR/product/nota_fiscal.yml +21 -0
- data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_autorizacao.yml +10 -0
- data/lib/config/locales/br_nfe/pt-BR/product/operation/nfe_recepcao_evento.yml +6 -0
- data/test/br_nfe/association/have_destinatario_test.rb +8 -8
- data/test/br_nfe/association/have_emitente_test.rb +6 -6
- data/test/br_nfe/base_test.rb +15 -4
- data/test/br_nfe/endereco_test.rb +15 -0
- data/test/br_nfe/person_test.rb +55 -6
- data/test/br_nfe/product/destinatario_test.rb +26 -0
- data/test/br_nfe/product/emitente_test.rb +1 -2
- data/test/br_nfe/product/evento/base_test.rb +58 -0
- data/test/br_nfe/product/evento/cancelamento_test.rb +32 -0
- data/test/br_nfe/product/gateway/web_service_am_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_ba_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_ce_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_go_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_mg_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_ms_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_mt_test.rb +408 -0
- data/test/br_nfe/product/gateway/web_service_pe_test.rb +408 -0
- data/test/br_nfe/product/gateway/web_service_pr_test.rb +408 -0
- data/test/br_nfe/product/gateway/web_service_rs_test.rb +407 -0
- data/test/br_nfe/product/gateway/web_service_sp_test.rb +408 -0
- data/test/br_nfe/product/gateway/web_service_svan_test.rb +242 -0
- data/test/br_nfe/product/gateway/web_service_svc_an_test.rb +185 -0
- data/test/br_nfe/product/gateway/web_service_svc_rs_test.rb +185 -0
- data/test/br_nfe/product/gateway/web_service_svrs_test.rb +208 -2
- data/test/br_nfe/product/nfe/adicao_importacao_test.rb +19 -0
- data/test/br_nfe/product/nfe/cobranca/duplicata_test.rb +19 -0
- data/test/br_nfe/product/nfe/cobranca/fatura_test.rb +32 -0
- data/test/br_nfe/product/nfe/cobranca/pagamento_test.rb +105 -0
- data/test/br_nfe/product/nfe/declaracao_importacao_test.rb +116 -0
- data/test/br_nfe/product/nfe/detalhe_exportacao_test.rb +97 -0
- data/test/br_nfe/product/nfe/item_tax/cofins_st_test.rb +22 -0
- data/test/br_nfe/product/nfe/item_tax/cofins_test.rb +113 -0
- data/test/br_nfe/product/nfe/item_tax/icms_test.rb +1011 -0
- data/test/br_nfe/product/nfe/item_tax/icms_uf_destino_test.rb +99 -0
- data/test/br_nfe/product/nfe/item_tax/importacao_test.rb +23 -0
- data/test/br_nfe/product/nfe/item_tax/ipi_test.rb +160 -0
- data/test/br_nfe/product/nfe/item_tax/issqn_test.rb +84 -0
- data/test/br_nfe/product/nfe/item_tax/pis_st_test.rb +22 -0
- data/test/br_nfe/product/nfe/item_tax/pis_test.rb +113 -0
- data/test/br_nfe/product/nfe/item_test.rb +381 -0
- data/test/br_nfe/product/nfe/processo_referencia_test.rb +30 -0
- data/test/br_nfe/product/nfe/transporte/base_test.rb +182 -0
- data/test/br_nfe/product/nfe/transporte/transportador_test.rb +13 -0
- data/test/br_nfe/product/nfe/transporte/veiculo_test.rb +13 -0
- data/test/br_nfe/product/nfe/transporte/volume_test.rb +42 -0
- data/test/br_nfe/product/nota_fiscal_test.rb +662 -0
- data/test/br_nfe/product/operation/base_test.rb +538 -0
- data/test/br_nfe/product/operation/nfe_autorizacao_test.rb +378 -0
- data/test/br_nfe/product/operation/nfe_consulta_protocolo_test.rb +349 -0
- data/test/br_nfe/product/operation/nfe_download_nf_test.rb +93 -0
- data/test/br_nfe/product/operation/nfe_inutilizacao_test.rb +210 -0
- data/test/br_nfe/product/operation/nfe_recepcao_evento_test.rb +84 -0
- data/test/br_nfe/product/operation/nfe_ret_autorizacao_test.rb +309 -0
- data/test/br_nfe/product/operation/nfe_status_servico_test.rb +122 -0
- data/test/br_nfe/product/response/base_test.rb +75 -0
- data/test/br_nfe/product/response/build/base_test.rb +34 -0
- data/test/br_nfe/product/response/nfe_ret_autorizacao_test.rb +14 -0
- data/test/br_nfe/service/association/have_intermediario_test.rb +10 -10
- data/test/br_nfe/service/base_test.rb +9 -206
- data/test/br_nfe/service/betha/v1/cancela_nfse_test.rb +8 -6
- data/test/br_nfe/service/betha/v1/consulta_lote_rps_test.rb +6 -3
- data/test/br_nfe/service/betha/v1/consulta_nfs_por_rps_test.rb +6 -3
- data/test/br_nfe/service/betha/v1/consulta_nfse_test.rb +7 -4
- data/test/br_nfe/service/betha/v1/consulta_situacao_lote_rps_test.rb +12 -9
- data/test/br_nfe/service/betha/v1/recepcao_lote_rps_test.rb +6 -3
- data/test/br_nfe/service/rps_test.rb +2 -2
- data/test/br_nfe/service/simpliss/v1/cancela_nfse_test.rb +6 -3
- data/test/br_nfe/service/simpliss/v1/consulta_lote_rps_test.rb +7 -4
- data/test/br_nfe/service/simpliss/v1/consulta_nfs_por_rps_test.rb +7 -4
- data/test/br_nfe/service/simpliss/v1/consulta_nfse_test.rb +8 -5
- data/test/br_nfe/service/simpliss/v1/consulta_situacao_lote_rps_test.rb +9 -6
- data/test/br_nfe/service/simpliss/v1/recepcao_lote_rps_test.rb +6 -3
- data/test/br_nfe/service/thema/v1/cancela_nfse_test.rb +6 -3
- data/test/br_nfe/service/thema/v1/consulta_lote_rps_test.rb +6 -3
- data/test/br_nfe/service/thema/v1/consulta_nfs_por_rps_test.rb +6 -3
- data/test/br_nfe/service/thema/v1/consulta_nfse_test.rb +8 -5
- data/test/br_nfe/service/thema/v1/consulta_situacao_lote_rps_test.rb +9 -6
- data/test/br_nfe/service/thema/v1/recepcao_lote_rps_limitado_test.rb +6 -3
- data/test/br_nfe/service/thema/v1/recepcao_lote_rps_test.rb +6 -3
- data/test/factories/person.rb +1 -1
- data/test/factories/product/destinatario.rb +11 -0
- data/test/factories/product/emitente.rb +1 -1
- data/test/factories/product/evento/base.rb +9 -0
- data/test/factories/product/evento/cancelamento.rb +10 -0
- data/test/factories/product/gateway/web_service_am.rb +5 -0
- data/test/factories/product/gateway/web_service_ba.rb +5 -0
- data/test/factories/product/nfe/adicao_importacao.rb +7 -0
- data/test/factories/product/nfe/cobranca/duplicata.rb +7 -0
- data/test/factories/product/nfe/cobranca/fatura.rb +8 -0
- data/test/factories/product/nfe/cobranca/pagamento.rb +9 -0
- data/test/factories/product/nfe/declaracao_importacao.rb +10 -0
- data/test/factories/product/nfe/detalhe_exportacao.rb +5 -0
- data/test/factories/product/nfe/item.rb +24 -0
- data/test/factories/product/nfe/item_tax/cofins.rb +5 -0
- data/test/factories/product/nfe/item_tax/cofins_st.rb +5 -0
- data/test/factories/product/nfe/item_tax/icms.rb +9 -0
- data/test/factories/product/nfe/item_tax/icms_uf_destino.rb +11 -0
- data/test/factories/product/nfe/item_tax/importacao.rb +8 -0
- data/test/factories/product/nfe/item_tax/ipi.rb +6 -0
- data/test/factories/product/nfe/item_tax/issqn.rb +9 -0
- data/test/factories/product/nfe/item_tax/pis.rb +5 -0
- data/test/factories/product/nfe/item_tax/pis_st.rb +5 -0
- data/test/factories/product/nfe/processo_referencia.rb +6 -0
- data/test/factories/product/nfe/transporte/base.rb +5 -0
- data/test/factories/product/nfe/transporte/transportador.rb +7 -0
- data/test/factories/product/nfe/transporte/veiculo.rb +7 -0
- data/test/factories/product/nfe/transporte/volume.rb +5 -0
- data/test/factories/product/nota_fiscal.rb +22 -0
- data/test/factories/product/{base.rb → operation/base.rb} +1 -1
- data/test/factories/product/operation/nfe_autorizacao.rb +590 -0
- data/test/factories/product/operation/nfe_consulta_protocolo.rb +13 -0
- data/test/factories/product/operation/nfe_download_nf.rb +15 -0
- data/test/factories/product/operation/nfe_inutilizacao.rb +19 -0
- data/test/factories/product/operation/nfe_recepcao_evento.rb +14 -0
- data/test/factories/product/operation/nfe_ret_autorizacao.rb +13 -0
- data/test/factories/product/{consulta_status_servico.rb → operation/nfe_status_servico.rb} +1 -1
- data/test/factories/product/response/base.rb +12 -0
- data/test/factories/product/response/build/base.rb +6 -0
- data/test/factories/product/response/nfe_ret_autorizacao.rb +13 -0
- data/test/factories/service/emitente.rb +1 -1
- data/test/fixtures/product/operation/nfe_autorizacao/nfe_signed.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_fail.xml +21 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/async_success.xml +25 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/with_proc.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/nfe/without_proc.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/original_xml.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_fail.xml +32 -0
- data/test/fixtures/product/response/v3.10/nfe_autorizacao/sync_success.xml +33 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_1.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_2.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_3.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/event_cancel.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/event_xml/one_event.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/fail.xml +22 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/with_proc.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/nfe_original/without_proc.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_with_cancel.xml +198 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_many_without_cancel.xml +199 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_one.xml +89 -0
- data/test/fixtures/product/response/v3.10/nfe_consulta_protocolo/success_without.xml +34 -0
- data/test/fixtures/product/response/v3.10/nfe_inutilizacao/fail.xml +29 -0
- data/test/fixtures/product/response/v3.10/nfe_inutilizacao/success.xml +30 -0
- data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/fail.xml +34 -0
- data/test/fixtures/product/response/v3.10/nfe_recepcao_evento/cancelamento/success.xml +36 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_fail.xml +22 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail.xml +33 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_fail_and_one_ok.xml +46 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_one_invoice_ok.xml +34 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_fail.xml +46 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/lot_ok_two_invoice_ok.xml +46 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_with_protocol.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_2_without_protocol.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_with_protocol.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/nfe/nf_3_without_protocol.xml +1 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/lot.xml +2 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfe.xml +2 -0
- data/test/fixtures/product/response/v3.10/nfe_ret_autorizacao/original_xml/nfeProc.xml +4 -0
- data/test/fixtures/product/response/v3.10/nfe_status_servico/fail.xml +23 -0
- data/test/fixtures/product/response/v3.10/nfe_status_servico/success.xml +22 -0
- data/test/fixtures/product/schemas/CCe_v1.00.xsd +11 -0
- data/test/fixtures/product/schemas/EPEC_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/LeiauteCadastroEmissorDFe_v1.01.xsd +234 -0
- data/test/fixtures/product/schemas/SuframaInternaliza_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/SuframaVistoria_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/atuCadEmiDFe_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/cabecMsg_v1.02.xsd +29 -0
- data/test/fixtures/product/schemas/cadEmiDFe_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/cancNFe_v2.00.xsd +9 -0
- data/test/fixtures/product/schemas/confRecebto_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/consCad_v2.00.xsd +9 -0
- data/test/fixtures/product/schemas/consDPEC_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/consNFeDest_v1.01.xsd +10 -0
- data/test/fixtures/product/schemas/consReciNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consReciNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/consSitNFe_v2.01.xsd +10 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consSitNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/consStatServ_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/consStatServ_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/distDFeInt_v1.00.xsd +71 -0
- data/test/fixtures/product/schemas/downloadNFe_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/e110110_v1.00.xsd +58 -0
- data/test/fixtures/product/schemas/e110111_v1.00.xsd +42 -0
- data/test/fixtures/product/schemas/e110140_v1.00.xsd +124 -0
- data/test/fixtures/product/schemas/e111500_v1.00.xsd +69 -0
- data/test/fixtures/product/schemas/e111501_v1.00.xsd +69 -0
- data/test/fixtures/product/schemas/e111502_v1.00.xsd +50 -0
- data/test/fixtures/product/schemas/e111503_v1.00.xsd +50 -0
- data/test/fixtures/product/schemas/e210200_v1.00.xsd +32 -0
- data/test/fixtures/product/schemas/e210210_v1.00.xsd +32 -0
- data/test/fixtures/product/schemas/e210220_v1.00.xsd +45 -0
- data/test/fixtures/product/schemas/e210240_v1.00.xsd +44 -0
- data/test/fixtures/product/schemas/e411500_v1.00.xsd +134 -0
- data/test/fixtures/product/schemas/e411501_v1.00.xsd +134 -0
- data/test/fixtures/product/schemas/e411502_v1.00.xsd +95 -0
- data/test/fixtures/product/schemas/e411503_v1.00.xsd +95 -0
- data/test/fixtures/product/schemas/e990900_v1.00.xsd +87 -0
- data/test/fixtures/product/schemas/e990910_v1.00.xsd +81 -0
- data/test/fixtures/product/schemas/envCCe_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/envCancelPProrrogNFe_v1.0.xsd +50 -0
- data/test/fixtures/product/schemas/envConfRecebto_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/envDPEC_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/envEPEC_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/envEventoCancNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/envEvento_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/envFiscoNfe_v1.0.xsd +179 -0
- data/test/fixtures/product/schemas/envPProrrogNFe_v1.0.xsd +65 -0
- data/test/fixtures/product/schemas/envRemIndus_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/envSuframaInternaliza_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/envSuframaVistoria_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/enviNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/enviNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/eventoCancNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/eventoEPEC_v0.01.xsd +267 -0
- data/test/fixtures/product/schemas/eventoEPEC_v1.00.xsd +267 -0
- data/test/fixtures/product/schemas/eventoRemIndus_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/inutNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/inutNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/leiauteCCe_v1.00.xsd +418 -0
- data/test/fixtures/product/schemas/leiauteCancNFe_v2.00.xsd +143 -0
- data/test/fixtures/product/schemas/leiauteConfRecebto_v1.00.xsd +406 -0
- data/test/fixtures/product/schemas/leiauteConsNFeDest_v1.01.xsd +483 -0
- data/test/fixtures/product/schemas/leiauteConsSitNFe_v2.01.xsd +548 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsSitNFe_v3.10.xsd +502 -502
- data/test/fixtures/product/schemas/leiauteConsStatServ_v2.00.xsd +98 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteConsStatServ_v3.10.xsd +97 -97
- data/test/fixtures/product/schemas/leiauteConsultaCadastro_v1.01.xsd +355 -0
- data/test/fixtures/product/schemas/leiauteConsultaCadastro_v2.00.xsd +404 -0
- data/test/fixtures/product/schemas/leiauteDPEC_v1.01.xsd +464 -0
- data/test/fixtures/product/schemas/leiauteDownloadNFe_v1.00.xsd +149 -0
- data/test/fixtures/product/schemas/leiauteEPEC_v1.00.xsd +459 -0
- data/test/fixtures/product/schemas/leiauteEventoCancNFe_v1.00.xsd +394 -0
- data/test/fixtures/product/schemas/leiauteEvento_v1.00.xsd +373 -0
- data/test/fixtures/product/schemas/leiauteInutNFe_v2.00.xsd +193 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteInutNFe_v3.10.xsd +192 -192
- data/test/fixtures/product/schemas/leiauteNFe_v2.00.xsd +6661 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/leiauteNFe_v3.10.xsd +6060 -6060
- data/test/fixtures/product/schemas/leiauteRemIndus_v1.00.xsd +382 -0
- data/test/fixtures/product/schemas/leiauteSRE_v1.00.xsd +372 -0
- data/test/fixtures/product/schemas/leiauteSuframaInternaliza_v1.00.xsd +642 -0
- data/test/fixtures/product/schemas/leiauteSuframaVistoria_v1.00.xsd +648 -0
- data/test/fixtures/product/schemas/nfe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/nfe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/procCCeNFe_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/procCancNFe_v2.00.xsd +9 -0
- data/test/fixtures/product/schemas/procConfRecebtoNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/procEPEC_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/procEventoCancNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/procEventoNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/procEventoNFe_v99.99.xsd +37 -0
- data/test/fixtures/product/schemas/procInutNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procInutNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/procNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/procNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/procRemIndus_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/resEvento_v1.00.xsd +94 -0
- data/test/fixtures/product/schemas/resNFe_v1.00.xsd +110 -0
- data/test/fixtures/product/schemas/retAtuCadEmiDFe_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/retCancNFe_v2.00.xsd +9 -0
- data/test/fixtures/product/schemas/retConsCad_v2.00.xsd +9 -0
- data/test/fixtures/product/schemas/retConsDPEC_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/retConsReciNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsReciNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/retConsSitNFe_v2.01.xsd +10 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsSitNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/retConsStatServ_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retConsStatServ_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/retDPEC_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/retDistDFeInt_v1.00.xsd +84 -0
- data/test/fixtures/product/schemas/retDownloadNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvCCe_v1.00.xsd +10 -0
- data/test/fixtures/product/schemas/retEnvCancelPProrrogNFe_v1.0.xsd +231 -0
- data/test/fixtures/product/schemas/retEnvConfRecebto_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvEPEC_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvEventoCancNFe_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvEvento_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvFiscoNFe_v1.0.xsd +234 -0
- data/test/fixtures/product/schemas/retEnvRemIndus_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvSuframaInternaliza_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnvSuframaVistoria_v1.00.xsd +9 -0
- data/test/fixtures/product/schemas/retEnviNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retEnviNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/retEventoEPEC_v0.01.xsd +207 -0
- data/test/fixtures/product/schemas/retInutNFe_v2.00.xsd +9 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/retInutNFe_v3.10.xsd +8 -8
- data/test/fixtures/product/schemas/retPProrrogNFe_v1.0.xsd +233 -0
- data/test/fixtures/product/schemas/retconsNFeDest_v1.01.xsd +9 -0
- data/test/fixtures/product/schemas/tiposBasico_v1.03.xsd +816 -0
- data/test/fixtures/product/schemas/tiposBasico_v1.03_OPENSSL.xsd +816 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/tiposBasico_v3.10.xsd +571 -571
- data/test/fixtures/product/schemas/tiposBasico_v3.10_OPENSSL.xsd +877 -0
- data/test/fixtures/product/schemas/tiposDistDFe_v1.00.xsd +217 -0
- data/{lib/br_nfe/product/xml/v3_10/XSD → test/fixtures/product/schemas}/xmldsig-core-schema_v1.01.xsd +97 -97
- data/test/fixtures/product/wsdl/NFeRetAutorizacao.xml +80 -0
- data/test/fixtures/product/wsdl/NfeAutorizacao.xml +107 -0
- data/test/fixtures/product/wsdl/NfeConsulta2.xml +80 -0
- data/test/fixtures/product/wsdl/NfeStatusServico2.xml +70 -0
- data/test/fixtures/product/wsdl/nfeinutilizacao2.xml +80 -0
- data/test/fixtures/service/wsdl/betha/v1/cancelar_nfse.xml +178 -0
- data/test/fixtures/service/wsdl/betha/v1/consultar_lote_rps.xml +339 -0
- data/test/fixtures/service/wsdl/betha/v1/consultar_nfse.xml +348 -0
- data/test/fixtures/service/wsdl/betha/v1/consultar_nfse_por_rps.xml +365 -0
- data/test/fixtures/service/wsdl/betha/v1/consultar_situacao_lote_rps.xml +74 -0
- data/test/fixtures/service/wsdl/betha/v1/recepcionar_lote_rps.xml +299 -0
- data/test/fixtures/service/wsdl/simpliss/v1/nfseservice.xml +1 -0
- data/test/fixtures/service/wsdl/thema/v1/nfse_cancelamento.xml +82 -0
- data/test/fixtures/service/wsdl/thema/v1/nfse_consulta.xml +235 -0
- data/test/fixtures/service/wsdl/thema/v1/nfse_remessa.xml +185 -0
- data/test/test_helper.rb +369 -1
- metadata +711 -33
- data/lib/br_nfe/product/base.rb +0 -82
- data/lib/br_nfe/product/consulta_status_servico.rb +0 -35
- data/lib/br_nfe/product/value_nf.rb +0 -9
- data/lib/br_nfe/product/xml/v3_10/consulta_status_servico.xml.slim +0 -4
- data/test/br_nfe/product/base_test.rb +0 -150
- data/test/br_nfe/product/consulta_status_servico_test.rb +0 -59
@@ -0,0 +1,538 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Operation::Base do
|
4
|
+
subject { FactoryGirl.build(:product_operation_base) }
|
5
|
+
let(:nota_fiscal) { FactoryGirl.build(:product_nota_fiscal) }
|
6
|
+
|
7
|
+
describe "Validations" do
|
8
|
+
it do
|
9
|
+
subject.certificate_pkcs12_path = nil
|
10
|
+
must validate_presence_of(:certificate)
|
11
|
+
end
|
12
|
+
it { must validate_inclusion_of(:tipo_emissao).in_array([:normal, :svc]) }
|
13
|
+
|
14
|
+
describe '#inicio_contingencia' do
|
15
|
+
context "Quando estiver em contingência" do
|
16
|
+
before { subject.stubs(:contingencia?).returns(true) }
|
17
|
+
it { must validate_presence_of(:inicio_contingencia) }
|
18
|
+
it { must validate_length_of(:motivo_contingencia).is_at_least(15).is_at_most(256) }
|
19
|
+
end
|
20
|
+
context "Quando não estiver em contingência" do
|
21
|
+
before { subject.stubs(:contingencia?).returns(false) }
|
22
|
+
it { wont validate_presence_of(:inicio_contingencia) }
|
23
|
+
it { wont validate_length_of(:motivo_contingencia).is_at_least(15).is_at_most(256) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#default_values' do
|
29
|
+
it "tipo_emissao deve ser normal" do
|
30
|
+
subject.class.new.tipo_emissao.must_equal :normal
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#ssl_request? deve ser true' do
|
35
|
+
subject.ssl_request?.must_equal true
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#xml_current_dir_path' do
|
39
|
+
let(:path_v1_00) { "#{BrNfe.root}/lib/br_nfe/product/xml/v1_00" }
|
40
|
+
let(:path_v1_10) { "#{BrNfe.root}/lib/br_nfe/product/xml/v1_10" }
|
41
|
+
let(:path_v2_00) { "#{BrNfe.root}/lib/br_nfe/product/xml/v2_00" }
|
42
|
+
let(:path_v2_01) { "#{BrNfe.root}/lib/br_nfe/product/xml/v2_01" }
|
43
|
+
let(:path_v3_10) { "#{BrNfe.root}/lib/br_nfe/product/xml/v3_10" }
|
44
|
+
let(:product_default_path) { "#{BrNfe.root}/lib/br_nfe/product/xml" }
|
45
|
+
|
46
|
+
it "se a versão da operação for 1.0 deve pegar apenas o path da versão 1" do
|
47
|
+
subject.stubs(:gateway_xml_version).returns(:v1_00)
|
48
|
+
subject.xml_current_dir_path[0].must_equal path_v1_00
|
49
|
+
subject.xml_current_dir_path[1].must_equal product_default_path
|
50
|
+
|
51
|
+
subject.xml_current_dir_path.wont_include path_v1_10
|
52
|
+
subject.xml_current_dir_path.wont_include path_v2_00
|
53
|
+
subject.xml_current_dir_path.wont_include path_v3_10
|
54
|
+
end
|
55
|
+
|
56
|
+
it "se a versão da operação for 1.10 deve pegar apenas o path da versão 1 e 1.1" do
|
57
|
+
subject.stubs(:gateway_xml_version).returns(:v1_10)
|
58
|
+
subject.xml_current_dir_path[0].must_equal path_v1_10
|
59
|
+
subject.xml_current_dir_path[1].must_equal path_v1_00
|
60
|
+
subject.xml_current_dir_path[2].must_equal product_default_path
|
61
|
+
|
62
|
+
subject.xml_current_dir_path.wont_include path_v2_00
|
63
|
+
subject.xml_current_dir_path.wont_include path_v3_10
|
64
|
+
end
|
65
|
+
|
66
|
+
it "se a versão da operação for 2.00 deve pegar apenas o path da versão 2.0, 1.1 e 1" do
|
67
|
+
subject.stubs(:gateway_xml_version).returns(:v2_00)
|
68
|
+
subject.xml_current_dir_path[0].must_equal path_v2_00
|
69
|
+
subject.xml_current_dir_path[1].must_equal path_v1_10
|
70
|
+
subject.xml_current_dir_path[2].must_equal path_v1_00
|
71
|
+
subject.xml_current_dir_path[3].must_equal product_default_path
|
72
|
+
|
73
|
+
subject.xml_current_dir_path.wont_include path_v3_10
|
74
|
+
end
|
75
|
+
|
76
|
+
it "se a versão da operação for 3.10 deve pegar apenas os paths da versões 3.1, 2.0, 2.01, 1.1 e 1" do
|
77
|
+
subject.stubs(:gateway_xml_version).returns(:v3_10)
|
78
|
+
subject.xml_current_dir_path[0].must_equal path_v3_10
|
79
|
+
subject.xml_current_dir_path[1].must_equal path_v2_01
|
80
|
+
subject.xml_current_dir_path[2].must_equal path_v2_00
|
81
|
+
subject.xml_current_dir_path[3].must_equal path_v1_10
|
82
|
+
subject.xml_current_dir_path[4].must_equal path_v1_00
|
83
|
+
subject.xml_current_dir_path[5].must_equal product_default_path
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#gateway' do
|
88
|
+
let(:env) { SecureRandom.hex(5) }
|
89
|
+
describe 'UF: 12 - Acre/AC' do
|
90
|
+
it "Para tipo de emissão :normal" do
|
91
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '12', env: env
|
92
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
93
|
+
subject.gateway.env.must_equal env
|
94
|
+
end
|
95
|
+
it "Para tipo de emissão :svc" do
|
96
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '12', env: env, tipo_emissao: :svc
|
97
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
98
|
+
subject.gateway.env.must_equal env
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'UF: 27 - Alagoas/AL' do
|
103
|
+
it "Para tipo de emissão :normal" do
|
104
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '27', env: env
|
105
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
106
|
+
subject.gateway.env.must_equal env
|
107
|
+
end
|
108
|
+
it "Para tipo de emissão :svc" do
|
109
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '27', env: env, tipo_emissao: :svc
|
110
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
111
|
+
subject.gateway.env.must_equal env
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'UF: 16 - Amapá/AP' do
|
116
|
+
it "Para tipo de emissão :normal" do
|
117
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '16', env: env
|
118
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
119
|
+
subject.gateway.env.must_equal env
|
120
|
+
end
|
121
|
+
it "Para tipo de emissão :svc" do
|
122
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '16', env: env, tipo_emissao: :svc
|
123
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
124
|
+
subject.gateway.env.must_equal env
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'UF: 13 - Amazonas/AM' do
|
129
|
+
it "Para tipo de emissão :normal" do
|
130
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '13', env: env
|
131
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceAM
|
132
|
+
subject.gateway.env.must_equal env
|
133
|
+
end
|
134
|
+
it "Para tipo de emissão :svc" do
|
135
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '13', env: env, tipo_emissao: :svc
|
136
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
137
|
+
subject.gateway.env.must_equal env
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'UF: 29 - Bahia/BA' do
|
142
|
+
it "Para tipo de emissão :normal" do
|
143
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '29', env: env
|
144
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceBA
|
145
|
+
subject.gateway.env.must_equal env
|
146
|
+
end
|
147
|
+
it "Para tipo de emissão :svc" do
|
148
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '29', env: env, tipo_emissao: :svc
|
149
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
150
|
+
subject.gateway.env.must_equal env
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe 'UF: 23 - Ceará/CE' do
|
155
|
+
it "Para tipo de emissão :normal" do
|
156
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '23', env: env
|
157
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceCE
|
158
|
+
subject.gateway.env.must_equal env
|
159
|
+
end
|
160
|
+
it "Para tipo de emissão :svc" do
|
161
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '23', env: env, tipo_emissao: :svc
|
162
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
163
|
+
subject.gateway.env.must_equal env
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe 'UF: 53 - Distrito Federal/DF' do
|
168
|
+
it "Para tipo de emissão :normal" do
|
169
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '53', env: env
|
170
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
171
|
+
subject.gateway.env.must_equal env
|
172
|
+
end
|
173
|
+
it "Para tipo de emissão :svc" do
|
174
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '53', env: env, tipo_emissao: :svc
|
175
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
176
|
+
subject.gateway.env.must_equal env
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe 'UF: 32 - Espírito Santo/ES' do
|
181
|
+
it "Para tipo de emissão :normal" do
|
182
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '32', env: env
|
183
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
184
|
+
subject.gateway.env.must_equal env
|
185
|
+
end
|
186
|
+
it "Para tipo de emissão :svc" do
|
187
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '32', env: env, tipo_emissao: :svc
|
188
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
189
|
+
subject.gateway.env.must_equal env
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe 'UF: 52 - Goiás/GO' do
|
194
|
+
it "Para tipo de emissão :normal" do
|
195
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '52', env: env
|
196
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceGO
|
197
|
+
subject.gateway.env.must_equal env
|
198
|
+
end
|
199
|
+
it "Para tipo de emissão :svc" do
|
200
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '52', env: env, tipo_emissao: :svc
|
201
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
202
|
+
subject.gateway.env.must_equal env
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe 'UF: 21 - Maranhão/MA' do
|
207
|
+
it "Para tipo de emissão :normal" do
|
208
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '21', env: env
|
209
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVAN
|
210
|
+
subject.gateway.env.must_equal env
|
211
|
+
end
|
212
|
+
it "Para tipo de emissão :svc" do
|
213
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '21', env: env, tipo_emissao: :svc
|
214
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
215
|
+
subject.gateway.env.must_equal env
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe 'UF: 51 - Mato Grosso/MT' do
|
220
|
+
it "Para tipo de emissão :normal" do
|
221
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '51', env: env
|
222
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceMT
|
223
|
+
subject.gateway.env.must_equal env
|
224
|
+
end
|
225
|
+
it "Para tipo de emissão :svc" do
|
226
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '51', env: env, tipo_emissao: :svc
|
227
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
228
|
+
subject.gateway.env.must_equal env
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe 'UF: 50 - Mato Grosso do Sul/MS' do
|
233
|
+
it "Para tipo de emissão :normal" do
|
234
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '50', env: env
|
235
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceMS
|
236
|
+
subject.gateway.env.must_equal env
|
237
|
+
end
|
238
|
+
it "Para tipo de emissão :svc" do
|
239
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '50', env: env, tipo_emissao: :svc
|
240
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
241
|
+
subject.gateway.env.must_equal env
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe 'UF: 31 - Minas Gerais/MG' do
|
246
|
+
it "Para tipo de emissão :normal" do
|
247
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '31', env: env
|
248
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceMG
|
249
|
+
subject.gateway.env.must_equal env
|
250
|
+
end
|
251
|
+
it "Para tipo de emissão :svc" do
|
252
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '31', env: env, tipo_emissao: :svc
|
253
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
254
|
+
subject.gateway.env.must_equal env
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe 'UF: 15 - Pará/PA' do
|
259
|
+
it "Para tipo de emissão :normal" do
|
260
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '15', env: env
|
261
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVAN
|
262
|
+
subject.gateway.env.must_equal env
|
263
|
+
end
|
264
|
+
it "Para tipo de emissão :svc" do
|
265
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '15', env: env, tipo_emissao: :svc
|
266
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
267
|
+
subject.gateway.env.must_equal env
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe 'UF: 25 - Paraíba/PB' do
|
272
|
+
it "Para tipo de emissão :normal" do
|
273
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '25', env: env
|
274
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
275
|
+
subject.gateway.env.must_equal env
|
276
|
+
end
|
277
|
+
it "Para tipo de emissão :svc" do
|
278
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '25', env: env, tipo_emissao: :svc
|
279
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
280
|
+
subject.gateway.env.must_equal env
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe 'UF: 41 - Paraná/PR' do
|
285
|
+
it "Para tipo de emissão :normal" do
|
286
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '41', env: env
|
287
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServicePR
|
288
|
+
subject.gateway.env.must_equal env
|
289
|
+
end
|
290
|
+
it "Para tipo de emissão :svc" do
|
291
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '41', env: env, tipo_emissao: :svc
|
292
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
293
|
+
subject.gateway.env.must_equal env
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
describe 'UF: 26 - Pernambuco/PE' do
|
298
|
+
it "Para tipo de emissão :normal" do
|
299
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '26', env: env
|
300
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServicePE
|
301
|
+
subject.gateway.env.must_equal env
|
302
|
+
end
|
303
|
+
it "Para tipo de emissão :svc" do
|
304
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '26', env: env, tipo_emissao: :svc
|
305
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
306
|
+
subject.gateway.env.must_equal env
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe 'UF: 22 - Piauí/PI' do
|
311
|
+
it "Para tipo de emissão :normal" do
|
312
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '22', env: env
|
313
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVAN
|
314
|
+
subject.gateway.env.must_equal env
|
315
|
+
end
|
316
|
+
it "Para tipo de emissão :svc" do
|
317
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '22', env: env, tipo_emissao: :svc
|
318
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcRS
|
319
|
+
subject.gateway.env.must_equal env
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
describe 'UF: 33 - Rio de Janeiro/RJ' do
|
324
|
+
it "Para tipo de emissão :normal" do
|
325
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '33', env: env
|
326
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
327
|
+
subject.gateway.env.must_equal env
|
328
|
+
end
|
329
|
+
it "Para tipo de emissão :svc" do
|
330
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '33', env: env, tipo_emissao: :svc
|
331
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
332
|
+
subject.gateway.env.must_equal env
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe 'UF: 24 - Rio Grande do Norte/RN' do
|
337
|
+
it "Para tipo de emissão :normal" do
|
338
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '24', env: env
|
339
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
340
|
+
subject.gateway.env.must_equal env
|
341
|
+
end
|
342
|
+
it "Para tipo de emissão :svc" do
|
343
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '24', env: env, tipo_emissao: :svc
|
344
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
345
|
+
subject.gateway.env.must_equal env
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe 'UF: 43 - Rio Grande do Sul/RS' do
|
350
|
+
it "Para tipo de emissão :normal" do
|
351
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '43', env: env
|
352
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceRS
|
353
|
+
subject.gateway.env.must_equal env
|
354
|
+
end
|
355
|
+
it "Para tipo de emissão :svc" do
|
356
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '43', env: env, tipo_emissao: :svc
|
357
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
358
|
+
subject.gateway.env.must_equal env
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe 'UF: 11 - Rondônia/RO' do
|
363
|
+
it "Para tipo de emissão :normal" do
|
364
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '11', env: env
|
365
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
366
|
+
subject.gateway.env.must_equal env
|
367
|
+
end
|
368
|
+
it "Para tipo de emissão :svc" do
|
369
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '11', env: env, tipo_emissao: :svc
|
370
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
371
|
+
subject.gateway.env.must_equal env
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe 'UF: 14 - Roraima/RR' do
|
376
|
+
it "Para tipo de emissão :normal" do
|
377
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '14', env: env
|
378
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
379
|
+
subject.gateway.env.must_equal env
|
380
|
+
end
|
381
|
+
it "Para tipo de emissão :svc" do
|
382
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '14', env: env, tipo_emissao: :svc
|
383
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
384
|
+
subject.gateway.env.must_equal env
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe 'UF: 42 - Santa Catarina/SC' do
|
389
|
+
it "Para tipo de emissão :normal" do
|
390
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '42', env: env
|
391
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
392
|
+
subject.gateway.env.must_equal env
|
393
|
+
end
|
394
|
+
it "Para tipo de emissão :svc" do
|
395
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '42', env: env, tipo_emissao: :svc
|
396
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
397
|
+
subject.gateway.env.must_equal env
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
describe 'UF: 35 - São Paulo/SP' do
|
402
|
+
it "Para tipo de emissão :normal" do
|
403
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '35', env: env
|
404
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSP
|
405
|
+
subject.gateway.env.must_equal env
|
406
|
+
end
|
407
|
+
it "Para tipo de emissão :svc" do
|
408
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '35', env: env, tipo_emissao: :svc
|
409
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
410
|
+
subject.gateway.env.must_equal env
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
describe 'UF: 28 - Sergipe/SE' do
|
415
|
+
it "Para tipo de emissão :normal" do
|
416
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '28', env: env
|
417
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
418
|
+
subject.gateway.env.must_equal env
|
419
|
+
end
|
420
|
+
it "Para tipo de emissão :svc" do
|
421
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '28', env: env, tipo_emissao: :svc
|
422
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
423
|
+
subject.gateway.env.must_equal env
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
describe 'UF: 17 - Tocantins/TO' do
|
428
|
+
it "Para tipo de emissão :normal" do
|
429
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '17', env: env
|
430
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSVRS
|
431
|
+
subject.gateway.env.must_equal env
|
432
|
+
end
|
433
|
+
it "Para tipo de emissão :svc" do
|
434
|
+
subject.assign_attributes ibge_code_of_issuer_uf: '17', env: env, tipo_emissao: :svc
|
435
|
+
subject.gateway.must_be_kind_of BrNfe::Product::Gateway::WebServiceSvcAN
|
436
|
+
subject.gateway.env.must_equal env
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
describe 'Métodos que devem ser sobrescritos' do
|
442
|
+
it '#url_xmlns' do
|
443
|
+
assert_raises RuntimeError do
|
444
|
+
subject.url_xmlns
|
445
|
+
end
|
446
|
+
end
|
447
|
+
it '#gateway_xml_version' do
|
448
|
+
assert_raises RuntimeError do
|
449
|
+
subject.gateway_xml_version
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
describe '#xml_version - deve converter a versão em valor usável no XML' do
|
455
|
+
it "Para versão :v3_10" do
|
456
|
+
subject.stubs(:gateway_xml_version).returns(:v3_10)
|
457
|
+
subject.xml_version.must_equal '3.10'
|
458
|
+
end
|
459
|
+
it "Para versão :v2_00" do
|
460
|
+
subject.stubs(:gateway_xml_version).returns(:v2_00)
|
461
|
+
subject.xml_version.must_equal '2.00'
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
describe "#emitente" do
|
466
|
+
class OtherClassEmitente < BrNfe::ActiveModelBase
|
467
|
+
end
|
468
|
+
it "deve ter incluso o module HaveEmitente" do
|
469
|
+
subject.class.included_modules.must_include BrNfe::Association::HaveEmitente
|
470
|
+
end
|
471
|
+
it "o método #emitente_class deve ter por padrão a class BrNfe::Product::Emitente" do
|
472
|
+
subject.emitente.must_be_kind_of BrNfe::Product::Emitente
|
473
|
+
subject.send(:emitente_class).must_equal BrNfe::Product::Emitente
|
474
|
+
end
|
475
|
+
it "a class do emitente pode ser modificada através da configuração emitente_product_class" do
|
476
|
+
BrNfe.emitente_product_class = OtherClassEmitente
|
477
|
+
subject.emitente.must_be_kind_of OtherClassEmitente
|
478
|
+
subject.send(:emitente_class).must_equal OtherClassEmitente
|
479
|
+
|
480
|
+
# É necessário voltar a configuração original para não falhar outros testes
|
481
|
+
BrNfe.emitente_product_class = BrNfe::Product::Emitente
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
describe '#contingencia?' do
|
486
|
+
it "se o tipo_emissao for normal deve retornar false" do
|
487
|
+
subject.tipo_emissao = :normal
|
488
|
+
subject.contingencia?.must_equal false
|
489
|
+
end
|
490
|
+
it "se o tipo_emissao for svc deve retornar true" do
|
491
|
+
subject.tipo_emissao = :svc
|
492
|
+
subject.contingencia?.must_equal true
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
describe '#codigo_tipo_emissao' do
|
497
|
+
it "se a nfe for uma NFC-e deve retornar 9" do
|
498
|
+
nota_fiscal.modelo_nf = 65
|
499
|
+
subject.tipo_emissao = :normal
|
500
|
+
subject.codigo_tipo_emissao(nota_fiscal).must_equal 9
|
501
|
+
subject.tipo_emissao = :svc
|
502
|
+
subject.codigo_tipo_emissao(nota_fiscal).must_equal 9
|
503
|
+
end
|
504
|
+
it "se a emissão da nfe for normal deve retornar o código 1" do
|
505
|
+
subject.tipo_emissao = :normal
|
506
|
+
subject.codigo_tipo_emissao(nota_fiscal).must_equal 1
|
507
|
+
end
|
508
|
+
it "se a emissão da nfe for :svc e o estado usa o SVC-RS deve retornar 7" do
|
509
|
+
subject.tipo_emissao = :svc
|
510
|
+
subject.ibge_code_of_issuer_uf = 13
|
511
|
+
subject.codigo_tipo_emissao(nota_fiscal).must_equal 7
|
512
|
+
end
|
513
|
+
it "se a emissão da nfe for :svc e o estado usa o SVC-AN deve retornar 6" do
|
514
|
+
subject.tipo_emissao = :svc
|
515
|
+
subject.ibge_code_of_issuer_uf = 42
|
516
|
+
subject.codigo_tipo_emissao(nota_fiscal).must_equal 6
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
describe '#inicio_contingencia' do
|
521
|
+
it "deve fazer parse para Time se passar qualquer valor" do
|
522
|
+
subject.inicio_contingencia = '05/06/2018 03:35'
|
523
|
+
subject.inicio_contingencia.must_be_close_to Time.zone.parse('05/06/2018 03:35')
|
524
|
+
|
525
|
+
subject.inicio_contingencia = now = DateTime.current
|
526
|
+
subject.inicio_contingencia.must_be_close_to now.to_time.in_time_zone
|
527
|
+
end
|
528
|
+
it "se passar um valor Time deve retornar o mesmo valor" do
|
529
|
+
subject.inicio_contingencia = now = Time.current
|
530
|
+
subject.inicio_contingencia.to_s.must_equal now.in_time_zone.to_s
|
531
|
+
end
|
532
|
+
it "deve retornar nil se passar um valor inválido" do
|
533
|
+
subject.inicio_contingencia = '77777777777'
|
534
|
+
subject.inicio_contingencia.must_be_nil
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
end
|