Skip to content

Commit

Permalink
Merge pull request #113 from fyntex/develop
Browse files Browse the repository at this point in the history
Release v0.10.0.a2
  • Loading branch information
glarrain committed Apr 14, 2020
2 parents ed57cca + b113594 commit 1b70e3e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.10.0.a1
current_version = 0.10.0.a2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.10.0.a1'
__version__ = '0.10.0.a2'
18 changes: 10 additions & 8 deletions cl_sii/dte/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,12 @@ class DteDataL2(DteDataL1):
# fields
###########################################################################

emisor_razon_social: str = dc_field()
emisor_razon_social: Optional[str] = dc_field()
"""
"Razón social" (legal name) of the "emisor" of the DTE.
"""

receptor_razon_social: str = dc_field()
receptor_razon_social: Optional[str] = dc_field()
"""
"Razón social" (legal name) of the "receptor" of the DTE.
"""
Expand Down Expand Up @@ -405,13 +405,15 @@ def __post_init__(self) -> None:
"""
super().__post_init__()

if not isinstance(self.emisor_razon_social, str):
raise TypeError("Inappropriate type of 'emisor_razon_social'.")
validate_contribuyente_razon_social(self.emisor_razon_social)
if self.emisor_razon_social is not None:
if not isinstance(self.emisor_razon_social, str):
raise TypeError("Inappropriate type of 'emisor_razon_social'.")
validate_contribuyente_razon_social(self.emisor_razon_social)

if not isinstance(self.receptor_razon_social, str):
raise TypeError("Inappropriate type of 'receptor_razon_social'.")
validate_contribuyente_razon_social(self.receptor_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'.")
validate_contribuyente_razon_social(self.receptor_razon_social)

if self.fecha_vencimiento_date is not None:
if not isinstance(self.fecha_vencimiento_date, date):
Expand Down
36 changes: 20 additions & 16 deletions cl_sii/rcv/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class RvDetalleEntry(RcvDetalleEntry):
RCV_KIND = RcvKind.VENTAS
RC_ESTADO_CONTABLE = None

emisor_razon_social: str = dc_field()
emisor_razon_social: Optional[str] = dc_field()
"""
"Razón social" (legal name) of the "emisor" of the "documento".
"""
Expand All @@ -244,9 +244,10 @@ class RvDetalleEntry(RcvDetalleEntry):
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.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'.")
Expand Down Expand Up @@ -280,7 +281,7 @@ class RcRegistroDetalleEntry(RcvDetalleEntry):

# 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()
receptor_razon_social: Optional[str] = dc_field()

# TODO: docstring
# note: must be timezone-aware.
Expand All @@ -293,9 +294,10 @@ 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 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.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):
Expand Down Expand Up @@ -331,7 +333,7 @@ class RcReclamadoDetalleEntry(RcvDetalleEntry):

# 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()
receptor_razon_social: Optional[str] = dc_field()

# TODO: docstring
# note: must be timezone-aware.
Expand All @@ -344,9 +346,10 @@ 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 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.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):
Expand All @@ -371,7 +374,7 @@ class RcPendienteDetalleEntry(RcvDetalleEntry):

# 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()
receptor_razon_social: Optional[str] = dc_field()

def __post_init__(self) -> None:
super().__post_init__()
Expand All @@ -380,6 +383,7 @@ 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 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.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)
19 changes: 6 additions & 13 deletions tests/test_dte_data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,12 @@ def test_init_fail_razon_social_empty(self) -> None:
)
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

def test_init_fail_razon_social_none(self) -> None:
with self.assertRaises(TypeError) as cm:
dataclasses.replace(
self.dte_l2_1,
emisor_razon_social=None,
)
self.assertEqual(cm.exception.args, ("Inappropriate type of 'emisor_razon_social'.", ))
with self.assertRaises(TypeError) as cm:
dataclasses.replace(
self.dte_l2_1,
receptor_razon_social=None,
)
self.assertEqual(cm.exception.args, ("Inappropriate type of 'receptor_razon_social'.", ))
def test_init_ok_razon_social_none(self) -> None:
_ = dataclasses.replace(
self.dte_l2_1,
emisor_razon_social=None,
receptor_razon_social=None,
)

def test_init_fail_regression_signature_value_bytes_with_x20(self) -> None:
bytes_value_with_x20_as_base64 = 'IN2pkDBxqDnGl4Pfvboi'
Expand Down

0 comments on commit 1b70e3e

Please sign in to comment.