Skip to content

Ledger-style balance --lots, register --lots reports #1018

Open
@alensiljak

Description

@alensiljak

This is an issue specifically for adding Ledger's --lots flag. Ref #1015.

Examples

Here's Ledger's help for --lots and some related flags:

     --lot-dates
              Report the date on which each commodity in a balance report was
              purchased.

     --lot-notes
              Report the tag attached to each commodity in a balance report.

     --lot-prices
              Report the price at which each commodity in a balance report
              was purchased.

     --lots   Report the date and price at which each commodity was purchased
              in a balance report.

     --lots-actual
              Preserve the uniqueness of commodities so they aren't merged
              during reporting without printing the lot annotations.

Reference file: https://gitlab.com/snippets/1856416

; trades sample for hledger #1015

2019-01-05 Opening Balances
    Assets:Cash    1000.00 EUR
    Equity:Opening Balances    -1000.00 EUR

2019-01-10 Buy fund
    Assets:Shares    5 ETF @ 10 EUR
    Assets:Cash    -50 EUR

2019-01-15 Buy more
    Assets:Shares    5 ETF @ 12 EUR
    Assets:Cash    -60 EUR

2019-03-01 Sell
    Assets:Shares    -5 ETF {10 EUR} [2019-01-10] @ 15 EUR
    Assets:Shares    -1 ETF {12 EUR} [2019-01-15] @ 15 EUR
    Assets:Cash    90.00 EUR
    Capital Gains    -28.00 EUR

Ordinary balance report

$ ledger bal --flat
          980.00 EUR  Assets:Cash
               4 ETF  Assets:Shares
          -28.00 EUR  Capital Gains
        -1000.00 EUR  Equity:Opening Balances
--------------------
               4 ETF
          -48.00 EUR

Balance report showing lots at 1/20

At 1/20 there are two lots in Assets:Shares. {UNITCOST} [PURCHASEDATE] is shown after each amount (throwing off the alignment).

$ ledger bal --flat --lots -e 2019-01-20
          890.00 EUR  Assets:Cash
5 ETF {10.00 EUR} [2019-01-10]
5 ETF {12.00 EUR} [2019-01-15]  Assets:Shares
        -1000.00 EUR  Equity:Opening Balances
--------------------
5 ETF {10.00 EUR} [2019-01-10]
5 ETF {12.00 EUR} [2019-01-15]
         -110.00 EUR

Balance report after selling first lot and part of the second

$ ledger bal --flat --lots
          980.00 EUR  Assets:Cash
4 ETF {12.00 EUR} [2019-01-15]  Assets:Shares
          -28.00 EUR  Capital Gains
        -1000.00 EUR  Equity:Opening Balances
--------------------
4 ETF {12.00 EUR} [2019-01-15]
          -48.00 EUR

Ordinary register report

$ ledger reg shares
19-Jan-10 Buy fund               Assets:Shares                     5 ETF         5 ETF
19-Jan-15 Buy more               Assets:Shares                     5 ETF        10 ETF
19-Mar-01 Sell                   Assets:Shares                    -5 ETF         5 ETF
                                 Assets:Shares                    -1 ETF         4 ETF

Register report showing lots

$ ledger reg shares --lots
19-Jan-10 Buy fund               Assets:Shares             5 ETF {10.00 EUR} [19-Jan-10] 5 ETF {10.00 EUR} [19-Jan-10]
19-Jan-15 Buy more               Assets:Shares             5 ETF {12.00 EUR} [19-Jan-15] 5 ETF {10.00 EUR} [19-Jan-10]
                                                         5 ETF {12.00 EUR} [19-Jan-15]
19-Mar-01 Sell                   Assets:Shares             -5 ETF {10.00 EUR} [19-Jan-10] 5 ETF {12.00 EUR} [19-Jan-15]
                                 Assets:Shares             -1 ETF {12.00 EUR} [19-Jan-15] 4 ETF {12.00 EUR} [19-Jan-15]

Questions

How to reduce impact on alignment ? Other layout ideas ?

Any more intuitive/consistent display schemes than @/@@/{}/{=}/[]/etc. ?

Which other commands should support this ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WISHSome kind of improvement request or proposal.balanceinvestingRelated to investments, lots, capital gains, etc.register

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions