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

index 53c9c72..4f4cef5 100644 (file)
@@ -124,13 +124,10 @@ class GeneralLedgerEntry(object):
                 if le.account.is_cash or (le.account.type.value == 2 and total < 0):
                     cash_total = 0
                 else:
-                    coresponding = 0
-                    for c in le.t.ledgerentry_set.filter(account__is_cash=True):
-                        coresponding = coresponding + c.amount
-                    if coresponding < total:
-                        cash_total = coresponding
-                    else:
-                        cash_total = total
+                    cash_total = total
+                    for c_le in le.t.ledgerentry_set.filter(is_credit=not le.is_credit):
+                        if c_le.account.is_cash=False and c_le.account.type.value == 2:
+                            cash_total = cash_total - c_le.amount
             else:
                 cash_total = 0
             try: