X-Git-Url: https://plomlompom.com/repos/?p=misc;a=blobdiff_plain;f=ledger.py;fp=ledger.py;h=f29f73ec190d3b1391b4a3f05ca088607ac221d2;hp=46035bc3790ac42815fd1b9c2a1910cf574da07e;hb=76210b693b77e67bf8160a7fb869ae416309d333;hpb=28bd91c52ce1eab2b26793097e0d9cabc3c33c64 diff --git a/ledger.py b/ledger.py index 46035bc..f29f73e 100755 --- a/ledger.py +++ b/ledger.py @@ -449,8 +449,8 @@ class Booking: self.description = description self.top_comment = top_comment self.validate_head() - self.transfer_lines = transfer_lines - if len(self.transfer_lines) < 2 and self.validate: + self.transfer_lines = transfer_lines if transfer_lines else [] + if self.validate and len(self.transfer_lines) < 2: raise PlomException(f'{self.intro}: too few transfer lines') self.calculate_account_changes() self.lines = [LedgerTextLine(l) for l in self.for_writing] @@ -1032,8 +1032,11 @@ class LedgerDB(PlomDB): content = sent if sent else ([] if 'textarea'==edit_mode else None) else: content = self.bookings[index] + date_today = str(datetime.now())[:10] if copy: - content.date = str(datetime.now())[:10] + content.date = date_today + elif -1 == index and (content is None or [] == content): + content = Booking(date=date_today, validate=False) if 'textarea' == edit_mode and content: content = content.for_writing else: