diff --git a/facho/fe/data/dian/codelist/__init__.py b/facho/fe/data/dian/codelist/__init__.py index 40531c5..c9a5f38 100644 --- a/facho/fe/data/dian/codelist/__init__.py +++ b/facho/fe/data/dian/codelist/__init__.py @@ -95,3 +95,4 @@ Municipio = CodeList(path_for_codelist('Municipio-2.1.gc'), 'code', 'name') Departamento = CodeList(path_for_codelist('Departamentos-2.1.gc'), 'code', 'name') Paises = CodeList(path_for_codelist('Paises-2.1.gc'), 'code', 'name') TipoIdFiscal = CodeList(path_for_codelist('TipoIdFiscal-2.1.gc'), 'code', 'name') +CodigoDescuento = CodeList(path_for_codelist('CodigoDescuento-2.1.gc'), 'code', 'name') diff --git a/facho/fe/form.py b/facho/fe/form.py index 629a825..05ed2ef 100644 --- a/facho/fe/form.py +++ b/facho/fe/form.py @@ -344,11 +344,23 @@ class LegalMonetaryTotal: payable_amount: Amount = Amount(0.0) prepaid_amount: Amount = Amount(0.0) + +@dataclass +class AllowanceChargeReason: + code: str + reason: str + + def __post_init__(self): + if self.code not in codelist.CodigoDescuento: + raise ValueError("code [%s] not found" % (self.code)) + + @dataclass class AllowanceCharge: #DIAN 1.7.-2020: FAQ03 charge_indicator: bool = True amount: Amount = Amount(0.0) + reason: AllowanceChargeReason = None def isCharge(self): return self.charge_indicator == True @@ -362,6 +374,8 @@ class AllowanceCharge: def asDiscount(self): self.charge_indicator = False + def hasReason(self): + return self.reason is not None class NationalSalesInvoiceDocumentType(str): def __str__(self):