export: add xrechnung 2.3 + 3.0 + tests against xsd
This commit is contained in:
parent
253cc01045
commit
5171cbae09
7 changed files with 762 additions and 10 deletions
|
@ -3,11 +3,14 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from lxml import etree
|
||||
import os
|
||||
from unittest.mock import Mock
|
||||
from decimal import Decimal
|
||||
from datetime import date
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.modules.edocument_uncefact.tests.test_module import get_invoice
|
||||
from unittest.mock import Mock
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class EdocTestCase(ModuleTestCase):
|
||||
|
@ -27,6 +30,7 @@ class EdocTestCase(ModuleTestCase):
|
|||
BankNumber = pool.get('bank.account.number')
|
||||
|
||||
invoice = get_invoice()
|
||||
invoice.payment_term_date = date.today()
|
||||
invoice.party.get_xrechnung_route_id = Mock(
|
||||
return_value='xrechn-route-id-123')
|
||||
invoice.company.party.bank_accounts = [
|
||||
|
@ -48,9 +52,16 @@ class EdocTestCase(ModuleTestCase):
|
|||
]
|
||||
|
||||
template = Template(invoice)
|
||||
invoice_string = template.render('XRechnung-2.2')
|
||||
with open('xrechnung-test-invoice.xml', 'wt') as fhdl:
|
||||
fhdl.write(invoice_string.decode('utf8'))
|
||||
|
||||
schema_file = os.path.join(
|
||||
os.path.dirname(__file__), 'os-UBL-2.1',
|
||||
'xsd', 'maindoc', 'UBL-Invoice-2.1.xsd')
|
||||
|
||||
for x in ['XRechnung-2.2', 'XRechnung-2.3', 'XRechnung-3.0']:
|
||||
invoice_string = template.render(x)
|
||||
invoice_xml = etree.fromstring(invoice_string)
|
||||
schema = etree.XMLSchema(etree.parse(schema_file))
|
||||
schema.assertValid(invoice_xml)
|
||||
|
||||
@with_transaction()
|
||||
def test_xrechn_export_xml_creditnote(self):
|
||||
|
@ -97,9 +108,20 @@ class EdocTestCase(ModuleTestCase):
|
|||
]
|
||||
|
||||
template = Template(invoice)
|
||||
invoice_string = template.render('XRechnung-2.2')
|
||||
with open('xrechnung-test-creditnote.xml', 'wt') as fhdl:
|
||||
fhdl.write(invoice_string.decode('utf8'))
|
||||
|
||||
schema_file = os.path.join(
|
||||
os.path.dirname(__file__), 'os-UBL-2.1',
|
||||
'xsd', 'maindoc', 'UBL-CreditNote-2.1.xsd')
|
||||
|
||||
for x in ['XRechnung-2.2', 'XRechnung-2.3', 'XRechnung-3.0']:
|
||||
invoice_string = template.render(x)
|
||||
invoice_xml = etree.fromstring(invoice_string)
|
||||
schema = etree.XMLSchema(etree.parse(schema_file))
|
||||
schema.assertValid(invoice_xml)
|
||||
|
||||
# invoice_string = template.render('XRechnung-2.2')
|
||||
# with open('xrechnung-test-creditnote.xml', 'wt') as fhdl:
|
||||
# fhdl.write(invoice_string.decode('utf8'))
|
||||
|
||||
# end EdocTestCase
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue