From 0c5a0f9dad06a926937a259e2188f4d9696f576a Mon Sep 17 00:00:00 2001 From: Jose Tomas Robles Hahn Date: Mon, 14 Sep 2020 21:37:33 -0300 Subject: [PATCH 1/2] rtc.constants: Add `RolContribuyenteEnCesion` This commit was taken from https://github.com/fyntex/lib-cl-sii-api-python/commit/0bafb09711cfe1695e27f82eeeb8686b8f8626d3#diff-702a40cd2145a7ff3e38e762920368f9. --- cl_sii/rtc/constants.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cl_sii/rtc/constants.py diff --git a/cl_sii/rtc/constants.py b/cl_sii/rtc/constants.py new file mode 100644 index 00000000..ee032d3d --- /dev/null +++ b/cl_sii/rtc/constants.py @@ -0,0 +1,18 @@ +import enum + + +@enum.unique +class RolContribuyenteEnCesion(enum.Enum): + + """ + "Rol" of "contribuyente" in a "cesion". + """ + + CEDENTE = 'CEDENTE' + """Cesiones en las que el contribuyente ha sido cedente i.e. ha cedido""" + + CESIONARIO = 'CESIONARIO' + """Cesiones en las que el contribuyente ha sido cesionario i.e. le han cedido""" + + DEUDOR = 'DEUDOR' + """Cesiones de DTEs en que el contribuyente es el deudor.""" From 1675ade4c22600d60d77064d9ed63fcc6f6ca594 Mon Sep 17 00:00:00 2001 From: Jose Tomas Robles Hahn Date: Mon, 14 Sep 2020 21:43:09 -0300 Subject: [PATCH 2/2] rtc.constants: Add `TIPO_DTE_CEDIBLES` The collection of "tipo DTE" for which it is possible to "ceder" a "DTE". This commit was taken from https://github.com/fyntex/lib-cl-sii-api-python/commit/8a4fef80ca0ee397d7d72f28a1580832629266d0. --- cl_sii/rtc/constants.py | 24 ++++++++++++++++++++++++ tests/test_rtc_constants.py | 15 +++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/test_rtc_constants.py diff --git a/cl_sii/rtc/constants.py b/cl_sii/rtc/constants.py index ee032d3d..73ce4909 100644 --- a/cl_sii/rtc/constants.py +++ b/cl_sii/rtc/constants.py @@ -1,4 +1,28 @@ import enum +from typing import FrozenSet + +from cl_sii.dte.constants import TipoDteEnum + + +# The collection of "tipo DTE" for which it is possible to "ceder" a "DTE". +# They are defined in a document and also an XML schema. +# - Document "Formato Archivo Electrónico de Cesión (AEC)" +# (http://www.sii.cl/factura_electronica/cesion.pdf) are: +# > Sólo códigos 33, 34, 46 y 43 +# - XML element 'CesionDefType/DocumentoCesion/IdDTE/TipoDTE' +# - description: "Tipo de DTE" +# - XML type: 'SiiDte:DTEFacturasType' +# - source: +# https://github.com/fyntex/lib-cl-sii-python/blob/7e1c4b52/cl_sii/data/ref/factura_electronica/schemas-xml/Cesion_v10.xsd#L38-L42 +# - XML type 'SiiDte:DTEFacturasType' in official schema 'SiiTypes_v10.xsd' +# - source: +# https://github.com/fyntex/lib-cl-sii-python/blob/7e1c4b52/cl_sii/data/ref/factura_electronica/schemas-xml/SiiTypes_v10.xsd#L100-L126 +TIPO_DTE_CEDIBLES: FrozenSet[TipoDteEnum] = frozenset({ + TipoDteEnum.FACTURA_ELECTRONICA, + TipoDteEnum.FACTURA_NO_AFECTA_O_EXENTA_ELECTRONICA, + TipoDteEnum.FACTURA_COMPRA_ELECTRONICA, + TipoDteEnum.LIQUIDACION_FACTURA_ELECTRONICA, +}) @enum.unique diff --git a/tests/test_rtc_constants.py b/tests/test_rtc_constants.py new file mode 100644 index 00000000..89b3f277 --- /dev/null +++ b/tests/test_rtc_constants.py @@ -0,0 +1,15 @@ +import unittest + +from cl_sii.rtc.constants import TIPO_DTE_CEDIBLES + + +class TipoDteCediblesTest(unittest.TestCase): + + # For 'TIPO_DTE_CEDIBLES' + + def test_all_are_factura(self) -> None: + for element in TIPO_DTE_CEDIBLES: + self.assertTrue(element.is_factura) + + # TODO: implement test that check that the values correspond to those defined in + # XML type 'SiiDte:DTEFacturasType' in official schema 'SiiTypes_v10.xsd'.