# Tariffs

Contains tariff pricing and configuration data enriched with operator information.
This model combines tariff details with operator metadata to provide a comprehensive
view of pricing structures and their associated operators. Includes filtering 
capabilities for active tariffs and operator matching criteria.

**SQL:** `tariffs`

## Schema

| Column Name                       | Data Type     | Description                                                                               |
|:----------------------------------|:--------------|:------------------------------------------------------------------------------------------|
| **Primary ID**                    |               |                                                                                           |
| id                                | INTEGER       | Primary key                                                                               |
| **Other IDs**                     |               |                                                                                           |
| country_id                        | INTEGER       | References the country where this tariff applies                                          |
| country_area_id                   | INTEGER       | References the specific geographical area within the country for this tariff              |
| currency_id                       | INTEGER       | References the currency used for this tariff's pricing                                    |
| team_id                           | INTEGER       | References the team responsible for managing this tariff                                  |
| operator_id                       | INTEGER       | References the operator that owns or manages this tariff                                  |
| external_id                       | VARCHAR       | External system identifier used for integrations and API references                       |
| **Timestamps**                    |               |                                                                                           |
| created_at                        | TIMESTAMP_NTZ | Timestamp when the tariff record was initially created                                    |
| updated_at                        | TIMESTAMP_NTZ | Timestamp when the tariff record was last modified                                        |
| deleted_at                        | TIMESTAMP_NTZ | Timestamp when the tariff was soft deleted, null if still active                          |
| operator_deleted_at               | TIMESTAMP_NTZ | Timestamp when the associated operator was soft deleted, null if operator is still active |
| **Filters**                       |               |                                                                                           |
| is_active                         | BOOLEAN       | Indicates whether the tariff is currently available for new customers                     |
| **Attributes**                    |               |                                                                                           |
| name                              | VARCHAR       | Human-readable name or title of the tariff plan                                           |
| description                       | VARCHAR       | Detailed description of the tariff plan including terms and conditions                    |
| timezone                          | VARCHAR       | Timezone identifier used for time-based pricing calculations                              |
| customer_type                     | VARCHAR       | Category of customers this tariff is designed for (e.g., residential, commercial, fleet)  |
| prices_with_vat                   | BOOLEAN       | Indicates whether the tariff prices include VAT (true) or exclude VAT (false)             |
| type                              | VARCHAR       | Classification or category of the tariff structure                                        |
| area                              | VARCHAR       | Geographical area or region where this tariff is applicable                               |
| operator_is_main_operator_match   | BOOLEAN       | Indicates whether the associated operator matches the main operator criteria              |
| operator_is_parent_operator_match | BOOLEAN       | Indicates whether the associated operator matches the parent operator criteria            |

## Data inclusion criteria
This table works with `operators` table, requiring that `operator_id` is among the partner's `operators.id` records.

## Data flow 
| Upstream tables     | Downstream tables |
|:--------------------|:------------------|
| `operators` | ---               |

## Alignment
### Monta API
- Aligns with Monta API [get/tariffs](https://developer.monta.com/api/v1/tariffs/get) endpoint
