fache/fe/form: Quantity require UnidadesMedida.

FossilOrigin-Name: 675900c1251c0b7319dc8b395ce5d385297209197ce13b0ee5358b4ce619d9a8
This commit is contained in:
2020-11-04 00:40:46 +00:00
parent ee58dba82f
commit 44827fe811
6 changed files with 37 additions and 11 deletions

View File

@@ -71,6 +71,7 @@ __all__ = ['TipoOrganizacion',
'TipoAmbiente',
'TipoDocumento',
'TipoImpuesto',
'UnidadesMedida',
'CodigoPrecioReferencia',
'MediosPago',
'RegimenFiscal',
@@ -98,3 +99,4 @@ 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')
UnidadesMedida = CodeList(path_for_codelist('UnidadesMedida-2.1.gc'), 'code', 'name')

View File

@@ -113,8 +113,30 @@ class Amount:
return round(self.amount, DECIMAL_PRECISION)
class Quantity(Amount):
pass
class Quantity:
def __init__(self, val, code):
if not isinstance(val, int):
raise ValueError('val expected int')
if code not in codelist.UnidadesMedida:
raise ValueError("code [%s] not found" % (code))
self.value = val
self.code = code
def __mul__(self, other):
if isinstance(other, Amount):
return Amount(self.value) * other
return self.value * other
def __lt__(self, other):
if isinstance(other, Amount):
return Amount(self.value) < other
return self.value < other
def __str__(self):
return str(self.value)
@dataclass
class Item:

View File

@@ -523,7 +523,9 @@ class DIANInvoiceXML(fe.FeXML):
line.set_element('./cac:Price/cbc:PriceAmount', invoice_line.price.amount, currencyID="COP")
#DIAN 1.7.-2020: FBB04
line.set_element('./cac:Price/cbc:BaseQuantity', invoice_line.price.amount)
line.set_element('./cac:Price/cbc:BaseQuantity',
invoice_line.quantity,
unitCode=invoice_line.quantity.code)
def attach_invoice(fexml, invoice):