some fields validation and model cleaning
This commit is contained in:
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.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6
-1
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user