Fix less than desired filter

This commit is contained in:
Fabian Wunsch 2025-10-06 07:46:11 +02:00
parent e6b1b533a8
commit 2e32bdd0af

View file

@ -31,7 +31,7 @@ class LessThanDesiredConstraint extends BooleanConstraint
public function __construct(?string $property = null, ?string $identifier = null, ?bool $default_value = null) public function __construct(?string $property = null, ?string $identifier = null, ?bool $default_value = null)
{ {
parent::__construct($property ?? '( parent::__construct($property ?? '(
SELECT COALESCE(SUM(ld_partLot.amount), 0.0) SELECT COALESCE(SUM(ld_partLot.amount) + part.orderamount, 0.0)
FROM '.PartLot::class.' ld_partLot FROM '.PartLot::class.' ld_partLot
WHERE ld_partLot.part = part.id WHERE ld_partLot.part = part.id
AND ld_partLot.instock_unknown = false AND ld_partLot.instock_unknown = false
@ -48,9 +48,9 @@ class LessThanDesiredConstraint extends BooleanConstraint
//If value is true, we want to filter for parts with stock < desired stock //If value is true, we want to filter for parts with stock < desired stock
if ($this->value) { if ($this->value) {
$queryBuilder->andHaving($this->property . ' + part.orderamount < part.minamount'); $queryBuilder->andHaving($this->property . ' < part.minamount');
} else { } else {
$queryBuilder->andHaving($this->property . ' + part.orderamount >= part.minamount'); $queryBuilder->andHaving($this->property . ' >= part.minamount');
} }
} }
} }