Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting dates not displayed separately in hledger-web #1337

Open
Nadrieril opened this issue Aug 31, 2020 · 9 comments
Open

Posting dates not displayed separately in hledger-web #1337

Nadrieril opened this issue Aug 31, 2020 · 9 comments
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. docs Documentation-related. web The hledger-web tool.

Comments

@Nadrieril
Copy link
Contributor

Nadrieril commented Aug 31, 2020

If I make a transaction with individual posting dates, like in this example from the ledger docs:

2008/10/16 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 37.50  ; date:2008/10/01
    Expenses:Food:Groceries           $ 37.50  ; date:2008/11/01
    Expenses:Food:Groceries           $ 37.50  ; date:2008/12/01
    Expenses:Food:Groceries           $ 37.50  ; date:2009/01/01
    Expenses:Food:Groceries           $ 37.50  ; date:2009/02/01
    Expenses:Food:Groceries           $ 37.50  ; date:2009/03/01
    Assets:Checking

and if I look in hledger-web for the transactions in Expenses:Food:Groceries, hledger-web will show a single entry for the whole transaction, dated 2008/10/01 (which is the smallest of the individual posting dates).
I would have expected 6 different entries at the dates specified, like I see in the output of hledger register Expenses:Food:Groceries.
The reason I think this is a bug and not a feature request is that posting dates are clearly taken into account (otherwise the transaction date would have been used), but weirdly.

Platform: NixOS
Version: 1.18.1

@Nadrieril Nadrieril added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Aug 31, 2020
@simonmichael simonmichael added the web The hledger-web tool. label Aug 31, 2020
@simonmichael
Copy link
Owner

simonmichael commented Aug 31, 2020

Thanks for the report.

It's by design that the register in hledger-web (and hledger-ui) shows one line per transaction, to provide a simple UI that's more like other accounting apps, bank statements, etc.

In the general journal view, it shows the transaction date of course. In the account register view, it's supposed to show the date of posting to the account being viewed, for best accuracy. In this case in the Expenses:Food:Groceries register we have multiple posting dates, so what should it show ? Currently it picks the earliest posting date, as you say. (And when you hover over the transaction you can see all dates in the tooltip.)

That's not ideal, but seemed to me about equally useful in practice, and marginally more consistent (than switching to showing the transaction date). What do you think ?

@simonmichael
Copy link
Owner

The alternative is to implement and document: "Account registers show the date of posting to that account. Except, when a single transaction contains multiple such postings with different dates, the transaction date is shown."

@simonmichael simonmichael added the docs Documentation-related. label Aug 31, 2020
@Nadrieril
Copy link
Contributor Author

Nadrieril commented Aug 31, 2020

Thanks for your quick reply!

I see that I've been mixing postings and transactions in my head a bit. Indeed I don't want to see individual postings in hledger-web, that would be confusing. If there's only one posting date I think the current behavior is good.

When there are multiple posting dates though, I'd want to see one entry per date of posting to the account being viewed. But then I guess those entries would be neither individual postings nor individual transactions. Is there a way to make that work?

The idea I have is that in the account view, if a transaction has multiple postings to that account then they are displayed grouped by date. In the typical case, all postings have the same date so they are displayed as a single entry like they always have.
Does that sound reasonable to you?

Given

2008/10/16 * Bountiful Blessings Farm
    Assets:Checking
    Assets:Cash                       $-20  ; date:2008/10/14
    Expenses:Food:Groceries           $ 10  ; date:2008/10/01
    Expenses:Food:Groceries           $ 10  ; date:2008/11/01
    Expenses:Food:Groceries           $ 10  ; date:2008/12/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01

when listing Expenses:Food:Groceries, I expect to see

Date To/From Amount
2008/10/01 Assets:Checking,Assets:Cash 10
2008/11/01 Assets:Checking,Assets:Cash 10
2008/12/01 Assets:Checking,Assets:Cash 10
2009/01/01 Assets:Checking,Assets:Cash 30

when listing Assets:Checking, I expect to see (that's the current behaviour)

Date To/From Amount
2008/10/16 Expenses:Food:Groceries,Assets:Cash -40

when listing Assets, I expect to see (that's the current behaviour)

Date To/From Amount
2008/10/16 Expenses:Food:Groceries -60

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. and removed A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. labels Sep 2, 2020
@simonmichael
Copy link
Owner

Thanks for the mockups. I think the conventional UI in other accounting apps is that registers are transaction-oriented, but you can optionally show/hide the postings ("splits"), either for an individual transaction or for all.

@Nadrieril
Copy link
Contributor Author

I see. Do you know of accounting apps that support individual posting dates? I'd be curious to see how they solve this issue.

@simonmichael
Copy link
Owner

Not from memory, sorry..

@Nadrieril
Copy link
Contributor Author

Would you in principle be ok with an option like hledger-web --split-individual-posting-dates that does what I suggested? I might look into implementing it

@simonmichael
Copy link
Owner

I'm not fully clear on what it would do, I'd be happy to try out your prototype if you make it.

@Nadrieril
Copy link
Contributor Author

Cool thanks! Allow me to clarify what I mean: assume we are viewing Expenses:Food:Groceries in the web interface, and the journal contains the following transaction:

2008/10/16 * Bountiful Blessings Farm
    Assets:Checking
    Assets:Cash                       $-20  ; date:2008/10/14
    Expenses:Food:Groceries           $ 10  ; date:2008/10/01
    Expenses:Food:Groceries           $ 10  ; date:2008/11/01
    Expenses:Food:Groceries           $ 10  ; date:2008/12/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01

Currently, the code first filters the transaction and keeps only the relevant postings:

2008/10/16 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10  ; date:2008/10/01
    Expenses:Food:Groceries           $ 10  ; date:2008/11/01
    Expenses:Food:Groceries           $ 10  ; date:2008/12/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01

then it takes the earliest date from the relevant postings:

2008/10/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10
    Expenses:Food:Groceries           $ 10
    Expenses:Food:Groceries           $ 10
    Expenses:Food:Groceries           $ 15
    Expenses:Food:Groceries           $ 15

and finally displays the whole as a single entry:

2008/10/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 60

What I propose, is that when the --split-individual-posting-dates is enabled, the following happens instead. First we keep only the relevant postings like before:

2008/10/16 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10  ; date:2008/10/01
    Expenses:Food:Groceries           $ 10  ; date:2008/11/01
    Expenses:Food:Groceries           $ 10  ; date:2008/12/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01

now we do something different: we split the transaction into many subtransactions, one for each date present (most of the time this doesn't change anything because individual posting dates are uncommon)

2008/10/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10  ; date:2008/10/01
2008/11/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10  ; date:2008/11/01
2008/12/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10  ; date:2008/12/01
2009/01/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01
    Expenses:Food:Groceries           $ 15  ; date:2009/01/01

and finally we display one entry for each of those subtransactions:

2008/10/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10
2008/11/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10
2008/12/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 10
2009/01/01 * Bountiful Blessings Farm
    Expenses:Food:Groceries           $ 30

I investigated a bit, and it doesn't look very hard to implement. I think it would be enough to change this function:

accountTransactionsReport :: ReportOpts -> Journal -> Query -> Query -> AccountTransactionsReport

so that between ts4 and ts5 it takes splits the transactions like I described. That should be sound because AccountTransactionsReportItem already supports transactions that carry only a relevant subset of their postings.
The main uncertainty I have is how to add a new option and thread it to where I want to use it.

Btw, thanks for developing this insanely powerful tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. docs Documentation-related. web The hledger-web tool.
Projects
None yet
Development

No branches or pull requests

2 participants