# Refusals

> Every stable refusal code: when it happens and what to do.


Every error is a `Refusal` with a stable `code`, a `message`, and where available
`at` (file:line:column, a key path, or a usage id) and `fix`. Codes never change
meaning; match on them, not on messages.

## Compiling a book

| Code | When | Fix |
|---|---|---|
| `book.parse` | A file is not UTF-8 or not valid TOML | The message names line and column |
| `book.unknown-key` | A key the format does not define | The fix names the nearest valid key |
| `book.missing` | `book.toml`, the `[book]` header or a required key is missing | Add it |
| `book.invalid-value` | An amount, date, quantity, Takt or currency has the wrong form | Amounts are strings with a decimal point: `"49.99"` |
| `book.duplicate` | An id is defined twice, a kind is priced twice or draws on two allowances | Keep one |
| `book.reference` | A plan, kind, tax schedule or recurring item that is not defined | Define it or fix the name |
| `book.measure-mismatch` | Kinds of different measures in one charge or allowance | Split the charge |
| `book.negative-price` | A negative amount outside a discount | Use a discount |
| `book.limit` | Too many files, plans or tiers, a file over 1 MiB, an amount over 10¹² | Split the book |
| `book.eu-cap` | An intra-EU call or SMS price above Regulation (EU) 2015/2120 Art. 5a (rule `EU-2015-2120-5a-cap`) | Price at most 0,19 €/min or 0,06 €/SMS excluding VAT |

## Rating

| Code | When |
|---|---|
| `rate.unknown-plan` | The subscription's plan is not in the book |
| `rate.unknown-kind` | A usage kind the book does not define |
| `rate.unpriced-kind` | A usage kind the plan neither prices nor includes |
| `rate.outside-period` | A usage record dated outside the month or the contract |
| `rate.duplicate-usage` | Two usage records with the same id in one call |
| `rate.empty-id` | A usage record without an id |
| `rate.out-of-order` | A batch earlier than the previous batch of the period |
| `rate.no-tax-rate` | No VAT rate is valid on a date |
| `rate.overflow` | An amount or quantity exceeds the representable range |
| `rate.invalid-subscription` | The contract ends before it starts |

## Contracts

| Code | When | Rule |
|---|---|---|
| `contract.term-too-long` | A consumer contract binds for more than 24 months | `DE-TKG-56-1-term` |
| `contract.notice-too-long` | A consumer's notice before the end of the initial term exceeds one month | `DE-BGB-309-9-c-notice` |
| `contract.invalid-terms` | A term over 120 months or a notice over 24 months | — |
| `contract.addon-extends-term` | An add-on would extend the term without the customer's express consent | `DE-TKG-66-3-addon` |
| `subscription.transition` | A lifecycle step that is not allowed (e.g. restricting an ordered subscription) | — |

A refusal that a law decided carries the rule id in `rule`.

## Bills

| Code | When |
|---|---|
| `bill.unknown-book` | A plan assignment pins a price-book version that is not loaded; the account's bill is held |
| `bill.mixed-prices` | One account's subscriptions use gross and net books |

## Documents and letters

| Code | When |
|---|---|
| `document.issuer-invalid` | The operator's data lacks a field a bill must carry (§ 62 Abs. 1 TKG, § 14 Abs. 4 UStG) or has an invalid IBAN, BIC or creditor id; `at` names the field |
| `document.payment-invalid` | A direct debit without mandate reference, with an invalid IBAN, or without the operator's creditor id |
| `letter.not-applicable` | The renewal notice is asked for a business contract, a contract that does not renew, a terminated one, or after the last day to cancel |

## Totals and inputs

| Code | When |
|---|---|
| `totals.mixed-books` | Charges from another book were totalled with this one |
| `input.invalid` | A period string or a date has the wrong form |
