nf-e 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- 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,31 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Helpers
|
3
|
+
module XmlModel
|
4
|
+
class AttributeText < AttributeBase
|
5
|
+
def format
|
6
|
+
@format || "%s"
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def add_element(attribute)
|
12
|
+
format % normalize_attribute(attribute)
|
13
|
+
end
|
14
|
+
|
15
|
+
def normalize_attribute(attribute)
|
16
|
+
attribute.to_s.
|
17
|
+
gsub(/\n/, " ").
|
18
|
+
gsub(/\r/, " ").
|
19
|
+
gsub(/\s+/, " ").
|
20
|
+
gsub(/&/, "&").
|
21
|
+
gsub(/</, "<").
|
22
|
+
gsub(/>/, ">").
|
23
|
+
gsub(/\"/, """).
|
24
|
+
gsub(/\'/, "'").
|
25
|
+
gsub(/[(ÿ-\uFFFF| )]/, " ").
|
26
|
+
gsub(/ +/, " ")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Helpers
|
3
|
+
module XmlModel
|
4
|
+
class Factory
|
5
|
+
def self.create(name, options={})
|
6
|
+
type = options[:type] || :text
|
7
|
+
|
8
|
+
if type == :attribute
|
9
|
+
AttributeNodeattribute.new(name, options)
|
10
|
+
else
|
11
|
+
XmlModel::const_get("Attribute#{type.capitalize}").new(name, options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Helpers
|
3
|
+
module XmlModel
|
4
|
+
module NfeModel
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def attr_xml(xml_attr, options={})
|
11
|
+
register_xml_attr xml_attr, options
|
12
|
+
register_attr_acessor xml_attribute(xml_attr)
|
13
|
+
end
|
14
|
+
|
15
|
+
def xml_attributes
|
16
|
+
@xml_attributes ||= {}
|
17
|
+
if self.superclass.methods.include?(:xml_attributes)
|
18
|
+
@xml_attributes = self.superclass.xml_attributes.merge @xml_attributes
|
19
|
+
end
|
20
|
+
@xml_attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def xml_attribute(attribute)
|
24
|
+
xml_attributes[attribute]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def register_xml_attr(xml_attr, options)
|
29
|
+
xml_attributes[xml_attr] = Factory.create xml_attr, options
|
30
|
+
end
|
31
|
+
|
32
|
+
def register_attr_acessor(xml_attr)
|
33
|
+
instance_eval do
|
34
|
+
attr_accessor xml_attr.name unless xml_attr.type.equal? :enumerize
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def present?
|
40
|
+
check_present
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_present
|
44
|
+
present = false
|
45
|
+
self.class.xml_attributes.each do |key, value|
|
46
|
+
present ||= value_present? key, value
|
47
|
+
end
|
48
|
+
present
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse!(xml)
|
52
|
+
parse_elements xml
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_xml
|
56
|
+
xml = Builder::XmlMarkup.new
|
57
|
+
|
58
|
+
add_elements xml
|
59
|
+
|
60
|
+
xml.target!
|
61
|
+
end
|
62
|
+
|
63
|
+
def parse_elements(doc, *elements)
|
64
|
+
doc = Nokogiri::XML(doc) if doc.is_a? String
|
65
|
+
|
66
|
+
elements = get_elements(elements)
|
67
|
+
|
68
|
+
Array(elements).each { |attribute| parse_value doc, attribute }
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_elements(xml, *elements)
|
72
|
+
elements = get_elements(elements)
|
73
|
+
|
74
|
+
Array(elements).each { |attribute| add_element xml, attribute }
|
75
|
+
end
|
76
|
+
|
77
|
+
def validate_optional_attributes(*attributes)
|
78
|
+
attributes.each do |attribute|
|
79
|
+
Array(send(attribute)).each do |item|
|
80
|
+
if item.present? && !item.valid?
|
81
|
+
errors.add(attribute, :invalid) unless errors.include?(attribute)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def validate_required_attributes(*attributes)
|
88
|
+
attributes.each do |attribute|
|
89
|
+
if !send(attribute).valid?
|
90
|
+
errors.add(attribute, :invalid) unless errors.include?(attribute)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def parse_value(doc, attribute)
|
97
|
+
self.class.xml_attribute(attribute).parse self, doc
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_element(xml, attribute)
|
101
|
+
self.class.xml_attribute(attribute).add_to_xml self, xml, attribute
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_elements(elements)
|
105
|
+
elements = self.class.xml_attributes.keys if elements.empty?
|
106
|
+
|
107
|
+
elements
|
108
|
+
end
|
109
|
+
|
110
|
+
def value_present?(key, value)
|
111
|
+
if value.type.equal? :bigdecimal
|
112
|
+
send(key) > 0
|
113
|
+
else
|
114
|
+
send(key).present?
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Models
|
3
|
+
class NFe
|
4
|
+
include ActiveModel::Model
|
5
|
+
include Helpers::XmlModel::NfeModel
|
6
|
+
|
7
|
+
attr_accessor :infNFe, :signature
|
8
|
+
|
9
|
+
validate { validate_required_attributes :infNFe }
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@infNFe = Nfe::Models::InfNFe.new
|
13
|
+
@signature = Nfe::Models::Signature.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.namespace
|
17
|
+
"http://www.portalfiscal.inf.br/nfe"
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse!(xml)
|
21
|
+
doc = Nokogiri::XML(xml)
|
22
|
+
|
23
|
+
@infNFe.parse!(doc.css("infNFe").to_xml)
|
24
|
+
|
25
|
+
sign = doc.xpath("//ds:Signature", ds: Signature.namespace).to_xml
|
26
|
+
@signature.parse!(sign)
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_xml
|
30
|
+
xml = Builder::XmlMarkup.new
|
31
|
+
|
32
|
+
xml.NFe(xmlns: Nfe::Models::NFe.namespace) do |nfe|
|
33
|
+
|
34
|
+
nfe.infNFe({versao: infNFe.versao, Id: infNFe.id}) do |node|
|
35
|
+
node << @infNFe.to_xml
|
36
|
+
end
|
37
|
+
|
38
|
+
nfe.Signature(xmlns: Signature.namespace) do |node|
|
39
|
+
node << @signature.value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
xml.target!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Models
|
3
|
+
class Avulsa
|
4
|
+
include ActiveModel::Model
|
5
|
+
include Helpers::XmlModel::NfeModel
|
6
|
+
|
7
|
+
attr_xml :cnpj, required: true, xml_alias: "CNPJ"
|
8
|
+
attr_xml :xOrgao, required: true
|
9
|
+
attr_xml :matr, required: true
|
10
|
+
attr_xml :xAgente, required: true
|
11
|
+
attr_xml :fone
|
12
|
+
attr_xml :uf, required: true, xml_alias: "UF"
|
13
|
+
attr_xml :nDAR
|
14
|
+
attr_xml :dEmi, type: :date
|
15
|
+
attr_xml :vDAR, type: :float
|
16
|
+
attr_xml :repEmi, required: true
|
17
|
+
attr_xml :dPag, type: :date
|
18
|
+
|
19
|
+
validates :cnpj,
|
20
|
+
presence: true,
|
21
|
+
cnpj: true,
|
22
|
+
length: { is: 14}
|
23
|
+
|
24
|
+
validates :xOrgao,
|
25
|
+
length: { in: 1..60 }
|
26
|
+
|
27
|
+
validates :matr,
|
28
|
+
length: { in: 1..60 }
|
29
|
+
|
30
|
+
validates :xAgente,
|
31
|
+
length: { in: 1..60 }
|
32
|
+
|
33
|
+
validates :fone,
|
34
|
+
length: { in: 6..14, allow_blank: true },
|
35
|
+
numericality: { only_integer: true, allow_blank: true }
|
36
|
+
|
37
|
+
validates :uf,
|
38
|
+
length: { is: 2 }
|
39
|
+
|
40
|
+
validates :nDAR,
|
41
|
+
length: { in: 1..60, allow_blank: true }
|
42
|
+
|
43
|
+
validates :dEmi,
|
44
|
+
length: { is: 10, allow_blank: true }
|
45
|
+
|
46
|
+
validates :vDAR,
|
47
|
+
numericality: {
|
48
|
+
greater_than_or_equal_to: 0,
|
49
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
50
|
+
allow_blank: true }
|
51
|
+
|
52
|
+
validates :repEmi,
|
53
|
+
length: { in: 1..60 }
|
54
|
+
|
55
|
+
validates :dPag,
|
56
|
+
length: { is: 10, allow_blank: true }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Models
|
3
|
+
module Bill
|
4
|
+
class Cobr
|
5
|
+
include ActiveModel::Model
|
6
|
+
include Helpers::XmlModel::NfeModel
|
7
|
+
|
8
|
+
attr_xml :fat, type: :node
|
9
|
+
attr_xml :dup, type: :collection, klass: "Nfe::Models::Bill::Dup"
|
10
|
+
|
11
|
+
validates :dup,
|
12
|
+
length: { maximum: 120, message: :less_than_or_equal_to }
|
13
|
+
|
14
|
+
validate { validate_optional_attributes :fat, :dup }
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@fat = Fat.new
|
18
|
+
@dup = []
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Models
|
3
|
+
module Bill
|
4
|
+
class Dup
|
5
|
+
include ActiveModel::Model
|
6
|
+
include Helpers::XmlModel::NfeModel
|
7
|
+
|
8
|
+
attr_xml :nDup
|
9
|
+
attr_xml :dVenc, type: :date
|
10
|
+
attr_xml :vDup, type: :float
|
11
|
+
|
12
|
+
validates :nDup,
|
13
|
+
length: { maximum: 60 }
|
14
|
+
|
15
|
+
validates :vDup,
|
16
|
+
numericality: {
|
17
|
+
greater_than_or_equal_to: 0,
|
18
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
19
|
+
allow_blank: true }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Nfe
|
2
|
+
module Models
|
3
|
+
module Bill
|
4
|
+
class Fat
|
5
|
+
include ActiveModel::Model
|
6
|
+
include Helpers::XmlModel::NfeModel
|
7
|
+
|
8
|
+
attr_xml :nFat
|
9
|
+
attr_xml :vOrig, type: :float
|
10
|
+
attr_xml :vDesc, type: :float
|
11
|
+
attr_xml :vLiq, type: :float
|
12
|
+
|
13
|
+
validates :nFat,
|
14
|
+
length: { maximum: 60 }
|
15
|
+
|
16
|
+
validates :vOrig,
|
17
|
+
numericality: {
|
18
|
+
greater_than_or_equal_to: 0,
|
19
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
20
|
+
allow_blank: true }
|
21
|
+
|
22
|
+
validates :vDesc,
|
23
|
+
numericality: {
|
24
|
+
greater_than_or_equal_to: 0,
|
25
|
+
less_than_or_equal_to: 9_999_999_999_999.99,
|
26
|
+
allow_blank: true }
|
27
|
+
|
28
|
+
validates :vLiq,
|
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
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class BigdecimalGreaterThanValidator < ActiveModel::EachValidator
|
2
|
+
def validate_each(record, attribute, value)
|
3
|
+
max = BigDecimal("99999999999.9999999999")
|
4
|
+
|
5
|
+
if value > max
|
6
|
+
record.errors.add(attribute,
|
7
|
+
I18n.t("errors.messages.less_than_or_equal_to", count: max.to_s("F")))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require_relative "bigdecimal_less_than_validator"
|
2
|
+
require_relative "bigdecimal_greater_than_validator"
|
3
|
+
|
4
|
+
module Nfe
|
5
|
+
module Models
|
6
|
+
module Cane
|
7
|
+
class Cana
|
8
|
+
include ActiveModel::Model
|
9
|
+
include Helpers::XmlModel::NfeModel
|
10
|
+
|
11
|
+
attr_xml :safra, required: true
|
12
|
+
attr_xml :ref, required: true
|
13
|
+
attr_xml :vFor, type: :float, required: true
|
14
|
+
attr_xml :vTotDed, type: :float, required: true
|
15
|
+
attr_xml :vLiqFor, type: :float, required: true
|
16
|
+
attr_xml :forDia, type: :collection, klass: "Nfe::Models::Cane::ForDia"
|
17
|
+
attr_xml :deduc, type: :collection, klass: "Nfe::Models::Cane::Deduc"
|
18
|
+
attr_xml :qTotMes, type: :bigdecimal, required: true
|
19
|
+
attr_xml :qTotAnt, type: :bigdecimal, required: true
|
20
|
+
attr_xml :qTotGer, type: :bigdecimal, required: true
|
21
|
+
|
22
|
+
validates :safra,
|
23
|
+
length: { in: 4..9 }
|
24
|
+
|
25
|
+
validates :ref,
|
26
|
+
length: { is: 7 }
|
27
|
+
|
28
|
+
validates :qTotMes,
|
29
|
+
bigdecimal_less_than: true,
|
30
|
+
bigdecimal_greater_than: true
|
31
|
+
|
32
|
+
validates :qTotAnt,
|
33
|
+
bigdecimal_less_than: true,
|
34
|
+
bigdecimal_greater_than: true
|
35
|
+
|
36
|
+
validates :qTotGer,
|
37
|
+
bigdecimal_less_than: true,
|
38
|
+
bigdecimal_greater_than: true
|
39
|
+
|
40
|
+
validates :vFor,
|
41
|
+
presence: true,
|
42
|
+
numericality: {
|
43
|
+
greater_than_or_equal_to: 0,
|
44
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
45
|
+
}
|
46
|
+
|
47
|
+
validates :vTotDed,
|
48
|
+
presence: true,
|
49
|
+
numericality: {
|
50
|
+
greater_than_or_equal_to: 0,
|
51
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
52
|
+
}
|
53
|
+
|
54
|
+
validates :vLiqFor,
|
55
|
+
presence: true,
|
56
|
+
numericality: {
|
57
|
+
greater_than_or_equal_to: 0,
|
58
|
+
less_than_or_equal_to: 9_999_999_999_999.99
|
59
|
+
}
|
60
|
+
|
61
|
+
validate { validate_optional_attributes :forDia, :deduc }
|
62
|
+
|
63
|
+
def initialize
|
64
|
+
@qTotMes = BigDecimal("0", 22)
|
65
|
+
@qTotAnt = BigDecimal("0", 22)
|
66
|
+
@qTotGer = BigDecimal("0", 22)
|
67
|
+
@forDia = []
|
68
|
+
@deduc = []
|
69
|
+
end
|
70
|
+
|
71
|
+
def qTotMes=(value)
|
72
|
+
@qTotMes = BigDecimal(value, 22)
|
73
|
+
end
|
74
|
+
|
75
|
+
def qTotAnt=(value)
|
76
|
+
@qTotAnt = BigDecimal(value, 22)
|
77
|
+
end
|
78
|
+
|
79
|
+
def qTotGer=(value)
|
80
|
+
@qTotGer = BigDecimal(value, 22)
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_xml
|
84
|
+
xml = Builder::XmlMarkup.new
|
85
|
+
|
86
|
+
add_elements xml, :safra, :ref
|
87
|
+
|
88
|
+
@forDia.each do |forDia|
|
89
|
+
xml.forDia(dia: forDia.dia) { |node| node << forDia.to_xml }
|
90
|
+
end
|
91
|
+
|
92
|
+
add_elements xml, :qTotMes, :qTotAnt, :qTotGer, :deduc, :vFor,
|
93
|
+
:vTotDed, :vLiqFor
|
94
|
+
|
95
|
+
xml.target!
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|