From: Christian Heller Date: Sun, 23 Mar 2025 11:52:46 +0000 (+0100) Subject: In /edit_structured's "fill sink" only allow single sink account. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%22https:/validator.w3.org/todo?a=commitdiff_plain;h=31d42b07b1fbbbd9ee8fbb6e0bac780539c00e61;p=ledgplom In /edit_structured's "fill sink" only allow single sink account. --- diff --git a/src/templates/edit_structured.tmpl b/src/templates/edit_structured.tmpl index 0ca2416..3250ae4 100644 --- a/src/templates/edit_structured.tmpl +++ b/src/templates/edit_structured.tmpl @@ -203,6 +203,7 @@ function mirror() { } function fill_sink() { + let sink_account = ''; let sink_indices = []; const sum_per_currency = {}; for (let i = 0; i < dat_lines.length; i++) { @@ -210,7 +211,12 @@ function fill_sink() { if (!dat_line.is_intro && !dat_line.error) { const currency = dat_line.booked.currency || '€'; if (dat_line.booked.amount == 'None') { - sink_indices.push(i); + if (sink_account == dat_line.booked.account || !sink_account) { + if (!sink_account) { + sink_account = dat_line.booked.account; + } + sink_indices.push(i); + } } else { if (!Object.hasOwn(sum_per_currency, currency)) { sum_per_currency[currency] = 0; @@ -219,6 +225,9 @@ function fill_sink() { } } } + if (!sink_account) { + sink_account = '?'; + } const sink_amounts_per_currency = {}; for (const [currency, amount] of Object.entries(sum_per_currency)) { if (amount != 0) { @@ -227,7 +236,7 @@ function fill_sink() { } 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: ''}}; + new_line = {error: '', comment: '', booked: {account: sink_account, amount: 'None', currency: ''}}; dat_lines.push(new_line); } let sink_indices_index = 0;