Better bs_pl_cf
authorgniibe <gniibe@fsij.org>
Thu, 27 May 2010 13:04:09 +0000 (22:04 +0900)
committergniibe <gniibe@fsij.org>
Thu, 27 May 2010 13:04:09 +0000 (22:04 +0900)
ChangeLog
accounting/models.py
accounting/views.py
templates/accounting/account_list.html
templates/accounting/bs_pl_cf.html

index a808a2e..a514173 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-05-27  NIIBE Yutaka  <gniibe@fsij.org>
 
+       * templates/accounting/bs_pl_cf.html: C/F drawing with
+       abs_cash_total and cash_total_less_than_zero.
+
+       * accounting/models.py (GeneralLedgerEntry.__init__): New
+       attributes, cash_total_less_than_zero and abs_cash_total.
+       (GeneralLedgerEntry.get_cash_total): Add even if e['cash_total']
+       is less than zero.
+
+       * templates/accounting/account_list.html: Remove excluding Kurikoshi.
+
        * accounting/models.py (GeneralLedgerEntry.__init__): Added u-prefix
        for utf-8 string Kurikoshi.
 
index ac4d132..776e229 100644 (file)
@@ -131,13 +131,24 @@ class GeneralLedgerEntry(object):
             try:
                 a = ac_dict[le.account.name]
                 a['cash_total'] = a['cash_total'] + cash_total
+                a['cash_total_less_than_zero'] = (a['cash_total'] < 0)
+                if a['cash_total'] < 0:
+                    a['abs_cash_total'] = -a['cash_total']
+                else:
+                    a['abs_cash_total'] = a['cash_total']
                 a['ledgerentries'].append((le.is_credit,le.amount,le.t))
                 a['total'] = a['total'] + total
             except:
+                if cash_total < 0:
+                    abs_cash_total = -cash_total
+                else:
+                    abs_cash_total = cash_total
                 ac_dict[le.account.name] = {'name': le.account.name,
                                'type': le.account.type,
                                'is_cash': le.account.is_cash,
                                'cash_total': cash_total, 
+                               'cash_total_less_than_zero': (cash_total < 0), 
+                               'abs_cash_total': abs_cash_total,
                                'ledgerentries':
                                [(le.is_credit,le.amount,le.t)],
                                'total': total, }
@@ -159,11 +170,10 @@ class GeneralLedgerEntry(object):
     def get_cash_total(self):
         cash = 0
         for e in self.gles:
-            if e['cash_total'] > 0:
-                if e['type'].is_credit():
-                    cash += e['cash_total']
-                else:
-                    cash -= e['cash_total']
+            if e['type'].is_credit():
+                cash += e['cash_total']
+            else:
+                cash -= e['cash_total']
         return cash
 
     def get_initial_value(self,account):
index 3f3529c..ae3dc2e 100644 (file)
@@ -106,7 +106,7 @@ def account_list(request,year):
 @user_passes_test(lambda u: u.has_perm('accounting.can_view_sheets'), LOGIN_URL)
 def bs_pl_cf(request,year):
     gles = GeneralLedgerEntry(int(year))
-    cash_accounts = Account.objects.filter(is_cash=True)
+    cash_accounts = Account.objects.filter(is_cash=True).order_by('-name')
     cash_initial_list = map(lambda x: gles.get_initial_value(x), cash_accounts)
     return render_to_response('accounting/bs_pl_cf.html',
                               {'year' : year,
index 4307450..f8578cb 100644 (file)
@@ -1,7 +1,6 @@
 <h1>総勘定元帳 {{ year }}年度 </h1>
 
 {% for a in ac_list %}
-{% ifnotequal a.name "繰越" %}
 <!--
 -->
 <h2>{{ a.name }}</h2>
@@ -18,5 +17,4 @@
 <td align=right width=100>{% if a.type.is_credit %}{{ a.total }}{% endif %}</td>
 </tr>
 </table>
-{% endifnotequal %}
 {% endfor %}
index 5d94d3e..5485be9 100644 (file)
 <table frame=void cellspacing=4>
 {% for a in ac_list %}
 {% ifnotequal a.cash_total 0 %}
-{% if not a.type.is_credit %}
-<tr><td aligh=left width=80>{{a.name}}</td>
-<td align=right width=80>{{ a.cash_total }}</td></tr>
+{% if a.type.is_credit %}
+  {% if a.cash_total_less_than_zero %}
+  <tr><td aligh=left width=80>{{a.name}}{% ifequal a.type.value 2 %}返済{% endifequal %}支出</td>
+  <td align=right width=80>{{ a.abs_cash_total }}</td></tr>
+  {% endif %}
+{% else %}
+  {% if not a.cash_total_less_than_zero %}
+  <tr><td aligh=left width=80>{{a.name}}</td>
+  <td align=right width=80>{{ a.cash_total }}</td></tr>
+  {% endif %}
 {% endif %}
 {% endifnotequal %}
 {% endfor %}
 {% for a in ac_list %}
 {% ifnotequal a.cash_total 0 %}
 {% if a.type.is_credit %}
-<tr><td aligh=left width=80>{{a.name}}</td>
-<td align=right width=80>{{ a.cash_total }}</td></tr>
+  {% if not a.cash_total_less_than_zero %}
+  <tr><td aligh=left width=80>{{a.name}}</td>
+  <td align=right width=80>{{ a.cash_total }}</td></tr>
+  {% endif %}
+{% else %}
+  {% if a.cash_total_less_than_zero %}
+  <tr><td aligh=left width=80>{{a.name}}収入</td>
+  <td align=right width=80>{{ a.abs_cash_total }}</td></tr>
+  {% endif %}
 {% endif %}
 {% endifnotequal %}
 {% endfor %}
 </table>
 </td>
 </tr>
-</table>
\ No newline at end of file
+</table>