Member payment interface change.
authorgniibe <gniibe@fsij.org>
Wed, 26 May 2010 06:32:18 +0000 (15:32 +0900)
committergniibe <gniibe@fsij.org>
Wed, 26 May 2010 06:32:18 +0000 (15:32 +0900)
ChangeLog
README [new file with mode: 0644]
accounting/views.py
membership/models.py
membership/urls.py
membership/views.py
templates/accounting/tr_le.html [new file with mode: 0644]
templates/accounting/transaction_list.html
templates/membership/edit_member_payment.html [new file with mode: 0644]
templates/membership/member_payment.html

index bc0d399..263d688 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2010-05-26  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * templates/accounting/transaction_list.html: Added interface for
+       member payment.
+
+       * membership/views.py (add_member_payment_with_le)
+       (edit_member_payment, register_member_payment)
+       (manage_add_member_payment_with_le, manage_edit_member_payment)
+       (manage_register_member_payment): New.
+
+       * membership/urls.py: Added add_member_payment_with_le,
+         and edit_member_payment.
+
+       * membership/models.py (MemberPayment): Added new meaning
+       for fee_year==0 (Advanced payment).
+       * templates/membership/member_payment.html: Follow the change.
+
+       * accounting/views.py (transaction_list): Supply members.
+
+       * README: New file.
+       * templates/membership/edit_member_payment.html: New file.
+       * templates/accounting/tr_le.html: New file.
+
+2010-05-21  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * accounting/views.py (transaction_list): Sort by reverse
+       order of date.
+
 2010-05-19  NIIBE Yutaka  <gniibe@fsij.org>
 
        * templates/top_page.html: Updated for 2010.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..74990f3
--- /dev/null
+++ b/README
@@ -0,0 +1,34 @@
+INSTALL
+=======
+
+Modules needed:
+  * python-django
+  * python-django-doc
+  * python-markdown
+  * python-pysqlite2
+
+Then, create a file
+  $ cat >settings_private.py
+  SECRET_KEY = '01234567890123456789012345678901234567890123456789'
+  ^D
+
+Interface
+=========
+
+User view
+/meetings/[0-9]+/
+/membership/
+
+Secretariat View
+/meetings/registrations/
+/meetings/attendances/
+   * (Should implement) meeting end status goes 'close' -> no edit anymore
+   * (Should implement) delete attendance
+   * (Should implement) view of attendance by members (after meeting)
+
+Accounting
+==========
+
+/accounting/   *** index should be implemented
+/accounting/[0-9]+   *** annual index should be implemented
+ close (forbid to change) the transactions
index adb0d74..194cf2d 100644 (file)
@@ -3,6 +3,7 @@ from django.shortcuts import render_to_response, get_object_or_404
 from django.contrib.auth.decorators import login_required, user_passes_test
 from django.http import HttpResponse, HttpResponseRedirect
 from fsij.accounting.models import Transaction, Account, Business, LedgerEntry, FinancialYear, GeneralLedgerEntry
+from fsij.membership.models import Member, MemberPayment
 from fsij.settings import LOGIN_URL
 import datetime, time
 
@@ -74,12 +75,13 @@ def transaction_list(request,year=None):
         fy = FinancialYear(int(year))
         tr_list = Transaction.objects.filter(date__range=(fy.begin(),fy.end())).order_by('date')
     else:
-        tr_list = Transaction.objects.all().order_by('date')
+        tr_list = Transaction.objects.all().order_by('-date')
     return render_to_response('accounting/transaction_list.html',
                               {'year' : year,
                                'tr_list': tr_list,
                                'b_list': Business.objects.all(),
                                'a_list': Account.objects.all(),
+                               'members': Member.objects.all(),
                                'original_path': request.path,
                                })
 
index 5f5bb0c..11424ce 100644 (file)
@@ -54,14 +54,20 @@ class MemberAddress(models.Model):
 class MemberPayment(models.Model):
     member = models.ForeignKey(Member)
     date = models.DateField()
-    fee_year = models.IntegerField() # 9999 means Admission fee
+    #
+    # FEE_YEAR: Financial year to which this payment is connected
+    #           9999 means Admission-fee, 0 means Advance-payment
+    #
+    fee_year = models.IntegerField()
     # member type as of payment time
     member_type = models.CharField(max_length=1, choices=MEMBER_TYPE)
     # contribution as of payment time, valid if member_type == 'A'
     contribution = models.IntegerField() # Kuchi-Suu in Japanese
     le = models.ForeignKey(LedgerEntry, unique=True, blank=True, null=True)
     def __unicode__(self):
-        if self.fee_year == 9999:
+        if self.fee_year == 0:
+            payment_fee_str = u'前受金'
+        elif self.fee_year == 9999:
             payment_fee_str = u'入会金'
         else:
             payment_fee_str = "%04d" % self.fee_year
index a8a52af..fcc3e96 100644 (file)
@@ -26,7 +26,11 @@ urlpatterns = patterns('',
     (r'^(?P<member_id>\w+)/payment/$', 'fsij.membership.views.manage_member_payment'),
     (r'^(?P<member_id>\w+)/payment/add/$', 'fsij.membership.views.manage_add_member_payment'),
     (r'^(?P<member_id>\w+)/payment/delete/(?P<payment_id>\d+)/$', 'fsij.membership.views.manage_delete_member_payment'),
+###
+    (r'^add_member_payment_with_le/$', 'fsij.membership.views.manage_add_member_payment_with_le'),
+    (r'^edit_member_payment/(?P<member_payment_id>\d+)/$', 'fsij.membership.views.manage_edit_member_payment'),
+    (r'^edit_member_payment/(?P<member_payment_id>\d+)/register/$', 'fsij.membership.views.manage_register_member_payment'),
 #
-    (r'^(?P<member_id>\w+)/(?P<new>(new/)?)$', 'fsij.membership.views.manage_member'),
-    (r'^(?P<member_id>\w+)/register/$', 'fsij.membership.views.manage_register_member'),
+#    (r'^(?P<member_id>\w+)/(?P<new>(new/)?)$', 'fsij.membership.views.manage_member'),
+#    (r'^(?P<member_id>\w+)/register/$', 'fsij.membership.views.manage_register_member'),
 )
index 8278db0..76f2cd4 100644 (file)
@@ -5,6 +5,7 @@ from django.http import HttpResponseRedirect
 from django.core.urlresolvers import reverse
 from fsij.settings import LOGIN_URL, FY_START_MONTH
 import datetime, time, re
+from fsij.accounting.models import LedgerEntry
 
 def member_index(request, member):
     return render_to_response('membership/member_index.html',
@@ -16,7 +17,7 @@ def member_email(request, member, manage=False):
     try:
         email = request.session['member_email_data']
         del request.session['member_email_data']
-        errors = addr['errors']
+        errors = email['errors']
     except (KeyError):
         email = member.email
     try: referrer = request.META['HTTP_REFERER']
@@ -168,6 +169,89 @@ def delete_member_payment(request, member, payment_id):
     p.delete()
     return HttpResponseRedirect(reverse('fsij.membership.views.manage_member_payment', args=(member.member_id,)))
 
+def add_member_payment_with_le(request):
+    le_id = request.POST['le_id']
+    member_id = request.POST['member_id']
+    le = get_object_or_404(LedgerEntry, pk=le_id)
+    member = get_object_or_404(Member, member_id=member_id)
+    date = le.t.date
+    if member.member_type != 'A':
+        contribution = 1
+    else:
+        contribution = member.corporatemember.contribution
+    p = MemberPayment(member = member,
+                      date = date,
+                      member_type = member.member_type,
+                      fee_year = 0,
+                      contribution = contribution,
+                      le = le)
+    p.save()
+    return HttpResponseRedirect(reverse('fsij.membership.views.manage_edit_member_payment', args=(p.id,)))
+
+def edit_member_payment(request, member_payment):
+    try: referrer = request.META['HTTP_REFERER']
+    except: referrer = None
+    errors = None
+    try:
+        member_payment_data = request.session['member_payment_data']
+        del request.session['member_payment_data']
+        errors = member_payment_data['errors']
+    except (KeyError):
+        member_payment_data = None
+    #
+    le = member_payment.le
+    if le:
+        date = le.t.date
+    else:
+        date = datetime.date.today()
+    member = member_payment.member
+    if member:
+        start_year = member.date_joined.year
+        if member.date_joined.month < FY_START_MONTH:
+            start_year = start_year - 1
+        end_year = date.year
+        if date.month < FY_START_MONTH:
+            end_year = end_year - 1
+        fee_list = range(start_year, end_year + 1)
+        if member.member_type != 'A':
+            fee_list.append(0)    # Advance payment
+            fee_list.append(9999) # Admission fee
+        fee_list_in_payments = map(lambda (p): p.fee_year, member.memberpayment_set.all())
+        fee_list = filter(lambda (f): not f in fee_list_in_payments, fee_list)
+    else:
+        fee_list = None
+    return render_to_response('membership/edit_member_payment.html',
+                              {'date': date,
+                               'errors': errors,
+                               'member': member,
+                               'members': Member.objects.all(),
+                               'fee_list': fee_list,
+                               'member_type_list': MEMBER_TYPE,
+                               'original_path': referrer,
+                               })
+
+def register_member_payment(request, member_payment):
+    member_id = request.POST['member_id']
+    #
+    errors = []
+    if not member_id:
+        errors.append('member_id')
+    if errors:
+        request.session['member_payment_data'] = {
+            'member_id': member_id,
+            'errors': errors,}
+        return HttpResponseRedirect(request.POST['original_path'])
+    member = get_object_or_404(Member, member_id=member_id)
+    member_type = request.POST['member_type']
+    contribution = request.POST['contribution']
+    fee_year = request.POST['fee_year']
+    member_payment.member = member
+    member_payment.member_type = member_type
+    member_payment.contribution = contribution
+    member_payment.fee_year = fee_year
+    member_payment.save()
+    return HttpResponseRedirect(request.POST['original_path'])
+
 @login_required
 def index(request):
     member = request.user.get_profile()
@@ -295,6 +379,20 @@ def manage_delete_member_payment(request, member_id, payment_id):
     member = get_object_or_404(Member, member_id=member_id)
     return delete_member_payment(request, member, payment_id)
 
+@user_passes_test(lambda u: u.has_perm('membership.can_manage'), LOGIN_URL)
+def manage_add_member_payment_with_le(request):
+    return add_member_payment_with_le(request)
+
+@user_passes_test(lambda u: u.has_perm('membership.can_manage'), LOGIN_URL)
+def manage_edit_member_payment(request, member_payment_id):
+    member_payment = get_object_or_404(MemberPayment, pk=member_payment_id)
+    return edit_member_payment(request, member_payment)
+
+@user_passes_test(lambda u: u.has_perm('membership.can_manage'), LOGIN_URL)
+def manage_register_member_payment(request, member_payment_id):
+    member_payment = get_object_or_404(MemberPayment, pk=member_payment_id)
+    return register_member_payment(request, member_payment)
+
 @user_passes_test(lambda u: u.has_perm('membership.can_manage'), LOGIN_URL)
 def member_list_top(request):
     return render_to_response('membership/member_list_top.html',
diff --git a/templates/accounting/tr_le.html b/templates/accounting/tr_le.html
new file mode 100644 (file)
index 0000000..d342daf
--- /dev/null
@@ -0,0 +1,11 @@
+{% if not t.get_credit.memberpayment_set.get %}
+<form action="../../membership/add_member_payment_with_le/" method="POST">
+  <select name="member_id">
+  {% for person in members %}
+    <option value="{{ person.member_id }}">{{ person.member_id }} {{ person.name }}</option>
+  {% endfor %}
+  </select>
+<input type="submit" value="編集" />
+<input type="hidden" value="{{ t.get_credit.id }}" name="le_id" />
+</form>
+{% endif %}
index 8b7e1b7..e1b04a0 100644 (file)
 
 {% for t in tr_list %}
   {% for i in t.num_line %}
-  {% if not year %}
-<form action="{{ t.id }}/delete/" method="POST">
-  {% endif %}
 <tr bgcolor={% cycle lightcyan,white as rowcolors %}>
   <td>{% ifequal 0 forloop.counter0 %}<a href="{% if year %}../{% endif %}../transaction/{{ t.id }}/">{{ t.date }}</a>{% endifequal %}</td>
   <td>{% ifequal 0 forloop.counter0 %}{{ t.business.name }}{% endifequal %}</a></td>
   <td align=right>{{ t.get_debit.amount }}</td>
   <td align=left>{{ t.get_credit.account.name }}</td>
   <td align=right>{{ t.get_credit.amount }}</td>
-  <td align=left>{% ifequal 0 forloop.counter0 %}{{ t.memo }}{% endifequal %}</td>
+  <td align=left>
+   {% ifequal t.get_credit.account.name '会費収入' %}
+     {% include "accounting/tr_le.html" %}
+   {% else %}
+   {% ifequal t.get_debit.account.name '前受金' %}
+     {% include "accounting/tr_le.html" %}
+   {% else %}
+     {% ifequal 0 forloop.counter0 %}{{ t.memo }}{% endifequal %}
+   {% endifequal %}
+   {% endifequal %}
+  </td>
   <td align=left>{% ifequal 0 forloop.counter0 %}{{ t.memo_detail }}{% endifequal %}</td>
-  <td>{% if not year %}{% ifequal 0 forloop.revcounter0 %}<input type="submit" name="delete" value="{% trans 'Delete' %}"/>{% endifequal %}{% endif %}</td>
+  <td>{% if not year %}{% ifequal 0 forloop.revcounter0 %}
+    <form action="{{ t.id }}/delete/" method="POST">
+    <input type="hidden" value="{{ original_path }}" name="original_path" />
+    <input type="submit" name="delete" value="{% trans 'Delete' %}"/>
+    </form>{% endifequal %}{% endif %}
+  </td>
 </tr>
-  {% if not year %}
-<input type="hidden" value="{{ original_path }}" name="original_path" />
-</form>
-  {% endif %}
 <!--
 {{ t.next }}
 {% cycle rowcolors %}
diff --git a/templates/membership/edit_member_payment.html b/templates/membership/edit_member_payment.html
new file mode 100644 (file)
index 0000000..e7112d2
--- /dev/null
@@ -0,0 +1,48 @@
+{% load i18n %}
+
+<h1>会費入金: {{ date }}</h1>
+
+{% if errors %}
+{{ errors }}
+{% endif %}
+
+<form action="register/" method="POST">
+<ul>
+<li>会員番号
+  <select name="member_id">
+  {% for person in members %}
+    <option value="{{ person.member_id }}" {% ifequal person.member_id member.member_id %}selected{% endifequal %}>
+{{ person.member_id }}
+{{ person.user.last_name }} {{ person.user.first_name }}</option>
+  {% endfor %}
+  </select>
+</li>
+<li>支払い年度
+<select name="fee_year">
+{% for fee_year in fee_list %}
+<option value="{{ fee_year }}">
+{% ifequal fee_year 0 %}前受金{% else %}
+{% ifequal fee_year 9999 %}入会金{% else %}{{ fee_year }}年度{% endifequal %}
+{% endifequal %}
+</option>
+{% endfor %}
+</select>
+
+{% ifequal member.member_type 'A' %}
+<li> 口数
+<input type="text" name="contribution" value="{{ member.corporatemember.contribution }}" />
+<input type="hidden" name="member_type" value="{{member.member_type}}" />
+</li>
+{% else %}
+<select name="member_type">
+<li>(支払い時)会員種別
+{% for mt in member_type_list %}
+<option value="{{mt.0}}" {% ifequal mt member.member_type %}selected{% endifequal %}>{{mt.1}}</option>
+{% endfor %}
+</select>
+<input type="hidden" name="contribution" value="1" />
+{% endifequal %}
+
+<input type="submit" value="登録" />
+<input type="hidden" value="{{ original_path }}" name="original_path" />
+</form>
index 8b0f281..38efcfb 100644 (file)
@@ -21,26 +21,38 @@ parent.list.location.reload()
 <tr><th>日付</th><th>内容</th><th>編集</th></tr>
 {% for p in payments %}
 <tr bgcolor={% cycle lightcyan,white %}>
-<form action="delete/{{ p.id }}/" method="post">
+<form action="delete/{{ p.id }}/" method="POST">
 <td>{{ p.date }}</td>
-<td>{% ifequal p.fee_year 9999 %}入会金{% else %}{{ p.fee_year }}年度{% endifequal%}
-{% ifnotequal p.member_type member.member_type %}
-[ {{ p.get_member_type_display }} ]
-{% endifnotequal %}
-{% ifequal p.member_type 'A' %}
-( {{ p.contribution }} )
-{% endifequal %}
+<td>
+  {% ifequal p.fee_year 0 %}
+  前受金
+  {% else %}
+  {% ifequal p.fee_year 9999 %}
+  入会金
+  {% else %}
+  {{ p.fee_year }}年度
+  {% endifequal%}
+  {% endifequal%}
+  {% ifequal p.fee_year 9999 %}
+</td>
+<td>
+  {% ifnotequal p.member_type member.member_type %}
+  [ {{ p.get_member_type_display }} ]
+  {% endifnotequal %}
+  {% ifequal p.member_type 'A' %}
+  ( {{ p.contribution }} )
+  {% endifequal %}
 </td>
 <td><input type="submit" name="delete" value="{% trans 'Delete' %}"/></td>
 </tr>
 </form>
 {% endfor %}
-<form action="add/" method="post">
+<form action="add/" method="POST">
 <tr>
 <td><input type="text" name="date" value=""/></td>
 <td>
 <select name="fee_year">
-{% for fee_year in fee_list%}
+{% for fee_year in fee_list %}
 <option value="{{ fee_year }}">{% ifequal fee_year 9999 %}入会金{% else %}{{ fee_year }}年度{% endifequal %}</option>
 {% endfor %}
 </select>