From bd25bef21fc1df74e5a2d128836df8a2226ca768 Mon Sep 17 00:00:00 2001 From: bit4bit Date: Sat, 26 Jun 2021 00:11:57 +0000 Subject: [PATCH] se continua con el nuevo modelado de facturacion FossilOrigin-Name: 68ecac65b7ee5c2884161943e120df58ad596ffd3be82c3ce107ecf00eae6afa --- facho/fe/model/__init__.py | 28 +++++++++++++++++++++++++++- tests/test_model_invoice.py | 7 +++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/facho/fe/model/__init__.py b/facho/fe/model/__init__.py index a2cbe20..f144d32 100644 --- a/facho/fe/model/__init__.py +++ b/facho/fe/model/__init__.py @@ -44,6 +44,31 @@ class AccountingSupplierParty(model.Model): __name__ = 'AccountingSupplierParty' party = fields.Many2One(Party) + +class InvoicedQuantity(model.Model): + __name__ = 'InvoiceQuantity' + + code = fields.Attribute('unitCode', default='NAR') + + +class PriceAmount(model.Model): + __name__ = 'PriceAmount' + + currency = fields.Attribute('currencyID', default='COP') + +class Price(model.Model): + __name__ = 'Price' + + amount = fields.Many2One(PriceAmount) + + def __default_set__(self, value): + self.amount = value + +class InvoiceLine(model.Model): + __name__ = 'InvoiceLine' + + quantity = fields.Many2One(InvoicedQuantity) + price = fields.Many2One(Price) class Invoice(model.Model): __name__ = 'Invoice' @@ -57,7 +82,8 @@ class Invoice(model.Model): supplier = fields.Many2One(AccountingSupplierParty) customer = fields.Many2One(AccountingCustomerParty) - + lines = fields.One2Many(InvoiceLine) + def set_issue(self, name, value): if not isinstance(value, datetime): raise ValueError('expected type datetime') diff --git a/tests/test_model_invoice.py b/tests/test_model_invoice.py index 30f5b91..d85c87b 100644 --- a/tests/test_model_invoice.py +++ b/tests/test_model_invoice.py @@ -10,6 +10,7 @@ from datetime import datetime import pytest import facho.fe.model as model +import facho.fe.form as form def test_simple_invoice(): invoice = model.Invoice() @@ -17,3 +18,9 @@ def test_simple_invoice(): invoice.issue = datetime.strptime('2019-01-16 10:53:10-05:00', '%Y-%m-%d %H:%M:%S%z') invoice.supplier.party.id = '700085371' invoice.customer.party.id = '800199436' + + line = invoice.lines.create() + line.quantity = form.Quantity(1, '94') + line.price = form.Amount(5_000) + + assert '3232000001292019-01-16T10:53:10-05:0010:5310-05:007000853718001994361.05000.0' == invoice.to_xml()