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
2 changes: 2 additions & 0 deletions cl_sii/cte/f29/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class CteForm29:
586: None, # "CANT. VTAS. Y/O SERV. PREST. INT. EXENT."
587: None, # Facturas de Compra recibidas c/ret. total y Fact. de Inicio emitida | Monto
595: None, # "SUB TOTAL IMP. DETERMINADO ANVERSO"
596: None, # "RETENCION CAMBIO DE SUJETO"
601: None, # Fax
610: 'numero_direccion', # Nº Dirección
708: None, # "CANT. NOTAS CRED. EMIT. VALES MAQ. IVA"
Expand All @@ -167,6 +168,7 @@ class CteForm29:
795: None, # "MONTO DE CONDONACION SII"
915: 'fecha_condonacion', # "Fecha de Vigencia de Condonacion"
922: 'num_res_condonacion', # "NUMERO RESOLUCION SII AUTO. CONDONACION"
9906: None, # "FECHA PRESENTACION DECL. PRIMITIVA"
}

def __post_init__(self) -> None:
Expand Down
10 changes: 5 additions & 5 deletions cl_sii/data/cte/schemas-json/f29_datos_obj.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"campos": {
"type": "object",
"patternProperties": {
"^\\d{3}$": {
"^\\d{3,4}$": {
"type": "string"
}
},
Expand Down Expand Up @@ -108,7 +108,7 @@
"glosa": {
"type": "object",
"patternProperties": {
"^\\d{3}$": {
"^\\d{3,4}$": {
"type": "string"
}
},
Expand All @@ -117,7 +117,7 @@
"justif": {
"type": "object",
"patternProperties": {
"^\\d{3}$": {
"^\\d{3,4}$": {
"type": "string",
"enum": [
"I",
Expand All @@ -131,7 +131,7 @@
"linea": {
"type": "object",
"patternProperties": {
"^\\d{3}$": {
"^\\d{3,4}$": {
"type": "string",
"pattern": "^\\d+$"
}
Expand All @@ -141,7 +141,7 @@
"tipos": {
"type": "object",
"patternProperties": {
"^\\d{3}$": {
"^\\d{3,4}$": {
"type": "string",
"enum": [
"C",
Expand Down
104 changes: 104 additions & 0 deletions tests/test_cte_f29_parse_datos_obj.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import datetime
from decimal import Decimal
from typing import Any, Mapping
from unittest import TestCase

Expand Down Expand Up @@ -114,3 +115,106 @@ def test_full(self) -> None:
"fecha_presentacion": datetime.date(2017, 8, 28),
}
self.assertEqual(dict(obj), expected_dict)

def test_full_2(self) -> None:
datos_obj: Mapping[str, Any] = read_test_file_json_dict(
'test_data/sii-cte/f29/cte--6286736-1--f29-6700000056-datos-obj-fake.json',
)
obj = parse_datos_obj.parse_sii_cte_f29_datos_obj(
datos_obj=datos_obj,
deserialize_campo=parse_datos_obj.cte_f29_datos_obj_campo_best_effort_deserializer,
)

self.assertIsInstance(obj, data_models.CteForm29)
self.assertEqual(obj.contribuyente_rut, Rut('6286736-1'))
self.assertEqual(obj.periodo_tributario, PeriodoTributario(year=2018, month=12))
self.assertEqual(obj.folio, 6700000056)

expected_codes_dict = {
1: "BONVALLET",
2: "GODOY",
3: Rut('6286736-1'),
5: "EDWARD GUILLERMO",
6: "GRECIA 2001",
7: 6700000056,
8: "MELIPILLA",
9: '0',
15: PeriodoTributario(year=2018, month=12),
48: 22633,
55: "E.BONVALLET@EXAMPLE.COM",
62: 32875,
77: 584976,
91: 503286,
115: Decimal('0.25'),
142: 13000000,
151: 447778,
315: datetime.date(2019, 1, 22),
502: 28500,
503: 1,
511: 613476,
519: 37,
520: 613476,
521: 2365382,
537: 613476,
538: 28500,
547: 503286,
562: 518660,
563: 13150000,
564: 27,
584: 11,
586: 1,
595: 503286,
596: 0,
9906: "22/01/2019",
}
self.assertEqual(obj.as_codes_dict(include_none=False), expected_codes_dict)

expected_dict = {
"contribuyente_rut": Rut('6286736-1'),
"periodo_tributario": PeriodoTributario(year=2018, month=12),
"folio": 6700000056,
"apellido_paterno_o_razon_social": "BONVALLET",
"apellido_materno": "GODOY",
"nombres": "EDWARD GUILLERMO",
"calle_direccion": "GRECIA 2001",
"numero_direccion": None,
"comuna_direccion": "MELIPILLA",
"telefono": "0",
"correo_electronico": "E.BONVALLET@EXAMPLE.COM",
"representante_legal_rut": None,
"extra": {
48: 22633,
62: 32875,
77: 584976,
115: Decimal('0.25'),
142: 13000000,
151: 447778,
502: 28500,
503: 1,
511: 613476,
519: 37,
520: 613476,
521: 2365382,
537: 613476,
538: 28500,
547: 503286,
562: 518660,
563: 13150000,
564: 27,
584: 11,
586: 1,
595: 503286,
596: 0,
9906: "22/01/2019",
},
"total_a_pagar_en_plazo_legal": 503286,
"total_a_pagar_con_recargo": None,
"pct_condonacion": None,
"num_res_condonacion": None,
"fecha_condonacion": None,
"tipo_declaracion": "Rectificatoria con Giro",
"banco": "",
"medio_pago": "",
"fecha_presentacion": datetime.date(2019, 1, 22),
}
self.assertEqual(dict(obj), expected_dict)
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"campos": {
"001": "BONVALLET",
"002": "GODOY",
"003": "6286736-1",
"005": "EDWARD GUILLERMO",
"006": "GRECIA 2001",
"007": "6700000056",
"008": "MELIPILLA",
"009": "0",
"015": "201812",
"048": "22633",
"055": "E.BONVALLET@EXAMPLE.COM",
"062": "32875",
"077": "584976",
"091": "503286",
"115": "0.25",
"142": "13000000",
"151": "447778",
"315": "22/01/2019",
"502": "28500",
"503": "1",
"511": "613476",
"519": "37",
"520": "613476",
"521": "2365382",
"537": "613476",
"538": "28500",
"547": "503286",
"562": "518660",
"563": "13150000",
"564": "27",
"584": "11",
"586": "1",
"595": "503286",
"596": "0",
"9906": "22/01/2019"
},
"extras": {
"ADM8703": "",
"ADM8721": "",
"BANCO": "",
"CALIDADDECLARANTE": "Contribuyente",
"CARTRIB": "1",
"CLASE": "Rectificatoria con Giro",
"CODINT": "590000052",
"COD_FORM": "F29",
"DV_ORIGEN": "1",
"FECHA_HOY": "17/01/2020",
"FECHA_INGRESO": "22012019",
"FOLIO": "6700000056",
"MEDIO_INGRESO": "INTERNET",
"MEDIO_PAGO": "",
"MOSTRAR_FOLIO": "1",
"NOMBRES": "EDWARD GUILLERMO BONVALLET GODOY",
"NOMBRE_FUN": " ",
"OPCION": "VC",
"PERIODO": "201812",
"RUT_ORIGEN": "6286736",
"TIPO_MOVIMIENTO": "5",
"TOKEN": "VFC",
"USUARIO": "0",
"cant_anuladas": 1
},
"folioF": {
"COD_9902_1": "6700000046"
},
"glosa": {
"001": "APELLIDO PATERNO O RAZÓN SOCIAL",
"002": "APELLIDO MATERNO",
"003": "N DE RUT",
"005": "NOMBRES",
"006": "DIRECCION",
"007": "FOLIO",
"008": "COMUNA",
"009": "TELEFONO",
"015": "PERIODO TRIBUTARIO",
"048": "RET. IMP. ÚNICO TRAB. ART. 74 N 1 LIR",
"055": "CORREO ELECTRONICO",
"062": "PPM NETO DET.",
"077": "REMANENTE DE CRÉDITO FISC.",
"091": "TOTAL A PAGAR DENTRO DEL PLAZO",
"115": "TASA PPM 1ra. CATEGORIA",
"142": "VENTAS Y/O SERV. EXENTOS O NO GRAVADOS",
"151": "RET, TASAS DE 10 % SOBRE LAS RENT. ",
"315": "FECHA TIMBRE CAJA",
"502": "DÉBITOS FACTURAS EMITIDAS",
"503": "CANTIDAD FACTURAS EMITIDAS",
"511": "CRÉD. IVA POR DCTOS. ELECTRONICOS",
"519": "CANT. DE DCTOS. FACT. RECIB. DEL GIRO",
"520": "CRÉDITO REC. Y REINT./FACT. DEL GIRO",
"521": "MONTO NETO / INTERNAS AFECTAS",
"537": "TOTAL CRÉDITOS",
"538": "TOTAL DÉBITOS",
"547": "TOTAL DETERMINADO",
"562": "MONTO SIN DER. A CRED. FISCAL",
"563": "BASE IMPONIBLE ",
"564": "CANT. DOC. SIN DER. A CRED. FISCAL",
"584": "CANT.INT.EX.NO GRAV.SIN DER. CRED.FISCAL",
"586": "CANT. VTAS. Y/O SERV. PREST. INT. EXENT.",
"595": "SUB TOTAL IMP. DETERMINADO ANVERSO",
"596": "RETENCION CAMBIO DE SUJETO",
"9906": "FECHA PRESENTACION DECL. PRIMITIVA "
},
"justif": {
"001": "I",
"002": "I",
"003": "I",
"005": "I",
"006": "I",
"007": "I",
"008": "I",
"009": "I",
"015": "I",
"048": "I",
"055": "-",
"062": "D",
"077": "I",
"091": "-",
"115": "I",
"142": "D",
"151": "I",
"315": "I",
"502": "D",
"503": "I",
"511": "I",
"519": "I",
"520": "D",
"521": "D",
"537": "D",
"538": "D",
"547": "D",
"562": "D",
"563": "I",
"564": "I",
"584": "I",
"586": "I",
"595": "D",
"596": "D",
"9906": "I"
},
"linea": {
"001": "0",
"002": "0",
"003": "0",
"005": "0",
"006": "0",
"007": "0",
"008": "0",
"009": "0",
"015": "0",
"048": "49",
"055": "0",
"062": "56",
"077": "47",
"091": "119",
"115": "58",
"142": "2",
"151": "50",
"315": "0",
"502": "7",
"503": "7",
"511": "23",
"519": "27",
"520": "27",
"521": "24",
"537": "46",
"538": "22",
"547": "104",
"562": "26",
"563": "57",
"564": "24",
"584": "26",
"586": "2",
"595": "74",
"596": "111",
"9906": "118"
},
"tipos": {
"001": "C",
"002": "C",
"003": "R",
"005": "C",
"006": "C",
"007": "N",
"008": "C",
"009": "C",
"015": "N",
"048": "M",
"055": "C",
"062": "M",
"077": "M",
"091": "M",
"115": "D",
"142": "M",
"151": "M",
"315": "F",
"502": "M",
"503": "N",
"511": "M",
"519": "N",
"520": "M",
"521": "M",
"537": "M",
"538": "M",
"547": "M",
"562": "M",
"563": "M",
"564": "N",
"584": "N",
"586": "N",
"595": "M",
"596": "M",
"9906": "N"
}
}