fix(controllers): cast overproduced-qty flag to bool in subcontracting Case

The max-allowed-qty Case used `... | ValueWrapper(allow_delivery_of_overproduced_qty)`
where the flag is an int (0/1). Postgres rejects `OR <integer>` ("argument of
OR must be type boolean"). Wrap it in bool() so the literal renders as
true/false. MariaDB behaviour is unchanged.

Surgical: only the bool() wrap is applied; develop's weighted-average rate
logic and the internal/whitelisted status-helper split are left intact (the
staging branch predated both).

Covered by test_subcontracting_inward_order.test_over_production_delivery,
which now passes on Postgres and is unchanged on MariaDB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-21 05:28:12 +05:30
parent f95e32a581
commit 147a8672b4

View File

@@ -509,8 +509,9 @@ class SubcontractingInwardController:
(
Case()
.when(
# bool() so the literal renders as true/false; postgres rejects `OR <integer>`
(table.produced_qty < table.qty)
| ValueWrapper(allow_delivery_of_overproduced_qty),
| ValueWrapper(bool(allow_delivery_of_overproduced_qty)),
table.produced_qty,
)
.else_(table.qty)