reproducible, & possibly configurable rounding
Bradley M. Kuhn
bkuhn at sfconservancy.org
Thu May 8 11:03:04 EDT 2014
Josh Berkus wrote at 19:51 (EDT) on Wednesday:
> ???
> Ledger is written in Python
I respond with ??? in response, since Ledger-CLI is written in C++. :)
> Imagine that a particular kind of revenue gets automatically split
> evenly between 4 earmarks. Then you receive $14.21 in that account.
> How do you split it so that you don't lose a penny?
This is an interesting case that I wasn't even worried about yet, but
it's important to eventually deal with that.
I am not sure if we'd use Ledger-CLI itself to compute this or not.
Maybe we should?
(Ledger-CLI does have features to automatically split transactions. I
haven't been using them for earmarks and 10% back to the fiscal sponsor
in part because I'd historically avoided Ledger-CLI's automatic
transaction features for reasons that may now be moot).
> - split amount naively, rounding to two decimals (for USD)
> - compare that against the original amount
> - figure out the number of "lost" pennies
> - reassign those pennies to the splits, based on random selection with
> the probability of each penny being assigned to a split as the % of that
> split, with no duplicates.
This algorithm seems right. We could also keep track of who got the
pennies last time to avoid the randomness. Although perhaps that's
overkill.
A first step might to be investigate how Ledger-CLI's automated splits
handle this.
--
Bradley M. Kuhn, President, Software Freedom Conservancy
More information about the npo-accounting
mailing list