Hey there, one way to achieve your goal would be to have 20XX.ledger files containing only 20XX transactions (not the equity)
Then, create report.ledger with ------✂--------- include 2017.ledger include 2018.ledger ------✂--------- and current.ledger with ------✂--------- <insert your 2017 equity there> include 2018.ledger ------✂--------- and work with report.ledger or current.ledger depending on your needs. Would that suit you? (Mon, Jan 22, 2018 at 10:28:59PM +0700) Yuri Khan : > Hello, > > I have been using Ledger for half the last year and now I’m trying to > split my ledger file by year. So I have 2017.ledger, with my > transaction for that year, and 2018.ledger, with the new year’s > transactions. For a minimal example: > > # 2017.ledger > 2017-12-15 Foo > Expenses:Foo 100 RUB > Assets:Wallet > > # 2018.ledger > 2018-01-15 Foo > Expenses:Foo 200 RUB > Assets:Wallet > > For the most part, I will be working with 2018.ledger as my main > ledger file. So I want its totals to be accurate when it is used > alone. The documented way to achieve that is to run ‘ledger equity’ on > the last year’s file and place the output at the top of the new file. > So far, good. > > # 2018.ledger > 2017-12-15 Opening Balances > Assets:Wallet -100 RUB > Expenses:Foo > > 2018-01-15 Foo > Expenses:Foo 200 RUB > Assets:Wallet > > Now comes the quirk. For reporting purposes, I also want to be able to > use both years’ files together. To that end, I am trying to include > them both from a third file: > > # reports.ledger > include 2017.ledger > include 2018.ledger > > But if I specify ‘-f reports.ledger’, my totals are off because all > 2017’s transactions are also duplicated in the 2018’s opening > balances. > > So I tried to modify the opening balances to be balance assignments: > > 2017-12-15 Opening Balances > Assets:Wallet = -100 RUB > Expenses:Foo = 100 RUB > > 2018-01-15 Foo > Expenses:Foo 200 RUB > Assets:Wallet > > My expectation is that if I use 2018.ledger alone, these assignments > resolve to their stated values and I get correct totals, and if I use > the combined reports.ledger, they should resolve to zeros and I should > still get correct totals. > > The former works: > > $ ledger -f 2018.ledger balance > -300 RUB Assets:Wallet > 300 RUB Expenses:Foo > -------- > 0 > > The latter, however, does not: > > $ ledger -f reports.ledger balance > In file included from "reports.ledger", line 2: > While parsing file "2018.ledger", line 3: > Error: Only one posting with null amount allowed per transaction > > Apparently, Ledger cannot distinguish a zero amount from an > unspecified “calculate-it-for-me” amount and complains. > > I can probably work around it by using this: > > include 2017.ledger > include 2017-end.ledger > include 2018.ledger > > where 2017-end.ledger contains the inverse of the 2017’s equity report: > > # 2017-end.ledger > 2017-12-31 Dirty hack > Assets:Wallet 100 RUB > Expenses:Foo -100 RUB > > so that it cancels out with 2018’s opening balance, but it’s a bit inelegant… > > Am I overlooking something obvious? > > -- > > --- > You received this message because you are subscribed to the Google Groups > "Ledger" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- Ismael -- --- You received this message because you are subscribed to the Google Groups "Ledger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: PGP signature
