fix cash flow calc again 15
authorgniibe <gniibe@fsij.org>
Mon, 11 Jun 2012 14:28:39 +0000 (23:28 +0900)
committergniibe <gniibe@fsij.org>
Mon, 11 Jun 2012 14:28:39 +0000 (23:28 +0900)
accounting/models.py

index 44962c1..e56dcbc 100644 (file)
@@ -121,13 +121,15 @@ class GeneralLedgerEntry(object):
             else:
                 total = -le.amount
             if le.t.ledgerentry_set.filter(account__is_cash=True).count() > 0:
-                if le.account.is_cash or (le.account.type.value == 2 and total < 0):
+                if le.account.is_cash:
                     cash_total = 0
                 else:
                     cash_total = total
                     for c_le in le.t.ledgerentry_set.filter(is_credit=not le.is_credit):
                         if not c_le.account.is_cash and c_le.account.type.value == 2:
                             cash_total = cash_total - c_le.amount
+                    if cash_total < 0:
+                        cash_total = 0
             else:
                 cash_total = 0
             try: