From 1a3597ea5c1b7c80219ec69dc606dd65a2093135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Larra=C3=ADn?= Date: Mon, 13 Apr 2020 21:05:18 -0400 Subject: [PATCH] rcv.data_models: remove unnecessary fields For subclasses of `RcvDetalleEntry` only one of these fields is necessary, which depends on the specific class. - `emisor_razon_social` - `receptor_razon_social` These fields had been made optional in #112 (commit 1f21463). --- cl_sii/rcv/data_models.py | 37 ------------------------------------- cl_sii/rcv/parse_csv.py | 10 ---------- 2 files changed, 47 deletions(-) diff --git a/cl_sii/rcv/data_models.py b/cl_sii/rcv/data_models.py index 4c68fc2c..aa94131f 100644 --- a/cl_sii/rcv/data_models.py +++ b/cl_sii/rcv/data_models.py @@ -224,11 +224,6 @@ class RvDetalleEntry(RcvDetalleEntry): RCV_KIND = RcvKind.VENTAS RC_ESTADO_CONTABLE = None - emisor_razon_social: Optional[str] = dc_field() - """ - "Razón social" (legal name) of the "emisor" of the "documento". - """ - # TODO: docstring # TODO: can it be None? What happens for those "tipo docto" that do not have a receptor? receptor_razon_social: str = dc_field() @@ -244,11 +239,6 @@ class RvDetalleEntry(RcvDetalleEntry): def __post_init__(self) -> None: super().__post_init__() - if self.emisor_razon_social is not None: - if not isinstance(self.emisor_razon_social, str): - raise TypeError("Inappropriate type of 'emisor_razon_social'.") - cl_sii.dte.data_models.validate_contribuyente_razon_social(self.emisor_razon_social) - if not isinstance(self.receptor_razon_social, str): raise TypeError("Inappropriate type of 'receptor_razon_social'.") cl_sii.dte.data_models.validate_contribuyente_razon_social(self.receptor_razon_social) @@ -279,10 +269,6 @@ class RcRegistroDetalleEntry(RcvDetalleEntry): "Razón social" (legal name) of the "emisor" of the "documento". """ - # TODO: docstring - # TODO: can it be None? What happens for those "tipo docto" that do not have a receptor? - receptor_razon_social: Optional[str] = dc_field() - # TODO: docstring # note: must be timezone-aware. fecha_acuse_dt: Optional[datetime] = dc_field() @@ -294,11 +280,6 @@ def __post_init__(self) -> None: raise TypeError("Inappropriate type of 'emisor_razon_social'.") cl_sii.dte.data_models.validate_contribuyente_razon_social(self.emisor_razon_social) - if self.receptor_razon_social is not None: - if not isinstance(self.receptor_razon_social, str): - raise TypeError("Inappropriate type of 'receptor_razon_social'.") - cl_sii.dte.data_models.validate_contribuyente_razon_social(self.receptor_razon_social) - if self.fecha_acuse_dt is not None: if not isinstance(self.fecha_acuse_dt, datetime): raise TypeError("Inappropriate type of 'fecha_acuse_dt'.") @@ -331,10 +312,6 @@ class RcReclamadoDetalleEntry(RcvDetalleEntry): "Razón social" (legal name) of the "emisor" of the "documento". """ - # TODO: docstring - # TODO: can it be None? What happens for those "tipo docto" that do not have a receptor? - receptor_razon_social: Optional[str] = dc_field() - # TODO: docstring # note: must be timezone-aware. fecha_reclamo_dt: Optional[datetime] = dc_field() @@ -346,11 +323,6 @@ def __post_init__(self) -> None: raise TypeError("Inappropriate type of 'emisor_razon_social'.") cl_sii.dte.data_models.validate_contribuyente_razon_social(self.emisor_razon_social) - if self.receptor_razon_social is not None: - if not isinstance(self.receptor_razon_social, str): - raise TypeError("Inappropriate type of 'receptor_razon_social'.") - cl_sii.dte.data_models.validate_contribuyente_razon_social(self.receptor_razon_social) - if self.fecha_reclamo_dt is not None: if not isinstance(self.fecha_reclamo_dt, datetime): raise TypeError("Inappropriate type of 'fecha_reclamo_dt'.") @@ -372,18 +344,9 @@ class RcPendienteDetalleEntry(RcvDetalleEntry): "Razón social" (legal name) of the "emisor" of the "documento". """ - # TODO: docstring - # TODO: can it be None? What happens for those "tipo docto" that do not have a receptor? - receptor_razon_social: Optional[str] = dc_field() - def __post_init__(self) -> None: super().__post_init__() if not isinstance(self.emisor_razon_social, str): raise TypeError("Inappropriate type of 'emisor_razon_social'.") cl_sii.dte.data_models.validate_contribuyente_razon_social(self.emisor_razon_social) - - if self.receptor_razon_social is not None: - if not isinstance(self.receptor_razon_social, str): - raise TypeError("Inappropriate type of 'receptor_razon_social'.") - cl_sii.dte.data_models.validate_contribuyente_razon_social(self.receptor_razon_social) diff --git a/cl_sii/rcv/parse_csv.py b/cl_sii/rcv/parse_csv.py index c5d64ad7..55f4698c 100644 --- a/cl_sii/rcv/parse_csv.py +++ b/cl_sii/rcv/parse_csv.py @@ -656,8 +656,6 @@ def to_detalle_entry(self, data: dict) -> RvDetalleEntry: receptor_rut=receptor_rut, monto_total=monto_total, receptor_razon_social=receptor_razon_social, - # FIXME: remove after field 'emisor_razon_social' is removed from the dataclass - emisor_razon_social=None, fecha_recepcion_dt=fecha_recepcion_dt, fecha_acuse_dt=fecha_acuse_dt, fecha_reclamo_dt=fecha_reclamo_dt, @@ -791,8 +789,6 @@ def to_detalle_entry(self, data: dict) -> RcRegistroDetalleEntry: receptor_rut=receptor_rut, monto_total=monto_total, emisor_razon_social=emisor_razon_social, - # FIXME: remove after field 'receptor_razon_social' is removed from the dataclass - receptor_razon_social=None, fecha_recepcion_dt=fecha_recepcion_dt, fecha_acuse_dt=fecha_acuse_dt, ) @@ -827,8 +823,6 @@ def to_detalle_entry(self, data: dict) -> RcNoIncluirDetalleEntry: receptor_rut=receptor_rut, monto_total=monto_total, emisor_razon_social=emisor_razon_social, - # FIXME: remove after field 'receptor_razon_social' is removed from the dataclass - receptor_razon_social=None, fecha_recepcion_dt=fecha_recepcion_dt, fecha_acuse_dt=fecha_acuse_dt, ) @@ -967,8 +961,6 @@ def to_detalle_entry(self, data: dict) -> RcReclamadoDetalleEntry: receptor_rut=receptor_rut, monto_total=monto_total, emisor_razon_social=emisor_razon_social, - # FIXME: remove after field 'receptor_razon_social' is removed from the dataclass - receptor_razon_social=None, fecha_recepcion_dt=fecha_recepcion_dt, fecha_reclamo_dt=fecha_reclamo_dt, ) @@ -1090,8 +1082,6 @@ def to_detalle_entry(self, data: dict) -> RcPendienteDetalleEntry: receptor_rut=receptor_rut, monto_total=monto_total, emisor_razon_social=emisor_razon_social, - # FIXME: remove after field 'receptor_razon_social' is removed from the dataclass - receptor_razon_social=None, fecha_recepcion_dt=fecha_recepcion_dt, ) except (TypeError, ValueError):