Skip to main content

No project description provided

Project description

sharepay — split expenses, settle debts, and convert currencies

sharepay is a Python expense-splitting library and command-line tool for group trips, shared bills, and reimbursements. Import expenses from CSV or Google Sheets, split each payment across members, convert currencies with live exchange rates, and print the transactions needed to settle up.

Features

  • Split group expenses equally across payment members.
  • Calculate who owes whom and produce settlement transactions.
  • Use max-debtor settlement by default, where the largest net debtor coordinates remittances.
  • Import payments from CSV files or public Google Sheets.
  • Convert multi-currency expenses into one settlement currency.
  • Merge duplicate people with aliases such as johnny=john.
  • Use as a Typer CLI or as a Python library.

Installation

Requires Python 3.11 or newer.

pip install sharepay

For local development from this repository:

uv sync
uv run sharepay --help

Quick start: settle expenses from CSV

Create an expenses.csv file with the required columns: amount, payer, members, and currency.

amount,payer,members,currency
300,alice,"alice,bob,cara",TWD
200,bob,"bob,cara",TWD

Run the settlement calculator:

sharepay settle --file expenses.csv --currency TWD

sharepay prints member balances and the transactions needed to settle the group.

Google Sheets import

Use a public Google Sheets sharing URL, CSV URL, or export URL with the same payment columns:

sharepay settle \
  --sheet "https://docs.google.com/spreadsheets/d/<sheet-id>/edit#gid=0" \
  --currency TWD

The sheet is read as CSV. Make sure it contains:

Column Description
amount Payment amount, with optional thousands separators
payer Person who paid
members Comma-separated people sharing the payment
currency Payment currency code

Common CLI options

sharepay settle --file expenses.csv
sharepay settle \
  --sheet "https://docs.google.com/spreadsheets/d/<sheet-id>/edit#gid=0"
sharepay settle --file expenses.csv --currency USD
sharepay settle --file expenses.csv --settlement-method relay
sharepay settle --file expenses.csv --alias "johnny=john" --alias "jon=john"

Supported settlement currencies are EUR, GBP, JPY, TWD, USD, and CAD. The default settlement currency is TWD.

Settlement methods

sharepay settle uses --settlement-method max-debtor by default, where the member with the largest net debt sends money to every net creditor first; other debtors then reimburse that member. Use --settlement-method relay for the original settlement flow where one member may receive money and forward part of it to another member.

Python API example

from sharepay import Currency
from sharepay import ExpenseGroup

group = ExpenseGroup(name="trip", currency=Currency.TWD)
group.add_payment(
    amount=300,
    currency=Currency.TWD,
    payer="alice",
    members=["alice", "bob", "cara"],
)
group.add_payment(
    amount=200,
    currency=Currency.TWD,
    payer="bob",
    members=["bob", "cara"],
)

for transaction in group.settle_up():
    print(transaction)

Use group.settle_up(method="relay") to choose the relay method from Python.

Output:

cara   -> alice      200.00 TWD

How sharepay works

  1. Each payment is split equally among the listed members.
  2. The payer is credited for the shares paid on behalf of others.
  3. Expenses in other currencies are converted into the settlement currency with live exchange rates.
  4. Optional aliases canonicalize repeated names before balances are settled.
  5. settle_up() returns the transactions needed to bring balances back to zero, using max-debtor settlement by default or relay settlement when selected.

Development

Useful commands from the repository root:

uv sync
just lint
just type
just test
prek run -a

CI runs Ruff, ty, and pytest on Python 3.13. Before publishing, build a wheel with:

uv build --wheel

License

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharepay-0.5.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file sharepay-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: sharepay-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sharepay-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dac771d66be5fa79ed029a8e2fc2b3e84f7bf1f797646a3dec38c394d4bf519
MD5 4e75807f3d8590cfea3f820e527f2bac
BLAKE2b-256 c23884ae58c43b2e86de91ab0eca26f1c8bb6aee2dd23ab1a02b600e17b853e9

See more details on using hashes here.

Supported by

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