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 details)
Built Distribution
File details
Details for the file iouopt-0.1.0.tar.gz
.
File metadata
- Download URL: iouopt-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cc6dca988202790b86c899abb8aa7739d81d688dde001655eabbda4026ad76a |
|
MD5 | f8175fb44aa3322db29f97c3413c197f |
|
BLAKE2b-256 | ae84cb877b0e14bc40e6a93c5965f6982dd270e8de8f91e142989613b6b9eedf |
File details
Details for the file iouopt-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: iouopt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 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 | a8f587b1c622876b590045cfa8e9c9032b93808dd7d4b70af76ed406eaa241cd |
|
MD5 | 405adbff8c4292ee18b820a7911d772b |
|
BLAKE2b-256 | 0a2c850277bf2ff4627bd0d5132fb625e4e576bd989d17974c63d8a994c907b2 |