Anatomy of a scenario
A scenario has two parts:- Filters decide whether the scenario applies to a given document.
- Outputs describe what to attach to the document when the filters match.
bill/invoice), so a regime can hold one set of scenarios for invoices and a different set for orders or payments.
Filters
A scenario matches when every filter it defines is satisfied by the document. An empty filter is treated as “any value is fine”, so a scenario with no filters matches every document of the configured schema.| Filter | Matches against |
|---|---|
| Type | The document’s type (e.g. standard, corrective, credit-note). |
| Tags | Tags applied to the document via $tags (e.g. reverse-charge, simplified, self-billed). |
| Categories | The set of tax categories present across the document’s line, charge, and discount taxes (e.g. VAT, IGIC). |
| Extension key / code | A specific tax extension being present, optionally with a specific value. |
| Custom filter | A regime- or addon-defined function for cases the basic filters can’t express. |
Outputs
When a scenario matches, GOBL applies its outputs to the document:| Output | Where it lands |
|---|---|
| Note | Appended to the document’s tax.notes array. The note carries its own cat (category) and key, and notes with the same category-and-key pair are deduplicated. |
| Extensions | Merged into the document’s tax.ext map. Useful for addons that need to attach a code identifying the document under a reporting standard. |
| Codes | Made available through the scenario summary for downstream conversion processes; not auto-merged onto the document itself. |
How matching works
When you build a document:- GOBL collects every scenario defined by the document’s regime and any enabled addons for the document’s schema.
- Each scenario is evaluated against the document. All filters must match for the scenario to apply.
- For every matching scenario, the outputs are merged into the document. Notes are deduplicated by
cat+key; extensions overwrite any earlier value for the same key.