This commit is contained in:
2026-05-14 11:20:33 +02:00
parent 355831c76d
commit 2b3c823743
41 changed files with 2101 additions and 554 deletions

View File

@@ -1,3 +1,5 @@
<!-- Generated from docs_source/business by docs/tools/render_business_docs.py. -->
# SQL diagnostics for purchase_trade business rules
These scripts are read-only diagnostics for a PostgreSQL test database.
@@ -23,24 +25,34 @@ reported as anomalous.
Run it on a restored test database:
```sql
\i modules/purchase_trade/docs/business/sql/quantity_consistency_checks.sql
```
<pre style="background:#263238; color:#eef7ff; padding:1rem; border-radius:0.35rem; overflow:auto;"><code>\i modules/purchase_trade/docs/business/sql/quantity_consistency_checks.sql</code></pre>
The script returns rows only when it finds a potential issue.
Main columns:
- `check_name`: invariant or diagnostic that failed.
- `contract_model`: `purchase.purchase` or `sale.sale`.
- `contract_id`: database id of the contract.
- `contract_number`: purchase or sale contract number.
- `line_id`: `purchase.line` or `sale.line` id depending on the check.
- `virtual_lot_id`: virtual lot involved in the inconsistency.
- `observed_value`: value found in the database.
- `expected_value`: value required by the business rule.
- `diff`: observed minus expected.
- `detail`: human-readable explanation.
<ul style="margin:0.65rem 0 1rem 1.1rem; padding-left:1rem; list-style-type:disc;">
<li style="margin:0.38rem 0;"><code>check_name</code>: invariant or diagnostic that failed.
</li>
<li style="margin:0.38rem 0;"><code>contract_model</code>: <code>purchase.purchase</code> or <code>sale.sale</code>.
</li>
<li style="margin:0.38rem 0;"><code>contract_id</code>: database id of the contract.
</li>
<li style="margin:0.38rem 0;"><code>contract_number</code>: purchase or sale contract number.
</li>
<li style="margin:0.38rem 0;"><code>line_id</code>: <code>purchase.line</code> or <code>sale.line</code> id depending on the check.
</li>
<li style="margin:0.38rem 0;"><code>virtual_lot_id</code>: virtual lot involved in the inconsistency.
</li>
<li style="margin:0.38rem 0;"><code>observed_value</code>: value found in the database.
</li>
<li style="margin:0.38rem 0;"><code>expected_value</code>: value required by the business rule.
</li>
<li style="margin:0.38rem 0;"><code>diff</code>: observed minus expected.
</li>
<li style="margin:0.38rem 0;"><code>detail</code>: human-readable explanation.
</li>
</ul>
Cross-category UoM rows are reported as manual-review diagnostics because the
Python code may pass explicit conversion factors that cannot be inferred safely