diff --git a/modules/edocument_peppol/CHANGELOG b/modules/edocument_peppol/CHANGELOG index 260f651100..16db0745d5 100644 --- a/modules/edocument_peppol/CHANGELOG +++ b/modules/edocument_peppol/CHANGELOG @@ -1,3 +1,4 @@ +* Ensure that the unit price on the invoice line is not negative * Add an "Update Status" button to the Peppol document Version 7.8.0 - 2025-12-15 diff --git a/modules/edocument_peppol/account.py b/modules/edocument_peppol/account.py index 0b36299ae0..c5105f39ac 100644 --- a/modules/edocument_peppol/account.py +++ b/modules/edocument_peppol/account.py @@ -6,7 +6,7 @@ from trytond.model import fields from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval -from .exceptions import InvoicePeppolRequired +from .exceptions import InvoicePeppolError, InvoicePeppolRequired class Invoice(metaclass=PoolMeta): @@ -47,6 +47,7 @@ class Invoice(metaclass=PoolMeta): peppol_types = invoice.party.get_multivalue( 'peppol_types', company=invoice.company.id) if peppol_types and 'bis-billing-3' in peppol_types: + invoice.check_peppol() peppol.append(Peppol( direction='out', company=invoice.company, @@ -65,3 +66,13 @@ class Invoice(metaclass=PoolMeta): if peppol: Peppol.save(peppol) Peppol.submit(peppol) + + def check_peppol(self): + "Check if the invoice is valid for Peppol" + for line in self.lines: + if line.type == 'line' and line.unit_price < 0: # BR-27 + raise InvoicePeppolError(gettext( + 'edocument_peppol.' + 'msg_invoice_line_unit_price_not_negative', + invoice=self.rec_name, + line=line.rec_name)) diff --git a/modules/edocument_peppol/exceptions.py b/modules/edocument_peppol/exceptions.py index 049e5c83a4..69cc23946c 100644 --- a/modules/edocument_peppol/exceptions.py +++ b/modules/edocument_peppol/exceptions.py @@ -1,12 +1,16 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserWarning +from trytond.exceptions import UserError, UserWarning class InvoicePeppolRequired(UserWarning): pass +class InvoicePeppolError(UserError): + pass + + class PeppolServiceError(Exception): pass diff --git a/modules/edocument_peppol/message.xml b/modules/edocument_peppol/message.xml index 9b6263bdb5..9e7a0abbea 100644 --- a/modules/edocument_peppol/message.xml +++ b/modules/edocument_peppol/message.xml @@ -9,5 +9,8 @@ this repository contains the full copyright notices and license terms. --> The party "%(party)s" is not set up to send the invoice "%(invoice)s" via the Peppol network. + + In order to post the invoice "%(invoice)s" on the Peppol network, the unit price of the line "%(line)s" must not be negative. +