Error: Automated transaction's posting has no amount

36 views
Skip to first unread message

Tino Schmidt

unread,
Dec 28, 2020, 2:52:40 PM12/28/20
to ledge...@googlegroups.com
Hi folks,
I'm trying to understand how ledger works and while I'm trying to
reproduce some examples, I'm running into some unexpected behavior.

I want to split some of my expenses between me and my roommate. The file
looks like this:

$ cat example.dat
= tag(split_mate)
 $account   -0,5
 Assets:Mate 0,5

2020/12/09 * (CODE) Supermarket
    ;2020-12-08T08:47      Debit 2020-12
    ; bic: XXXXXXXX
    ; iban: XXXXXXXXXXXXXXXXXX
    ; split_mate: y
    Expenses:Grocery             €-40,91
   MyBank

2020/12/19 * (CODE) Supermarket
    ;2020-12-08T08:47      Debit 2020-12
    ; bic: XXXXXXXX
    ; iban: XXXXXXXXXXXXXXXXX
    ; split_mate: y
    Expenses:Grocery             €-50,91
    MyBank

2020/12/20 * (CODE) Supermarket
    ;2020-12-08T08:47      Debit 2020-12
    ; bic: XXXXXXXX
    ; iban: XXXXXXXXXXXXXXXXX
    Expenses:Grocery             €-60,91
    MyBank

My goal is to catch all entries tagged with 'split_mate', deduct 50% of
the expenses and move them to another account called Assets:Mate.
Starting ledger with that file results in the following output:

$ ledger --decimal-comma -f example.dat
Ledger 3.1.2-20190205, the command-line accounting tool

Copyright (c) 2003-2019, John Wiegley.  All rights reserved.

This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.
While parsing file "/tmp/ledger/example.dat", line 11:
While applying automated transaction from "/tmp/ledger/example.dat",
lines 1-3:
> = tag(split_mate)
>  $account   -0,5
>  Assets:Mate 0,5
While extending transaction from "/tmp/ledger/example.dat", lines 5-11:
> 2020/12/09 * (CODE) Supermarket
>     ;2020-12-08T08:47      Debit 2020-12
>     ; bic: XXXXXXXX
>     ; iban: XXXXXXXXXXXXXXXXXX
>     ; split_mate: y
>     Expenses:Grocery             €-40,91
>    MyBank
Error: Automated transaction's posting has no amount
While parsing file "/tmp/ledger/example.dat", line 19:
While applying automated transaction from "/tmp/ledger/example.dat",
lines 1-3:
> = tag(split_mate)
>  $account   -0,5
>  Assets:Mate 0,5
While extending transaction from "/tmp/ledger/example.dat", lines 13-19:
> 2020/12/19 * (CODE) Supermarket
>     ;2020-12-08T08:47      Debit 2020-12
>     ; bic: XXXXXXXX
>     ; iban: XXXXXXXXXXXXXXXXX
>     ; split_mate: y
>     Expenses:Grocery             €-50,91
>     MyBank
Error: Automated transaction's posting has no amount

I don't understand the error message here. What do I have to do to make
it work?

Tino

Martin Michlmayr

unread,
Dec 28, 2020, 9:47:22 PM12/28/20
to ledge...@googlegroups.com
* Tino Schmidt <tino.s...@wolves.northern.edu> [2020-12-27 21:37]:
> $ cat example.dat
> = tag(split_mate)
>  $account   -0,5
>  Assets:Mate 0,5

= tag(split_mate)
$account (amount * -0,5)
Assets:Mate (amount * 0,5)

--
Martin Michlmayr
https://www.cyrius.com/

Ismael Bouya

unread,
Dec 29, 2020, 6:56:13 AM12/29/20
to ledge...@googlegroups.com
This will only solve part of the issue. There are other issues that will
come then. If I take a relevant part:

-----
= tag(split_mate)
$account (amount * -0.5)
Assets:Mate (amount * 0.5)

2020/12/09 * (CODE) Supermarket
; split_mate: y
Expenses:Grocery             -40.91 EUR
MyBank
------

Since one of the amounts is empty, ledger will complain that more than
one account has null amount. So you need to specify it as this:

-----
2020/12/09 * (CODE) Supermarket
; split_mate: y
Expenses:Grocery             -40.91 EUR
MyBank 40.91 EUR
-----

The second issue is that since split_mate is applied to the whole
transaction, the Assets:Mate will always be empty because it will get
-20.46 (due to Expanse) and +20.46 (due to MyBank). You actually want to
apply it only to your expanse:

----
2020/12/09 * (CODE) Supermarket
Expenses:Grocery             -40.91 EUR
; split_mate: y
MyBank 40.91 EUR
----

Finally, as a bonus, you don’t need to give a value to split_mate if
it’s not relevant (note the colon before the tag though):

----
2020/12/09 * (CODE) Supermarket
Expenses:Grocery             -40.91 EUR
; :split_mate:
MyBank 40.91 EUR
----

--
Ismael
signature.asc

Martin Michlmayr

unread,
Dec 29, 2020, 8:13:27 AM12/29/20
to ledge...@googlegroups.com
* Ismael Bouya <ismael....@normalesup.org> [2020-12-29 12:56]:
> This will only solve part of the issue. There are other issues that
> will come then. If I take a relevant part:

Yes, I was only addressing the problematic part.

It should be:

= /Expenses:Grocery/ and %split_mate
$account (amount * -0.5)
Assets:Mate (amount * 0.5)

Yuri Khan

unread,
Dec 29, 2020, 9:51:32 AM12/29/20
to Ledger
On Tue, 29 Dec 2020 at 02:52, Tino Schmidt
<tino.s...@wolves.northern.edu> wrote:

> 2020/12/19 * (CODE) Supermarket
> Expenses:Grocery €-50,91
> MyBank

To add to all the responses you’ve got: your amounts are backwards.
When you buy something, your assets account balance decreases:

2020-12-19 * Supermarket
Expenses:Grocery 50.91 EUR
Assets:MyBank -50.91 EUR
Reply all
Reply to author
Forward
0 new messages