# Charge calculations, pre-invoices and invoices

> From the reviewed calculation to the financial document, and the four status axes that describe an invoice.

Source: https://app.relvoerp.com/docs/product/en/invoicing-collections/

Between "the contract says X should be billed" and "a tax invoice for X exists" there are three distinct objects. Confusing them is the most common cause of billing errors.

**From calculation to document:** Charge calculation → Pre-invoice → Issued invoice → Applied payment

## Charge calculation

A **charge calculation** is the result of computing a period: contract + usage + prices + adjustments. It is not yet a document and has no tax effect.

A charge calculation can be recomputed as many times as needed. If late usage arrives, an event is corrected or the contract is adjusted before issuing, the calculation is recomputed and reflects the current state. That is precisely the moment when corrections are cheap.

## Pre-invoice

A **pre-invoice** is the detail of the charge calculation shared with the customer before issuing. It lets the customer validate it, issue their purchase order (OC, *orden de compra*) or obtain an internal approval.

Issuing without a pre-invoice is normal for simple contracts. For contracts that require an OC or a service acceptance sheet (HES, *hoja de entrada de servicio*), the pre-invoice is the step that obtains that evidence. See [OC, HES and approvals](https://app.relvoerp.com/docs/product/en/approvals-commercial-references.md).

## Invoice

An invoice is a financial record. Its status is not a single value: it is **four independent axes**, because an invoice can be accepted by the SII (Chile's tax authority), not yet delivered to the customer and partially paid, all at once.

> **Shortcut: Four axes, not one combined status**
>
> Relvo never combines these axes into a single value like `EMITIDA_PENDIENTE_SII_IMPAGA`. Each axis advances on its own, and any valid combination can be represented without inventing new statuses.

### Axis 1 — Lifecycle

Where the document is in its life as a document.

| Status | Meaning |
| --- | --- |
| `upcoming` | The period has not closed yet |
| `draft` | Draft. Editable, no tax effect |
| `open` | Issued. A financial record, no longer editable |
| `partially_voided` | Issued and partially reversed by a credit note |
| `void` | Issued and then fully reversed |
| `cancelled` | Discarded before issuance. Never had a fiscal footprint |

> **Caution: `void` and `cancelled` are not synonyms**
>
> - **`cancelled`** — the document was never issued. It never existed for tax purposes and leaves no fiscal trail.
> - **`void`** — the document **was** issued and then reversed with a credit note. The original document still exists and can still be looked up.
>
> Only a draft can be cancelled. An issued invoice can only be voided, and that means issuing a second document.

The valid transitions are:

```
upcoming → draft → open → void
                   open → partially_voided → void
upcoming | draft → cancelled
```

### Axis 2 — Fiscal status

What the tax authority said about the document.

| Status | Meaning |
| --- | --- |
| `not_submitted` | Not yet submitted |
| `pending` | Submitted, no response yet |
| `accepted` | Accepted by the authority |
| `rejected` | Rejected. Requires correction and resubmission |

> **Caution: `pending` is not an error, and retrying does not resolve it**
>
> An invoice in `pending` has already been submitted. Resubmitting it can produce a duplicate document with its own folio number, which then has to be voided. When an issuance is stuck in `pending`, the right path is to reconcile with the provider to find out what happened, not to retry blindly.

### Axis 3 — Delivery

Whether the document reached the customer.

| Status | Meaning |
| --- | --- |
| `not_sent` | Not sent |
| `send_requested` | Sending requested, still queued |
| `sent_to_provider` | Handed off to the email provider |
| `delivered` | Confirmed as delivered |
| `delivery_failed` | Sending failed |

`send_requested` does not mean "sent": it means "queued". The difference matters when a customer claims they never received their invoice.

### Axis 4 — Payment

How much has been collected.

| Status | Meaning |
| --- | --- |
| `unpaid` | No payments applied |
| `partially_paid` | Partly paid |
| `paid` | Settled |

> **Key rule: Overdue is not a payment status**
>
> An overdue invoice is an unsettled invoice whose due date has passed. Relvo **derives** this from the due date and the balance instead of storing it as a status. A stored status becomes a lie the moment someone pays: the balance says one thing and the column says another. A derived value never contradicts the data.

## Document types

| Type | Use | SII code |
| --- | --- | --- |
| Domestic | Domestic sale | 33 (taxable, *afecta*) · 34 (exempt, *exenta*) |
| Export | Sale abroad | 110 |
| Receipt (*boleta*) | Sale to an end consumer | 39 · 41 (exempt) |

## Origin

Every invoice records where it came from: a billing cycle (`billing_run`), a one-off issuance outside a contract (`one_off`), or an import of documents already issued in another system (`imported_issued_invoice`). The origin is what lets you distinguish what Relvo calculated from what Relvo only recorded.

## Editing before issuing

A draft can be edited: add and remove lines, group them, adjust names, correct the currency conversion. Relvo records whether the draft body is the one **generated** by the calculation or was **edited by an operator**, so that a later recalculation does not silently overwrite a deliberate manual adjustment.

**Example: Acme, July close**

| Item | Amount |
| --- | --- |
| Platform (in advance) | USD 1,000.00 |
| AI conversations — 8,420 tiered (in arrears) | USD 639.40 |
| **Invoice total** | **USD 1,639.40** |

One period, one document, two charges with opposite timing. A later payment of USD 1,000 leaves it `partially_paid` with a USD 639.40 balance.

## API

Invoices live at `/api/v1/public/invoices` (scopes `invoices:read` and `invoices:write`). Actions are dedicated, named endpoints: `/issue`, `/cancel` and `/duplicate`. There are also subresources for `lines`, `line-groups`, `commercial-references`, `suppressed-lines` (with `/restore`) and `versions/{version}`, and downloads at `/pdf` and `/xml`. Every `POST` requires an `Idempotency-Key`, and every write to an existing invoice requires `If-Match`. Lists return `{items, next_cursor}`.

- [Credit and debit notes](https://app.relvoerp.com/docs/product/en/credit-debit-notes.md): How an already-issued invoice is corrected.
- [Payments and reconciliation](https://app.relvoerp.com/docs/product/en/payments-reconciliation.md): How money received is applied to documents.
- [OC, HES and approvals](https://app.relvoerp.com/docs/product/en/approvals-commercial-references.md): The evidence that can block issuance.
- [Messaging](https://app.relvoerp.com/docs/product/en/communications.md): How documents are sent to the customer.
