redstreet / beancount_reds_plugins

Miscellaneous plugins for Beancount double entry accounting
GNU General Public License v3.0
95 stars 18 forks source link

zerosum: allow cost units under EPSILON_DELTA/2 #15

Closed jaki closed 3 years ago

jaki commented 3 years ago

There is a bug when the cost of a zerosum posting is under half of EPSILON_DELTA (0.0099). When trying to find a matching posting, find_match looks at the same posting. If the absolute difference of the two postings is less than this delta, it says it's a match, and both postings' account names are changed. If the two postings refer to the same thing, we try to rename twice and get a

ValueError: list.remove(x): x not in list

on

txn.postings.remove(posting)

Fix this by avoiding looking at the same posting.

redstreet commented 3 years ago

Good catch, and thank you for the PR! Merged.

redstreet commented 3 years ago

Thanks for the test cases as well. Added to a new pytest in f410b452.