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:
co-authored by
Oli Juhl
parent
3fa1db9dea
commit
822217fa36
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user