home · contact · privacy
Add structured handling of intro lines.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 26 Jan 2025 11:39:17 +0000 (12:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 26 Jan 2025 11:39:17 +0000 (12:39 +0100)
ledger.py
templates/_macros.tmpl
templates/edit_structured.tmpl

index 87f58f5cc41353539d8f2e082814064da770fd60..364ca1f4cdf024e260567de680f6478847311d76 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -126,14 +126,17 @@ class IntroLine(BookingLine):
 
     def __init__(self, booking: 'Booking', code: str) -> None:
         super().__init__(booking)
+        self.date = '#'
+        self.target = ''
         if code[0].isspace():
             self.errors += ['intro line indented']
         toks = code.lstrip().split(maxsplit=1)
         if len(toks) != 2:
             self.errors += ['illegal number of tokens']
-        if len(toks) < 1:
+        elif len(toks) < 1:
             return
-        self.date = '#'
+        else:
+            self.target = toks[1]
         try:
             dt_date.fromisoformat(toks[0])
         except ValueError:
@@ -246,8 +249,10 @@ class Handler(PlomHttpHandler):
                 comment = self.postvars.first(f'line_{lineno}_comment')
                 for name in input_names:
                     input_ = self.postvars.first(f'line_{lineno}_{name}')
-                    if name == 'intro':
+                    if name == 'date':
                         data = input_
+                    elif name == 'target':
+                        data += f'  {input_}'
                     elif name == 'error':
                         data = f'{indent}{input_}'
                     elif name == 'account':
index 1412c84df2b1c54d23e6417d0d202c7b1e7fa88a..dd45db6e8231d2f459f00b8735b5dee412059316 100644 (file)
@@ -29,7 +29,8 @@ td.invalid, tr.warning td.invalid { background-color: #ff0000; }
     </td>
   {% else %}
     {% if dat_line.is_intro %}
-      <td{% if dat_line.error %} class="invalid"{% endif %} colspan=3><a href="/booking/{{dat_line.booking_id}}">{{dat_line.code}}</a></td>
+      <td{% if dat_line.error %} class="invalid"{% endif %}><a href="/booking/{{dat_line.booking_id}}">{{dat_line.booking_line.date}}</a></td>
+      <td{% if dat_line.error %} class="invalid"{% endif %} colspan=2>{{dat_line.booking_line.target}}</td>
     {% elif not dat_line.error %}
       <td class="amt">{{dat_line.booking_line.amount_short}}</td>
       <td class="curr">{{dat_line.booking_line.currency|truncate(4,true,"…")}}</td>
index 6e13a9a99d4f86dd0efae73f0c953d6bfb88b296..89919e51bf60d7259d2350b067361fdfd1b3fcbb 100644 (file)
@@ -14,7 +14,8 @@
 {% for dat_line in dat_lines %}
   <tr>
   {% if dat_line.is_intro %}
-    <td{% if dat_line.error %} class="invalid"{% endif %} colspan=3><input name="line_{{loop.index0}}_intro" value="{{dat_line.code}}"/></td>
+    <td{% if dat_line.error %} class="invalid"{% endif %}><input name="line_{{loop.index0}}_date" value="{{dat_line.booking_line.date}}" /></td>
+    <td{% if dat_line.error %} class="invalid"{% endif %} colspan=2><input name="line_{{loop.index0}}_target" value="{{dat_line.booking_line.target}}" /></td>
   {% elif not dat_line.error %}
     <td><input name="line_{{loop.index0}}_account" value="{{dat_line.booking_line.account}}" /></td>
     <td><input name="line_{{loop.index0}}_amount" value="{{dat_line.booking_line.amount or ''}}" /></td>