From: Christian Heller Date: Wed, 29 Jan 2025 07:27:37 +0000 (+0100) Subject: Re-date to-end Booking copies to current day. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/conditions?a=commitdiff_plain;h=ae04079dfdbae57b4253b7dd7b78e85ac539e0e8;p=plomledger Re-date to-end Booking copies to current day. --- diff --git a/ledger.py b/ledger.py index 60106c7..b9577dc 100755 --- 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]: