# SettleUp Calculator Library

A custom Python library for calculating expense splits and settlements.

## Features

- Calculate expense splits using multiple methods:
  - Equal split
  - Percentage-based split
  - Exact amount split
- Calculate net balances for users
- Generate minimum settlement transactions

## Installation

```bash
pip install settleup-calculator
```

Or install from source:

```bash
python setup.py install
```

## Usage

### Basic Expense Split

```python
from settleup_calculator import ExpenseCalculator, SplitMethod
from decimal import Decimal

# Equal split
splits = ExpenseCalculator.calculate_split(
    total_amount=Decimal("100.00"),
    participants=["user1", "user2", "user3"],
    split_method=SplitMethod.EQUAL
)
# Result: {"user1": Decimal("33.33"), "user2": Decimal("33.33"), "user3": Decimal("33.34")}

# Percentage split
splits = ExpenseCalculator.calculate_split(
    total_amount=Decimal("100.00"),
    participants=["user1", "user2"],
    split_method=SplitMethod.PERCENTAGE,
    participant_data={
        "user1": {"percentage": 60},
        "user2": {"percentage": 40}
    }
)
# Result: {"user1": Decimal("60.00"), "user2": Decimal("40.00")}

# Exact split
splits = ExpenseCalculator.calculate_split(
    total_amount=Decimal("100.00"),
    participants=["user1", "user2", "user3"],
    split_method=SplitMethod.EXACT,
    participant_data={
        "user1": {"amount": 50},
        "user2": {"amount": 30},
        "user3": {"amount": 20}
    }
)
# Result: {"user1": Decimal("50.00"), "user2": Decimal("30.00"), "user3": Decimal("20.00")}
```

### Calculate Settlements

```python
from settleup_calculator import SplitCalculator

expenses = [
    {
        "paid_by": "user1",
        "amount": Decimal("100.00"),
        "participants": ["user1", "user2"],
        "split_method": "equal"
    },
    {
        "paid_by": "user2",
        "amount": Decimal("50.00"),
        "participants": ["user1", "user2"],
        "split_method": "equal"
    }
]

balances = SplitCalculator.calculate_balances(expenses)
settlements = SplitCalculator.calculate_settlements(balances)
```

## License

MIT License

