# ontology_v0_1

## Scope

Базовая каноническая онтология бухгалтерского контура для MVP и assistant layer.

## Core Facts

### Posting (primary fact)

`Posting` — основной факт бухгалтерского отражения.

Required fields:
- `posting_id`
- `period`
- `document_id`
- `organization_id`
- `debit_account_id`
- `credit_account_id`
- `amount`
- `source_register`

Optional fields:
- `currency_id`
- `subconto_1`
- `subconto_2`
- `subconto_3`
- `content`
- `is_active`

### RegisterMovement (secondary fact)

`RegisterMovement` — вспомогательный факт трассировки, не второй источник истины для учета.

Required fields:
- `movement_id`
- `register_name`
- `period`
- `recorder_document_id`

Optional fields:
- `organization_id`
- `dimensions`
- `resources`
- `is_active`

### Document

Required fields:
- `document_id`
- `document_type`
- `number`
- `date`

Optional fields:
- `organization_id`
- `counterparty_id`
- `contract_id`
- `posted_flag`
- `author_id`
- `comment`
- `source_entity_set`

## Main Dimensions

- `Account`
- `SubcontoType`
- `Counterparty`
- `Contract`
- `Organization`
- `BankAccount`
- `Currency`
- `Item`

## Canonical Relations

- `Document -> creates -> Posting`
- `Posting -> basedOn -> Document`
- `Posting -> debitAccount -> Account`
- `Posting -> creditAccount -> Account`
- `Posting -> belongsTo -> Organization`
- `Posting -> hasCurrency -> Currency`
- `Posting -> usesSubcontoType -> SubcontoType`
- `Counterparty -> hasContract -> Contract`
- `Organization -> ownsBankAccount -> BankAccount`
- `Document -> referencesCounterparty -> Counterparty`
- `Document -> referencesContract -> Contract`
- `Document -> referencesOrganization -> Organization`
- `Document -> referencesBankAccount -> BankAccount`

## Modeling Rules

1. `Posting` и `RegisterMovement` не дублируют один и тот же факт без явного правила приоритета.
2. Каждая связь имеет `probe_status`: `direct|derivable|opaque|missing`.
3. Источник связи фиксируется через `source_evidence` (metadata, navigation link, key-based join, inference).
