print(f'{msg_prefix} FAILED – {abort_msg}')
sys_exit(1)
- jinja = JinjaEnv(loader=JinjaFSLoader(PATH_TEMPLATES), autoescape=True)
- tmpl = jinja.get_template(f'{PAGENAME_LEDGER_STRUCTURED}.tmpl')
+ tmpl = JinjaEnv(loader=JinjaFSLoader(PATH_TEMPLATES),
+ autoescape=True,
+ trim_blocks=True,
+ ).get_template(f'{PAGENAME_LEDGER_STRUCTURED}.tmpl')
for path in [p for p in _PATH_TESTS.iterdir()
if p.parts[-1].endswith(_EXT_DAT)]:
with Path(str(path)[:-len(_EXT_DAT)] + _EXT_HTML
<head>
<meta charset="UTF-8">
<script>
-{% block script %}{% endblock %}
+{% block script %}
+{% endblock %}
</script>
<style>
html {
div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical {
{{macros.css_bg_red()}}
}
-{% block css %}{% endblock %}
+{% block css %}
+{% endblock %}
</style>
</head>
<body>
-
<div id="header">
-<form action="{{path}}" method="POST">
-<span class="disable_on_change">
-ledger <a href="/ledger_structured">structured</a>
-/ <a href="/ledger_raw">raw</a>
-· <a href="/balance">balance</a>
-·
+ <form action="{{path}}" method="POST">
+ <span class="disable_on_change">
+ ledger <a href="/ledger_structured">structured</a>
+ / <a href="/ledger_raw">raw</a>
+ · <a href="/balance">balance</a>
{% if unsaved_changes %}
- <span class="critical">unsaved changes:
+ <span class="critical">
+ · unsaved changes:
+ <input type="submit"name="file_load" value="reload" />
+ · <input type="submit" name="file_save" value="save">
+
+ </span>
+{% else %}
+ · <input type="submit"name="file_load" value="reload" />
{% endif %}
-<input type="submit"name="file_load" value="reload" />
-{% if unsaved_changes %}
- · <input type="submit" name="file_save" value="save">
- </span>
-{% endif %}
-</span>
-</form>
+ </span>
+ </form>
</div>
-
-{% block content %}{% endblock %}
+{% block content %}
+{% endblock %}
</body>
</html>
{% endmacro %}
-
{% macro css_tabular_money() %}
td.amount {
text-align: right;
}
td.amount, td.currency {
- {{ css_noninput_monospace() }}
-}
-{% endmacro %}
+{{ css_noninput_monospace()
+}}}{% endmacro %}
+{# endmacro #}
}
td.balance.currency {
width: 3em;
-}
-{% endmacro %}
+}{%
+endmacro %}
+{# endmacro #}
}
td.block_column.critical {
{{css_bg_red()}}
-}
-{% endmacro %}
+}{% endmacro %}
+{# endmacro #}
{% macro ledger_block_columns(mode, block) %}
-<tr></tr><!-- just to keep the background-color alternation in proper order -->
-<tr id="block_{{block.id_}}">
-<td class="block_column {% if block.date_error %}critical{% endif %}" rowspan={{block.lines|length + 1}}>
-<input type="submit" name="ledger_moveup_{{block.id_}}" value="^" {% if not block.can_move(1) %}disabled{% endif %}/><br />
-<input type="submit" name="ledger_movedown_{{block.id_}}" value="v" {% if not block.can_move(0) %}disabled{% endif %}/><br />
-<input type="submit" name="ledger_copy_{{block.id_}}" value="C" />
-</td>
-<td class="block_column {% if block.booking and block.booking.sink_error %}critical{% endif %}" rowspan={{block.lines|length + 1}}>
-[<a href="#block_{{block.id_}}">#</a>]<br />
-[<a href="/balance?up_incl={{block.id_}}">b</a>]<br />
-[<a href="/edit_{{mode}}/{{block.id_}}">e</a>]
-</td>
-</tr >
-{% endmacro %}
-
+ <tr></tr><!-- just to keep the background-color alternation in proper order -->
+ <tr id="block_{{block.id_}}">
+ <td class="block_column {% if block.date_error %}critical{% endif %}" rowspan={{block.lines|length + 1}}>
+ <input type="submit" name="ledger_moveup_{{block.id_}}" value="^" {% if not block.can_move(1) %}disabled{% endif %}/><br />
+ <input type="submit" name="ledger_movedown_{{block.id_}}" value="v" {% if not block.can_move(0) %}disabled{% endif %}/><br />
+ <input type="submit" name="ledger_copy_{{block.id_}}" value="C" />
+ </td>
+ <td class="block_column {% if block.booking and block.booking.sink_error %}critical{% endif %}" rowspan={{block.lines|length + 1}}>
+ [<a href="#block_{{block.id_}}">#</a>]<br />
+ [<a href="/balance?up_incl={{block.id_}}">b</a>]<br />
+ [<a href="/edit_{{mode}}/{{block.id_}}">e</a>]
+ </td>
+ </tr >{% endmacro %}
+{# endmacro #}
{# =====================[ for edit pages ]======================= #}
{% block css %}
{{macros.css_ledger()}}
{{macros.css_tabular_money()}}
-td.amount {
- text-align: right;
-}
-td.amount, td.currency {
- vertical-align: bottom;
-}
{% endblock %}
{% block content %}
<form action="/ledger_structured" method="POST">
-{{macros.ledger_empty_lines_fix(has_redundant_empty_lines)}}
-<table class="alternating">
+{{ macros.ledger_empty_lines_fix(has_redundant_empty_lines)
+}}<table class="alternating">
{% for block in blocks %}
- {{macros.ledger_block_columns('structured', block)}}
- {% if block.booking %}
- <tr>
+{##}{{ macros.ledger_block_columns('structured', block) }}
+{##}{% if block.booking %}
+ <tr>
<td colspan=3 {% if block.booking.intro_line.errors %}class="critical"{% endif %}>{{block.booking.date}} {{block.booking.target}}</td>
<td>{{block.booking.intro_line.comment}}</td>
- </tr>
- {% for line in block.booking.transfer_lines %}
- <tr>
- <td class="amount {% if line.errors %}critical{% endif %}">{{line.amount_short}}</td>
- <td class="currency {% if line.errors %}critical{% endif %}">{{ macros.currency_short(line.currency) }}</td>
- <td {% if line.errors %}class="critical"{% endif %}>{{line.account}}</td>
- <td>{{line.comment}}</td>
- </tr>
- {% endfor %}
- {% endif %}
- {% for line in block.gap.lines %}
- <tr>
+ </tr>
+{######}{% for line in block.booking.transfer_lines %}
+ <tr>
+ <td class="amount {% if line.errors %}critical{% endif %}">{{line.amount_short}}</td>
+ <td class="currency {% if line.errors %}critical{% endif %}">{{ macros.currency_short(line.currency) }}</td>
+ <td {% if line.errors %}class="critical"{% endif %}>{{line.account}}</td>
+ <td>{{line.comment}}</td>
+ </tr>
+{######}{% endfor %}
+{##}{% endif %}
+{##}{% for line in block.gap.lines %}
+ <tr>
<td colspan=4>{{ line.raw }} </td>
- </tr>
- {% endfor %}
+ </tr>
+{##}{% endfor %}
{% endfor %}
</table>
<input type="submit" name="add_booking" value="add booking" />
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<script>
+</script>
+<style>
+html {
+ scroll-padding-top: 2em;
+}
+body {
+ background: #ffffff;
+ font-family: sans-serif;
+ text-align: left;
+ margin: 0;
+ padding: 0;
+}
+#header {
+ background: #ffffff;
+ position: sticky;
+ top: 0;
+ padding-left: 0.5em;
+ padding-bottom: 0.25em;
+ border-bottom: 1px solid black;
+}
+table.alternating > tbody > tr:nth-child(odd) {
+ background-color: #dcdcdc;
+}
+table.alternating > tbody > tr:nth-child(even) {
+ background: #ffffff;;
+}
+td {
+ vertical-align: top;
+}
+div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical {
+ background: #ff6666;
+}
+td.block_column {
+ background: #ffffff;
+}
+td.block_column.critical {
+ background: #ff6666;
+}
+td.amount {
+ text-align: right;
+}
+td.amount, td.currency {
+ font-family: monospace;
+ font-size: 1.25em;
+}
+</style>
+</head>
+<body>
+<div id="header">
+ <form action="" method="POST">
+ <span class="disable_on_change">
+ ledger <a href="/ledger_structured">structured</a>
+ / <a href="/ledger_raw">raw</a>
+ · <a href="/balance">balance</a>
+ · <input type="submit"name="file_load" value="reload" />
+ </span>
+ </form>
+</div>
+<form action="/ledger_structured" method="POST">
+<table class="alternating">
+ <tr></tr><!-- just to keep the background-color alternation in proper order -->
+ <tr id="block_0">
+ <td class="block_column " rowspan=2>
+ <input type="submit" name="ledger_moveup_0" value="^" disabled/><br />
+ <input type="submit" name="ledger_movedown_0" value="v" disabled/><br />
+ <input type="submit" name="ledger_copy_0" value="C" />
+ </td>
+ <td class="block_column " rowspan=2>
+ [<a href="#block_0">#</a>]<br />
+ [<a href="/balance?up_incl=0">b</a>]<br />
+ [<a href="/edit_structured/0">e</a>]
+ </td>
+ </tr >
+ <tr>
+ <td colspan=4> </td>
+ </tr>
+</table>
+<input type="submit" name="add_booking" value="add booking" />
+</form>
+</body>
+</html>
--- /dev/null
+2001-01-01 test
+ foo 10 €
+ bar -10 €
+
+2001-01-02 test
+ bar 20 €
+ baz -20 €
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<script>
+</script>
+<style>
+html {
+ scroll-padding-top: 2em;
+}
+body {
+ background: #ffffff;
+ font-family: sans-serif;
+ text-align: left;
+ margin: 0;
+ padding: 0;
+}
+#header {
+ background: #ffffff;
+ position: sticky;
+ top: 0;
+ padding-left: 0.5em;
+ padding-bottom: 0.25em;
+ border-bottom: 1px solid black;
+}
+table.alternating > tbody > tr:nth-child(odd) {
+ background-color: #dcdcdc;
+}
+table.alternating > tbody > tr:nth-child(even) {
+ background: #ffffff;;
+}
+td {
+ vertical-align: top;
+}
+div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical {
+ background: #ff6666;
+}
+td.block_column {
+ background: #ffffff;
+}
+td.block_column.critical {
+ background: #ff6666;
+}
+td.amount {
+ text-align: right;
+}
+td.amount, td.currency {
+ font-family: monospace;
+ font-size: 1.25em;
+}
+</style>
+</head>
+<body>
+<div id="header">
+ <form action="" method="POST">
+ <span class="disable_on_change">
+ ledger <a href="/ledger_structured">structured</a>
+ / <a href="/ledger_raw">raw</a>
+ · <a href="/balance">balance</a>
+ · <input type="submit"name="file_load" value="reload" />
+ </span>
+ </form>
+</div>
+<form action="/ledger_structured" method="POST">
+<table class="alternating">
+ <tr></tr><!-- just to keep the background-color alternation in proper order -->
+ <tr id="block_0">
+ <td class="block_column " rowspan=1>
+ <input type="submit" name="ledger_moveup_0" value="^" disabled/><br />
+ <input type="submit" name="ledger_movedown_0" value="v" disabled/><br />
+ <input type="submit" name="ledger_copy_0" value="C" />
+ </td>
+ <td class="block_column " rowspan=1>
+ [<a href="#block_0">#</a>]<br />
+ [<a href="/balance?up_incl=0">b</a>]<br />
+ [<a href="/edit_structured/0">e</a>]
+ </td>
+ </tr >
+ <tr></tr><!-- just to keep the background-color alternation in proper order -->
+ <tr id="block_1">
+ <td class="block_column " rowspan=5>
+ <input type="submit" name="ledger_moveup_1" value="^" disabled/><br />
+ <input type="submit" name="ledger_movedown_1" value="v" disabled/><br />
+ <input type="submit" name="ledger_copy_1" value="C" />
+ </td>
+ <td class="block_column " rowspan=5>
+ [<a href="#block_1">#</a>]<br />
+ [<a href="/balance?up_incl=1">b</a>]<br />
+ [<a href="/edit_structured/1">e</a>]
+ </td>
+ </tr >
+ <tr>
+ <td colspan=3 >2001-01-01 test</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td class="amount ">10.00</td>
+ <td class="currency ">€</td>
+ <td >foo</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td class="amount ">-10.00</td>
+ <td class="currency ">€</td>
+ <td >bar</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td colspan=4> </td>
+ </tr>
+ <tr></tr><!-- just to keep the background-color alternation in proper order -->
+ <tr id="block_2">
+ <td class="block_column " rowspan=5>
+ <input type="submit" name="ledger_moveup_2" value="^" disabled/><br />
+ <input type="submit" name="ledger_movedown_2" value="v" disabled/><br />
+ <input type="submit" name="ledger_copy_2" value="C" />
+ </td>
+ <td class="block_column " rowspan=5>
+ [<a href="#block_2">#</a>]<br />
+ [<a href="/balance?up_incl=2">b</a>]<br />
+ [<a href="/edit_structured/2">e</a>]
+ </td>
+ </tr >
+ <tr>
+ <td colspan=3 >2001-01-02 test</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td class="amount ">20.00</td>
+ <td class="currency ">€</td>
+ <td >bar</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td class="amount ">-20.00</td>
+ <td class="currency ">€</td>
+ <td >baz</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td colspan=4> </td>
+ </tr>
+</table>
+<input type="submit" name="add_booking" value="add booking" />
+</form>
+</body>
+</html>
+++ /dev/null
-
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="UTF-8">
-<script>
-
-</script>
-<style>
-html {
- scroll-padding-top: 2em;
-}
-body {
- background: #ffffff;
- font-family: sans-serif;
- text-align: left;
- margin: 0;
- padding: 0;
-}
-#header {
- background: #ffffff;
- position: sticky;
- top: 0;
- padding-left: 0.5em;
- padding-bottom: 0.25em;
- border-bottom: 1px solid black;
-}
-table.alternating > tbody > tr:nth-child(odd) {
- background-color: #dcdcdc;
-}
-table.alternating > tbody > tr:nth-child(even) {
- background: #ffffff;;
-}
-td {
- vertical-align: top;
-}
-div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical {
- background: #ff6666;
-}
-
-
-td.block_column {
- background: #ffffff;
-}
-td.block_column.critical {
- background: #ff6666;
-}
-
-
-td.amount {
- text-align: right;
-}
-td.amount, td.currency {
-
- font-family: monospace;
- font-size: 1.25em;
-
-}
-
-td.amount {
- text-align: right;
-}
-td.amount, td.currency {
- vertical-align: bottom;
-}
-
-</style>
-</head>
-<body>
-
-<div id="header">
-<form action="" method="POST">
-<span class="disable_on_change">
-ledger <a href="/ledger_structured">structured</a>
-/ <a href="/ledger_raw">raw</a>
-· <a href="/balance">balance</a>
-·
-
-<input type="submit"name="file_load" value="reload" />
-
-</span>
-</form>
-</div>
-
-
-<form action="/ledger_structured" method="POST">
-
-
-
-<table class="alternating">
-
-
-<tr></tr><!-- just to keep the background-color alternation in proper order -->
-<tr id="block_0">
-<td class="block_column " rowspan=2>
-<input type="submit" name="ledger_moveup_0" value="^" disabled/><br />
-<input type="submit" name="ledger_movedown_0" value="v" disabled/><br />
-<input type="submit" name="ledger_copy_0" value="C" />
-</td>
-<td class="block_column " rowspan=2>
-[<a href="#block_0">#</a>]<br />
-[<a href="/balance?up_incl=0">b</a>]<br />
-[<a href="/edit_structured/0">e</a>]
-</td>
-</tr >
-
-
-
- <tr>
- <td colspan=4> </td>
- </tr>
-
-
-</table>
-<input type="submit" name="add_booking" value="add booking" />
-</form>
-
-</body>
-</html>