home · contact · privacy
In /edit_structured, fix mirroring of empty amounts.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 10:29:27 +0000 (11:29 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 10:29:27 +0000 (11:29 +0100)
src/templates/edit_structured.tmpl

index 867374661f89d0ea2b327ed01952e27246d475d8..32816e3a4bed1f2c1bfd7f38dc806d2ba529cb5f 100644 (file)
@@ -135,7 +135,7 @@ function update_form() {
         // 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: '', currency: ''}};
+            new_line = {error: '', comment: '', booked: {account: '', amount: 'None', currency: ''}};
             dat_lines.splice(i + 1, 0, new_line);
         });
         if (i > 0) {
@@ -181,9 +181,12 @@ function replace() {
 
 function mirror() {
     dat_lines.slice(1).forEach((dat_line) => {
-        let inverted_amount = `-${dat_line.booked.amount}`;
-        if (inverted_amount.startsWith('--')) {
-            inverted_amount = inverted_amount.slice(2);
+        let inverted_amount = 'None';
+        if (dat_line.booked.amount != 'None') {
+            inverted_amount = `-${dat_line.booked.amount}`;
+            if (inverted_amount.startsWith('--')) {
+                inverted_amount = inverted_amount.slice(2);
+            }
         }
         dat_lines.push({
             error: '',