nf-e 0.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +201 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/circle.yml +7 -0
- data/config/locales/commons.yml +15 -0
- data/config/locales/models/dest.yml +13 -0
- data/config/locales/models/emit.yml +14 -0
- data/config/locales/models/ender.yml +13 -0
- data/config/locales/models/envi_nfe.yml +7 -0
- data/config/locales/models/ide.yml +5 -0
- data/config/locales/models/nfe.yml +5 -0
- data/config/locales/operations/correction_letter.yml +4 -0
- data/config/locales/operations/nfe_cancel.yml +4 -0
- data/config/locales/operations/nfe_discard.yml +7 -0
- data/config/locales/pt-BR.yml +211 -0
- data/lib/nf-e.rb +20 -0
- data/lib/nfe/helpers/nfe_key.rb +103 -0
- data/lib/nfe/helpers/schema_validator.rb +24 -0
- data/lib/nfe/helpers/signer.rb +25 -0
- data/lib/nfe/helpers/uf_helper.rb +23 -0
- data/lib/nfe/helpers/xml_model/attribute_base.rb +60 -0
- data/lib/nfe/helpers/xml_model/attribute_bigdecimal.rb +16 -0
- data/lib/nfe/helpers/xml_model/attribute_collection.rb +37 -0
- data/lib/nfe/helpers/xml_model/attribute_date.rb +20 -0
- data/lib/nfe/helpers/xml_model/attribute_datetime.rb +20 -0
- data/lib/nfe/helpers/xml_model/attribute_enumerize.rb +12 -0
- data/lib/nfe/helpers/xml_model/attribute_float.rb +20 -0
- data/lib/nfe/helpers/xml_model/attribute_integer.rb +12 -0
- data/lib/nfe/helpers/xml_model/attribute_node.rb +17 -0
- data/lib/nfe/helpers/xml_model/attribute_nodeattribute.rb +16 -0
- data/lib/nfe/helpers/xml_model/attribute_text.rb +31 -0
- data/lib/nfe/helpers/xml_model/factory.rb +17 -0
- data/lib/nfe/helpers/xml_model/nfe_model.rb +120 -0
- data/lib/nfe/models/NFe.rb +47 -0
- data/lib/nfe/models/avulsa.rb +59 -0
- data/lib/nfe/models/bill/cobr.rb +23 -0
- data/lib/nfe/models/bill/dup.rb +23 -0
- data/lib/nfe/models/bill/fat.rb +36 -0
- data/lib/nfe/models/cane/bigdecimal_greater_than_validator.rb +11 -0
- data/lib/nfe/models/cane/bigdecimal_less_than_validator.rb +9 -0
- data/lib/nfe/models/cane/cana.rb +100 -0
- data/lib/nfe/models/cane/deduc.rb +24 -0
- data/lib/nfe/models/cane/forDia.rb +33 -0
- data/lib/nfe/models/compra.rb +21 -0
- data/lib/nfe/models/concerns/cnpj_cpf_validatable.rb +22 -0
- data/lib/nfe/models/concerns/ufable.rb +20 -0
- data/lib/nfe/models/det.rb +34 -0
- data/lib/nfe/models/emitter/emit.rb +56 -0
- data/lib/nfe/models/ender.rb +64 -0
- data/lib/nfe/models/entrega_retirada.rb +47 -0
- data/lib/nfe/models/evento.rb +71 -0
- data/lib/nfe/models/exporta.rb +19 -0
- data/lib/nfe/models/ide.rb +140 -0
- data/lib/nfe/models/infNFe.rb +82 -0
- data/lib/nfe/models/information/infAdic.rb +51 -0
- data/lib/nfe/models/information/obsContFisco.rb +21 -0
- data/lib/nfe/models/information/procRef.rb +25 -0
- data/lib/nfe/models/itens/CIDE.rb +32 -0
- data/lib/nfe/models/itens/DI.rb +55 -0
- data/lib/nfe/models/itens/adi.rb +34 -0
- data/lib/nfe/models/itens/arma.rb +31 -0
- data/lib/nfe/models/itens/comb.rb +41 -0
- data/lib/nfe/models/itens/med.rb +40 -0
- data/lib/nfe/models/itens/prod.rb +115 -0
- data/lib/nfe/models/itens/veicProd.rb +140 -0
- data/lib/nfe/models/nfeProc.rb +29 -0
- data/lib/nfe/models/procEventoNFe.rb +29 -0
- data/lib/nfe/models/procInutNFe.rb +28 -0
- data/lib/nfe/models/recipient/dest.rb +57 -0
- data/lib/nfe/models/referenced/NFref.rb +44 -0
- data/lib/nfe/models/referenced/refECF.rb +26 -0
- data/lib/nfe/models/referenced/refNF.rb +43 -0
- data/lib/nfe/models/referenced/refNFP.rb +40 -0
- data/lib/nfe/models/signature.rb +53 -0
- data/lib/nfe/models/taxes/ICMS.rb +100 -0
- data/lib/nfe/models/taxes/ICMS00.rb +39 -0
- data/lib/nfe/models/taxes/ICMS10.rb +82 -0
- data/lib/nfe/models/taxes/ICMS101.rb +26 -0
- data/lib/nfe/models/taxes/ICMS102.rb +10 -0
- data/lib/nfe/models/taxes/ICMS103.rb +13 -0
- data/lib/nfe/models/taxes/ICMS20.rb +46 -0
- data/lib/nfe/models/taxes/ICMS201.rb +67 -0
- data/lib/nfe/models/taxes/ICMS202.rb +53 -0
- data/lib/nfe/models/taxes/ICMS203.rb +13 -0
- data/lib/nfe/models/taxes/ICMS30.rb +55 -0
- data/lib/nfe/models/taxes/ICMS300.rb +13 -0
- data/lib/nfe/models/taxes/ICMS40.rb +24 -0
- data/lib/nfe/models/taxes/ICMS400.rb +13 -0
- data/lib/nfe/models/taxes/ICMS41.rb +13 -0
- data/lib/nfe/models/taxes/ICMS50.rb +13 -0
- data/lib/nfe/models/taxes/ICMS500.rb +28 -0
- data/lib/nfe/models/taxes/ICMS51.rb +48 -0
- data/lib/nfe/models/taxes/ICMS60.rb +28 -0
- data/lib/nfe/models/taxes/ICMS70.rb +89 -0
- data/lib/nfe/models/taxes/ICMS90.rb +90 -0
- data/lib/nfe/models/taxes/ICMS900.rb +100 -0
- data/lib/nfe/models/taxes/ICMSBase.rb +21 -0
- data/lib/nfe/models/taxes/ICMSNormalBase.rb +15 -0
- data/lib/nfe/models/taxes/ICMSPart.rb +112 -0
- data/lib/nfe/models/taxes/ICMSSNBase.rb +19 -0
- data/lib/nfe/models/taxes/ICMSST.rb +50 -0
- data/lib/nfe/models/taxes/ICMSTot.rb +124 -0
- data/lib/nfe/models/taxes/II.rb +39 -0
- data/lib/nfe/models/taxes/IPI.rb +133 -0
- data/lib/nfe/models/taxes/IPINT.rb +17 -0
- data/lib/nfe/models/taxes/IPITrib.rb +51 -0
- data/lib/nfe/models/taxes/ISSQN.rb +54 -0
- data/lib/nfe/models/taxes/ISSQNtot.rb +51 -0
- data/lib/nfe/models/taxes/PISCOFINS.rb +173 -0
- data/lib/nfe/models/taxes/PISCOFINSAliq.rb +62 -0
- data/lib/nfe/models/taxes/PISCOFINSNT.rb +20 -0
- data/lib/nfe/models/taxes/PISCOFINSOutr.rb +87 -0
- data/lib/nfe/models/taxes/PISCOFINSQtde.rb +56 -0
- data/lib/nfe/models/taxes/PISCOFINSST.rb +78 -0
- data/lib/nfe/models/taxes/imposto.rb +44 -0
- data/lib/nfe/models/taxes/retTrib.rb +67 -0
- data/lib/nfe/models/total.rb +23 -0
- data/lib/nfe/models/transport/lacres.rb +16 -0
- data/lib/nfe/models/transport/retTransp.rb +49 -0
- data/lib/nfe/models/transport/transp.rb +50 -0
- data/lib/nfe/models/transport/transporta.rb +42 -0
- data/lib/nfe/models/transport/veicTransp_reboque.rb +23 -0
- data/lib/nfe/models/transport/vol.rb +50 -0
- data/lib/nfe/operations/base.rb +101 -0
- data/lib/nfe/operations/consult_emitter.rb +62 -0
- data/lib/nfe/operations/correction_letter.rb +37 -0
- data/lib/nfe/operations/event.rb +117 -0
- data/lib/nfe/operations/nfe_cancel.rb +47 -0
- data/lib/nfe/operations/nfe_discard.rb +106 -0
- data/lib/nfe/operations/nfe_send.rb +125 -0
- data/lib/nfe/operations/nfe_situation.rb +46 -0
- data/lib/nfe/operations/service_status.rb +44 -0
- data/lib/nfe/schemas/CCe_v1.00.xsd +11 -0
- data/lib/nfe/schemas/consCad_v2.00.xsd +9 -0
- data/lib/nfe/schemas/consReciNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/consSitNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/consStatServ_v3.10.xsd +9 -0
- data/lib/nfe/schemas/envCCe_v1.00.xsd +10 -0
- data/lib/nfe/schemas/envEventoCancNFe_v1.00.xsd +9 -0
- data/lib/nfe/schemas/enviNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/inutNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/leiauteCCe_v1.00.xsd +423 -0
- data/lib/nfe/schemas/leiauteConsSitNFe_v3.10.xsd +502 -0
- data/lib/nfe/schemas/leiauteConsStatServ_v3.10.xsd +98 -0
- data/lib/nfe/schemas/leiauteConsultaCadastro_v2.00.xsd +404 -0
- data/lib/nfe/schemas/leiauteEventoCancNFe_v1.00.xsd +400 -0
- data/lib/nfe/schemas/leiauteInutNFe_v3.10.xsd +193 -0
- data/lib/nfe/schemas/leiauteNFe_v3.10.xsd +7212 -0
- data/lib/nfe/schemas/nfe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/procInutNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/procNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/retConsReciNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/retConsSitNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/retConsStatServ_v3.10.xsd +9 -0
- data/lib/nfe/schemas/retEnviNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/retInutNFe_v3.10.xsd +9 -0
- data/lib/nfe/schemas/tiposBasico_v1.03.xsd +791 -0
- data/lib/nfe/schemas/tiposBasico_v3.10.xsd +877 -0
- data/lib/nfe/schemas/xmldsig-core-schema_v1.01.xsd +98 -0
- data/lib/nfe/services/dispatch/consCad.rb +57 -0
- data/lib/nfe/services/dispatch/consSitNFe.rb +43 -0
- data/lib/nfe/services/dispatch/consStatServ.rb +42 -0
- data/lib/nfe/services/dispatch/detEventoCC.rb +55 -0
- data/lib/nfe/services/dispatch/detEventoCancel.rb +45 -0
- data/lib/nfe/services/dispatch/envEvento.rb +28 -0
- data/lib/nfe/services/dispatch/enviNFe.rb +45 -0
- data/lib/nfe/services/dispatch/inutNFe.rb +93 -0
- data/lib/nfe/services/regress/infCad.rb +34 -0
- data/lib/nfe/services/regress/protNFe.rb +54 -0
- data/lib/nfe/services/regress/retConsCad.rb +27 -0
- data/lib/nfe/services/regress/retConsSitNFe.rb +26 -0
- data/lib/nfe/services/regress/retConsStatServ.rb +25 -0
- data/lib/nfe/services/regress/retEnvEvento.rb +27 -0
- data/lib/nfe/services/regress/retEnviNFe.rb +23 -0
- data/lib/nfe/services/regress/retEvento.rb +60 -0
- data/lib/nfe/services/regress/retInutNFe.rb +56 -0
- data/lib/nfe/version.rb +3 -0
- data/lib/nfe/webservices/client_soap.rb +35 -0
- data/lib/nfe/webservices/sender.rb +42 -0
- data/lib/nfe/webservices/wsinfo/base.rb +35 -0
- data/lib/nfe/webservices/wsinfo/consult_emitter.rb +16 -0
- data/lib/nfe/webservices/wsinfo/event.rb +20 -0
- data/lib/nfe/webservices/wsinfo/factory.rb +31 -0
- data/lib/nfe/webservices/wsinfo/nfe_disenable.rb +16 -0
- data/lib/nfe/webservices/wsinfo/nfe_send.rb +16 -0
- data/lib/nfe/webservices/wsinfo/nfe_situation.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/am.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/ba.rb +21 -0
- data/lib/nfe/webservices/wsinfo/production/ce.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/go.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/mg.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/ms.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/mt.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/pe.rb +16 -0
- data/lib/nfe/webservices/wsinfo/production/pr.rb +22 -0
- data/lib/nfe/webservices/wsinfo/production/rs.rb +21 -0
- data/lib/nfe/webservices/wsinfo/production/sp.rb +21 -0
- data/lib/nfe/webservices/wsinfo/production/svan.rb +24 -0
- data/lib/nfe/webservices/wsinfo/production/svrs.rb +21 -0
- data/lib/nfe/webservices/wsinfo/service_status.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/am.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/ba.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/ce.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/go.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/mg.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/ms.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/mt.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/pe.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/pr.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/rs.rb +17 -0
- data/lib/nfe/webservices/wsinfo/test/sp.rb +16 -0
- data/lib/nfe/webservices/wsinfo/test/svan.rb +20 -0
- data/lib/nfe/webservices/wsinfo/test/svrs.rb +18 -0
- data/lib/nfe/webservices/wsinfo/wsdl_base.rb +46 -0
- data/lib/nfe/webservices/wsinfo/wsdl_finder.rb +31 -0
- data/lib/xmldsig/canonicalize.rb +22 -0
- data/lib/xmldsig/canonicalizer.rb +27 -0
- data/lib/xmldsig/enveloped_signature.rb +10 -0
- data/lib/xmldsig/namespaces.rb +6 -0
- data/lib/xmldsig/reference.rb +72 -0
- data/lib/xmldsig/signature.rb +106 -0
- data/lib/xmldsig/signed_document.rb +28 -0
- data/lib/xmldsig/transform.rb +10 -0
- data/lib/xmldsig/transforms.rb +28 -0
- data/lib/xmldsig/xmldsig.rb +12 -0
- data/nf-e.gemspec +42 -0
- data/spec/nfe/factories/models/NFe.rb +9 -0
- data/spec/nfe/factories/models/avulsa.rb +16 -0
- data/spec/nfe/factories/models/bill/cobr.rb +14 -0
- data/spec/nfe/factories/models/bill/dup.rb +9 -0
- data/spec/nfe/factories/models/bill/fat.rb +10 -0
- data/spec/nfe/factories/models/cane/cana.rb +26 -0
- data/spec/nfe/factories/models/cane/deduc.rb +6 -0
- data/spec/nfe/factories/models/cane/forDia.rb +8 -0
- data/spec/nfe/factories/models/compra.rb +7 -0
- data/spec/nfe/factories/models/det.rb +11 -0
- data/spec/nfe/factories/models/emitter/emit.rb +15 -0
- data/spec/nfe/factories/models/ender.rb +17 -0
- data/spec/nfe/factories/models/entrega_retirada.rb +14 -0
- data/spec/nfe/factories/models/evento.rb +15 -0
- data/spec/nfe/factories/models/exporta.rb +6 -0
- data/spec/nfe/factories/models/ide.rb +43 -0
- data/spec/nfe/factories/models/infNFe.rb +26 -0
- data/spec/nfe/factories/models/information/infAdic.rb +23 -0
- data/spec/nfe/factories/models/information/obsContFisco.rb +8 -0
- data/spec/nfe/factories/models/information/procRef.rb +8 -0
- data/spec/nfe/factories/models/itens/CIDE.rb +7 -0
- data/spec/nfe/factories/models/itens/DI.rb +17 -0
- data/spec/nfe/factories/models/itens/adi.rb +8 -0
- data/spec/nfe/factories/models/itens/arma.rb +8 -0
- data/spec/nfe/factories/models/itens/comb.rb +9 -0
- data/spec/nfe/factories/models/itens/med.rb +9 -0
- data/spec/nfe/factories/models/itens/prod.rb +48 -0
- data/spec/nfe/factories/models/itens/veicProd.rb +28 -0
- data/spec/nfe/factories/models/recipient/dest.rb +13 -0
- data/spec/nfe/factories/models/referenced/NFref.rb +13 -0
- data/spec/nfe/factories/models/referenced/refECF.rb +7 -0
- data/spec/nfe/factories/models/referenced/refNF.rb +10 -0
- data/spec/nfe/factories/models/referenced/refNFP.rb +12 -0
- data/spec/nfe/factories/models/signature.rb +10 -0
- data/spec/nfe/factories/models/taxes/ICMS.rb +203 -0
- data/spec/nfe/factories/models/taxes/ICMS00.rb +10 -0
- data/spec/nfe/factories/models/taxes/ICMS10.rb +16 -0
- data/spec/nfe/factories/models/taxes/ICMS101.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS102.rb +6 -0
- data/spec/nfe/factories/models/taxes/ICMS103.rb +6 -0
- data/spec/nfe/factories/models/taxes/ICMS20.rb +11 -0
- data/spec/nfe/factories/models/taxes/ICMS201.rb +14 -0
- data/spec/nfe/factories/models/taxes/ICMS202.rb +12 -0
- data/spec/nfe/factories/models/taxes/ICMS203.rb +12 -0
- data/spec/nfe/factories/models/taxes/ICMS30.rb +12 -0
- data/spec/nfe/factories/models/taxes/ICMS300.rb +6 -0
- data/spec/nfe/factories/models/taxes/ICMS40.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS400.rb +6 -0
- data/spec/nfe/factories/models/taxes/ICMS41.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS50.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS500.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS51.rb +11 -0
- data/spec/nfe/factories/models/taxes/ICMS60.rb +8 -0
- data/spec/nfe/factories/models/taxes/ICMS70.rb +17 -0
- data/spec/nfe/factories/models/taxes/ICMS90.rb +17 -0
- data/spec/nfe/factories/models/taxes/ICMS900.rb +19 -0
- data/spec/nfe/factories/models/taxes/ICMSPart.rb +19 -0
- data/spec/nfe/factories/models/taxes/ICMSST.rb +9 -0
- data/spec/nfe/factories/models/taxes/ICMSTot.rb +20 -0
- data/spec/nfe/factories/models/taxes/II.rb +8 -0
- data/spec/nfe/factories/models/taxes/IPI.rb +24 -0
- data/spec/nfe/factories/models/taxes/IPINT.rb +5 -0
- data/spec/nfe/factories/models/taxes/IPITrib.rb +10 -0
- data/spec/nfe/factories/models/taxes/ISSQN.rb +10 -0
- data/spec/nfe/factories/models/taxes/ISSQNtot.rb +9 -0
- data/spec/nfe/factories/models/taxes/PISCOFINS.rb +72 -0
- data/spec/nfe/factories/models/taxes/PISCOFINSAliq.rb +21 -0
- data/spec/nfe/factories/models/taxes/PISCOFINSNT.rb +5 -0
- data/spec/nfe/factories/models/taxes/PISCOFINSOutr.rb +23 -0
- data/spec/nfe/factories/models/taxes/PISCOFINSQtde.rb +17 -0
- data/spec/nfe/factories/models/taxes/PISCOFINSST.rb +21 -0
- data/spec/nfe/factories/models/taxes/imposto.rb +15 -0
- data/spec/nfe/factories/models/taxes/retTrib.rb +11 -0
- data/spec/nfe/factories/models/total.rb +7 -0
- data/spec/nfe/factories/models/transport/lacres.rb +6 -0
- data/spec/nfe/factories/models/transport/retTransp.rb +10 -0
- data/spec/nfe/factories/models/transport/transp.rb +18 -0
- data/spec/nfe/factories/models/transport/transporta.rb +11 -0
- data/spec/nfe/factories/models/transport/veicTranspReboque.rb +8 -0
- data/spec/nfe/factories/models/transport/vol.rb +17 -0
- data/spec/nfe/factories/services/consCad.rb +10 -0
- data/spec/nfe/factories/services/consSitNFe.rb +12 -0
- data/spec/nfe/factories/services/consStatServ.rb +7 -0
- data/spec/nfe/factories/services/detEventoCC.rb +6 -0
- data/spec/nfe/factories/services/detEventoCancel.rb +7 -0
- data/spec/nfe/factories/services/envEvento.rb +7 -0
- data/spec/nfe/factories/services/enviNFe.rb +11 -0
- data/spec/nfe/factories/services/inutNFe.rb +15 -0
- data/spec/nfe/factories/services/protNFe.rb +14 -0
- data/spec/nfe/factories/services/retEvento.rb +15 -0
- data/spec/nfe/factories/services/retInutNFe.rb +19 -0
- data/spec/nfe/fixtures/cassettes/correction_letter/error_in_lot.yml +176 -0
- data/spec/nfe/fixtures/cassettes/correction_letter/invalid_response.yml +175 -0
- data/spec/nfe/fixtures/cassettes/correction_letter/rejected.yml +177 -0
- data/spec/nfe/fixtures/cassettes/correction_letter/success.yml +177 -0
- data/spec/nfe/fixtures/cassettes/nfe_cancel/error_in_lot.yml +176 -0
- data/spec/nfe/fixtures/cassettes/nfe_cancel/invalid_response.yml +174 -0
- data/spec/nfe/fixtures/cassettes/nfe_cancel/rejected.yml +177 -0
- data/spec/nfe/fixtures/cassettes/nfe_cancel/success.yml +177 -0
- data/spec/nfe/fixtures/cassettes/nfe_discard/invalid_response.yml +175 -0
- data/spec/nfe/fixtures/cassettes/nfe_discard/rejected.yml +176 -0
- data/spec/nfe/fixtures/cassettes/nfe_discard/success.yml +176 -0
- data/spec/nfe/fixtures/cassettes/nfe_send/authorized.yml +197 -0
- data/spec/nfe/fixtures/cassettes/nfe_send/denied.yml +198 -0
- data/spec/nfe/fixtures/cassettes/nfe_send/error_in_lot.yml +195 -0
- data/spec/nfe/fixtures/cassettes/nfe_send/invalid_response.yml +193 -0
- data/spec/nfe/fixtures/cassettes/nfe_send/rejected.yml +198 -0
- data/spec/nfe/fixtures/certificate.pem +16 -0
- data/spec/nfe/fixtures/invalid_nfe.xml +1 -0
- data/spec/nfe/fixtures/nfe.xml +1 -0
- data/spec/nfe/fixtures/private-key.pem +15 -0
- data/spec/nfe/helpers/nfe_key_spec.rb +87 -0
- data/spec/nfe/helpers/schema_validator_spec.rb +34 -0
- data/spec/nfe/helpers/signer_spec.rb +22 -0
- data/spec/nfe/helpers/uf_helper_spec.rb +331 -0
- data/spec/nfe/helpers/xml_model/attribute_base_spec.rb +63 -0
- data/spec/nfe/helpers/xml_model/attribute_bigdecimal_spec.rb +32 -0
- data/spec/nfe/helpers/xml_model/attribute_collection_spec.rb +46 -0
- data/spec/nfe/helpers/xml_model/attribute_date_spec.rb +40 -0
- data/spec/nfe/helpers/xml_model/attribute_datetime_spec.rb +41 -0
- data/spec/nfe/helpers/xml_model/attribute_enumerize_spec.rb +34 -0
- data/spec/nfe/helpers/xml_model/attribute_float_spec.rb +40 -0
- data/spec/nfe/helpers/xml_model/attribute_integer_spec.rb +33 -0
- data/spec/nfe/helpers/xml_model/attribute_node_spec.rb +44 -0
- data/spec/nfe/helpers/xml_model/attribute_nodeattribute_spec.rb +33 -0
- data/spec/nfe/helpers/xml_model/attribute_text_spec.rb +173 -0
- data/spec/nfe/helpers/xml_model/factory_spec.rb +102 -0
- data/spec/nfe/helpers/xml_model/nfe_model_spec.rb +225 -0
- data/spec/nfe/models/NFe_spec.rb +48 -0
- data/spec/nfe/models/avulsa_spec.rb +140 -0
- data/spec/nfe/models/bigdecimal_greater_than_validator_spec.rb +33 -0
- data/spec/nfe/models/bigdecimal_less_than_validator_spec.rb +33 -0
- data/spec/nfe/models/bill/cobr_spec.rb +98 -0
- data/spec/nfe/models/bill/dup_spec.rb +80 -0
- data/spec/nfe/models/bill/fat_spec.rb +129 -0
- data/spec/nfe/models/cane/cana_spec.rb +161 -0
- data/spec/nfe/models/cane/deduc_spec.rb +40 -0
- data/spec/nfe/models/cane/forDia_spec.rb +51 -0
- data/spec/nfe/models/compra_spec.rb +78 -0
- data/spec/nfe/models/det_spec.rb +94 -0
- data/spec/nfe/models/emitter/emit_spec.rb +150 -0
- data/spec/nfe/models/ender_spec.rb +129 -0
- data/spec/nfe/models/entrega_retirada_spec.rb +159 -0
- data/spec/nfe/models/evento_spec.rb +52 -0
- data/spec/nfe/models/exporta_spec.rb +54 -0
- data/spec/nfe/models/ide_spec.rb +215 -0
- data/spec/nfe/models/infNFe_spec.rb +292 -0
- data/spec/nfe/models/information/infAdic_spec.rb +126 -0
- data/spec/nfe/models/information/obsContFisco_spec.rb +37 -0
- data/spec/nfe/models/information/procRef_spec.rb +41 -0
- data/spec/nfe/models/itens/CIDE_spec.rb +57 -0
- data/spec/nfe/models/itens/DI_spec.rb +67 -0
- data/spec/nfe/models/itens/adi_spec.rb +79 -0
- data/spec/nfe/models/itens/arma_spec.rb +43 -0
- data/spec/nfe/models/itens/comb_spec.rb +103 -0
- data/spec/nfe/models/itens/med_spec.rb +52 -0
- data/spec/nfe/models/itens/prod_spec.rb +249 -0
- data/spec/nfe/models/itens/veicProd_spec.rb +173 -0
- data/spec/nfe/models/nfeProc_spec.rb +21 -0
- data/spec/nfe/models/procEventoNFe_spec.rb +21 -0
- data/spec/nfe/models/procInutNFe_spec.rb +21 -0
- data/spec/nfe/models/recipient/dest_spec.rb +152 -0
- data/spec/nfe/models/referenced/NFref_spec.rb +102 -0
- data/spec/nfe/models/referenced/refECF_spec.rb +59 -0
- data/spec/nfe/models/referenced/refNFP_spec.rb +115 -0
- data/spec/nfe/models/referenced/refNF_spec.rb +82 -0
- data/spec/nfe/models/shared_examples_for_tdec_0302.rb +35 -0
- data/spec/nfe/models/shared_examples_for_tdec_0803.rb +21 -0
- data/spec/nfe/models/shared_examples_for_tdec_1104.rb +38 -0
- data/spec/nfe/models/shared_examples_for_tdec_1204.rb +34 -0
- data/spec/nfe/models/shared_examples_for_tdec_1302.rb +34 -0
- data/spec/nfe/models/signature_spec.rb +56 -0
- data/spec/nfe/models/taxes/ICMS00_spec.rb +27 -0
- data/spec/nfe/models/taxes/ICMS101_spec.rb +21 -0
- data/spec/nfe/models/taxes/ICMS102_spec.rb +15 -0
- data/spec/nfe/models/taxes/ICMS103_spec.rb +15 -0
- data/spec/nfe/models/taxes/ICMS10_spec.rb +83 -0
- data/spec/nfe/models/taxes/ICMS201_spec.rb +67 -0
- data/spec/nfe/models/taxes/ICMS202_spec.rb +61 -0
- data/spec/nfe/models/taxes/ICMS203_spec.rb +61 -0
- data/spec/nfe/models/taxes/ICMS20_spec.rb +30 -0
- data/spec/nfe/models/taxes/ICMS300_spec.rb +16 -0
- data/spec/nfe/models/taxes/ICMS30_spec.rb +67 -0
- data/spec/nfe/models/taxes/ICMS400_spec.rb +15 -0
- data/spec/nfe/models/taxes/ICMS40_spec.rb +51 -0
- data/spec/nfe/models/taxes/ICMS41_spec.rb +51 -0
- data/spec/nfe/models/taxes/ICMS500_spec.rb +46 -0
- data/spec/nfe/models/taxes/ICMS50_spec.rb +51 -0
- data/spec/nfe/models/taxes/ICMS51_spec.rb +55 -0
- data/spec/nfe/models/taxes/ICMS60_spec.rb +52 -0
- data/spec/nfe/models/taxes/ICMS70_spec.rb +84 -0
- data/spec/nfe/models/taxes/ICMS900_spec.rb +80 -0
- data/spec/nfe/models/taxes/ICMS90_spec.rb +83 -0
- data/spec/nfe/models/taxes/ICMSPart_spec.rb +141 -0
- data/spec/nfe/models/taxes/ICMSST_spec.rb +60 -0
- data/spec/nfe/models/taxes/ICMSTot_spec.rb +119 -0
- data/spec/nfe/models/taxes/ICMS_spec.rb +159 -0
- data/spec/nfe/models/taxes/II_spec.rb +58 -0
- data/spec/nfe/models/taxes/IPINT_spec.rb +39 -0
- data/spec/nfe/models/taxes/IPITrib_spec.rb +55 -0
- data/spec/nfe/models/taxes/IPI_spec.rb +128 -0
- data/spec/nfe/models/taxes/ISSQN_spec.rb +62 -0
- data/spec/nfe/models/taxes/ISSQNtot_spec.rb +72 -0
- data/spec/nfe/models/taxes/PISCOFINSAliq_spec.rb +22 -0
- data/spec/nfe/models/taxes/PISCOFINSNT_spec.rb +12 -0
- data/spec/nfe/models/taxes/PISCOFINSOutr_spec.rb +37 -0
- data/spec/nfe/models/taxes/PISCOFINSQtde_spec.rb +21 -0
- data/spec/nfe/models/taxes/PISCOFINSST_spec.rb +60 -0
- data/spec/nfe/models/taxes/PISCOFINS_spec.rb +68 -0
- data/spec/nfe/models/taxes/imposto_spec.rb +159 -0
- data/spec/nfe/models/taxes/retTrib_spec.rb +78 -0
- data/spec/nfe/models/taxes/shared_examples_for_COFINSAliq.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_COFINSNT.rb +35 -0
- data/spec/nfe/models/taxes/shared_examples_for_COFINSOutr.rb +119 -0
- data/spec/nfe/models/taxes/shared_examples_for_COFINSQtde.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS00.rb +45 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS10.rb +57 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS101.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS102.rb +37 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS103.rb +37 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS20.rb +47 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS201.rb +53 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS202.rb +49 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS203.rb +49 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS30.rb +49 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS300.rb +37 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS40.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS400.rb +37 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS41.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS50.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS500.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS51.rb +47 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS60.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS70.rb +59 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS90.rb +59 -0
- data/spec/nfe/models/taxes/shared_examples_for_ICMS900.rb +63 -0
- data/spec/nfe/models/taxes/shared_examples_for_PISAliq.rb +41 -0
- data/spec/nfe/models/taxes/shared_examples_for_PISNT.rb +35 -0
- data/spec/nfe/models/taxes/shared_examples_for_PISOutr.rb +119 -0
- data/spec/nfe/models/taxes/shared_examples_for_PISQtde.rb +41 -0
- data/spec/nfe/models/total_spec.rb +144 -0
- data/spec/nfe/models/transport/lacres_spec.rb +35 -0
- data/spec/nfe/models/transport/retTransp_spec.rb +69 -0
- data/spec/nfe/models/transport/transp_spec.rb +149 -0
- data/spec/nfe/models/transport/transporta_spec.rb +128 -0
- data/spec/nfe/models/transport/veicTranspReboque_spec.rb +83 -0
- data/spec/nfe/models/transport/vol_spec.rb +97 -0
- data/spec/nfe/operations/consult_emitter_spec.rb +31 -0
- data/spec/nfe/operations/correction_letter_spec.rb +198 -0
- data/spec/nfe/operations/nfe_cancel_spec.rb +223 -0
- data/spec/nfe/operations/nfe_discard_spec.rb +172 -0
- data/spec/nfe/operations/nfe_send_spec.rb +220 -0
- data/spec/nfe/operations/nfe_situation_spec.rb +14 -0
- data/spec/nfe/operations/service_status_spec.rb +11 -0
- data/spec/nfe/operations/shared_examples_for_operations.rb +84 -0
- data/spec/nfe/services/dispatch/consCad_spec.rb +80 -0
- data/spec/nfe/services/dispatch/consSitNFe_spec.rb +29 -0
- data/spec/nfe/services/dispatch/consStatServ_spec.rb +25 -0
- data/spec/nfe/services/dispatch/detEventoCC_spec.rb +45 -0
- data/spec/nfe/services/dispatch/detEventoCancel_spec.rb +39 -0
- data/spec/nfe/services/dispatch/envEvento_spec.rb +33 -0
- data/spec/nfe/services/dispatch/enviNFe_spec.rb +27 -0
- data/spec/nfe/services/dispatch/inutNFe_spec.rb +51 -0
- data/spec/nfe/services/regress/infCad_spec.rb +61 -0
- data/spec/nfe/services/regress/protNFe_spec.rb +56 -0
- data/spec/nfe/services/regress/retConsCad_spec.rb +67 -0
- data/spec/nfe/services/regress/retConsSitNFe_spec.rb +46 -0
- data/spec/nfe/services/regress/retConsStatServ_spec.rb +34 -0
- data/spec/nfe/services/regress/retEnvEvento_spec.rb +44 -0
- data/spec/nfe/services/regress/retEnviNFe_spec.rb +44 -0
- data/spec/nfe/services/regress/retEvento_spec.rb +66 -0
- data/spec/nfe/services/regress/retInutNFe_spec.rb +70 -0
- data/spec/nfe/webservices/client_soap_spec.rb +32 -0
- data/spec/nfe/webservices/fixtures/nfe_status_servico2.wsdl +62 -0
- data/spec/nfe/webservices/fixtures/retConsCad.xml +1 -0
- data/spec/nfe/webservices/fixtures/retConsSitNFe.xml +1 -0
- data/spec/nfe/webservices/fixtures/retConsStatServ.xml +1 -0
- data/spec/nfe/webservices/fixtures/retEnvEventoCancNFe.xml +1 -0
- data/spec/nfe/webservices/fixtures/retEnviNFe.xml +1 -0
- data/spec/nfe/webservices/fixtures/retInutNFe.xml +1 -0
- data/spec/nfe/webservices/sender_spec.rb +65 -0
- data/spec/nfe/webservices/wsinfo/consult_emitter_spec.rb +37 -0
- data/spec/nfe/webservices/wsinfo/event_spec.rb +50 -0
- data/spec/nfe/webservices/wsinfo/factory_spec.rb +50 -0
- data/spec/nfe/webservices/wsinfo/nfe_disenable_spec.rb +37 -0
- data/spec/nfe/webservices/wsinfo/nfe_send_spec.rb +37 -0
- data/spec/nfe/webservices/wsinfo/nfe_situation_spec.rb +37 -0
- data/spec/nfe/webservices/wsinfo/production/am_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/ba_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/ce_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/go_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/mg_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/ms_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/mt_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/pe_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/pr_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/rs_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/sp_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/production/svan_spec.rb +26 -0
- data/spec/nfe/webservices/wsinfo/production/svrs_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/service_status_spec.rb +37 -0
- data/spec/nfe/webservices/wsinfo/shared_examples_for_wsdl.rb +39 -0
- data/spec/nfe/webservices/wsinfo/test/am_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/ba_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/ce_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/go_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/mg_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/ms_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/mt_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/pe_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/pr_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/rs_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/sp_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/test/svan_spec.rb +26 -0
- data/spec/nfe/webservices/wsinfo/test/svrs_spec.rb +21 -0
- data/spec/nfe/webservices/wsinfo/wsdl_finder_spec.rb +56 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/utilities.rb +3 -0
- data/spec/xmldsig/canonicalizer_spec.rb +43 -0
- data/spec/xmldsig/enveloped_signature_spec.rb +19 -0
- data/spec/xmldsig/fixtures/certificate.cer +16 -0
- data/spec/xmldsig/fixtures/certificate2.cer +16 -0
- data/spec/xmldsig/fixtures/key.pem +15 -0
- data/spec/xmldsig/fixtures/signed.xml +23 -0
- data/spec/xmldsig/fixtures/unsigned.xml +26 -0
- data/spec/xmldsig/fixtures/unsigned_multiple_references.xml +43 -0
- data/spec/xmldsig/fixtures/unsigned_nested_signature.xml +50 -0
- data/spec/xmldsig/reference_spec.rb +62 -0
- data/spec/xmldsig/signature_spec.rb +119 -0
- data/spec/xmldsig/signed_document_spec.rb +97 -0
- metadata +1201 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class II
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :vBC, type: :float, required: true
|
|
9
|
+
attr_xml :vDespAdu, type: :float, required: true
|
|
10
|
+
attr_xml :vII, type: :float, required: true
|
|
11
|
+
attr_xml :vIOF, type: :float, required: true
|
|
12
|
+
|
|
13
|
+
validates :vBC,
|
|
14
|
+
numericality: {
|
|
15
|
+
greater_than_or_equal_to: 0,
|
|
16
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
validates :vDespAdu,
|
|
20
|
+
numericality: {
|
|
21
|
+
greater_than_or_equal_to: 0,
|
|
22
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
validates :vII,
|
|
26
|
+
numericality: {
|
|
27
|
+
greater_than_or_equal_to: 0,
|
|
28
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
validates :vIOF,
|
|
32
|
+
numericality: {
|
|
33
|
+
greater_than_or_equal_to: 0,
|
|
34
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class IPI
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :clEnq
|
|
9
|
+
attr_xml :cnpjProd, xml_alias: "CNPJProd"
|
|
10
|
+
attr_xml :cSelo
|
|
11
|
+
attr_xml :qSelo
|
|
12
|
+
|
|
13
|
+
attr_accessor :cst, :vBC, :pIPI, :qUnid, :vUnid, :vIPI
|
|
14
|
+
|
|
15
|
+
validates :clEnq,
|
|
16
|
+
length: { is: 5, allow_blank: true }
|
|
17
|
+
|
|
18
|
+
validates :cnpjProd,
|
|
19
|
+
cnpj: true,
|
|
20
|
+
length: { is: 14, allow_blank: true }
|
|
21
|
+
|
|
22
|
+
validates :cSelo,
|
|
23
|
+
length: { maximum: 60, allow_blank: true }
|
|
24
|
+
|
|
25
|
+
validates :qSelo,
|
|
26
|
+
length: { maximum: 12, allow_blank: true }
|
|
27
|
+
|
|
28
|
+
validates :cst,
|
|
29
|
+
presence: true,
|
|
30
|
+
inclusion: { in: ["00", "01", "02", "03", "04", "49", "50", "51", "52",
|
|
31
|
+
"53", "54", "55", "99"]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def cEnq
|
|
35
|
+
"999"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def present?
|
|
39
|
+
check_present || @cst.present? || @vBC.present? || @pIPI.present? ||
|
|
40
|
+
@qUnid.present? || @vUnid.present? || @vIPI.present?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def parse!(xml)
|
|
44
|
+
doc = Nokogiri::XML(xml)
|
|
45
|
+
|
|
46
|
+
parse_elements doc
|
|
47
|
+
reset_values
|
|
48
|
+
parse_when_IPITrib doc
|
|
49
|
+
parse_when_IPINT doc
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_xml
|
|
53
|
+
xml = Builder::XmlMarkup.new
|
|
54
|
+
|
|
55
|
+
add_elements xml, :clEnq, :cnpjProd, :cSelo, :qSelo
|
|
56
|
+
|
|
57
|
+
xml.cEnq cEnq
|
|
58
|
+
|
|
59
|
+
to_xml_when_IPITrib xml
|
|
60
|
+
to_xml_when_IPINT xml
|
|
61
|
+
|
|
62
|
+
xml.target!
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
def IPITrib?
|
|
67
|
+
["00", "49", "50", "99"].include? @cst
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def IPINT?
|
|
71
|
+
["01", "02", "03", "04", "05", "51", "52", "53", "54", "55"].include? @cst
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def reset_values
|
|
75
|
+
@cst = nil
|
|
76
|
+
@vBC = nil
|
|
77
|
+
@pIPI = nil
|
|
78
|
+
@qUnid = nil
|
|
79
|
+
@vUnid = nil
|
|
80
|
+
@vIPI = nil
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def parse_when_IPITrib(doc)
|
|
84
|
+
if doc.css("IPITrib").present?
|
|
85
|
+
ipi = IPITrib.new
|
|
86
|
+
ipi.parse!(doc.css("IPITrib").to_xml)
|
|
87
|
+
|
|
88
|
+
@cst = ipi.cst
|
|
89
|
+
@vBC = ipi.vBC
|
|
90
|
+
@pIPI = ipi.pIPI
|
|
91
|
+
@qUnid = ipi.qUnid
|
|
92
|
+
@vUnid = ipi.vUnid
|
|
93
|
+
@vIPI = ipi.vIPI
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def parse_when_IPINT(doc)
|
|
98
|
+
if doc.css("IPINT").present?
|
|
99
|
+
ipi = IPINT.new
|
|
100
|
+
ipi.parse!(doc.css("IPINT").to_xml)
|
|
101
|
+
|
|
102
|
+
@cst = ipi.cst
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def to_xml_when_IPITrib(xml)
|
|
107
|
+
if IPITrib?
|
|
108
|
+
ipi = IPITrib.new
|
|
109
|
+
|
|
110
|
+
ipi.cst = @cst
|
|
111
|
+
ipi.vBC = @vBC
|
|
112
|
+
ipi.pIPI = @pIPI
|
|
113
|
+
ipi.qUnid = @qUnid
|
|
114
|
+
ipi.vUnid = @vUnid
|
|
115
|
+
ipi.vIPI = @vIPI
|
|
116
|
+
|
|
117
|
+
xml.IPITrib { |node| node << ipi.to_xml }
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def to_xml_when_IPINT(xml)
|
|
122
|
+
if IPINT?
|
|
123
|
+
ipi = IPINT.new
|
|
124
|
+
|
|
125
|
+
ipi.cst = @cst
|
|
126
|
+
|
|
127
|
+
xml.IPINT { |node| node << ipi.to_xml }
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class IPINT
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :cst, required: :true, xml_alias: "CST"
|
|
9
|
+
|
|
10
|
+
validates :cst,
|
|
11
|
+
presence: true,
|
|
12
|
+
inclusion: { in: ["01", "02", "03", "04", "05", "51", "52", "53",
|
|
13
|
+
"54", "55"] }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class IPITrib
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :cst, required: :true, xml_alias: "CST"
|
|
9
|
+
attr_xml :vBC, type: :float
|
|
10
|
+
attr_xml :pIPI, type: :float
|
|
11
|
+
attr_xml :qUnid, type: :float, format: "%0.4f"
|
|
12
|
+
attr_xml :vUnid, type: :float, format: "%0.4f"
|
|
13
|
+
attr_xml :vIPI, type: :float, required: :true
|
|
14
|
+
|
|
15
|
+
validates :cst,
|
|
16
|
+
presence: true,
|
|
17
|
+
inclusion: { in: ["00", "49", "50", "99"] }
|
|
18
|
+
|
|
19
|
+
validates :vBC,
|
|
20
|
+
numericality: {
|
|
21
|
+
greater_than_or_equal_to: 0,
|
|
22
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
validates :pIPI,
|
|
26
|
+
numericality: {
|
|
27
|
+
greater_than_or_equal_to: 0,
|
|
28
|
+
less_than_or_equal_to: 999.99
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
validates :qUnid,
|
|
32
|
+
numericality: {
|
|
33
|
+
greater_than_or_equal_to: 0,
|
|
34
|
+
less_than_or_equal_to: 999_999_999_999.9999
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
validates :vUnid,
|
|
38
|
+
numericality: {
|
|
39
|
+
greater_than_or_equal_to: 0,
|
|
40
|
+
less_than_or_equal_to: 99_999_999_999.9999
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
validates :vIPI,
|
|
44
|
+
numericality: {
|
|
45
|
+
greater_than_or_equal_to: 0,
|
|
46
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class ISSQN
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :vBC, type: :float, required: true
|
|
9
|
+
attr_xml :vAliq, type: :float, required: true
|
|
10
|
+
attr_xml :vISSQN, type: :float, required: true
|
|
11
|
+
attr_xml :cMunFG, required: true
|
|
12
|
+
attr_xml :cListServ, required: true
|
|
13
|
+
attr_xml :cSitTrib, type: :enumerize, required: true
|
|
14
|
+
|
|
15
|
+
extend Enumerize
|
|
16
|
+
|
|
17
|
+
enumerize :cSitTrib, in: { normal: "N", retida: "R",
|
|
18
|
+
substituta: "S", isenta: "I" }
|
|
19
|
+
|
|
20
|
+
validates :vBC,
|
|
21
|
+
numericality: {
|
|
22
|
+
greater_than_or_equal_to: 0,
|
|
23
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
validates :vAliq,
|
|
27
|
+
numericality: {
|
|
28
|
+
greater_than_or_equal_to: 0,
|
|
29
|
+
less_than_or_equal_to: 999.99
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
validates :vISSQN,
|
|
33
|
+
numericality: {
|
|
34
|
+
greater_than_or_equal_to: 0,
|
|
35
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
validates :cMunFG,
|
|
39
|
+
presence: true,
|
|
40
|
+
length: { is: 7 },
|
|
41
|
+
numericality: { only_integer: true }
|
|
42
|
+
|
|
43
|
+
validates :cListServ,
|
|
44
|
+
presence: true,
|
|
45
|
+
numericality: { only_integer: true,
|
|
46
|
+
less_than_or_equal_to: 9999
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
validates :cSitTrib,
|
|
50
|
+
presence: true
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class ISSQNtot
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
include Helpers::XmlModel::NfeModel
|
|
7
|
+
|
|
8
|
+
attr_xml :vServ, type: :float
|
|
9
|
+
attr_xml :vBC, type: :float
|
|
10
|
+
attr_xml :vISS, type: :float
|
|
11
|
+
attr_xml :vPIS, type: :float
|
|
12
|
+
attr_xml :vCOFINS, type: :float
|
|
13
|
+
|
|
14
|
+
validates :vServ,
|
|
15
|
+
numericality: {
|
|
16
|
+
greater_than_or_equal_to: 0,
|
|
17
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
|
18
|
+
allow_blank: true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
validates :vBC,
|
|
22
|
+
numericality: {
|
|
23
|
+
greater_than_or_equal_to: 0,
|
|
24
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
|
25
|
+
allow_blank: true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validates :vISS,
|
|
29
|
+
numericality: {
|
|
30
|
+
greater_than_or_equal_to: 0,
|
|
31
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
|
32
|
+
allow_blank: true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
validates :vPIS,
|
|
36
|
+
numericality: {
|
|
37
|
+
greater_than_or_equal_to: 0,
|
|
38
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
|
39
|
+
allow_blank: true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
validates :vCOFINS,
|
|
43
|
+
numericality: {
|
|
44
|
+
greater_than_or_equal_to: 0,
|
|
45
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
|
46
|
+
allow_blank: true
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
module Nfe
|
|
2
|
+
module Models
|
|
3
|
+
module Taxes
|
|
4
|
+
class PISCOFINS
|
|
5
|
+
include ActiveModel::Model
|
|
6
|
+
|
|
7
|
+
attr_accessor :cst, :vBC, :tax, :value, :qBCProd, :vAliqProd,
|
|
8
|
+
:qBCProd
|
|
9
|
+
|
|
10
|
+
validates :cst,
|
|
11
|
+
presence: true,
|
|
12
|
+
inclusion: { in: ["01", "02", "03", "04", "06", "07", "08", "09", "49",
|
|
13
|
+
"50", "51", "52", "53", "54", "55", "56", "60", "61", "62", "63", "64",
|
|
14
|
+
"65", "66", "67", "70", "71", "72", "73", "74", "75", "98", "99"]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def initialize(type)
|
|
18
|
+
if type == "cofins"
|
|
19
|
+
@type = "COFINS"
|
|
20
|
+
else
|
|
21
|
+
@type = "PIS"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def present?
|
|
26
|
+
@cst.present? || @vBC.present? || @tax.present? || @qBCProd.present? ||
|
|
27
|
+
@vAliqProd.present? || @qBCProd.present?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def parse!(xml)
|
|
31
|
+
doc = Nokogiri::XML(xml)
|
|
32
|
+
|
|
33
|
+
reset_values
|
|
34
|
+
parse_when_aliq(doc)
|
|
35
|
+
parse_when_qtde(doc)
|
|
36
|
+
parse_when_nt(doc)
|
|
37
|
+
parse_when_outr(doc)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_xml
|
|
41
|
+
xml = Builder::XmlMarkup.new
|
|
42
|
+
|
|
43
|
+
to_xml_when_aliq(xml)
|
|
44
|
+
to_xml_when_qtde(xml)
|
|
45
|
+
to_xml_when_nt(xml)
|
|
46
|
+
to_xml_when_outr(xml)
|
|
47
|
+
|
|
48
|
+
xml.target!
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
def aliq?
|
|
53
|
+
PISCOFINSAliq.csts.include? @cst
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def qtde?
|
|
57
|
+
"03" == @cst
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def nt?
|
|
61
|
+
PISCOFINSNT.csts.include? @cst
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def outr?
|
|
65
|
+
PISCOFINSOutr.csts.include? @cst
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def reset_values
|
|
69
|
+
@cst = nil
|
|
70
|
+
@vBC = nil
|
|
71
|
+
@tax = nil
|
|
72
|
+
@value = nil
|
|
73
|
+
@qBCProd = nil
|
|
74
|
+
@vAliqProd = nil
|
|
75
|
+
@qBCProd = nil
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def parse_when_aliq(doc)
|
|
79
|
+
if doc.css("#{@type}Aliq").present?
|
|
80
|
+
aliq = PISCOFINSAliq.new("p#{@type}", "v#{@type}")
|
|
81
|
+
aliq.parse!(doc.css("#{@type}Aliq").to_xml)
|
|
82
|
+
|
|
83
|
+
@cst = aliq.cst
|
|
84
|
+
@vBC = aliq.vBC
|
|
85
|
+
@tax = aliq.tax
|
|
86
|
+
@value = aliq.value
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def parse_when_qtde(doc)
|
|
91
|
+
if doc.css("#{@type}Qtde").present?
|
|
92
|
+
qtde = PISCOFINSQtde.new("v#{@type}")
|
|
93
|
+
qtde.parse!(doc.css("#{@type}Qtde").to_xml)
|
|
94
|
+
|
|
95
|
+
@cst = qtde.cst
|
|
96
|
+
@qBCProd = qtde.qBCProd
|
|
97
|
+
@vAliqProd = qtde.vAliqProd
|
|
98
|
+
@value = qtde.value
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def parse_when_nt(doc)
|
|
103
|
+
if doc.css("#{@type}NT").present?
|
|
104
|
+
nt = PISCOFINSNT.new
|
|
105
|
+
nt.parse!(doc.css("#{@type}NT").to_xml)
|
|
106
|
+
|
|
107
|
+
@cst = nt.cst
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def parse_when_outr(doc)
|
|
112
|
+
if doc.css("#{@type}Outr").present?
|
|
113
|
+
outr = PISCOFINSOutr.new("p#{@type}", "v#{@type}")
|
|
114
|
+
outr.parse!(doc.css("#{@type}Outr").to_xml)
|
|
115
|
+
|
|
116
|
+
@cst = outr.cst
|
|
117
|
+
@vBC = outr.vBC
|
|
118
|
+
@tax = outr.tax
|
|
119
|
+
@qBCProd = outr.qBCProd
|
|
120
|
+
@vAliqProd = outr.vAliqProd
|
|
121
|
+
@value = outr.value
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def to_xml_when_aliq(xml)
|
|
126
|
+
if aliq?
|
|
127
|
+
aliq = PISCOFINSAliq.new("p#{@type}", "v#{@type}")
|
|
128
|
+
aliq.cst = @cst
|
|
129
|
+
aliq.vBC = @vBC
|
|
130
|
+
aliq.tax = @tax
|
|
131
|
+
aliq.value = @value
|
|
132
|
+
|
|
133
|
+
xml.tag!("#{@type}Aliq") { |node| node << aliq.to_xml }
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def to_xml_when_qtde(xml)
|
|
138
|
+
if qtde?
|
|
139
|
+
qtde = PISCOFINSQtde.new("v#{@type}")
|
|
140
|
+
qtde.qBCProd = @qBCProd
|
|
141
|
+
qtde.vAliqProd = @vAliqProd
|
|
142
|
+
qtde.value = @value
|
|
143
|
+
|
|
144
|
+
xml.tag!("#{@type}Qtde") { |node| node << qtde.to_xml }
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def to_xml_when_nt(xml)
|
|
149
|
+
if nt?
|
|
150
|
+
nt = PISCOFINSNT.new
|
|
151
|
+
nt.cst = @cst
|
|
152
|
+
|
|
153
|
+
xml.tag!("#{@type}NT") { |node| node << nt.to_xml }
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def to_xml_when_outr(xml)
|
|
158
|
+
if outr?
|
|
159
|
+
outr = PISCOFINSOutr.new("p#{@type}", "v#{@type}")
|
|
160
|
+
outr.cst = @cst
|
|
161
|
+
outr.vBC = @vBC
|
|
162
|
+
outr.tax = @tax
|
|
163
|
+
outr.qBCProd = @qBCProd
|
|
164
|
+
outr.vAliqProd = @vAliqProd
|
|
165
|
+
outr.value = @value
|
|
166
|
+
|
|
167
|
+
xml.tag!("#{@type}Outr") { |node| node << outr.to_xml }
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|