X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/do_todos?a=blobdiff_plain;f=ledger.py;h=276b1cc87a07d5dd4b30323871736886405e217c;hb=a628dc4404bec729a4989c7d2198eac474d667c1;hp=0dbc9fe4debe3c133a766d039394d1828a88a600;hpb=1b9c909cedf7e135f9b3ab977e9554a45d1f09d9;p=misc
diff --git a/ledger.py b/ledger.py
index 0dbc9fe..276b1cc 100755
--- a/ledger.py
+++ b/ledger.py
@@ -282,7 +282,10 @@ class MyServer(BaseHTTPRequestHandler):
new_main = f'{account} {amount} {currency}'
if '' == new_main.rstrip() == comment.rstrip(): # don't write empty lines
continue
- lines += [f'{new_main} ; {comment}']
+ new_line = new_main
+ if comment.rstrip() != '':
+ new_line += f' ; {comment}'
+ lines += [new_line]
elif '/add_free' == parsed_url.path:
lines = postvars['booking'][0].splitlines()
start = int(postvars['start'][0])
@@ -391,7 +394,7 @@ class MyServer(BaseHTTPRequestHandler):
lines = []
line_sep = '
'
for comment in db.comments:
- line = f'; {comment}' if comment != '' else ''
+ line = f' ; {comment}' if comment != '' else ''
lines += [line + line_sep]
for booking in db.bookings:
i = booking.start_line
@@ -434,26 +437,27 @@ edit:
input_lines = ''
last_line = 0
def inpu(name, val=""):
+ val = val if val is not None else ""
safe_val = html.escape(str(val))
return f''
if len(bookings) == 0:
today = str(datetime.datetime.now())[:10]
- input_lines += f'{inpu("date", today)} {inpu("description")} ; {inpu("comment")}
'
+ input_lines += f'{inpu("date", today)} {inpu("description")} ; {inpu("line_0_comment")}
'
last_line = 1
else:
booking = bookings[0]
last_line = len(comments)
- input_lines += f'{inpu("date", booking.date_string)} {inpu("description", booking.description)} ; {inpu("comment", comments[0])}
'
+ input_lines += f'{inpu("date", booking.date_string)} {inpu("description", booking.description)} ; {inpu("line_0_comment", comments[0])}
'
for i in range(1, len(comments)):
account = amount = currency = ''
if i < len(booking.lines) and booking.lines[i] != '':
account = booking.lines[i][0]
amount = booking.lines[i][1]
currency = booking.lines[i][2]
- input_lines += f'{inpu("line_{i}_account", account)} {inpu("line_{i}_amount", amount)} {inpu("line_{i}_currency", currency)} ; {inpu("line_{i}_comment", comments[i])}
'
+ input_lines += f'{inpu(f"line_{i}_account", account)} {inpu(f"line_{i}_amount", amount)} {inpu(f"line_{i}_currency", currency)} ; {inpu(f"line_{i}_comment", comments[i])}
'
for j in range(bonus_lines):
i = j + last_line
- input_lines += f'{inpu("line_{i}_account")} {inpu("line_{i}_amount")} {inpu("line_{i}_currency")} ; {inpu("line_{i}_comment")}
'
+ input_lines += f'{inpu(f"line_{i}_account")} {inpu(f"line_{i}_amount")} {inpu(f"line_{i}_currency")} ; {inpu(f"line_{i}_comment")}
'
return f'{self.header_add_form("add_structured")}{input_lines}{self.footer_add_form(start, end)}'