Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

iouopt-0.2.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page