Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cl_sii/rtc/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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
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."""
15 changes: 15 additions & 0 deletions tests/test_rtc_constants.py
Original file line number Diff line number Diff line change
@@ -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'.