Skip to content

Commit

Permalink
Merge pull request #187 from fyntex/develop
Browse files Browse the repository at this point in the history
Release v0.12.1
  • Loading branch information
jtrh committed Feb 9, 2021
2 parents ca0b96f + 826e695 commit 7caf547
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 2 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.12.0
current_version = 0.12.1
commit = True
tag = True

Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
History
-------

0.12.1 (2021-02-09)
+++++++++++++++++++++++

* (PR #186, 2021-02-09) rtc: Add methods to build CesionL2, CesionL1, and CesionL0 from other data
models

0.12.0 (2021-01-17)
+++++++++++++++++++++++

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.12.0'
__version__ = '0.12.1'
23 changes: 23 additions & 0 deletions cl_sii/rtc/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ def dte_deudor_rut(self) -> Rut:
# Custom Methods
###########################################################################

def as_cesion_l0(self) -> CesionL0:
return CesionL0(
dte_key=self.dte_key,
seq=self.seq,
cedente_rut=self.cedente_rut,
cesionario_rut=self.cesionario_rut,
fecha_cesion_dt=self.fecha_cesion_dt,
)

def as_dte_data_l1(self) -> dte_data_models.DteDataL1:
return dte_data_models.DteDataL1(
emisor_rut=self.dte_key.emisor_rut,
Expand Down Expand Up @@ -632,6 +641,20 @@ class CesionL2(CesionL1):
# Custom Methods
###########################################################################

def as_cesion_l1(self) -> CesionL1:
return CesionL1(
dte_key=self.dte_key,
seq=self.seq,
cedente_rut=self.cedente_rut,
cesionario_rut=self.cesionario_rut,
fecha_cesion_dt=self.fecha_cesion_dt,
monto_cedido=self.monto_cedido,
fecha_ultimo_vencimiento=self.fecha_ultimo_vencimiento,
dte_fecha_emision=self.dte_fecha_emision,
dte_receptor_rut=self.dte_receptor_rut,
dte_monto_total=self.dte_monto_total,
)

def as_dte_data_l2(self) -> dte_data_models.DteDataL2:
return dte_data_models.DteDataL2(
emisor_rut=self.dte_key.emisor_rut,
Expand Down
24 changes: 24 additions & 0 deletions cl_sii/rtc/data_models_aec.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,30 @@ def alt_natural_key(self) -> data_models.CesionAltNaturalKey:
fecha_cesion_dt=self.fecha_cesion_dt,
)

###########################################################################
# Custom Methods
###########################################################################

def as_cesion_l2(self) -> data_models.CesionL2:
return data_models.CesionL2(
dte_key=self.dte.natural_key,
seq=self.seq,
cedente_rut=self.cedente_rut,
cesionario_rut=self.cesionario_rut,
fecha_cesion_dt=self.fecha_cesion_dt,
monto_cedido=self.monto_cesion,
dte_receptor_rut=self.dte.receptor_rut,
dte_fecha_emision=self.dte.fecha_emision_date,
dte_monto_total=self.dte.monto_total,
fecha_ultimo_vencimiento=self.fecha_ultimo_vencimiento,
cedente_razon_social=self.cedente_razon_social,
cedente_email=self.cedente_email,
cesionario_razon_social=self.cesionario_razon_social,
cesionario_email=self.cesionario_email,
dte_deudor_email=self.dte_deudor_email,
cedente_declaracion_jurada=self.cedente_declaracion_jurada,
)

###########################################################################
# Validators
###########################################################################
Expand Down
45 changes: 45 additions & 0 deletions tests/test_rtc_data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,26 @@ def test_as_dict(self) -> None:
)
self.assertEqual(obj.as_dict(), expected_output)

def test_as_cesion_l0(self):
self._set_obj_1()

obj = self.obj_1
expected_output = CesionL0(
dte_key=DteNaturalKey(
emisor_rut=Rut('76354771-K'),
tipo_dte=TipoDteEnum.FACTURA_ELECTRONICA,
folio=170,
),
seq=32,
cedente_rut=Rut('76389992-6'),
cesionario_rut=Rut('76598556-0'),
fecha_cesion_dt=tz_utils.convert_naive_dt_to_tz_aware(
dt=datetime(2019, 4, 5, 12, 57, 32),
tz=CesionL0.DATETIME_FIELDS_TZ,
),
)
self.assertEqual(obj.as_cesion_l0(), expected_output)

def test_as_dte_data_l1(self):
self._set_obj_1()

Expand Down Expand Up @@ -813,6 +833,31 @@ def test_as_dict(self) -> None:
)
self.assertEqual(obj.as_dict(), expected_output)

def test_as_cesion_l1(self):
self._set_obj_1()

obj = self.obj_1
expected_output = CesionL1(
dte_key=DteNaturalKey(
emisor_rut=Rut('76354771-K'),
tipo_dte=TipoDteEnum.FACTURA_ELECTRONICA,
folio=170,
),
seq=32,
cedente_rut=Rut('76389992-6'),
cesionario_rut=Rut('76598556-0'),
fecha_cesion_dt=tz_utils.convert_naive_dt_to_tz_aware(
dt=datetime(2019, 4, 5, 12, 57, 32),
tz=CesionL1.DATETIME_FIELDS_TZ,
),
monto_cedido=2996301,
fecha_ultimo_vencimiento=date(2019, 5, 1),
dte_fecha_emision=date(2019, 4, 1),
dte_receptor_rut=Rut('96790240-3'),
dte_monto_total=2996301,
)
self.assertEqual(obj.as_cesion_l1(), expected_output)

def test_as_dte_data_l2(self):
self._set_obj_1()

Expand Down
42 changes: 42 additions & 0 deletions tests/test_rtc_data_models_aec.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,48 @@ def test_alt_natural_key(self) -> None:
)
self.assertEqual(obj.alt_natural_key, expected_output)

def test_as_cesion_l2(self) -> None:
self._set_obj_1()

obj = self.obj_1
expected_output = CesionL2(
dte_key=DteNaturalKey(
emisor_rut=Rut('76354771-K'),
tipo_dte=TipoDteEnum.FACTURA_ELECTRONICA,
folio=170,
),
seq=1,
cedente_rut=Rut('76354771-K'),
cesionario_rut=Rut('76389992-6'),
fecha_cesion_dt=tz_utils.convert_naive_dt_to_tz_aware(
dt=datetime(2019, 4, 1, 10, 22, 2),
tz=CesionL2.DATETIME_FIELDS_TZ,
),
monto_cedido=2996301,
dte_receptor_rut=Rut('96790240-3'),
dte_fecha_emision=date(2019, 4, 1),
dte_monto_total=2996301,
fecha_ultimo_vencimiento=date(2019, 5, 1),
cedente_razon_social='SERVICIOS BONILLA Y LOPEZ Y COMPAÑIA LIMITADA',
cedente_email='enaconltda@gmail.com',
cesionario_razon_social='ST CAPITAL S.A.',
cesionario_email='fynpal-app-notif-st-capital@fynpal.com',
dte_deudor_email=None,
cedente_declaracion_jurada=(
'Se declara bajo juramento que SERVICIOS BONILLA Y LOPEZ Y COMPAÑIA '
'LIMITADA, RUT 76354771-K ha puesto a disposición del cesionario ST '
'CAPITAL S.A., RUT 76389992-6, el o los documentos donde constan los '
'recibos de las mercaderías entregadas o servicios prestados, entregados '
'por parte del deudor de la factura MINERA LOS PELAMBRES, RUT 96790240-3, '
'deacuerdo a lo establecido en la Ley N°19.983.'
),
)
obj_cesion_l2 = obj.as_cesion_l2()
self.assertEqual(obj_cesion_l2, expected_output)
self.assertEqual(obj_cesion_l2.natural_key, obj.natural_key)
self.assertEqual(obj_cesion_l2.alt_natural_key, obj.alt_natural_key)
self.assertEqual(obj_cesion_l2.dte_key, obj.dte.natural_key)


class AecXmlTest(unittest.TestCase):
"""
Expand Down

0 comments on commit 7caf547

Please sign in to comment.