Tweak account transactions with commodities to remove redundancy, and show amount details on hover

This commit is contained in:
RunasSudo 2020-03-23 17:28:32 +11:00
parent c379a28fbd
commit 79305f8a8f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 16 additions and 16 deletions

View File

@ -189,8 +189,8 @@ def transactions_commodity():
account = l.get_account(account) account = l.get_account(account)
transactions = [t for t in l.transactions if t.date <= date and t.date >= pstart and any(p.account == account for p in t.postings)] transactions = [t for t in l.transactions if t.date <= date and t.date >= pstart and any(p.account == account for p in t.postings)]
opening_balance = accounting.trial_balance(l, pstart, pstart).get_balance(account) opening_balance = accounting.trial_balance(l, pstart, pstart).get_balance(account).clean()
closing_balance = accounting.trial_balance(l, date, pstart).get_balance(account) closing_balance = accounting.trial_balance(l, date, pstart).get_balance(account).clean()
def matching_posting(transaction, amount): def matching_posting(transaction, amount):
return next((p for p in transaction.postings if p.account == account and p.amount.currency == amount.currency), None) return next((p for p in transaction.postings if p.account == account and p.amount.currency == amount.currency), None)

View File

@ -31,7 +31,7 @@
<th>Description</th> <th>Description</th>
<th class="h1" style="width: 1em;"></th> <th class="h1" style="width: 1em;"></th>
<th class="h1" style="text-align: right; width: 5em;">Amount</th> <th class="h1" style="text-align: right; width: 5em;">Amount</th>
<th class="h1" style="width: 4em;"></th> {#<th class="h1" style="width: 4em;"></th>#}
<th class="h1" style="text-align: right; width: 5em;">Balance</th> <th class="h1" style="text-align: right; width: 5em;">Balance</th>
<th class="h1" style="width: 4em;"></th> <th class="h1" style="width: 4em;"></th>
<th class="h1" style="width: 1em;"></th> <th class="h1" style="width: 1em;"></th>
@ -43,11 +43,11 @@
<tr class="total"> <tr class="total">
<td>{% if loop.first %}<a href="{{ prevlink }}">{{ pstart.strftime('%Y-%m-%d') }}</a>{% endif %}</td> <td>{% if loop.first %}<a href="{{ prevlink }}">{{ pstart.strftime('%Y-%m-%d') }}</a>{% endif %}</td>
<td>{% if loop.first %}<a href="{{ prevlink }}">Opening Balance</a>{% endif %}</td> <td>{% if loop.first %}<a href="{{ prevlink }}">Opening Balance</a>{% endif %}</td>
<td style="text-align: right;"></td>
<td></td> <td></td>
{#<td></td>#}
<td></td> <td></td>
<td style="text-align: right;"><a href="{{ prevlink }}">{{ amount|abs|bc }}</a></td> <td style="text-align: right;"><a href="{{ prevlink }}"><span title="{{ amount.tostr(False) }}">{{ amount|abs|bc }}</span></a></td>
<td><a href="{{ prevlink }}">{% if amount.currency.price %}{{ '{' + amount.currency.price|bc + '}' }}{% endif %}</a></td> <td>{% if amount.currency.price %}<span title="{{ amount.tostr(False) }}">{{ '{' + amount.currency.price|bc + '}' }}</span>{% endif %}</td>
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td> <td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -64,13 +64,13 @@
<td>{% if loop.first %}{{ transaction.description }}{% endif %}</td> <td>{% if loop.first %}{{ transaction.description }}{% endif %}</td>
{% if posting %} {% if posting %}
<td>{% if posting.amount >= 0 %}Dr{% else %}Cr{% endif %}</td> <td>{% if posting.amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
<td style="text-align: right;">{{ posting.amount|abs|bc }}</td> <td style="text-align: right;"><span title="{{ posting.amount.tostr(False) }}">{{ posting.amount|abs|bc }}</span></td>
<td>{% if posting.amount.currency.price %}{{ '{' + posting.amount.currency.price|bc + '}' }}{% endif %}</td> {#<td>{% if posting.amount.currency.price %}{{ '{' + posting.amount.currency.price|bc + '}' }}{% endif %}</td>#}
{% else %} {% else %}
<td colspan="3"></td> <td colspan="2"></td>
{% endif %} {% endif %}
<td style="text-align: right;">{{ amount|abs|bc }}</td> <td style="text-align: right;"><span title="{{ amount.tostr(False) }}">{{ amount|abs|bc }}</span></td>
<td>{% if amount.currency.price %}{{ '{' + amount.currency.price|bc + '}' }}{% endif %}</td> <td>{% if amount.currency.price %}<span title="{{ amount.tostr(False) }}">{{ '{' + amount.currency.price|bc + '}' }}</span>{% endif %}</td>
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td> <td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
@ -81,11 +81,11 @@
<tr class="total explicit-rules" style="{% if loop.first %}border-top: 1pt solid black;{% endif %}{% if loop.last %}border-bottom: 1pt solid black;{% endif %}"> <tr class="total explicit-rules" style="{% if loop.first %}border-top: 1pt solid black;{% endif %}{% if loop.last %}border-bottom: 1pt solid black;{% endif %}">
<td>{% if loop.first %}{{ date.strftime('%Y-%m-%d') }}{% endif %}</td> <td>{% if loop.first %}{{ date.strftime('%Y-%m-%d') }}{% endif %}</td>
<td>{% if loop.first %}Closing Balance{% endif %}</td> <td>{% if loop.first %}Closing Balance{% endif %}</td>
<td style="text-align: right;"></td>
<td></td> <td></td>
{#<td></td>#}
<td></td> <td></td>
<td style="text-align: right;">{{ amount|abs|bc }}</td> <td style="text-align: right;"><span title="{{ amount.tostr(False) }}">{{ amount|abs|bc }}</span></td>
<td>{% if amount.currency.price %}{{ '{' + amount.currency.price|bc + '}' }}{% endif %}</td> <td>{% if amount.currency.price %}<span title="{{ amount.tostr(False) }}">{{ '{' + amount.currency.price|bc + '}' }}</span>{% endif %}</td>
<td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td> <td>{% if amount >= 0 %}Dr{% else %}Cr{% endif %}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -150,10 +150,10 @@ class Amount:
if self.currency.is_prefix: if self.currency.is_prefix:
amount_str = ('{}{:.2f}' if round else '{}{}').format(self.currency.name, self.amount) amount_str = ('{}{:.2f}' if round else '{}{}').format(self.currency.name, self.amount)
else: else:
amount_str = ('{:.2f} {}' if round else '{:.2f} {}').format(self.amount, self.currency.name) amount_str = ('{:.2f} {}' if round else '{} {}').format(self.amount, self.currency.name)
if self.currency.price: if self.currency.price:
return '{} {{{}}}'.format(amount_str, self.currency.price) return '{} {{{}}}'.format(amount_str, self.currency.price.tostr(round))
return amount_str return amount_str
def __repr__(self): def __repr__(self):