Skip to main content

Nfe

Struct Nfe 

Source
pub struct Nfe {
    pub versao: VersaoLayout,
    pub chave_acesso: String,
    pub ide: Identificacao,
    pub emit: Emitente,
    pub dest: Option<Destinatario>,
    pub itens: Vec<Item>,
    pub totais: Totalizacao,
    pub transporte: Transporte,
    pub informacao_complementar: Option<String>,
}
Expand description

Estrutura principal da Nota Fiscal Eletrônica (NF-e)

Esta estrutura representa uma NF-e parseada, contendo todos os grupos de informações definidos no layout 4.00 da SEFAZ.

A NF-e pode ser de dois modelos:

  • Modelo 55 (NF-e): Nota Fiscal Eletrônica tradicional para operações B2B
  • Modelo 65 (NFC-e): Nota Fiscal de Consumidor Eletrônica para varejo

§Campos Principais

CampoTag XMLDescrição
versao@versaoVersão do layout (4.00)
chave_acesso@IdChave de 44 dígitos que identifica a nota
ide<ide>Dados de identificação
emit<emit>Dados do emitente
dest<dest>Dados do destinatário
itens<det>Lista de produtos (1 a 990)
totais<total>Valores totalizados
transporte<transp>Informações de frete

§Exemplo de Uso

use std::fs::File;
use nfe::Nfe;

let file = File::open("nota.xml")?;
let nfe = Nfe::try_from(file)?;

println!("Chave: {}", nfe.chave_acesso);
println!("Total: R$ {:.2}", nfe.totais.valor_total);

Fields§

§versao: VersaoLayout

Versão do layout XML da NF-e (atualmente 4.00)

§chave_acesso: String

Chave de acesso de 44 dígitos que identifica unicamente a NF-e Formato: UF(2) + AAMM(4) + CNPJ(14) + MOD(2) + SERIE(3) + NNF(9) + CODIGO(9) + DV(1)

§ide: Identificacao

Grupo de identificação da NF-e (tag ) Contém: UF, número, série, modelo, datas, tipo de emissão, etc.

§emit: Emitente

Dados do emitente da nota fiscal (tag ) Contém: CNPJ, razão social, endereço, IE, etc.

§dest: Option<Destinatario>

Dados do destinatário/comprador (tag ) Opcional em algumas operações (ex: NFC-e para consumidor não identificado)

§itens: Vec<Item>

Lista de itens/produtos da nota fiscal (tags ) Cada NF-e pode conter de 1 a 990 itens

§totais: Totalizacao

Totalização de valores da nota fiscal (tag ) Contém: BC ICMS, valor ICMS, valor produtos, frete, desconto, total, etc.

§transporte: Transporte

Informações de transporte/frete (tag ) Contém: modalidade do frete (CIF/FOB), transportador, volumes, etc.

§informacao_complementar: Option<String>

Informações complementares de interesse do contribuinte (tag ) Campo de texto livre para observações adicionais

Trait Implementations§

Source§

impl Debug for Nfe

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Nfe

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromStr for Nfe

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Nfe

Source§

fn eq(&self, other: &Nfe) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Nfe

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToString for Nfe

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl TryFrom<File> for Nfe

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(f: File) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Nfe

Auto Trait Implementations§

§

impl Freeze for Nfe

§

impl RefUnwindSafe for Nfe

§

impl Send for Nfe

§

impl Sync for Nfe

§

impl Unpin for Nfe

§

impl UnwindSafe for Nfe

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,