#69 refactor(ReconciliationJar): remove old view.
This commit is contained in:
@@ -70,24 +70,6 @@ class ReconciliationJar(models.Model):
|
||||
cash_taken = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
cash_discrepancy = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
|
||||
def clean(self):
|
||||
if not self.is_valid:
|
||||
payments = Payment.get_reconciliation_jar_summary().payments
|
||||
else:
|
||||
payments = self.payment_set.all()
|
||||
|
||||
payments_amount = Decimal(sum([p.amount for p in payments]))
|
||||
reconciliation_ammount = Decimal(sum([
|
||||
self.cash_taken,
|
||||
self.cash_discrepancy,
|
||||
]))
|
||||
|
||||
equal_ammounts = reconciliation_ammount.compare(payments_amount) == Decimal('0')
|
||||
if not equal_ammounts:
|
||||
raise ValidationError(
|
||||
{"cash_taken": _("The taken ammount has discrepancy.")}
|
||||
)
|
||||
|
||||
def add_payments(self, payments):
|
||||
for payment in payments:
|
||||
self.payment_set.add(payment)
|
||||
|
||||
Reference in New Issue
Block a user