#69 feat(ReconciliationJar): Add total_cash_purchases field.
This commit is contained in:
@@ -69,12 +69,23 @@ class ReconciliationJar(models.Model):
|
||||
reconcilier = models.CharField(max_length=255, null=False, blank=False)
|
||||
cash_taken = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
cash_discrepancy = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
total_cash_purchases = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
|
||||
def clean(self):
|
||||
self._validate_taken_ammount()
|
||||
|
||||
def add_payments(self, payments):
|
||||
for payment in payments:
|
||||
self.payment_set.add(payment)
|
||||
self.is_valid = True
|
||||
|
||||
def _validate_taken_ammount(self):
|
||||
ammount_cash = self.cash_taken + self.cash_discrepancy
|
||||
if not self.total_cash_purchases == ammount_cash:
|
||||
raise ValidationError(
|
||||
{"cash_taken": _("The taken ammount has discrepancy.")}
|
||||
)
|
||||
|
||||
|
||||
class Sale(models.Model):
|
||||
customer = models.ForeignKey(Customer, on_delete=models.PROTECT)
|
||||
|
||||
Reference in New Issue
Block a user