formatting
This commit is contained in:
parent
e893c1be2b
commit
c4571a28b9
6 changed files with 65 additions and 68 deletions
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
|
23
edocument.py
23
edocument.py
|
@ -1,10 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the edcoment-module for Tryton.
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
import genshi.template
|
import genshi.template
|
||||||
import os, html
|
import os
|
||||||
|
import html
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.modules.edocument_uncefact.edocument import Invoice
|
from trytond.modules.edocument_uncefact.edocument import Invoice
|
||||||
|
@ -45,17 +46,15 @@ class Invoice(Invoice):
|
||||||
if len(line.invoice_taxes) != 1:
|
if len(line.invoice_taxes) != 1:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_linetax_invalid_number',
|
'edocument_xrechnung.msg_linetax_invalid_number',
|
||||||
linename = line.rec_name,
|
linename=line.rec_name,
|
||||||
numtax = len(line.invoice_taxes),
|
numtax=len(line.invoice_taxes)))
|
||||||
))
|
|
||||||
|
|
||||||
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
|
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
|
||||||
if not line.invoice_taxes[0].tax.unece_category_code in allowed_cat:
|
if not line.invoice_taxes[0].tax.unece_category_code in allowed_cat:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
||||||
taxname = line.invoice_taxes[0].tax.rec_name,
|
taxname=line.invoice_taxes[0].tax.rec_name,
|
||||||
allowed = ', '.join(allowed_cat),
|
allowed=', '.join(allowed_cat)))
|
||||||
))
|
|
||||||
|
|
||||||
return line.invoice_taxes[0].tax
|
return line.invoice_taxes[0].tax
|
||||||
|
|
||||||
|
@ -84,8 +83,7 @@ class Invoice(Invoice):
|
||||||
if len(line.unit.unece_code or '') == 0:
|
if len(line.unit.unece_code or '') == 0:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_uom_code_missing',
|
'edocument_xrechnung.msg_uom_code_missing',
|
||||||
uomname = line.unit.rec_name,
|
uomname=line.unit.rec_name))
|
||||||
))
|
|
||||||
return line.unit.unece_code
|
return line.unit.unece_code
|
||||||
|
|
||||||
def tax_category_code(self, tax):
|
def tax_category_code(self, tax):
|
||||||
|
@ -94,8 +92,7 @@ class Invoice(Invoice):
|
||||||
if len(tax.unece_category_code or '') == 0:
|
if len(tax.unece_category_code or '') == 0:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.mds_tax_category_missing',
|
'edocument_xrechnung.mds_tax_category_missing',
|
||||||
taxname = tax.rec_name,
|
taxname=tax.rec_name))
|
||||||
))
|
|
||||||
return tax.unece_category_code
|
return tax.unece_category_code
|
||||||
|
|
||||||
def quote_text(self, text):
|
def quote_text(self, text):
|
||||||
|
@ -112,7 +109,7 @@ class Invoice(Invoice):
|
||||||
os.path.join(os.path.dirname(__file__), 'template'),
|
os.path.join(os.path.dirname(__file__), 'template'),
|
||||||
auto_reload=True)
|
auto_reload=True)
|
||||||
return loader.load(os.path.join(version, 'XRechnung.xml'))
|
return loader.load(os.path.join(version, 'XRechnung.xml'))
|
||||||
else :
|
else:
|
||||||
return super(Invoice, self)._get_template(version)
|
return super(Invoice, self)._get_template(version)
|
||||||
|
|
||||||
# end Invoice
|
# end Invoice
|
||||||
|
|
5
party.py
5
party.py
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the edcoment-module for Tryton.
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ class Party(metaclass=PoolMeta):
|
||||||
return ident.code
|
return ident.code
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
'edocument_xrechnung.msg_missing_xrechnung_route_id',
|
||||||
partyname = self.rec_name,
|
partyname=self.rec_name))
|
||||||
))
|
|
||||||
|
|
||||||
# end Party
|
# end Party
|
||||||
|
|
||||||
|
|
65
setup.py
65
setup.py
|
@ -2,7 +2,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -36,7 +36,7 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
|
||||||
l2 = i.strip().split(';')
|
l2 = i.strip().split(';')
|
||||||
if len(l2) < 4:
|
if len(l2) < 4:
|
||||||
continue
|
continue
|
||||||
modversion[l2[0]] = {'min':l2[1], 'max':l2[2], 'prefix':l2[3]}
|
modversion[l2[0]] = {'min': l2[1], 'max': l2[2], 'prefix': l2[3]}
|
||||||
|
|
||||||
# tryton-version
|
# tryton-version
|
||||||
major_version = 6
|
major_version = 6
|
||||||
|
@ -51,19 +51,21 @@ for dep in info.get('depends', []):
|
||||||
prefix = modversion[dep]['prefix']
|
prefix = modversion[dep]['prefix']
|
||||||
|
|
||||||
if len(modversion[dep]['max']) > 0:
|
if len(modversion[dep]['max']) > 0:
|
||||||
requires.append('%s_%s >= %s, <= %s' %
|
requires.append('%s_%s >= %s, <= %s' % (
|
||||||
(prefix, dep, modversion[dep]['min'], modversion[dep]['max']))
|
prefix, dep, modversion[dep]['min'],
|
||||||
else :
|
modversion[dep]['max']))
|
||||||
requires.append('%s_%s >= %s' %
|
else:
|
||||||
(prefix, dep, modversion[dep]['min']))
|
requires.append('%s_%s >= %s' % (
|
||||||
else :
|
prefix, dep, modversion[dep]['min']))
|
||||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
else:
|
||||||
('trytond', dep, major_version, minor_version,
|
requires.append('%s_%s >= %s.%s, < %s.%s' % (
|
||||||
|
'trytond', dep, major_version, minor_version,
|
||||||
major_version, minor_version + 1))
|
major_version, minor_version + 1))
|
||||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
requires.append('trytond >= %s.%s, < %s.%s' % (
|
||||||
(major_version, minor_version, major_version, minor_version + 1))
|
major_version, minor_version, major_version, minor_version + 1))
|
||||||
|
|
||||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
setup(
|
||||||
|
name='%s_%s' % (PREFIX, MODULE),
|
||||||
version=info.get('version', '0.0.1'),
|
version=info.get('version', '0.0.1'),
|
||||||
description='Tryton module to XRechnung to edocument.',
|
description='Tryton module to XRechnung to edocument.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
@ -72,22 +74,22 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
author_email='service@m-ds.de',
|
author_email='service@m-ds.de',
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Plugins',
|
'Environment :: Plugins',
|
||||||
'Framework :: Tryton',
|
'Framework :: Tryton',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Customer Service',
|
'Intended Audience :: Customer Service',
|
||||||
'Intended Audience :: Information Technology',
|
'Intended Audience :: Information Technology',
|
||||||
'Intended Audience :: Financial and Insurance Industry',
|
'Intended Audience :: Financial and Insurance Industry',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
'Topic :: Office/Business :: Financial :: Accounting',
|
'Topic :: Office/Business :: Financial :: Accounting',
|
||||||
'Natural Language :: German',
|
'Natural Language :: German',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||||
'Programming Language :: Python :: 3.7',
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: 3.8',
|
'Programming Language :: Python :: 3.8',
|
||||||
'Programming Language :: Python :: 3.9',
|
'Programming Language :: Python :: 3.9',
|
||||||
],
|
],
|
||||||
|
|
||||||
keywords='tryton xrechnung edcoument',
|
keywords='tryton xrechnung edcoument',
|
||||||
|
@ -96,9 +98,10 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
'trytond.modules.%s' % MODULE,
|
'trytond.modules.%s' % MODULE,
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
'trytond.modules.%s' % MODULE: (
|
||||||
|
info.get('xml', [])
|
||||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||||
'template/*/*.xml','versiondep.txt', 'README.rst']),
|
'template/*/*.xml', 'versiondep.txt', 'README.rst']),
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
|
|
|
@ -1,23 +1,18 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# -*- coding: utf-8 -*-
|
||||||
# this repository contains the full copyright notices and license terms.
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
import trytond.tests.test_tryton
|
import trytond.tests.test_tryton
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from trytond.modules.edocument_xrechnung.tests.test_edocument import EdocTestCase
|
from .test_edocument import EdocTestCase
|
||||||
|
|
||||||
__all__ = ['suite']
|
__all__ = ['suite']
|
||||||
|
|
||||||
|
|
||||||
class EDocumentTestCase(\
|
|
||||||
EdocTestCase,\
|
|
||||||
):
|
|
||||||
'Test edocument module'
|
|
||||||
module = 'edocument_xrechnung'
|
|
||||||
|
|
||||||
# end EDocumentTestCase
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
suite = trytond.tests.test_tryton.suite()
|
suite = trytond.tests.test_tryton.suite()
|
||||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(EDocumentTestCase))
|
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||||
|
EdocTestCase))
|
||||||
return suite
|
return suite
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
# This file is part of the edocument-module for Tryton from m-ds.de.
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.modules.edocument_uncefact.tests.test_module import get_invoice
|
from trytond.modules.edocument_uncefact.tests.test_module import get_invoice
|
||||||
from unittest.mock import Mock, MagicMock
|
from unittest.mock import Mock
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ class EdocTestCase(ModuleTestCase):
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Template = pool.get('edocument.xrechnung.invoice')
|
Template = pool.get('edocument.xrechnung.invoice')
|
||||||
Address = pool.get('party.address')
|
|
||||||
Identifier = pool.get('party.identifier')
|
Identifier = pool.get('party.identifier')
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
Bank = pool.get('bank')
|
Bank = pool.get('bank')
|
||||||
|
@ -28,19 +27,22 @@ class EdocTestCase(ModuleTestCase):
|
||||||
BankNumber = pool.get('bank.account.number')
|
BankNumber = pool.get('bank.account.number')
|
||||||
|
|
||||||
invoice = get_invoice()
|
invoice = get_invoice()
|
||||||
invoice.party.get_xrechnung_route_id = Mock(return_value='xrechn-route-id-123')
|
invoice.party.get_xrechnung_route_id = Mock(
|
||||||
|
return_value='xrechn-route-id-123')
|
||||||
invoice.company.party.bank_accounts = [
|
invoice.company.party.bank_accounts = [
|
||||||
Mock(spec=BankAccount,
|
Mock(
|
||||||
|
spec=BankAccount,
|
||||||
currency=invoice.currency,
|
currency=invoice.currency,
|
||||||
bank=Mock(spec=Bank, party=Mock(spec=Party, name='Bank')),
|
bank=Mock(spec=Bank, party=Mock(spec=Party, name='Bank')),
|
||||||
owners = [invoice.company.party],
|
owners=[invoice.company.party],
|
||||||
numbers = [Mock(spec=BankNumber, type='other', number='123456')],
|
numbers=[Mock(spec=BankNumber, type='other', number='123456')],
|
||||||
)]
|
)]
|
||||||
invoice.description = 'description of invoice'
|
invoice.description = 'description of invoice'
|
||||||
invoice.comment = 'note line 1\nnote line 2'
|
invoice.comment = 'note line 1\nnote line 2'
|
||||||
invoice.taxes[0].tax.rate = Decimal('0.1')
|
invoice.taxes[0].tax.rate = Decimal('0.1')
|
||||||
invoice.identifiers = [
|
invoice.identifiers = [
|
||||||
Mock(spec=Identifier,
|
Mock(
|
||||||
|
spec=Identifier,
|
||||||
type='edoc_route_id',
|
type='edoc_route_id',
|
||||||
code='xrechn-route-id-123')
|
code='xrechn-route-id-123')
|
||||||
]
|
]
|
||||||
|
@ -52,4 +54,5 @@ class EdocTestCase(ModuleTestCase):
|
||||||
|
|
||||||
# end EdocTestCase
|
# end EdocTestCase
|
||||||
|
|
||||||
|
|
||||||
del ModuleTestCase
|
del ModuleTestCase
|
||||||
|
|
Loading…
Reference in a new issue