2022-10-17 15:20:25 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-06-30 09:36:17 +00:00
|
|
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
2022-10-17 15:20:25 +00:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains the
|
|
|
|
# full copyright notices and license terms.
|
|
|
|
|
|
|
|
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
|
|
|
from trytond.pool import Pool
|
2023-04-04 10:58:00 +00:00
|
|
|
from trytond.modules.edocument_uncefact.tests.test_module import get_invoice
|
2023-06-30 09:36:17 +00:00
|
|
|
from unittest.mock import Mock
|
2022-10-19 15:15:56 +00:00
|
|
|
from decimal import Decimal
|
2022-10-17 15:20:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EdocTestCase(ModuleTestCase):
|
|
|
|
'Test e-rechnung module'
|
|
|
|
module = 'edocument_xrechnung'
|
|
|
|
|
|
|
|
@with_transaction()
|
|
|
|
def test_xrechn_export_xml(self):
|
|
|
|
""" run export
|
|
|
|
"""
|
|
|
|
pool = Pool()
|
|
|
|
Template = pool.get('edocument.xrechnung.invoice')
|
|
|
|
Identifier = pool.get('party.identifier')
|
2022-10-19 15:15:56 +00:00
|
|
|
Party = pool.get('party.party')
|
|
|
|
Bank = pool.get('bank')
|
|
|
|
BankAccount = pool.get('bank.account')
|
|
|
|
BankNumber = pool.get('bank.account.number')
|
2022-10-17 15:20:25 +00:00
|
|
|
|
|
|
|
invoice = get_invoice()
|
2023-06-30 09:36:17 +00:00
|
|
|
invoice.party.get_xrechnung_route_id = Mock(
|
|
|
|
return_value='xrechn-route-id-123')
|
2022-10-19 15:15:56 +00:00
|
|
|
invoice.company.party.bank_accounts = [
|
2023-06-30 09:36:17 +00:00
|
|
|
Mock(
|
|
|
|
spec=BankAccount,
|
2022-10-19 15:15:56 +00:00
|
|
|
currency=invoice.currency,
|
|
|
|
bank=Mock(spec=Bank, party=Mock(spec=Party, name='Bank')),
|
2023-06-30 09:36:17 +00:00
|
|
|
owners=[invoice.company.party],
|
|
|
|
numbers=[Mock(spec=BankNumber, type='other', number='123456')],
|
2022-10-19 15:15:56 +00:00
|
|
|
)]
|
|
|
|
invoice.description = 'description of invoice'
|
|
|
|
invoice.comment = 'note line 1\nnote line 2'
|
|
|
|
invoice.taxes[0].tax.rate = Decimal('0.1')
|
2022-10-17 15:20:25 +00:00
|
|
|
invoice.identifiers = [
|
2023-06-30 09:36:17 +00:00
|
|
|
Mock(
|
|
|
|
spec=Identifier,
|
2022-10-17 15:20:25 +00:00
|
|
|
type='edoc_route_id',
|
|
|
|
code='xrechn-route-id-123')
|
|
|
|
]
|
|
|
|
|
|
|
|
template = Template(invoice)
|
|
|
|
invoice_string = template.render('XRechnung-2.2')
|
|
|
|
with open('xrechnung-test.xml', 'wt') as fhdl:
|
|
|
|
fhdl.write(invoice_string.decode('utf8'))
|
|
|
|
|
|
|
|
# end EdocTestCase
|
2023-04-04 10:58:00 +00:00
|
|
|
|
2023-06-30 09:36:17 +00:00
|
|
|
|
2023-04-04 10:58:00 +00:00
|
|
|
del ModuleTestCase
|