get amount on line as net-value (even if invoice is gross-mode)
This commit is contained in:
parent
a5bf930e55
commit
214cbb086f
4 changed files with 85 additions and 3 deletions
|
@ -7,7 +7,8 @@ from lxml import etree
|
|||
import os
|
||||
from decimal import Decimal
|
||||
from datetime import date
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.tests.test_tryton import (
|
||||
ModuleTestCase, with_transaction, activate_module)
|
||||
from trytond.pool import Pool
|
||||
from trytond.modules.company.tests import create_company, set_company
|
||||
from trytond.modules.account.tests import create_chart, get_fiscalyear
|
||||
|
@ -42,6 +43,14 @@ class EdocTestCase(ModuleTestCase):
|
|||
'Test e-rechnung module'
|
||||
module = 'edocument_xrechnung'
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
activate_module([
|
||||
'edocument_uncefact', 'party', 'bank',
|
||||
'account_invoice', 'sale_point_invoice',
|
||||
'product_grossprice'], 'en')
|
||||
|
||||
def prep_fiscalyear(self, company1):
|
||||
""" prepare fiscal year, sequences...
|
||||
"""
|
||||
|
@ -84,7 +93,7 @@ class EdocTestCase(ModuleTestCase):
|
|||
'number': 'DE02300209000106531065'}])]}])
|
||||
return company
|
||||
|
||||
def prep_invoice(self, credit_note=False):
|
||||
def prep_invoice(self, credit_note=False, modegross='net'):
|
||||
""" add invoice
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -130,6 +139,7 @@ class EdocTestCase(ModuleTestCase):
|
|||
|
||||
to_create_invoice = [{
|
||||
'type': 'out',
|
||||
'modegross': modegross,
|
||||
'description': 'description of invoice',
|
||||
'comment': 'note line 1\nnote line 2',
|
||||
'invoice_date': date(2024, 7, 1),
|
||||
|
@ -149,6 +159,11 @@ class EdocTestCase(ModuleTestCase):
|
|||
'currency': currency1.id,
|
||||
}])],
|
||||
}]
|
||||
|
||||
if modegross == 'gross':
|
||||
to_create_invoice[0]['lines'][0][1][0]['unit_gross_price'] = (
|
||||
Decimal('50.0') * Decimal('1.2'))
|
||||
|
||||
inv_lst, = Invoice.create(to_create_invoice)
|
||||
inv_lst.on_change_lines()
|
||||
inv_lst.save()
|
||||
|
@ -233,6 +248,34 @@ class EdocTestCase(ModuleTestCase):
|
|||
{'identifiers': [('delete', [party.identifiers[0].id])]}]
|
||||
)
|
||||
|
||||
@with_transaction()
|
||||
def test_xrechn_export_facturx_gross(self):
|
||||
""" run export - factur-x, modegross='gross'
|
||||
"""
|
||||
pool = Pool()
|
||||
Template = pool.get('edocument.facturxext.invoice')
|
||||
|
||||
company = self.prep_company()
|
||||
with set_company(company):
|
||||
create_chart(company=company, tax=True)
|
||||
self.prep_fiscalyear(company)
|
||||
invoice = self.prep_invoice(modegross='gross')
|
||||
|
||||
template = Template(invoice)
|
||||
|
||||
schema_file = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'Factur-X_1.07.2_EXTENDED',
|
||||
'Factur-X_1.07.2_EXTENDED.xsd')
|
||||
|
||||
invoice_string = template.render('Factur-X-1.07.2-extended')
|
||||
with open('gross_invoice_string.xml', 'wb') as fhdl:
|
||||
fhdl.write(invoice_string)
|
||||
|
||||
invoice_xml = etree.fromstring(invoice_string)
|
||||
schema = etree.XMLSchema(etree.parse(schema_file))
|
||||
schema.assertValid(invoice_xml)
|
||||
|
||||
@with_transaction()
|
||||
def test_xrechn_export_facturx(self):
|
||||
""" run export - factur-x
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue