export: add factur-x 1.07.2
This commit is contained in:
parent
3d703e300e
commit
764cacc091
5 changed files with 259 additions and 10 deletions
58
edocument.py
58
edocument.py
|
@ -12,6 +12,42 @@ from trytond.modules.edocument_uncefact.edocument import Invoice
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
class FacturX(Invoice):
|
||||
'Factur-X'
|
||||
__name__ = 'edocument.facturxext.invoice'
|
||||
|
||||
def get_list_of_comments(self):
|
||||
""" comment, to export in <ram:IncludedNote/>
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
result = []
|
||||
if self.invoice.comment:
|
||||
result.append({
|
||||
'content': self.invoice.comment,
|
||||
'subject_code': '',
|
||||
'content_code': ''})
|
||||
return result
|
||||
|
||||
def _get_template(self, version):
|
||||
""" load our own template if 'version' is ours
|
||||
"""
|
||||
loader = genshi.template.TemplateLoader(
|
||||
os.path.join(os.path.dirname(__file__), 'template'),
|
||||
auto_reload=True)
|
||||
|
||||
if version == 'Factur-X-1.07.2-extended':
|
||||
if self.type_code in ['380', '389', '381', '261']:
|
||||
return loader.load(os.path.join(version, 'invoice.xml'))
|
||||
else:
|
||||
raise ValueError('invalid type-code "%s"' % self.type_code)
|
||||
else:
|
||||
return super(Invoice, self)._get_template(version)
|
||||
|
||||
# end FacturX
|
||||
|
||||
|
||||
class Invoice(Invoice):
|
||||
'EDocument XRechnung'
|
||||
__name__ = 'edocument.xrechnung.invoice'
|
||||
|
@ -123,16 +159,20 @@ class Invoice(Invoice):
|
|||
def _get_template(self, version):
|
||||
""" load our own template if 'version' is ours
|
||||
"""
|
||||
loader = genshi.template.TemplateLoader(
|
||||
os.path.join(os.path.dirname(__file__), 'template'),
|
||||
auto_reload=True)
|
||||
|
||||
if version in ['XRechnung-2.2', 'XRechnung-2.3', 'XRechnung-3.0']:
|
||||
loader = genshi.template.TemplateLoader(
|
||||
os.path.join(os.path.dirname(__file__), 'template'),
|
||||
auto_reload=True)
|
||||
if self.type_code in ['380', '389']:
|
||||
return loader.load(os.path.join(
|
||||
version, 'XRechnung_invoice.xml'))
|
||||
elif self.type_code in ['381', '261']:
|
||||
return loader.load(os.path.join(
|
||||
version, 'XRechnung_credit.xml'))
|
||||
file_name = {
|
||||
'380': 'XRechnung_invoice.xml',
|
||||
'389': 'XRechnung_invoice.xml',
|
||||
'381': 'XRechnung_credit.xml',
|
||||
'261': 'XRechnung_credit.xml',
|
||||
}.get(self.type_code)
|
||||
|
||||
if file_name:
|
||||
return loader.load(os.path.join(version, file_name))
|
||||
else:
|
||||
raise ValueError('invalid type-code "%s"' % self.type_code)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue