se continua con el nuevo modelado de facturacion
FossilOrigin-Name: 68ecac65b7ee5c2884161943e120df58ad596ffd3be82c3ce107ecf00eae6afa
This commit is contained in:
		| @@ -45,6 +45,31 @@ class AccountingSupplierParty(model.Model): | |||||||
|  |  | ||||||
|     party = fields.Many2One(Party) |     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): | class Invoice(model.Model): | ||||||
|     __name__ = 'Invoice' |     __name__ = 'Invoice' | ||||||
|  |  | ||||||
| @@ -57,6 +82,7 @@ class Invoice(model.Model): | |||||||
|  |  | ||||||
|     supplier = fields.Many2One(AccountingSupplierParty) |     supplier = fields.Many2One(AccountingSupplierParty) | ||||||
|     customer = fields.Many2One(AccountingCustomerParty) |     customer = fields.Many2One(AccountingCustomerParty) | ||||||
|  |     lines = fields.One2Many(InvoiceLine) | ||||||
|  |  | ||||||
|     def set_issue(self, name, value): |     def set_issue(self, name, value): | ||||||
|         if not isinstance(value, datetime): |         if not isinstance(value, datetime): | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ from datetime import datetime | |||||||
| import pytest | import pytest | ||||||
|  |  | ||||||
| import facho.fe.model as model | import facho.fe.model as model | ||||||
|  | import facho.fe.form as form | ||||||
|  |  | ||||||
| def test_simple_invoice(): | def test_simple_invoice(): | ||||||
|     invoice = model.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.issue = datetime.strptime('2019-01-16 10:53:10-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||||
|     invoice.supplier.party.id = '700085371' |     invoice.supplier.party.id = '700085371' | ||||||
|     invoice.customer.party.id = '800199436' |     invoice.customer.party.id = '800199436' | ||||||
|  |  | ||||||
|  |     line = invoice.lines.create() | ||||||
|  |     line.quantity = form.Quantity(1, '94') | ||||||
|  |     line.price = form.Amount(5_000) | ||||||
|  |  | ||||||
|  |     assert '<Invoice><ID>323200000129</ID><IssueDate>2019-01-16T10:53:10-05:00</IssueDate><IssueTime>10:5310-05:00</IssueTime><AccountingSupplierParty><Party><ID>700085371</ID></Party></AccountingSupplierParty><AccountingCustomerParty><Party><ID>800199436</ID></Party></AccountingCustomerParty><InvoiceLine><InvoiceQuantity unitCode="NAR">1.0</InvoiceQuantity><Price><PriceAmount currencyID="COP">5000.0</PriceAmount></Price></InvoiceLine></Invoice>' == invoice.to_xml() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user