fix cash flow calc again 9
authorgniibe <gniibe@fsij.org>
Mon, 11 Jun 2012 13:39:43 +0000 (22:39 +0900)
committergniibe <gniibe@fsij.org>
Mon, 11 Jun 2012 13:39:43 +0000 (22:39 +0900)
accounting/models.py

index a0771bd..a2223f9 100644 (file)
@@ -120,13 +120,12 @@ class GeneralLedgerEntry(object):
                 total = le.amount
             else:
                 total = -le.amount
-            try:
-                le.t.ledgerentry_set.get(account__is_cash=True)
-                if le.account.is_cash or (le.account.type.value == 2 and total < 0 ):
+            if le.t.ledgerentry_set.count(account__is_cash=True) > 0:
+                if le.account.is_cash or (le.account.type.value == 2 and total < 0):
                     cash_total = 0
                 else:
                     cash_total = total
-            except:
+            else:
                 cash_total = 0
             try:
                 a = ac_dict[le.account.name]