add: creditnote

This commit is contained in:
Frederik Jaeckel 2023-06-30 15:29:51 +02:00
parent c4571a28b9
commit 28a96bc7c9
4 changed files with 259 additions and 6 deletions

View file

@ -22,6 +22,19 @@ class Invoice(Invoice):
if getattr(self.invoice, 'sales', None) is not None:
return ', '.join([x.number for x in self.invoice.sales])
def negate_amount(self, amount):
""" amount * -1.0
"""
if amount is not None and amount:
if isinstance(amount, Decimal):
return amount.copy_negate()
elif isinstance(amount, float):
return -1.0 * amount
elif isinstance(amount, int):
return -1 * amount
else :
return amount
def prepaid_amount(self, invoice):
""" compute already paid amount
"""
@ -108,7 +121,12 @@ class Invoice(Invoice):
loader = genshi.template.TemplateLoader(
os.path.join(os.path.dirname(__file__), 'template'),
auto_reload=True)
return loader.load(os.path.join(version, 'XRechnung.xml'))
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'))
else :
raise ValueError('invalid type-code "%s"' % self.type_code)
else:
return super(Invoice, self)._get_template(version)