return tuple(errors)
-class _TransferLine(_BookingLine):
- 'Non-first _Booking line, expected to carry value movement.'
+class _BookingBodyLine(_BookingLine):
+ 'Non-first _Booking line, expected to carry value movement and/or comment.'
_field_names = {'account', 'amount', 'currency', 'len_indent'}
@property
@property
def errors(self) -> tuple[str, ...]:
errors = []
- # if not self.len_indent:
- # errors += ['transfer line not indented']
- if not self.account:
- errors += ['account missing']
- if isinstance(self.amount, str):
- errors += [f'improper amount value: {self.amount}']
- if len(self.currency.split()) > 1:
- errors += ['improper number of tokens']
+ if self.account:
+ if isinstance(self.amount, str):
+ errors += [f'improper amount value: {self.amount}']
+ if len(self.currency.split()) > 1:
+ errors += ['improper number of tokens']
return tuple(errors)
@property
@property
def booking_lines(self) -> tuple[_BookingLine, ...]:
- 'Sequence of .intro_line and .transfer_lines.'
- return (self.intro_line, ) + self.transfer_lines
+ 'Sequence of .intro_line and .body_lines.'
+ return (self.intro_line, ) + self.body_lines
+
+ @property
+ def body_lines(self) -> tuple[_BookingBodyLine, ...]:
+ 'Any lines past the first one (which would be .intro_line).'
+ return tuple(_BookingBodyLine(line.raw) for line in self.lines[1:])
@property
def _diffs_targeted(self) -> dict[str, _Wealth]:
@property
@_LinesBlock._cache('transfer_lines')
- def transfer_lines(self) -> tuple[_TransferLine, ...]:
- 'Any lines past the first with .code.'
- return tuple(_TransferLine(line.raw) for line in self.lines[1:]
- if line.code)
+ def transfer_lines(self) -> tuple[_BookingBodyLine, ...]:
+ 'Any lines past the first with .account.'
+ return tuple(line for line in self.body_lines if line.account)
@property
def date(self) -> str:
def booking(self) -> Optional[_Booking]:
'Booking made from lines indented or with code.'
booking_lines = tuple(_DatLine(line.raw) for line in self.lines
- if line.len_indent or line.code)
+ if line.code or line.len_indent)
if not booking_lines:
return None
booking = _Booking()
</td>
<td>{{ block.booking.intro_line.comment }}</td>
</tr>
-{####}{% for line in block.booking.transfer_lines %}
+{####}{% for line in block.booking.body_lines %}
<tr>
+{######}{% if line.account %}
<td class="amount{{ ' critical' if line.errors }}">
{{- line.amount_short -}}
</td>
{{- line.account -}}
</td>
<td>{{ line.comment }}</td>
+{######}{% else %}
+ <td colspan=4>{{ line.comment }}</td>
+{######}{% endif %}
</tr>
{####}{% endfor %}
{##}{% endif %}
; #def bar:x bla bla bla
2001-01-01 test ; foo
+ ; in-body comment 1
foo 10 €
+ ; in-body comment 2
bar -10 €
+ ; in-body comment 3
2001-01-02 test test
bar -10 € ; bar
</span>
<hr>
-<textarea name="raw_lines" class="tainter" cols="100" rows="6">; #def bar:x bla bla bla
+<textarea name="raw_lines" class="tainter" cols="100" rows="9">; #def bar:x bla bla bla
2001-01-01 test ; foo
+ ; in-body comment 1
foo 10 €
+ ; in-body comment 2
bar -10 €
+ ; in-body comment 3
</textarea>
</form>
<table class="alternating">
<input name="line_1_len_indent" size="1" value="4" type="number" min="1" step="1">
</td>
<td colspan="1">
- <input name="line_1_account" size="30" value="foo" list="all_accounts" autocomplete="off">
+ <input name="line_1_account" size="30" value="" list="all_accounts" autocomplete="off">
</td>
<td colspan="1">
- <input name="line_1_amount" size="12" value="10" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
+ <input name="line_1_amount" size="12" value="" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
</td>
<td colspan="1">
- <input name="line_1_currency" size="3" value="€" placeholder="€">
+ <input name="line_1_currency" size="3" value="" placeholder="€">
</td>
<td colspan="1">
- <input name="line_1_comment" size="40" value="">
+ <input name="line_1_comment" size="40" value="in-body comment 1">
</td>
<td colspan="1">
<button type="button">add new</button>
<input name="line_2_len_indent" size="1" value="4" type="number" min="1" step="1">
</td>
<td colspan="1">
- <input name="line_2_account" size="30" value="bar" list="all_accounts" autocomplete="off">
+ <input name="line_2_account" size="30" value="foo" list="all_accounts" autocomplete="off">
</td>
<td colspan="1">
- <input name="line_2_amount" size="12" value="-10" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
+ <input name="line_2_amount" size="12" value="10" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
</td>
<td colspan="1">
<input name="line_2_currency" size="3" value="€" placeholder="€">
<button type="button">delete</button>
</td>
</tr>
+ <tr>
+ <td colspan="1">
+ <button type="button">^</button>
+ <button type="button">v</button>
+ </td>
+ <td colspan="1">
+ <input name="line_3_len_indent" size="1" value="4" type="number" min="1" step="1">
+ </td>
+ <td colspan="1">
+ <input name="line_3_account" size="30" value="" list="all_accounts" autocomplete="off">
+ </td>
+ <td colspan="1">
+ <input name="line_3_amount" size="12" value="" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
+ </td>
+ <td colspan="1">
+ <input name="line_3_currency" size="3" value="" placeholder="€">
+ </td>
+ <td colspan="1">
+ <input name="line_3_comment" size="40" value="in-body comment 2">
+ </td>
+ <td colspan="1">
+ <button type="button">add new</button>
+ <button type="button">delete</button>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="1">
+ <button type="button">^</button>
+ <button type="button">v</button>
+ </td>
+ <td colspan="1">
+ <input name="line_4_len_indent" size="1" value="4" type="number" min="1" step="1">
+ </td>
+ <td colspan="1">
+ <input name="line_4_account" size="30" value="bar" list="all_accounts" autocomplete="off">
+ </td>
+ <td colspan="1">
+ <input name="line_4_amount" size="12" value="-10" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
+ </td>
+ <td colspan="1">
+ <input name="line_4_currency" size="3" value="€" placeholder="€">
+ </td>
+ <td colspan="1">
+ <input name="line_4_comment" size="40" value="">
+ </td>
+ <td colspan="1">
+ <button type="button">add new</button>
+ <button type="button">delete</button>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="1">
+ <button type="button">^</button>
+ <button type="button">v</button>
+ </td>
+ <td colspan="1">
+ <input name="line_5_len_indent" size="1" value="4" type="number" min="1" step="1">
+ </td>
+ <td colspan="1">
+ <input name="line_5_account" size="30" value="" list="all_accounts" autocomplete="off">
+ </td>
+ <td colspan="1">
+ <input name="line_5_amount" size="12" value="" pattern="^-?[0-9]+(.[0-9]+)?$" class="amount">
+ </td>
+ <td colspan="1">
+ <input name="line_5_currency" size="3" value="" placeholder="€">
+ </td>
+ <td colspan="1">
+ <input name="line_5_comment" size="40" value="in-body comment 3">
+ </td>
+ <td colspan="1">
+ <button type="button">add new</button>
+ <button type="button">delete</button>
+ </td>
+ </tr>
</table>
</EXPANDED>
</form>
<tbody>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_0">
- <td rowspan="6" class="block_column">
+ <td rowspan="9" class="block_column">
<input type="submit" name="ledger_moveup_0" value="^" disabled="">
<br>
<input type="submit" name="ledger_movedown_0" value="v" disabled="">
<br>
<input type="submit" name="ledger_copy_0" value="C">
</td>
- <td rowspan="6" class="block_column">
+ <td rowspan="9" class="block_column">
[<a href="#block_0">#</a>]<br>
[<a href="/balance/0">b</a>]<br>
[<a href="/edit_raw/0">e</a>]
<tr><td>; #def bar:x bla bla bla </td></tr>
<tr><td> </td></tr>
<tr><td>2001-01-01 test ; foo </td></tr>
+ <tr><td> ; in-body comment 1 </td></tr>
<tr><td> foo 10 € </td></tr>
+ <tr><td> ; in-body comment 2 </td></tr>
<tr><td> bar -10 € </td></tr>
+ <tr><td> ; in-body comment 3 </td></tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_1">
<td rowspan="5" class="block_column">
<tbody>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_0">
- <td rowspan="6" class="block_column">
+ <td rowspan="9" class="block_column">
<input type="submit" name="ledger_moveup_0" value="^" disabled="">
<br>
<input type="submit" name="ledger_movedown_0" value="v" disabled="">
<br>
<input type="submit" name="ledger_copy_0" value="C">
</td>
- <td rowspan="6" class="block_column">
+ <td rowspan="9" class="block_column">
[<a href="#block_0">#</a>]<br>
[<a href="/balance/0">b</a>]<br>
[<a href="/edit_structured/0">e</a>]
<td colspan="3">2001-01-01 test</td>
<td>foo</td>
</tr>
+ <tr>
+ <td colspan="4">in-body comment 1</td>
+ </tr>
<tr>
<td class="amount">10.00</td>
<td class="currency">€</td>
<td>foo</td>
<td></td>
</tr>
+ <tr>
+ <td colspan="4">in-body comment 2</td>
+ </tr>
<tr>
<td class="amount">-10.00</td>
<td class="currency">€</td>
<td>bar</td>
<td></td>
</tr>
+ <tr>
+ <td colspan="4">in-body comment 3</td>
+ </tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_1">
<td rowspan="5" class="block_column">