On transaction detail by commodity page, show total by commodity
This commit is contained in:
parent
f470182e49
commit
b729b53ceb
@ -100,6 +100,18 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for amount in closing_balance.strip_prices().amounts %}
|
||||||
|
<tr class="total explicit-rules{% if loop.first %} trn-first{% endif %}{% if loop.last %} trn-last{% endif %}" style="{% if loop.first %}border-top: 1pt solid black;{% endif %}{% if loop.last %}border-bottom: 1pt solid black;{% endif %}">
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
{{ amount|abs|bt(True) }}
|
||||||
|
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<tr class="total trn-first trn-last">
|
<tr class="total trn-first trn-last">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
@ -271,10 +271,14 @@ class Balance:
|
|||||||
def __init__(self, amounts=None):
|
def __init__(self, amounts=None):
|
||||||
self.amounts = amounts or []
|
self.amounts = amounts or []
|
||||||
|
|
||||||
def tidy(self):
|
def strip_prices(self):
|
||||||
new_amounts = []
|
new_amounts = []
|
||||||
for amount in self.amounts:
|
for amount in self.amounts:
|
||||||
new_amount = next((a for a in new_amounts if a.commodity == amount.commodity), None)
|
new_amount = next((a for a in new_amounts if a.commodity.name == amount.commodity.name), None)
|
||||||
|
if new_amount is None:
|
||||||
|
new_amounts.append(Amount(amount.amount, amount.commodity.strip_price()))
|
||||||
|
else:
|
||||||
|
new_amount.amount += amount.amount
|
||||||
return Balance(new_amounts)
|
return Balance(new_amounts)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
Reference in New Issue
Block a user