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 minimum-cost flow 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.
Install
Install the latest version from the Python Package Index (PyPI).
$ pip install iouopt
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.2.0.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file iouopt-0.2.0.tar.gz
.
File metadata
- Download URL: iouopt-0.2.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bec4128a9bf4e8b5a0015303a202ae8fb12998cd5f9354a798e500c51ab05e7 |
|
MD5 | 6cf358a8a134f6c7533601b76f3b1e8e |
|
BLAKE2b-256 | 3aa53237eed5d585b289b7067cec33060071b11a9cddccbd2f2f4144a2947d99 |
File details
Details for the file iouopt-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: iouopt-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1860c18c9f6090656ea35ce90be94e126bd7cfbe0e3b6f2b4b9452204ca41fd |
|
MD5 | 1fe0ea5d84b38f68f686b60efa292c63 |
|
BLAKE2b-256 | ea7e7a7d240f9d22003aaa8e1f19b38f84e9ebf0ff747343be5f3bf5aecaed47 |