home · contact · privacy
Re-date to-end Booking copies to current day.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 29 Jan 2025 07:27:37 +0000 (08:27 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 29 Jan 2025 07:27:37 +0000 (08:27 +0100)
ledger.py

index 60106c740ca833e75c102bf48d6803ff72538f14..b9577dc008e4cf38b08fe5b9e37a102cf675844c 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -427,17 +427,20 @@ class Server(PlomHttpServer):
     def copy_booking(self, id_: int, to_end: bool) -> int:
         """Add copy of Booking of id_ to_end of ledger, or after copied."""
         copied = self.bookings[id_]
-        new_lines = [DatLine('')] + [DatLine(dat_line.raw) for dat_line
-                                     in copied.dat_lines]
+        empty_line = DatLine('')
         if to_end or copied is self.bookings[-1]:
-            self.dat_lines += new_lines
-            new_id = self.bookings[-1].id_ + 1
+            intro = DatLine(
+                f'{dt_date.today().isoformat()} '
+                f'{copied.intro_line.target} ; {copied.dat_lines[0].comment}')
+            self.dat_lines += [empty_line, intro] + copied.dat_lines[1:]
+            prev_id = self.bookings[-1].id_
         else:
             start = self.dat_lines.index(copied.dat_lines[-1])
-            self._replace_from_to(start + 1, start, new_lines)
-            new_id = copied.id_ + 1
+            self._replace_from_to(start + 1, start,
+                                  [empty_line] + copied.dat_lines)
+            prev_id = copied.id_
         self._load_bookings()
-        return new_id
+        return prev_id + 1
 
     @property
     def dat_lines_sans_empty(self) -> list[DatLine]: