From 90cf2917d1042361809b028414fdca0cdcdfb4a4 Mon Sep 17 00:00:00 2001 From: "bit4bit@riseup.net" Date: Sat, 20 Jun 2020 14:28:50 +0000 Subject: [PATCH] facho/fe/form.py: se valida tipo de code en precio de referencia FossilOrigin-Name: 63bb8ab5bd2d52af2113ba34c404af5120889cbca595c283c00f04a1a8c66316 --- facho/fe/data/dian/codelist/__init__.py | 1 + facho/fe/form.py | 6 +++++- tests/test_fe_form.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/facho/fe/data/dian/codelist/__init__.py b/facho/fe/data/dian/codelist/__init__.py index f3c23bc..cfc397d 100644 --- a/facho/fe/data/dian/codelist/__init__.py +++ b/facho/fe/data/dian/codelist/__init__.py @@ -70,3 +70,4 @@ TipoOrganizacion = CodeList(path_for_codelist('TipoOrganizacion-2.1.gc'), 'code' TipoResponsabilidad = CodeList(path_for_codelist('TipoResponsabilidad-2.1.gc'), 'code', 'name') TipoAmbiente = CodeList(path_for_codelist('TipoAmbiente-2.1.gc'), 'code', 'name') TipoDocumento = CodeList(path_for_codelist('TipoDocumento-2.1.gc'), 'code', 'name') +CodigoPrecioReferencia = CodeList(path_for_codelist('CodigoPrecioReferencia-2.1.gc'), 'code', 'name') diff --git a/facho/fe/form.py b/facho/fe/form.py index bb4d5a1..ce35c39 100644 --- a/facho/fe/form.py +++ b/facho/fe/form.py @@ -210,7 +210,11 @@ class DianResolucion0001Validator: self._validate_party('supplier', supplier) def visit_invoice_line(self, line): - pass + try: + codelist.CodigoPrecioReferencia[line.price.type_code] + except KeyError: + self.errors.append(('invoice_line', 'line.price', + 'not found %s' % (line.price.type_code))) def valid(self): return not self.errors diff --git a/tests/test_fe_form.py b/tests/test_fe_form.py index 7fcd299..6401402 100644 --- a/tests/test_fe_form.py +++ b/tests/test_fe_form.py @@ -58,7 +58,7 @@ def simple_invoice(): quantity = 1, description = 'producto facho', item = form.StandardItem('test', 9999), - price = form.Price(100.0, '', ''), + price = form.Price(100.0, '01', ''), tax = form.TaxTotal( tax_amount = 0.0, taxable_amount = 0.0,