home · contact · privacy
Fix swallowing of booking targets past their first whitespace. master
authorChristian Heller <c.heller@plomlompom.de>
Tue, 3 Feb 2026 02:41:04 +0000 (03:41 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 3 Feb 2026 02:41:04 +0000 (03:41 +0100)
src/ledgplom/ledger.py
src/tests/full.dat
src/tests/full.ledger_raw
src/tests/full.ledger_structured

index 27624985e063369ec4f95ed6b949b5acb8ae33b2..e5ed20fade0dd4f9658095002faf07d8b726b592 100644 (file)
@@ -195,10 +195,10 @@ class _BookingLine(_DatLine, ABC):
         return d
 
     def _code_into_parts(self, n_parts: int) -> tuple[str, ...]:
         return d
 
     def _code_into_parts(self, n_parts: int) -> tuple[str, ...]:
-        maxsplit = n_parts + 1
+        maxsplit = n_parts - 1
         parts = self.code.split(maxsplit=maxsplit)
         parts = self.code.split(maxsplit=maxsplit)
-        return tuple((parts[idx] if len(parts) > idx else '')
-                     for idx in range(maxsplit))
+        return tuple((parts[idx].rstrip() if len(parts) > idx else '')
+                     for idx in range(n_parts))
 
     @property
     @abstractmethod
 
     @property
     @abstractmethod
index 080eec25618719c0c7564630f28c579373b03b52..324edada9b373e5e074d79c2cf0ef78af46ec7ba 100644 (file)
@@ -4,7 +4,7 @@
     foo    10 €
     bar   -10 €
 
     foo    10 €
     bar   -10 €
 
-2001-01-02 test
+2001-01-02 test test
     bar   -10 €  ; bar
     baz    10 €
 
     bar   -10 €  ; bar
     baz    10 €
 
index 40fef85d8b871ba204f4a8799b3b5dd3de9e9fff..3de28c950b415b3b51b9c7ca8666ced5224469e1 100644 (file)
@@ -91,7 +91,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
         </td>
     </tr>
     <tr><td>&nbsp;</td></tr>
         </td>
     </tr>
     <tr><td>&nbsp;</td></tr>
-    <tr><td>2001-01-02 test&nbsp;</td></tr>
+    <tr><td>2001-01-02 test test&nbsp;</td></tr>
     <tr><td>    bar   -10 €  ; bar&nbsp;</td></tr>
     <tr><td>    baz    10 €&nbsp;</td></tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
     <tr><td>    bar   -10 €  ; bar&nbsp;</td></tr>
     <tr><td>    baz    10 €&nbsp;</td></tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
index 6227d8e16ff017b259148eb8aa3c3ed149d5ac92..cc46c9927309a5e25ad4403fc49c65b32a13c7f7 100644 (file)
@@ -116,7 +116,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
         <td colspan="4">&nbsp;</td>
     </tr>
     <tr>
         <td colspan="4">&nbsp;</td>
     </tr>
     <tr>
-        <td colspan="3">2001-01-02 test</td>
+        <td colspan="3">2001-01-02 test test</td>
         <td></td>
     </tr>
     <tr>
         <td></td>
     </tr>
     <tr>