Simplify group IOU settlement.
Project description
iouopt
iouopt
simplifies group IOU settlement. If you've used Splitwise or similar apps, you're familiar with the concept.
Usage
import iouopt import Journal
j = Journal[str]()
j.append(borrower="A", lender="B", amount=5)
j.append("A", "C", 15)
j.append("B", "A", 10)
j.append("B", "C", 5)
j.append("C", "A", 20)
j.append("C", "B", 15)
for borrower, lender, amount in j.simplify():
print(f"#=> {borrower} pays {lender} {amount}")
#=> C pays A 10
#=> C pays B 5
Note: iouopt
requires that all amounts are represented as an int
. This is a constraint of the underlying network simplex algorithm. If you need to express partial units, such as 15.78, multiply amounts by a suitable constant factor (e.g., 100) and then convert them to an int.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
iouopt-0.1.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
iouopt-0.1.0-py3-none-any.whl
(4.2 kB
view hashes)