def __init__(self, moneys: Optional[dict[str, Decimal]] = None) -> None:
self.moneys = moneys if moneys else {}
+ self._move_euro_up()
+
+ def _move_euro_up(self) -> None:
+ if '€' in self.moneys:
+ temp = {'€': self.moneys['€']}
+ for curr in [c for c in self.moneys if c != '€']:
+ temp[curr] = self.moneys[curr]
+ self.moneys = temp
def _inc_by(self, other: Self, add=True) -> Self:
for currency, amount in other.moneys.items():
if currency not in self.moneys:
self.moneys[currency] = Decimal(0)
self.moneys[currency] += amount if add else -amount
+ self._move_euro_up()
return self
def __iadd__(self, other: Self) -> Self:
if self.parent:
self.parent.children += [self]
+ @property
+ def full_name(self) -> str:
+ """Return full account path."""
+ if self.parent:
+ return f'{self.parent.full_name}:{self.basename}'
+ return self.basename
+
@property
def wealth(self) -> Wealth:
"""Total of .local_wealth with that of .children."""
redir_path = Path('/')
if self.pagename.startswith('edit_'):
id_ = int(self.path_toks[2])
- redir_path = Path('/').joinpath(self.pagename).joinpath(str(id_))
+ redir_path = redir_path.joinpath(self.pagename).joinpath(str(id_))
if self.pagename == 'file':
if 'reload' in self.postvars.as_dict:
self.server.load()
<style>
body { background-color: white; font-family: sans-serif; }
tr:nth-child(odd) { background-color: #dcdcdc; }
+tr:nth-child(even) { background-color: #ffffff; }
td { text-align: left; vertical-align: top; }
span.warning, table.warning tbody tr td, tr.warning td { background-color: #ff8888; }
{% block css %}{% endblock %}
{% extends '_base.tmpl' %}
{% macro account_with_children(account, indent) %}
-<tr>
-{% for curr, amt in account.wealth.moneys.items() %}
-{% if 1 == loop.index %}
-<td class="amt">{{amt}}</td>
-<td class="curr">{{curr|truncate(4,true,"…")}}</td>
-{% endif %}
-{% endfor %}
-<td>{% for _ in range(indent) %}[…]:{% endfor %}{{account.basename}}{% if account.children %}:–{% endif %}</td>
-</tr>
-{% for curr, amt in account.wealth.moneys.items() %}
-{% if 1 < loop.index %}
-<tr>
-<td class="amt">{{amt}}</td>
-<td class="curr">{{curr|truncate(4,true,"…")}}</td>
-<td>#</td>
-</tr>
-{% endif %}
-{% endfor %}
-{% for child in account.children %}
-{{ account_with_children(child, indent=indent+1) }}
-{% endfor %}
+ <tr>
+ {% for curr, amt in account.wealth.moneys.items() %}
+ {% if 1 == loop.index %}
+ <td class="amt">{{amt}}</td>
+ <td class="curr">{{curr|truncate(4,true,"…")}}</td>
+ {% endif %}
+ {% endfor %}
+ <td>{{account.full_name}}{% if account.children %}:…{% endif %}</td>
+ </tr>
+ {% if account.wealth.moneys|length > 1 %}
+ <tr>
+ <td colspan=2>
+ <details><summary>other currencies</summary>
+ <table>
+ {% for curr, amt in account.wealth.moneys.items() %}
+ {% if 1 < loop.index %}
+ <tr>
+ <td class="amt">{{amt}}</td>
+ <td class="curr">{{curr|truncate(4,true,"…")}}</td>
+ </tr>
+ {% endif %}
+ {% endfor %}
+ </table>
+ </details>
+ <td>
+ </tr>
+ {% endif %}
+ {% for child in account.children %}
+ {{ account_with_children(child, indent=indent+1) }}
+ {% endfor %}
{% endmacro %}