From f3e2280041f9311efcfe5d7b55e67ac2761e7ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 2 Aug 2020 17:57:16 +0800 Subject: [PATCH] Revised the debit_amount and credit_amount pseudo property in the Record data model in the accounting application. --- accounting/models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/accounting/models.py b/accounting/models.py index 24374e9..57d43e5 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -296,10 +296,10 @@ class Record(DirtyFieldsMixin, models.Model): @property def debit_amount(self): - """The debit amount of this accounting record""" - if self._debit_amount is not None: - return self._debit_amount - return self.amount if not self.is_credit else None + """The debit amount of this accounting record.""" + if self._debit_amount is None: + self._debit_amount = self.amount if not self.is_credit else None + return self._debit_amount @debit_amount.setter def debit_amount(self, value): @@ -307,10 +307,10 @@ class Record(DirtyFieldsMixin, models.Model): @property def credit_amount(self): - """The credit amount of this accounting record""" - if self._credit_amount is not None: - return self._credit_amount - return self.amount if self.is_credit else None + """The credit amount of this accounting record.""" + if self._credit_amount is None: + self._credit_amount = self.amount if self.is_credit else None + return self._credit_amount @credit_amount.setter def credit_amount(self, value):