home · contact · privacy
Fix Booking postings from /edit_structured disrespecting indents for comment-only... master
authorChristian Heller <c.heller@plomlompom.de>
Sun, 8 Feb 2026 22:01:13 +0000 (23:01 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 8 Feb 2026 22:01:13 +0000 (23:01 +0100)
src/ledgplom/http.py

index eae6f22d79e1bf401184835b40c5a38ce4ec6817..1d70cd1c25b88f8931019c59341e2ce6e9c5038e 100644 (file)
@@ -101,14 +101,16 @@ class _Handler(PlomHttpHandler):
                 else:
                     line_items = booking_lines_items[idx - 1]
                     line_raw = SPACE * line_items[0]  # indent
-                    line_raw += line_items[3]  # account
-                    line_raw += SPACE * (idx_amt_dot_max - line_items[1])
-                    line_raw += 2*SPACE + line_items[4]  # amount
-                    line_raw += SPACE * (len_from_dot_max - line_items[2])
-                    line_raw += SPACE + line_items[5]  # currency
-                    line_raw = line_raw.rstrip()
+                    if line_items[3]:
+                        line_raw += line_items[3]  # account
+                        line_raw += SPACE * (idx_amt_dot_max - line_items[1])
+                        line_raw += 2*SPACE + line_items[4]  # amount
+                        line_raw += SPACE * (len_from_dot_max - line_items[2])
+                        line_raw += SPACE + line_items[5]  # currency
+                        line_raw = line_raw.rstrip()
                 if comment:
-                    line_raw = SPACE.join((line_raw, SEP_COMMENTS, comment))
+                    line_raw += SPACE if line_raw[-1] != SPACE else ''
+                    line_raw += SPACE.join((SEP_COMMENTS, comment))
                 new_lines += [line_raw]
         new_lines = self.postvars.first('raw_lines').splitlines() + new_lines
         new_id = self.server.ledger.rewrite_block(old_id, new_lines)