Skip to content

Bug - Entidade NotaFiscalPagamentos #455

@LuanMiranda77

Description

@LuanMiranda77

Aqui está a descrição do bug para o issue no GitHub:


Title: NotaFiscalPagamentos.t_band defined as int causes schema rejection by SEFAZ

Description:

The field t_band in NotaFiscalPagamentos is defined as int():

class NotaFiscalPagamentos(Entidade):
    t_band = int()

This causes the serializer to emit the value without zero-padding, e.g. <tBand>1</tBand>, while the SEFAZ NF-e schema requires a 2-digit string, e.g. <tBand>01</tBand>.

Steps to reproduce:

  1. Create a payment with t_band=1 (Visa)
  2. Serialize and transmit the NF-e
  3. SEFAZ rejects with: Rejeicao: Falha no Schema XML da NFe (Elemento: enviNFe/NFe[1]/infNFe/pag/detPag/card/tBand/)

Expected behavior:
tBand should be serialized as a zero-padded 2-digit string ("01" to "09", "99").

Suggested fix:

In _serializar_pagamentos, replace:

xmlw.write_txt(card, "tBand", item.t_band, False)

With:

if item.t_band is not None and item.t_band != "":
    etree.SubElement(card, "tBand").text = str(item.t_band).zfill(2)

Or change the field type in NotaFiscalPagamentos:

t_band = str()  # was int()

And document that the caller is responsible for passing a zero-padded 2-digit string.

Environment:

  • PyNFe version: 0.6.0
  • Python: 3.12
    Evidencia
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions