update_form();
}
+function fill_sink() {
+ let sink_indices = [];
+ const sum_per_currency = {};
+ for (let i = 0; i < dat_lines.length; i++) {
+ const dat_line = dat_lines[i];
+ if (!dat_line.is_intro && !dat_line.error) {
+ const currency = dat_line.booked.currency || '€';
+ if (dat_line.booked.amount == 'None') {
+ sink_indices.push(i);
+ } else {
+ if (!Object.hasOwn(sum_per_currency, currency)) {
+ sum_per_currency[currency] = 0;
+ }
+ sum_per_currency[currency] += parseFloat(dat_line.booked.amount);
+ }
+ }
+ }
+ const sink_amounts_per_currency = {};
+ for (const [currency, amount] of Object.entries(sum_per_currency)) {
+ if (amount != 0) {
+ sink_amounts_per_currency[currency] = -amount;
+ }
+ }
+ for (i = 0; i < Object.keys(sink_amounts_per_currency).length - sink_indices.length; i++) {
+ sink_indices.push(dat_lines.length);
+ new_line = {error: '', comment: '', booked: {account: '?', amount: 'None', currency: ''}};
+ dat_lines.push(new_line);
+ }
+ let sink_indices_index = 0;
+ for (const [currency, amount] of Object.entries(sink_amounts_per_currency)) {
+ const dat_line = dat_lines[sink_indices[sink_indices_index]];
+ sink_indices_index++;
+ dat_line.booked.currency = currency;
+ dat_line.booked.amount = (-amount).toString();
+ }
+ taint();
+ update_form();
+}
+
window.onload = update_form;
{% endblock %}
<form action="/edit_structured/{{id}}" method="POST">
{{ macros.edit_bar("raw", id) }}
<input type="button" onclick="mirror()" value="mirror" class="disable_on_change">
+<input type="button" onclick="fill_sink()" value="fill sink" class="disable_on_change">
|
<input type="button" onclick="replace()" value="replace string" class="disable_on_change">
from