Check tolerance
This commit is contained in:
@@ -288,8 +288,12 @@ them with Python guards and SQL diagnostics.
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">The check is performed during <code>Add physical lots</code>.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Matched forecast</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">If <code>lot_qt</code> carries both <code>lot_p</code> and <code>lot_s</code>, the check applies to both purchase and sale sides.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Line excess</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Confirmable warning in English when the projected physical quantity exceeds the current line tolerance.</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Confirmable warning in English when the projected physical quantity exceeds the current line tolerance. The message names the blocking side: <code>purchase</code>, <code>sale</code>, or both if both checks are triggered successively.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Global envelope</td>
|
||||
|
||||
@@ -287,8 +287,12 @@ puis les sécuriser par des checks Python et des diagnostics SQL.
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Le contrôle se fait au moment de <code>Add physical lots</code>.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Forecast matché</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Si <code>lot_qt</code> porte <code>lot_p</code> et <code>lot_s</code>, le contrôle porte sur les deux côtés achat et vente.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Dépassement ligne</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Warning confirmable en anglais si la quantité physique projetée dépasse la tolérance courante de la ligne.</td>
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Warning confirmable en anglais si la quantité physique projetée dépasse la tolérance courante de la ligne. Le message indique le côté bloquant : <code>purchase</code>, <code>sale</code>, ou les deux si les deux checks déclenchent successivement.</td>
|
||||
</tr>
|
||||
<tr style="border-bottom:1px solid #e0e0e0;">
|
||||
<td style="vertical-align:top; padding:0.5rem 0.7rem;">Enveloppe globale</td>
|
||||
|
||||
@@ -114,7 +114,8 @@ quantity_theorical
|
||||
| Inheritance | Lines inherit the header tolerance by default. |
|
||||
| Transport | No independent tolerance per transport. |
|
||||
| Physical lot addition | The check is performed during `Add physical lots`. |
|
||||
| Line excess | Confirmable warning in English when the projected physical quantity exceeds the current line tolerance. |
|
||||
| Matched forecast | If `lot_qt` carries both `lot_p` and `lot_s`, the check applies to both purchase and sale sides. |
|
||||
| Line excess | Confirmable warning in English when the projected physical quantity exceeds the current line tolerance. The message names the blocking side: `purchase`, `sale`, or both if both checks are triggered successively. |
|
||||
| Global envelope | A line excess is accepted after confirmation and consumes the contract-level envelope. |
|
||||
| Remaining tolerance | Contract lines are recalculated with `inherit_tol = False`. |
|
||||
| Over-execution | A line exceeding the header tolerance keeps a `+` tolerance at least equal to its actual excess. |
|
||||
|
||||
@@ -113,7 +113,8 @@ quantity_theorical
|
||||
| Héritage | Les lignes héritent de la tolérance header par défaut. |
|
||||
| Transport | Pas de tolérance indépendante par transport. |
|
||||
| Ajout physique | Le contrôle se fait au moment de `Add physical lots`. |
|
||||
| Dépassement ligne | Warning confirmable en anglais si la quantité physique projetée dépasse la tolérance courante de la ligne. |
|
||||
| Forecast matché | Si `lot_qt` porte `lot_p` et `lot_s`, le contrôle porte sur les deux côtés achat et vente. |
|
||||
| Dépassement ligne | Warning confirmable en anglais si la quantité physique projetée dépasse la tolérance courante de la ligne. Le message indique le côté bloquant : `purchase`, `sale`, ou les deux si les deux checks déclenchent successivement. |
|
||||
| Enveloppe globale | Le dépassement ponctuel d'une ligne est accepté après confirmation et consomme l'enveloppe globale du contrat. |
|
||||
| Tolérance restante | Les lignes du contrat sont recalculées avec `inherit_tol = False`. |
|
||||
| Surconsommation | Une ligne qui dépasse la tolérance header garde une tolérance `+` au moins égale à son dépassement réel. |
|
||||
|
||||
@@ -1420,14 +1420,25 @@ class LotQt(
|
||||
if Warning.check(warning_name):
|
||||
over_percent = (
|
||||
(projected - theoretical) / theoretical * Decimal(100))
|
||||
side = 'purchase'
|
||||
contract = getattr(line, 'purchase', None)
|
||||
if getattr(line, 'sale', None):
|
||||
side = 'sale'
|
||||
contract = line.sale
|
||||
contract_number = getattr(contract, 'number', None) or getattr(
|
||||
contract, 'id', None)
|
||||
raise LotToleranceWarning(
|
||||
warning_name,
|
||||
"The physical lot quantity exceeds the current tolerance "
|
||||
"for this line (projected quantity: %s, maximum with "
|
||||
"current tolerance: %s, projected tolerance: %s%%). "
|
||||
"on the %s side (contract: %s, line: %s, projected "
|
||||
"quantity: %s, maximum with current tolerance: %s, "
|
||||
"projected tolerance: %s%%). "
|
||||
"Do you want to continue and consume the contract "
|
||||
"tolerance envelope?"
|
||||
% (
|
||||
side,
|
||||
contract_number,
|
||||
getattr(line, 'id', None),
|
||||
round(projected, 5),
|
||||
round(max_quantity, 5),
|
||||
round(over_percent, 2),
|
||||
|
||||
Reference in New Issue
Block a user