[GNC] Rounding & formulas

Adrien Monteleone adrien.monteleone at lusfiber.net
Wed Dec 23 11:03:56 EST 2020


The ability to use one split's value as the variable input to a 
subsequent split would be nice for many such formulas. (or say, the 
sum/average of all other splits as part of a formula)

The rounding issue aside, I think this enhancement would be quite useful 
and open up lots of possibilities.

I can't comment on the coding difficulty however, or the best way to 
implement it. (do you need to name the split to be used as a variable? 
will you instead refer to it as 'split1, split2' etc? Is this even 
possible with the way the current register code works?)

Regards,
Adrien

On 12/23/20 2:25 AM, Thomas Lenherr wrote:
> Thank you all for your responses.
> 
> For the record, this is for private bookkeeping purposes (mainly splitting
> costs for different things with roommates), and so regulations generally
> don't apply as accuracy to a cent is more than enough and I mostly just
> want to prevent having to fix imbalances often. Having done this for the
> past ~12 years, for anything between 5-10 monthly transactions, I was
> hoping to automate this ever so slightly more, as is the trend with
> software.
> 
> Given the late rounding, somebody mentioned the idea earlier that adding or
> subtracting 0.005 could be used to turn the "normal rounding" into either
> "rounding up" or "rounding down", I haven't tested that yet, but I suspect
> that could work, at least as long as the amount only has be split between
> two parties:
> 
> my_expense_amount = (total_amount / 2)  # Normal rounding
> roommates_expense_amount = (total_amount / 2) - 0.005  # Rounding down
> 
> This is a little messier than I hoped and only works well when splitting
> two-ways (when you do 3+-ways it gets a little trickier). I was wondering
> if any devs here could comment on the options to rather supporting a
> function to explicitly trigger the rounding early, that way the above could
> e.g. be written as:
> 
> roommates_expense_amount = (total_amount / 2)  # Or really any fraction
> could work with this
> my_expense_account = total_amount - roommates_expense_amount = total_amount
> - gnc_round(total_amount / 2)
> 
> I'm aware that custom functions can be added to fin.scm, but I didn't dig
> deep enough yet to understand how I could explicitly trigger the
> rounding-step from there, if at all. Plus it seemed like there's a slim
> chance this could be a useful function to include by default since gnucash
> doing rounding is an omnipresent operation.



More information about the gnucash-user mailing list