Added the debit and credit pseudo properties to the JournalEntry data model, and retired the redundant ReportEntry model from the "accounting.report.reports.journal" module.

This commit is contained in:
2023-03-09 07:55:36 +08:00
parent 2f27ad5bef
commit 555ad388bc
3 changed files with 50 additions and 35 deletions

View File

@ -640,3 +640,19 @@ class JournalEntry(db.Model):
:return: The account code.
"""
return self.account.code
@property
def debit(self) -> Decimal | None:
"""Returns the debit amount.
:return: The debit amount, or None if this is not a debit entry.
"""
return self.amount if self.is_debit else None
@property
def credit(self) -> Decimal | None:
"""Returns the credit amount.
:return: The credit amount, or None if this is not a credit entry.
"""
return None if self.is_debit else self.amount