我列出了我的帐户交易的借方和贷方。现在我想在最后一列中运行总计,借方减去贷方加上先前到达的金额作为运行总计(如您所知)。谢谢你的支持。
我的观点:
def listaccounttrans(request):
alltrans = FinTransDetail.objects.all()
context = {'alltrans': alltrans}
return render(request, 'waccounts/list_account_trans.html', context)
我的html:
{{% extends 'wstore_base_generic.html' %}}
{% block content %}
<h3>Table</h3>
<div>
<table id="customers" >
<thead>
<tr>
<td>AcctCode</td>
<td>TransNo</td>
<td>TransDate</td>
<td>AcctDetail</td>
<td>Debit</td>
<td>Credit</td>
<td>Balance</td>
</tr>
</thead>
<tbody>
{% for acct in alltrans%}
<tr>
<td>{{ acct.fd_acct }}</td>
<td>{{ acct.fd_no}}</td>
<td>{{ acct.fd_no.fh_dt}}</td>
<td>{{ acct.fd_no.fh_detail }}</td>
<td>{{ acct.fd_debit }}</td>
<td>{{ acct.fd_credit }}</td>
<td>{{ acct.fd_no}}</td> # needs running total here#
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
我的模板现在显示:
AcctCode TransNo TransDate AcctDetail Debit Credit Balance
1101 94 May 18, 2021 Detail 11.00 0.00 94 (needs to be replaced with
1101 94 May 18, 2021 Detail 0.00 11.00 94 running balance)
[total balance]