-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support more arithmetic in amount entry #34
Comments
Sure, good idea. It shouldn't be too hard to add the rest of basic arithmetic. |
This adds the ability to multiply amounts. It's currently implemented rather hackish, see the corresponding source comment. References #34
Yeah well... we currently let hledger parse the amounts and with the way the parser works and the existence of default commodities it's really hard to distinguish amounts from plain numbers. Multiplying amounts by amounts doesn't make sense either (or else you'd get €²), but that's what I implemented now in the hope that nobody will notice. Could you please try the features/amount-arith branch to see if it works for you? |
A possibly related WIP hledger PR: simonmichael/hledger#871 (comment) |
This adds the ability to multiply amounts. It's currently implemented rather hackish, see the corresponding source comment. References #34
This adds the ability to multiply amounts. It's currently implemented rather hackish, see the corresponding source comment. References #34
Sorry for the delayed reply, I missed the Github notification. I've just built the feature branch and tested multiplication. Works exactly as expected:
So, I can't reproduce the behavior you mentioned above, but that's a good thing I would say :) Let me know if I you need more testing. For now: thanks a lot, you've made me a even happier bookkeeper! |
Nice! We might get similar functionality into hledger core at some point. Use cases, like the one you gave, are helpful. Here's some syntax sugar for percentages I was thinking about:
|
Yes, that's what I meant. This should be a syntax error, but that's hard to do in the presence of default commodities.
Great to hear that it works for you! I'm still not sure whether I should merge this. On the one hand it solves a real problem now, on the other hand, it's implemented as a hack and I would rather wait for proper multiplication support in hledger-lib. |
How would associativity and commutativity work in this case? E.g what would |
How would associativity and commutativity work in this case? E.g what would 5 + 5 + 50%, 5 + 25%*2 or 2*5 + 50% be?
I was thinking it would operate on "the left operand, following usual precedence rules" HAND WAVE.
Probably it isn't worth the trouble.
|
This adds the ability to multiply amounts. It's currently implemented rather hackish, see the corresponding source comment. References #34
Good idea to provide basic arithmetic!! When I'm buying things in some shop I do divide total amount in few categories - e.g. food, cosmetic, gifts, misc etc. and then after summing some category I substract the rest from total amount as well as multiplying items in the same category... |
@hpdeifel Hi, absolutely love the idea - my use case is sharing expenses with other people, so IMO
|
Please add "+" operator too. |
Addition already works. |
As far as I'm aware it is only possible to calculate the amount of a posting based on the sum of multiple numbers. I'd like to suggest an enhancement: it would be superuseful for me - and I guess others as well - to be able to quickly calculate the amount of a posting by multiplying.
My usecase is this: some of the invoices I need to book only provide a subtotal amount for specific invoice items excluding VAT. I'm not working for an organization that has a VAT-status so I need to book these items including VAT. If I would be able to add these by simply entering
50*1.21
(Dutch VAT is 21%), that would speed up data entry considerably.If this is already possible, I'd like to know how of course. (I'm running hledger-iadd version 1.3.5 and hledger version 1.10). Thanks for considering.
The text was updated successfully, but these errors were encountered: