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,105 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Nfe::Cobranca::Pagamento do
|
4
|
+
subject { FactoryGirl.build(:product_cobranca_pagamento) }
|
5
|
+
|
6
|
+
describe "Alias attributes" do
|
7
|
+
it { must_have_alias_attribute :tPag, :forma_pagamento }
|
8
|
+
it { must_have_alias_attribute :vPag, :total }
|
9
|
+
it { must_have_alias_attribute :CNPJ, :cartao_cnpj, '01234567890' }
|
10
|
+
it { must_have_alias_attribute :tBand, :cartao_bandeira }
|
11
|
+
it { must_have_alias_attribute :cAut, :cartao_autorizacao }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'Validations' do
|
15
|
+
it { must validate_presence_of(:forma_pagamento) }
|
16
|
+
it { must validate_presence_of(:total) }
|
17
|
+
it { must validate_inclusion_of(:forma_pagamento).in_array(BrNfe::Constants::FORMAS_PAGAMENTO) }
|
18
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0) }
|
19
|
+
|
20
|
+
context "validações para forma de pagaemtno com cartão" do
|
21
|
+
describe "Quando o pagamento for com cartão" do
|
22
|
+
before { subject.stubs(:cartao?).returns(true) }
|
23
|
+
it { must validate_presence_of(:cartao_cnpj) }
|
24
|
+
it { must validate_presence_of(:cartao_bandeira) }
|
25
|
+
it { must validate_presence_of(:cartao_autorizacao) }
|
26
|
+
it { must validate_length_of(:cartao_cnpj).is_at_most(14) }
|
27
|
+
it { must validate_length_of(:cartao_autorizacao).is_at_most(20) }
|
28
|
+
it { must validate_inclusion_of(:cartao_bandeira).in_array([1, 2, 3, 4, 99, '1', '2', '3', '4', '01', '02', '03', '04', '99']) }
|
29
|
+
end
|
30
|
+
describe "Quando o pagamento não for com cartão" do
|
31
|
+
before { subject.stubs(:cartao?).returns(false) }
|
32
|
+
it { wont validate_presence_of(:cartao_cnpj) }
|
33
|
+
it { wont validate_presence_of(:cartao_bandeira) }
|
34
|
+
it { wont validate_presence_of(:cartao_autorizacao) }
|
35
|
+
it { wont validate_length_of(:cartao_cnpj).is_at_most(14) }
|
36
|
+
it { wont validate_length_of(:cartao_autorizacao).is_at_most(20) }
|
37
|
+
it { wont validate_inclusion_of(:cartao_bandeira).in_array([1, 2, 3, 4, 99, '1', '2', '3', '4', '01', '02', '03', '04', '99']) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "cartao_cnpj deve retornar apenas os números" do
|
43
|
+
subject.cartao_cnpj = '012.345.55/0001-66'
|
44
|
+
subject.cartao_cnpj.must_equal '01234555000166'
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#cartao?' do
|
48
|
+
it "deve retornar true se a forma de pagamento for 3 ou 4" do
|
49
|
+
subject.forma_pagamento = 3
|
50
|
+
subject.cartao?.must_equal true
|
51
|
+
subject.forma_pagamento = '3'
|
52
|
+
subject.cartao?.must_equal true
|
53
|
+
subject.forma_pagamento = '03'
|
54
|
+
subject.cartao?.must_equal true
|
55
|
+
subject.forma_pagamento = 4
|
56
|
+
subject.cartao?.must_equal true
|
57
|
+
subject.forma_pagamento = '4'
|
58
|
+
subject.cartao?.must_equal true
|
59
|
+
subject.forma_pagamento = '04'
|
60
|
+
subject.cartao?.must_equal true
|
61
|
+
end
|
62
|
+
it "deve retornar false se a forma de pagamento não for 3 ou 4" do
|
63
|
+
subject.forma_pagamento = 1
|
64
|
+
subject.cartao?.must_equal false
|
65
|
+
subject.forma_pagamento = '1'
|
66
|
+
subject.cartao?.must_equal false
|
67
|
+
subject.forma_pagamento = '01'
|
68
|
+
subject.cartao?.must_equal false
|
69
|
+
subject.forma_pagamento = 2
|
70
|
+
subject.cartao?.must_equal false
|
71
|
+
subject.forma_pagamento = '2'
|
72
|
+
subject.cartao?.must_equal false
|
73
|
+
subject.forma_pagamento = '02'
|
74
|
+
subject.cartao?.must_equal false
|
75
|
+
subject.forma_pagamento = 5
|
76
|
+
subject.cartao?.must_equal false
|
77
|
+
subject.forma_pagamento = '5'
|
78
|
+
subject.cartao?.must_equal false
|
79
|
+
subject.forma_pagamento = '05'
|
80
|
+
subject.cartao?.must_equal false
|
81
|
+
subject.forma_pagamento = 10
|
82
|
+
subject.cartao?.must_equal false
|
83
|
+
subject.forma_pagamento = '10'
|
84
|
+
subject.cartao?.must_equal false
|
85
|
+
subject.forma_pagamento = 11
|
86
|
+
subject.cartao?.must_equal false
|
87
|
+
subject.forma_pagamento = '11'
|
88
|
+
subject.cartao?.must_equal false
|
89
|
+
subject.forma_pagamento = 12
|
90
|
+
subject.cartao?.must_equal false
|
91
|
+
subject.forma_pagamento = '12'
|
92
|
+
subject.cartao?.must_equal false
|
93
|
+
subject.forma_pagamento = 13
|
94
|
+
subject.cartao?.must_equal false
|
95
|
+
subject.forma_pagamento = '13'
|
96
|
+
subject.cartao?.must_equal false
|
97
|
+
subject.forma_pagamento = 99
|
98
|
+
subject.cartao?.must_equal false
|
99
|
+
subject.forma_pagamento = '99'
|
100
|
+
subject.cartao?.must_equal false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Nfe::DeclaracaoImportacao do
|
4
|
+
subject { FactoryGirl.build(:product_declaracao_importacao) }
|
5
|
+
|
6
|
+
describe "Alias attributes" do
|
7
|
+
it { must_have_alias_attribute :nDI, :numero_documento }
|
8
|
+
it { must_have_alias_attribute :dDI, :data_registro, Date.current }
|
9
|
+
it { must_have_alias_attribute :xLocDesemb, :local_desembaraco }
|
10
|
+
it { must_have_alias_attribute :UFDesemb, :uf_desembaraco }
|
11
|
+
it { must_have_alias_attribute :dDesemb, :data_desembaraco, Date.current }
|
12
|
+
it { must_have_alias_attribute :tpViaTransp, :via_transporte }
|
13
|
+
it { must_have_alias_attribute :vAFRMM, :valor_afrmm }
|
14
|
+
it { must_have_alias_attribute :tpIntermedio, :tipo_intermediacao }
|
15
|
+
it { must_have_alias_attribute :CNPJ, :cnpj_adquirente, '01234567890' }
|
16
|
+
it { must_have_alias_attribute :UFTerceiro, :uf_terceiro }
|
17
|
+
it { must_have_alias_attribute :cExportador, :codigo_exportador }
|
18
|
+
it { must_have_alias_attribute :nAdicao, :adicoes, [BrNfe.adicao_importacao_product_class.new] }
|
19
|
+
end
|
20
|
+
describe "Default values" do
|
21
|
+
it "for via_transporte" do
|
22
|
+
subject.class.new.via_transporte.must_equal 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'Validações' do
|
27
|
+
it { must validate_presence_of(:numero_documento) }
|
28
|
+
it { must validate_length_of(:numero_documento).is_at_most(12) }
|
29
|
+
it { must validate_presence_of(:data_registro) }
|
30
|
+
it { must validate_presence_of(:local_desembaraco) }
|
31
|
+
it { must validate_length_of(:local_desembaraco).is_at_most(60) }
|
32
|
+
it { must validate_presence_of(:uf_desembaraco) }
|
33
|
+
it { must validate_inclusion_of(:uf_desembaraco).in_array(BrNfe::Constants::SIGLAS_UF) }
|
34
|
+
it { must validate_presence_of(:via_transporte) }
|
35
|
+
it { must validate_inclusion_of(:via_transporte).in_array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) }
|
36
|
+
it { must validate_presence_of(:tipo_intermediacao) }
|
37
|
+
it { must validate_inclusion_of(:tipo_intermediacao).in_array([1, 2, 3]) }
|
38
|
+
it { must validate_presence_of(:codigo_exportador) }
|
39
|
+
it { must validate_length_of(:codigo_exportador).is_at_most(60) }
|
40
|
+
|
41
|
+
describe '#valor_afrmm' do
|
42
|
+
it "deve ser obrigatório se a via_transporte for 1" do
|
43
|
+
subject.via_transporte = 1
|
44
|
+
must validate_presence_of(:valor_afrmm)
|
45
|
+
end
|
46
|
+
it "não deve ser obrigatório se a via_transporte for diferente de 1" do
|
47
|
+
subject.via_transporte = 2
|
48
|
+
wont validate_presence_of(:valor_afrmm)
|
49
|
+
subject.via_transporte = 3
|
50
|
+
wont validate_presence_of(:valor_afrmm)
|
51
|
+
subject.via_transporte = 12
|
52
|
+
wont validate_presence_of(:valor_afrmm)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#cnpj_adquirente' do
|
57
|
+
it "Não deve ser obrigatório se o tipo_intermediacao for 1" do
|
58
|
+
subject.tipo_intermediacao = 1
|
59
|
+
wont validate_presence_of(:cnpj_adquirente)
|
60
|
+
end
|
61
|
+
it "Deve ser obrigatório se o tipo_intermediacao for 2" do
|
62
|
+
subject.tipo_intermediacao = 2
|
63
|
+
must validate_presence_of(:cnpj_adquirente)
|
64
|
+
end
|
65
|
+
it "Deve ser obrigatório se o tipo_intermediacao for 3" do
|
66
|
+
subject.tipo_intermediacao = 3
|
67
|
+
must validate_presence_of(:cnpj_adquirente)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe '#uf_terceiro' do
|
71
|
+
it { must validate_inclusion_of(:uf_terceiro).in_array(BrNfe::Constants::SIGLAS_UF-['EX']) }
|
72
|
+
it { wont allow_value('EX').for(:uf_terceiro) }
|
73
|
+
|
74
|
+
it "Não deve ser obrigatório se o tipo_intermediacao for 1" do
|
75
|
+
subject.tipo_intermediacao = 1
|
76
|
+
wont validate_presence_of(:uf_terceiro)
|
77
|
+
end
|
78
|
+
it "Deve ser obrigatório se o tipo_intermediacao for 2" do
|
79
|
+
subject.tipo_intermediacao = 2
|
80
|
+
must validate_presence_of(:uf_terceiro)
|
81
|
+
end
|
82
|
+
it "Deve ser obrigatório se o tipo_intermediacao for 3" do
|
83
|
+
subject.tipo_intermediacao = 3
|
84
|
+
must validate_presence_of(:uf_terceiro)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#adicoes' do
|
90
|
+
it { must_validate_length_has_many(:adicoes, BrNfe.adicao_importacao_product_class, {in: 1..100}) }
|
91
|
+
it { must_validates_has_many(:adicoes, BrNfe.adicao_importacao_product_class, :invalid_adicao) }
|
92
|
+
it { must_have_many(:adicoes, BrNfe.adicao_importacao_product_class, {numero_adicao: 'NR123', sequencial: '1'}) }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#via_transporte' do
|
96
|
+
it "sempre deve converter o valor para inteiro" do
|
97
|
+
subject.via_transporte = '123'
|
98
|
+
subject.via_transporte.must_equal 123
|
99
|
+
subject.via_transporte = '7'
|
100
|
+
subject.via_transporte.must_equal 7
|
101
|
+
end
|
102
|
+
it "se via_transporte não tiver valor setado deve retornar nil" do
|
103
|
+
subject.via_transporte = ''
|
104
|
+
subject.via_transporte.must_be_nil
|
105
|
+
subject.via_transporte = nil
|
106
|
+
subject.via_transporte.must_be_nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "cnpj_adquirente" do
|
111
|
+
it "Deve retornar apenas os numeros" do
|
112
|
+
subject.cnpj_adquirente = '012.345.55/0001-66'
|
113
|
+
subject.cnpj_adquirente.must_equal '01234555000166'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Nfe::DetalheExportacao do
|
4
|
+
subject { FactoryGirl.build(:product_detalhe_exportacao) }
|
5
|
+
|
6
|
+
describe "Alias attributes" do
|
7
|
+
it { must_have_alias_attribute :nDraw, :numero_drawback, '1' }
|
8
|
+
it { must_have_alias_attribute :nRE, :numero_registro, '1' }
|
9
|
+
it { must_have_alias_attribute :chNFe, :chave_nfe_recebida, '1' }
|
10
|
+
it { must_have_alias_attribute :qExport, :quantidade }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Validações' do
|
14
|
+
before { MiniTest::Spec.string_for_validation_length = '1' }
|
15
|
+
after { MiniTest::Spec.string_for_validation_length = 'x' }
|
16
|
+
it { must validate_length_of(:numero_drawback).is_at_least(9).is_at_most(12) }
|
17
|
+
it { must validate_length_of(:numero_registro).is_equal_to(12) }
|
18
|
+
it { must validate_length_of(:chave_nfe_recebida).is_equal_to(44) }
|
19
|
+
it { must validate_numericality_of(:quantidade).is_greater_than(0.0).allow_nil }
|
20
|
+
end
|
21
|
+
describe '#numero_drawback' do
|
22
|
+
it "deve aceitar apenas números" do
|
23
|
+
subject.numero_drawback = 'ABC123DEF456G'
|
24
|
+
subject.numero_drawback.must_equal '123456'
|
25
|
+
end
|
26
|
+
it "deve ignorar os espacos em branco" do
|
27
|
+
subject.numero_drawback = ' 6546.546 '
|
28
|
+
subject.numero_drawback.must_equal '6546546'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe '#numero_registro' do
|
32
|
+
it "deve aceitar apenas números" do
|
33
|
+
subject.numero_registro = 'ABC123DEF456G'
|
34
|
+
subject.numero_registro.must_equal '123456'
|
35
|
+
end
|
36
|
+
it "deve ignorar os espacos em branco" do
|
37
|
+
subject.numero_registro = ' 6546.546 '
|
38
|
+
subject.numero_registro.must_equal '6546546'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
describe '#chave_nfe_recebida' do
|
42
|
+
it "deve aceitar apenas números" do
|
43
|
+
subject.chave_nfe_recebida = 'ABC123DEF456G'
|
44
|
+
subject.chave_nfe_recebida.must_equal '123456'
|
45
|
+
end
|
46
|
+
it "deve ignorar os espacos em branco" do
|
47
|
+
subject.chave_nfe_recebida = ' 6546.546 '
|
48
|
+
subject.chave_nfe_recebida.must_equal '6546546'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
describe '#ignore?' do
|
52
|
+
before do
|
53
|
+
subject.assign_attributes(numero_drawback: '', numero_registro: nil,
|
54
|
+
chave_nfe_recebida: '', quantidade: nil)
|
55
|
+
end
|
56
|
+
it "deve retornar true se todas as informaçẽos estiverem em branco" do
|
57
|
+
subject.ignore?.must_equal true
|
58
|
+
end
|
59
|
+
it "deve retornar false se numero_drawback estiver preenchido" do
|
60
|
+
subject.numero_drawback = '213456'
|
61
|
+
subject.ignore?.must_equal false
|
62
|
+
end
|
63
|
+
it "deve retornar false se numero_registro estiver preenchido" do
|
64
|
+
subject.numero_registro = '213456'
|
65
|
+
subject.ignore?.must_equal false
|
66
|
+
end
|
67
|
+
it "deve retornar false se chave_nfe_recebida estiver preenchido" do
|
68
|
+
subject.chave_nfe_recebida = '213456'
|
69
|
+
subject.ignore?.must_equal false
|
70
|
+
end
|
71
|
+
it "deve retornar false se quantidade estiver preenchido" do
|
72
|
+
subject.quantidade = 45.78
|
73
|
+
subject.ignore?.must_equal false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
describe '#exportacao_indireta?' do
|
77
|
+
before do
|
78
|
+
subject.assign_attributes(numero_drawback: '123', numero_registro: nil,
|
79
|
+
chave_nfe_recebida: '', quantidade: nil)
|
80
|
+
end
|
81
|
+
it "deve retornar false se nenhuma informação de exportação indireta for preenchida" do
|
82
|
+
subject.exportacao_indireta?.must_equal false
|
83
|
+
end
|
84
|
+
it "deve retornar true se numero_registro estiver preenchido" do
|
85
|
+
subject.numero_registro = '213456'
|
86
|
+
subject.exportacao_indireta?.must_equal true
|
87
|
+
end
|
88
|
+
it "deve retornar true se chave_nfe_recebida estiver preenchido" do
|
89
|
+
subject.chave_nfe_recebida = '213456'
|
90
|
+
subject.exportacao_indireta?.must_equal true
|
91
|
+
end
|
92
|
+
it "deve retornar true se quantidade estiver preenchido" do
|
93
|
+
subject.quantidade = 45.78
|
94
|
+
subject.exportacao_indireta?.must_equal true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Nfe::ItemTax::CofinsSt do
|
4
|
+
subject { FactoryGirl.build(:product_item_tax_cofins_st) }
|
5
|
+
|
6
|
+
describe 'Alias attributes' do
|
7
|
+
it { must_have_alias_attribute :vBC, :total_base_calculo }
|
8
|
+
it { must_have_alias_attribute :pCOFINS, :aliquota }
|
9
|
+
it { must_have_alias_attribute :vCOFINS, :total }
|
10
|
+
it { must_have_alias_attribute :qBCProd, :quantidade_vendida }
|
11
|
+
it { must_have_alias_attribute :vAliqProd, :total_aliquota }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'Validations' do
|
15
|
+
it { must validate_presence_of(:total) }
|
16
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
17
|
+
it { must validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
18
|
+
it { must validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
19
|
+
it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
20
|
+
it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe BrNfe::Product::Nfe::ItemTax::Cofins do
|
4
|
+
subject { FactoryGirl.build(:product_item_tax_cofins) }
|
5
|
+
|
6
|
+
describe 'Alias attributes' do
|
7
|
+
it { must_have_alias_attribute :CST, :codigo_cst, '01' }
|
8
|
+
it { must_have_alias_attribute :vBC, :total_base_calculo }
|
9
|
+
it { must_have_alias_attribute :pCOFINS, :aliquota }
|
10
|
+
it { must_have_alias_attribute :vCOFINS, :total }
|
11
|
+
it { must_have_alias_attribute :qBCProd, :quantidade_vendida }
|
12
|
+
it { must_have_alias_attribute :vAliqProd, :total_aliquota }
|
13
|
+
end
|
14
|
+
|
15
|
+
it { must_have_default_value_for(:codigo_cst, '07') }
|
16
|
+
|
17
|
+
describe 'Validations' do
|
18
|
+
context '#codigo_cst' do
|
19
|
+
it { must validate_presence_of(:codigo_cst) }
|
20
|
+
it { must validate_inclusion_of(:codigo_cst).in_array(%w[01 02 03 04 05 06 07 08 09 49 50 51 52 53 54 55 56 60 61 62 63 64 65 66 67 70 71 72 73 74 75 98 99]) }
|
21
|
+
end
|
22
|
+
context "CST 01" do
|
23
|
+
before { subject.codigo_cst = '01' }
|
24
|
+
it { must validate_presence_of(:total_base_calculo) }
|
25
|
+
it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
26
|
+
it { must validate_presence_of(:aliquota) }
|
27
|
+
it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
28
|
+
it { must validate_presence_of(:total) }
|
29
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
30
|
+
|
31
|
+
it { wont validate_presence_of(:quantidade_vendida) }
|
32
|
+
it { wont validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
33
|
+
it { wont validate_presence_of(:total_aliquota) }
|
34
|
+
it { wont validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
35
|
+
end
|
36
|
+
context "CST 02" do
|
37
|
+
before { subject.codigo_cst = '02' }
|
38
|
+
it { must validate_presence_of(:total_base_calculo) }
|
39
|
+
it { must validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
40
|
+
it { must validate_presence_of(:aliquota) }
|
41
|
+
it { must validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
42
|
+
it { must validate_presence_of(:total) }
|
43
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
44
|
+
|
45
|
+
it { wont validate_presence_of(:quantidade_vendida) }
|
46
|
+
it { wont validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
47
|
+
it { wont validate_presence_of(:total_aliquota) }
|
48
|
+
it { wont validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
49
|
+
end
|
50
|
+
context "CST 03" do
|
51
|
+
before { subject.codigo_cst = '03' }
|
52
|
+
it { must validate_presence_of(:quantidade_vendida) }
|
53
|
+
it { must validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
54
|
+
it { must validate_presence_of(:total_aliquota) }
|
55
|
+
it { must validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
56
|
+
it { must validate_presence_of(:total) }
|
57
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
58
|
+
|
59
|
+
it { wont validate_presence_of(:total_base_calculo) }
|
60
|
+
it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
61
|
+
it { wont validate_presence_of(:aliquota) }
|
62
|
+
it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "CSTs 04, 05, 06, 07, 08 e 09" do
|
66
|
+
%w[04 05 06 07 08 09].each do |cst|
|
67
|
+
before { subject.codigo_cst = cst }
|
68
|
+
it { wont validate_presence_of(:quantidade_vendida) }
|
69
|
+
it { wont validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
70
|
+
it { wont validate_presence_of(:total_aliquota) }
|
71
|
+
it { wont validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
72
|
+
it { wont validate_presence_of(:total) }
|
73
|
+
it { wont validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
74
|
+
it { wont validate_presence_of(:total_base_calculo) }
|
75
|
+
it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
76
|
+
it { wont validate_presence_of(:aliquota) }
|
77
|
+
it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "CST 49..99" do
|
82
|
+
%w[49 50 51 52 53 54 55 56 60 61 62 63 64 65 66 67 70 71 72 73 74 75 98 99].each do |cst|
|
83
|
+
before { subject.codigo_cst = cst }
|
84
|
+
it { must validate_presence_of(:total) }
|
85
|
+
it { must validate_numericality_of(:total).is_greater_than_or_equal_to(0.0).allow_nil }
|
86
|
+
|
87
|
+
it { wont validate_presence_of(:quantidade_vendida) }
|
88
|
+
it { wont validate_numericality_of(:quantidade_vendida).is_greater_than_or_equal_to(0.0).allow_nil }
|
89
|
+
it { wont validate_presence_of(:total_aliquota) }
|
90
|
+
it { wont validate_numericality_of(:total_aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
91
|
+
it { wont validate_presence_of(:total_base_calculo) }
|
92
|
+
it { wont validate_numericality_of(:total_base_calculo).is_greater_than_or_equal_to(0.0).allow_nil }
|
93
|
+
it { wont validate_presence_of(:aliquota) }
|
94
|
+
it { wont validate_numericality_of(:aliquota).is_greater_than_or_equal_to(0.0).allow_nil }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#codigo_cst' do
|
100
|
+
it "deve sempre retornar uam string" do
|
101
|
+
subject.codigo_cst = 100
|
102
|
+
subject.codigo_cst.must_equal '100'
|
103
|
+
end
|
104
|
+
it "deve ajustar o valor para 2 posições adicionando zeros" do
|
105
|
+
subject.codigo_cst = 0
|
106
|
+
subject.codigo_cst.must_equal '00'
|
107
|
+
end
|
108
|
+
it "se não tiver valor setado deve retornar nil" do
|
109
|
+
subject.codigo_cst = ''
|
110
|
+
subject.codigo_cst.must_be_nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|