fix(pricing): fix pricing query when max_quantity is null (#12981)

what: 

Prices when max_quantity value is null is accounted for when quantity is passed in context.

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2025-07-21 06:34:58 +00:00
committed by GitHub
co-authored by Oli Juhl
parent 3fa1db9dea
commit 822217fa36
3 changed files with 77 additions and 3 deletions
@@ -126,14 +126,24 @@ export class PricingRepository
if (quantity !== undefined) {
query.andWhere(function (this: Knex.QueryBuilder) {
this.where(function (this: Knex.QueryBuilder) {
this.orWhere(function (this: Knex.QueryBuilder) {
this.where("price.min_quantity", "<=", quantity).andWhere(
"price.max_quantity",
">=",
quantity
)
}).orWhere(function (this: Knex.QueryBuilder) {
this.whereNull("price.min_quantity").whereNull("price.max_quantity")
this.orWhere("price.min_quantity", "<=", quantity).whereNull(
"price.max_quantity"
)
this.orWhereNull("price.min_quantity").whereNull("price.max_quantity")
this.orWhereNull("price.min_quantity").andWhere(
"price.max_quantity",
">=",
quantity
)
})
})
} else {