{{ macros.taint_js() }}
+function new_dat_line(account='', amount='None', currency='') {
+ return {
+ error: '',
+ comment: '',
+ booked: {
+ account: account,
+ amount: amount,
+ currency: currency,
+ }
+ };
+}
+
function update_form() {
// catch and empty table
const table = document.getElementById("dat_lines");
// line deletion and addition buttons
td_add_del = add_td(tr);
add_button(td_add_del, 'add new', false, function() {
- new_line = {error: '', comment: '', booked: {account: '', amount: 'None', currency: ''}};
- dat_lines.splice(i + 1, 0, new_line);
+ dat_lines.splice(i + 1, 0, new_dat_line());
});
if (i > 0) {
add_button(td_add_del, 'delete', i > 0 ? false : true, function() {
inverted_amount = inverted_amount.slice(2);
}
}
- dat_lines.push({
- error: '',
- comment: '',
- booked: {
- account: '?',
- amount: inverted_amount,
- currency: dat_line.booked.currency
- }
- });
+ dat_lines.push(new_dat_line('?', inverted_amount, dat_line.booked.currency));
})
taint();
update_form();
}
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: sink_account, amount: 'None', currency: ''}};
- dat_lines.push(new_line);
+ dat_lines.push(new_dat_line(sink_account));
}
let sink_indices_index = 0;
for (const [currency, amount] of Object.entries(sink_amounts_per_currency)) {