From 67156ec9a683e51b83809656ccce832f4787a6dd Mon Sep 17 00:00:00 2001 From: bit4bit <bit4bit@noemail.net> Date: Tue, 10 Nov 2020 23:17:25 +0000 Subject: [PATCH] usa Amount en Quantity FossilOrigin-Name: 0f51683a044925969f6f113710ca9456dfa541a80ec3d7a3b9e5235718cbf0ea --- facho/fe/form/__init__.py | 6 +++--- tests/test_fe_form.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/facho/fe/form/__init__.py b/facho/fe/form/__init__.py index fd1f21c..395c748 100644 --- a/facho/fe/form/__init__.py +++ b/facho/fe/form/__init__.py @@ -116,12 +116,12 @@ class Amount: class Quantity: def __init__(self, val, code): - if not isinstance(val, int): - raise ValueError('val expected int') + if type(val) not in [float, int]: + raise ValueError('val expected int or float') if code not in codelist.UnidadesMedida: raise ValueError("code [%s] not found" % (code)) - self.value = val + self.value = Amount(val) self.code = code def __mul__(self, other): diff --git a/tests/test_fe_form.py b/tests/test_fe_form.py index b74707f..2c01b96 100644 --- a/tests/test_fe_form.py +++ b/tests/test_fe_form.py @@ -112,7 +112,7 @@ def test_invoice_cufe(simple_invoice_without_lines): simple_invoice.invoice_supplier.ident = form.PartyIdentification('700085371', '5', '31') simple_invoice.invoice_customer.ident = form.PartyIdentification('800199436', '5', '31') simple_invoice.add_invoice_line(form.InvoiceLine( - quantity = form.Quantity(1, '94'), + quantity = form.Quantity(1.00, '94'), description = 'producto', item = form.StandardItem(111), price = form.Price(form.Amount(1_500_000), '01', ''),