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
WIP: Signed costs #2139
WIP: Signed costs #2139
Conversation
What's the point of this PR? There are reasons ledger works the way it does and I don't see why adding this increased complexity would be useful. Personally, I feel the solution here is for your brain to get adjusted to how ledger works. Everything after Does that make sense? |
I understand you're saying that whatever follows @ (the unit price) is always positive. I get that, and I'm not arguing otherwise. If I trade n THINGs at 10 EUR a piece, then it's n THING @ 10 EUR, regardless of how much I'm trading and whether I'm buying or selling. What I don't understand is how you get to the conclusion that whatever follows @@ (the total price) should also be positive. If 1 THING is worth 10 EUR, then 2 THINGs are worth 20 EUR, 10 THINGs are worth 100 EUR, and generally n THINGs are worth 10n EUR, regardless of n. In particular, -1 THING would be worth -10 EUR, -2 THINGs worth -20 EUR and so on. However, when n is negative, then for some reason the UI of ledger pretends that n THINGs are worth -10n EUR instead, swapping the sign of the internally stored negative post->cost on input and output. I still have no idea why. |
It's a price. Have you ever gone into a shop and seen a negative price? If you return an item, you get back money, but the price is still positive. You're getting a refund of a positive price. You buy a t-shirt for $10. You spend $10. The price is $10. You return the t-shirt, You get back $10 (expenses is -$10 in ledger). But the price is still +$10. |
I'm sorry, I still don't see why the actual sign of a price should matter at all. By definition, gross income is positive, but normally all the amounts posted to an income account are negative. In the case of income, everyone seems to be happy to disregard the actual positive sign and use negative numbers because that's how the math works. I really don't see why one should treat prices any differently from income in that respect. In fact, if ledger also flipped the sign of all entries on income accounts (and perhaps something else I can't think of off the top of my head), I'd at least find its behavior consistent and understand the reasoning behind it, even though I still wouldn't agree. |
I have a feature request that might be somewhat idiosyncratic, so I'm prepared to do most of the work myself, mainly asking for feedback and guidance.
My brain insists that the total cost or price of a lot is really a signed quantity (positive when you buy, negative when you sell), just like Ledger does internally. I'd like to have command-line switches to expose the internal sign of a total cost, separately for input and output to let you easily transform a journal from one format to the other either way. Here's my proposal for the output switch, which seems to be more straightforward than the input one. It worked as expected when I ran a couple of simple tests. I'll be happy to write some proper automated tests, document the new feature, and do whatever else is needed, but I'd like to first know if I'm going in the right direction at all.