From 10170d613dab74e62646b6b066e505a80313cc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 22 Mar 2023 19:54:27 +0800 Subject: [PATCH] Fixed the debit and credit methods of the Account data model, removing the payable accounts that need offset from the debit accounts, and the receivable accounts that need offset from the credit accounts. They should not be selectable. --- src/accounting/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index a29ad31..459f3b9 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -275,7 +275,8 @@ class Account(db.Model): :return: The debit accounts. """ return cls.query.filter(sa.or_(cls.base_code.startswith("1"), - cls.base_code.startswith("2"), + sa.and_(cls.base_code.startswith("2"), + sa.not_(cls.is_need_offset)), cls.base_code.startswith("3"), cls.base_code.startswith("5"), cls.base_code.startswith("6"), @@ -295,7 +296,8 @@ class Account(db.Model): :return: The debit accounts. """ - return cls.query.filter(sa.or_(cls.base_code.startswith("1"), + return cls.query.filter(sa.or_(sa.and_(cls.base_code.startswith("1"), + sa.not_(cls.is_need_offset)), cls.base_code.startswith("2"), cls.base_code.startswith("3"), cls.base_code.startswith("4"),