Skip to content

Commit

Permalink
added export function to DIOT
Browse files Browse the repository at this point in the history
  • Loading branch information
satcfdi committed Feb 15, 2024
1 parent 84f6d40 commit 92e488a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion satcfdi/diot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,34 @@ def render(self, w: DIOTWriter):
if self.devoluciones is not None:
w(302261, 1, 1, self.devoluciones)

def to_list(self):
return [
self.tipo_tercero,
self.tipo_operacion,
self.rfc,
self.id_fiscal,
self.nombre_extranjero,
self.pais,
self.nacionalidad,
self.iva16,
"",
self.iva16_na,
"",
"",
self.iva_rfn,
"",
self.iva_rfn_na,
self.iva_import16,
self.iva_import16_na,
"",
"",
self.iva_import_exento,
self.iva0,
self.iva_exento,
self.retenido,
self.devoluciones
]


class DatosComplementaria:
def __init__(
Expand Down Expand Up @@ -338,7 +366,7 @@ def __init__(
datos_identificacion: DatosIdentificacion,
periodo: Periodo,
complementaria: DatosComplementaria = None,
proveedores: ProveedorTercero | Sequence[ProveedorTercero] = None
proveedores: Sequence[ProveedorTercero] = None
):
proveedores = list(iterate(proveedores))

Expand Down Expand Up @@ -398,6 +426,11 @@ def _tmp_filename(self):

return f"{rfc}{v_dem}{n_formulario}{ver_clte}{ver_form}{period}{mes_inicial}{period}{mes_final}{anio}{mes}{dia}{hora}{suffix}"

def export(self, target):
for p in self.proveedores:
target.write("|".join(str(v or "") for v in p.to_list()).encode('windows-1252'))
target.write(b"|\r\n")

def plain_bytes(self) -> bytes:
with BytesIO() as b:
self.plain_write(b)
Expand Down

0 comments on commit 92e488a

Please sign in to comment.