# E-Invoice Lines

One row per line item of the e-invoice documents in [E-Invoices](/docs/e_invoices). Amounts are in major units of the document currency, rounded to 2 decimals per line. Lines of credit notes carry negative quantities and amounts, as sent to the buyer.

**SQL:** `e_invoice_lines`

## Schema

| Column Name               | Data Type     | Description                                                                                                                                                      |
|:--------------------------|:--------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Primary ID**            |               |                                                                                                                                                                  |
| id                        | INTEGER       | Primary key, unique identifier of the document line                                                                                                              |
| **Other IDs**             |               |                                                                                                                                                                  |
| e_invoice_document_id     | INTEGER       | ID of the e-invoice document. References `e_invoices.id`                                                                                                         |
| **Timestamps**            |               |                                                                                                                                                                  |
| created_at                | TIMESTAMP_NTZ | Timestamp when the line was created                                                                                                                              |
| updated_at                | TIMESTAMP_NTZ | Timestamp when the line was last updated                                                                                                                         |
| deleted_at                | TIMESTAMP_NTZ | Timestamp when the line itself was soft deleted, null if not deleted                                                                                             |
| document_deleted_at       | TIMESTAMP_NTZ | Timestamp when the parent document was soft deleted, null if not deleted. Lines of deleted documents are not returned by the Partner API                         |
| **Item**                  |               |                                                                                                                                                                  |
| item_name                 | VARCHAR       | Name of the item charged for                                                                                                                                     |
| item_description          | VARCHAR       | Longer description of the item charged for                                                                                                                       |
| unit_code                 | VARCHAR       | UN/ECE Recommendation 20 code of the unit the quantity is measured in                                                                                            |
| quantity                  | FLOAT         | Quantity charged for, in `unit_code` units. Negative on credit notes                                                                                             |
| unit_price                | FLOAT         | Price per unit excluding VAT, in major units                                                                                                                     |
| **Tax**                   |               |                                                                                                                                                                  |
| tax_category              | VARCHAR       | VAT category applied to the line (for example standard, exempt, reverse charge)                                                                                  |
| tax_percent               | FLOAT         | VAT rate applied, as a percentage                                                                                                                                |
| tax_country_code          | VARCHAR       | ISO 3166-1 alpha-2 country whose VAT rules apply                                                                                                                 |
| **Amounts**               |               |                                                                                                                                                                  |
| net_amount                | NUMBER        | Line total excluding VAT, in major units (`quantity * unit_price`, rounded to 2 decimals); negative on credit notes                                              |
| vat_amount                | NUMBER        | VAT on the line, in major units; negative on credit notes                                                                                                        |
| gross_amount              | NUMBER        | Line total including VAT, in major units; negative on credit notes                                                                                               |
| **Status**                |               |                                                                                                                                                                  |
| document_status           | VARCHAR       | Status of the parent document, same values as `e_invoices.document_status` (`deleted`, `delivered`, `failed`, `draft`, `processing`, `pending`, `no_submission`) |

## Inclusion Criteria

A line is included if its parent document is in `e_invoices`, so the scope is the same: documents issued by your teams and operators. Lines of purged documents are kept, with `document_deleted_at` set. Filter on `document_status = 'delivered'` to keep the lines of documents the buyer received.

## Data flow

| Upstream tables  | Downstream tables |
|:-----------------|:------------------|
| `e_invoices`     | ---               |

## Alignment
### Monta API
- Aligns with the line items returned by the Monta API e-invoices endpoint (seller side only)
- Lines of soft-deleted documents are included here and never returned by the API
