ledger icon indicating copy to clipboard operation
ledger copied to clipboard

csv parser: mark guessed account as calculated

Open madroach opened this issue 4 years ago • 21 comments

This will change the output of the convert command so that the amount is printed on the bucket account, not the guessed account.

2022/02/01* Blublub
    Expenses:Groceries                   100,00
    Accounts:Cache

becomes

2022/02/01* Blublub
    Expenses:Groceries
    Accounts:Cache                      -100,00

This makes subclassifying after conversion a bit easier

madroach avatar Feb 01 '22 22:02 madroach

I'm not sure I see the advantage of this. Can you elaborate?

Why not put the amount on both postings; but maybe some people don't like that

tbm avatar Feb 02 '22 02:02 tbm

When importing via csv you always get transactions with two postings. One is the posting on the real account the csv is about. The other one is guessed. Now I often want something like this:

2022-02-02 Supermarket
    Assets:Credit Card    -50
    Expenses:Groceries     10
    Expenses:Household     20
    Expenses:Drinks        20
  • It is easier to get there if there is already an amount on the asset. Otherwise I need to move the amount from an arbitrary account to the asset and negate it. I want to avoid that.
  • It makes sense, because the csv was about the asset, not the guessed account. Indeed the other account has a calculated amount to balance the real asset account.

Putting the amount on both postings would be fine with me, but this would require a change to print.cc, which would affect more than just the output of convert.

madroach avatar Feb 02 '22 06:02 madroach

Ok, thanks for the clarification. I agree with your points; otoh, people might not like the negative numbers that the change will cause (even if they accurately represent the transaction).

I think I'll leave this up for John to decide (but he has been busy).

You may want to email the ledger mailing list about this and gather feedback from other users.

tbm avatar Feb 03 '22 08:02 tbm

I agree with this change 100%. I think users will often want to split their income/expenses and moving the posted amount to the bank account would facilitate this. Further, the CSV is likely provided by a source for one account, the bank/credit account, and it would logically make sense for ledger convert to attach the amount in the CSV to the referenced account.

JesseFL avatar Apr 08 '22 13:04 JesseFL

can someone email the ledger mailing list to discuss this change and see what the feedback is.

I think the arguments here are good, but since it's a change in behaviour I think it's better to discuss it more widely.

tbm avatar Apr 10 '22 01:04 tbm

Added https://groups.google.com/g/ledger-cli/c/_eXMLgohq6Y

JesseFL avatar Apr 15 '22 22:04 JesseFL

Only received one comment, but it was from @jwiegley, so it may be worth more than one vote ;)

Sounds like a great feature request to me!

John

JesseFL avatar Apr 24 '22 22:04 JesseFL

Could we add an option to do this flipping? It could change the workflow for many people.

jwiegley avatar Apr 27 '22 22:04 jwiegley

@madroach what do you think of John's suggest to make it an option.

tbm avatar May 05 '22 22:05 tbm

sure, that would be fine with me.

madroach avatar Jan 23 '23 09:01 madroach

@madroach Great, just let me know when that change is in!

jwiegley avatar Jan 27 '23 20:01 jwiegley

@madroach Mind merging the current state of master, which has seen some improvements regarding the checks run on PRs, to this PRs branch too?

afh avatar Feb 01 '23 05:02 afh

Friendly ping for @madroach

afh avatar Apr 12 '23 22:04 afh

I rebased my change. Sorry for taking so long. @afh, @jwiegley

madroach avatar Jun 05 '23 08:06 madroach

I like the change, but it seems to break a few tests? Can you confirm that these tests need to be changed now, and if so, include those changes here in the PR until it passes CI?

jwiegley avatar Jun 09 '23 19:06 jwiegley

I took the liberty to address the breaking tests. The changes can be found here. I'm ot sure how to best update this PR with these changes as this PR's branch is on a fork, hence I created a PR madroach/ledger#1.

@madroach would you be willing to accept that, so this PR's branch gets those changes and we can move forward with merging this PR?

@jwiegley Are you okay with the fixes (see Fix DocTests and tests: Fix Baseline and Regression tests) and are any changes to the documentation necessary?

afh avatar Dec 09 '23 21:12 afh

Merged. Thanks for the work. I couldn't find the time for it...

madroach avatar Dec 10 '23 16:12 madroach

Thanks for merging, @madroach, very much appreciated! No worries regarding not finding the time, often enough other obligations stand in the way of the fun stuff 🙂

afh avatar Dec 10 '23 17:12 afh

I think this is set to go, it just still needs the option to flip the behavior, which should be relatively easy to add as a session_t option.

jwiegley avatar Dec 11 '23 23:12 jwiegley

@madroach would you be okay with me taking over the work and adding the requested option as well as accompanying documentation and tests?

If yes, I'd close this PR in favor of one I'd create in order to more easily push changes to it. You'd be credited with Co-authored-by: @madroach on one of the commits unless you object.

afh avatar Dec 12 '23 07:12 afh

Yes, please do! I just won't find the time.

madroach avatar Dec 18 '23 07:12 madroach