Invoices: Change expected behaviour for switches in numbering scheme

This commit is contained in:
Raphael Michel
2021-10-29 12:09:09 +02:00
parent c209d195bf
commit abeddd360e
3 changed files with 14 additions and 8 deletions

View File

@@ -36,7 +36,7 @@ from django.db import transaction
dirty_transactions = threading.local()
logger = logging.getLogger(__name__)
fail_loudly = os.getenv('PRETIX_DIRTY_TRANSACTIONS_QUIET', 'false') not in ('true', 'True', 'on', '1')
fail_loudly = os.getenv('PRETIX_DIRTY_TRANSACTIONS_QUIET', 'false' if settings.DEBUG else 'true') not in ('true', 'True', 'on', '1')
class DirtyTransactionsForOrderException(Exception):

View File

@@ -237,7 +237,7 @@ class Invoice(models.Model):
def _get_invoice_number_from_order(self):
return '{order}-{count}'.format(
order=self.order.code,
count=Invoice.objects.filter(event=self.event, order=self.order).count() + 1,
count=Invoice.objects.filter(event=self.event, prefix=self.prefix, invoice_no__startswith=f"{self.order.code}-", order=self.order).count() + 1,
)
def save(self, *args, **kwargs):