some fields validation and model cleaning

This commit is contained in:
2025-08-05 21:38:16 +03:00
parent 06a3b105d3
commit f16ea7c748
130 changed files with 148 additions and 69 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -1
View File
@@ -18,6 +18,11 @@ class Payment(models.Model):
paid_info = models.TextField(blank=True, null=True)
description = models.CharField(max_length=255, blank=True, null=True)
def clean(self):
if Payment.objects.filter(invoice_number=self.invoice_number).exclude(id=self.id).exists():
raise ValueError(f'Payment with invoice number {self.invoice_number} already exists.')
class PaymentItem(models.Model):
payment = models.ForeignKey(Payment, related_name='payment_items', on_delete=models.CASCADE)
container = models.ForeignKey(Container, related_name='payment_containers', on_delete=models.CASCADE)
@@ -47,4 +52,4 @@ class AdditionalFees(models.Model):
class Meta:
verbose_name = 'Additional Fees'
verbose_name_plural = 'Additional Fees'
verbose_name_plural = 'Additional Fees'