adamcharnock / django-hordak

Double entry accounting in Django
http://django-hordak.readthedocs.io
MIT License
231 stars 55 forks source link

Improvements to ratio_split() #38

Closed damiendr closed 4 years ago

damiendr commented 5 years ago

The current implementation of ratio_split() distributes any change left after rounding to the last participant.

This causes two minor issues:

This PR fixes this by using the Largest Remainder method to allocate change between participants with a ratio != 0.

It also fixes a further problem whereby ratio_split() assumed DECIMAL_PLACES=2.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.05%) to 95.433% when pulling 92423c930d5e0cd8512ae7373ec3f6ceef9bb7fc on damiendr:better_ratio_split into 0ffcad1d3b388b860c8c47fde12aa40df213066f on adamcharnock:master.

adamcharnock commented 4 years ago

Hi @damiendr! Thank you for this, and sorry for taking so long to get back to you. I've merged this now and it should be released soon.

adamcharnock commented 4 years ago

Released in 1.10.0, which also drops support for Python 3.5 and includes #40