# Wallets

Wallet data from the wallet service. Each wallet is owned by either a team or an operator (via `owner_id` and `owner_type`). A wallet is included if its owner matches a team or operator within the partner's scope. Soft-deleted wallets are excluded.

**SQL:** `wallets`

## Schema

| Column Name        | Data Type     | Description                                                                    |
|:-------------------|:--------------|:-------------------------------------------------------------------------------|
| **Primary ID**     |               |                                                                                |
| id                 | INTEGER       | Primary key, unique identifier for each wallet                                 |
| **Other IDs**      |               |                                                                                |
| country_id         | INTEGER       | Foreign key to the country table                                               |
| currency_id        | INTEGER       | Foreign key to the currency table                                              |
| owner_id           | INTEGER       | ID of the entity that owns this wallet (team or operator)                      |
| **Timestamps**     |               |                                                                                |
| created_at         | TIMESTAMP_NTZ | Timestamp when the wallet was created                                          |
| updated_at         | TIMESTAMP_NTZ | Timestamp when the wallet was last updated                                     |
| **Filters**        |               |                                                                                |
| is_team_match      | BOOLEAN       | True if the wallet belongs to a team within the partner's scope                |
| is_operator_match  | BOOLEAN       | True if the wallet belongs to an operator within the partner's scope           |
| **Attributes**     |               |                                                                                |
| currency_code      | VARCHAR       | Three-letter ISO currency code (e.g. USD, EUR)                                 |
| owner_type         | VARCHAR       | Type of the wallet owner: TEAM or OPERATOR                                     |
| primary            | INTEGER       | Indicates if this is the primary wallet (1 for yes, 0 for no)                  |

## Inclusion Criteria

A wallet is included if its `owner_id` matches a team or operator within the partner's scope. The owner is identified by `owner_type` (TEAM or OPERATOR).

Soft-deleted wallets are excluded at the base level.

## Data flow

| Upstream tables  | Downstream tables |
|:-----------------|:------------------|
| `teams`          | `wallet_balances` |
| `operators`      | `invoices`        |
