Bug Create contract

This commit is contained in:
2026-05-14 17:11:54 +02:00
parent 18c0329a94
commit 160ec1544b
6 changed files with 101 additions and 77 deletions

View File

@@ -392,6 +392,18 @@ them with Python guards and SQL diagnostics.
</li>
<li style="margin:0.38rem 0;"><code>Lot.validate</code> creates the open <code>lot.qt</code> through <code>createVirtualPart</code>.
</li>
<li style="margin:0.38rem 0;">If the line is <code>created_by_code</code>:
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">it comes from a business workflow (<code>Create contracts</code>, matching, etc.);
</li>
<li style="margin:0.38rem 0;"><code>Lot.validate</code> does not create an automatic open <code>lot.qt</code>;
</li>
<li style="margin:0.38rem 0;">the workflow attaches or splits its source <code>lot.qt</code>;
</li>
<li style="margin:0.38rem 0;">the blocking check applies only after the workflow is stable.
</li>
</ul>
</li>
</ul>
### Updating `quantity_theorical`
@@ -615,6 +627,18 @@ them with Python guards and SQL diagnostics.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">Trigger rule:
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">block inconsistent final states;
</li>
<li style="margin:0.38rem 0;">do not block internal transient workflow states;
</li>
<li style="margin:0.38rem 0;">use <code>Lot.skip_quantity_consistency()</code> only around a sequence that restores the invariants afterwards;
</li>
<li style="margin:0.38rem 0;">call an explicit final check after the sequence.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">Non-zero orphan <code>lot.qt</code> block:
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;"><code>lot.qt.validate</code>
@@ -631,10 +655,20 @@ them with Python guards and SQL diagnostics.
</li>
<li style="margin:0.38rem 0;">shipping / unshipping;
</li>
<li style="margin:0.38rem 0;">matched <code>Create contracts</code>;
</li>
<li style="margin:0.38rem 0;">weighing.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">The <code>created_by_code</code> case is intentionally excluded from the immediate <code>Lot.validate</code> check:
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">the virtual lot is saved before the matched <code>lot.qt</code> is attached;
</li>
<li style="margin:0.38rem 0;">the invariant is checked by the final workflow guard.
</li>
</ul>
</li>
</ul>
### SQL Diagnostic

View File

@@ -391,6 +391,18 @@ puis les sécuriser par des checks Python et des diagnostics SQL.
</li>
<li style="margin:0.38rem 0;"><code>Lot.validate</code> crée le <code>lot.qt</code> ouvert via <code>createVirtualPart</code>.
</li>
<li style="margin:0.38rem 0;">Si la ligne est <code>created_by_code</code> :
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">elle provient d&#x27;un workflow métier (<code>Create contracts</code>, matching, etc.) ;
</li>
<li style="margin:0.38rem 0;"><code>Lot.validate</code> ne crée pas de <code>lot.qt</code> ouvert automatique ;
</li>
<li style="margin:0.38rem 0;">le workflow rattache ou subdivise son <code>lot.qt</code> source ;
</li>
<li style="margin:0.38rem 0;">le check bloquant s&#x27;applique seulement après stabilisation du workflow.
</li>
</ul>
</li>
</ul>
### Modification de `quantity_theorical`
@@ -614,6 +626,18 @@ puis les sécuriser par des checks Python et des diagnostics SQL.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">Règle de déclenchement :
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">bloquer les états finaux incohérents ;
</li>
<li style="margin:0.38rem 0;">ne pas bloquer les états transitoires internes d&#x27;un workflow ;
</li>
<li style="margin:0.38rem 0;">utiliser <code>Lot.skip_quantity_consistency()</code> uniquement autour d&#x27;une séquence qui rétablit ensuite les invariants ;
</li>
<li style="margin:0.38rem 0;">appeler un check final explicite après la séquence.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">Blocage <code>lot.qt</code> orphelin non zéro :
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;"><code>lot.qt.validate</code>
@@ -630,10 +654,20 @@ puis les sécuriser par des checks Python et des diagnostics SQL.
</li>
<li style="margin:0.38rem 0;">shipping / unshipping ;
</li>
<li style="margin:0.38rem 0;"><code>Create contracts</code> en mode matched ;
</li>
<li style="margin:0.38rem 0;">weighing.
</li>
</ul>
</li>
<li style="margin:0.38rem 0;">Le cas <code>created_by_code</code> est volontairement exclu du check immédiat <code>Lot.validate</code> :
<ul style="margin:0.65rem 0 1rem 1.35rem; padding-left:1rem; list-style-type:circle;">
<li style="margin:0.38rem 0;">le lot virtuel est sauvegardé avant que le <code>lot.qt</code> matched soit rattaché ;
</li>
<li style="margin:0.38rem 0;">l&#x27;invariant est contrôlé par le check final du workflow.
</li>
</ul>
</li>
</ul>
### Diagnostic SQL