fix(promotion, types): non discountable items check (#12644)

* fix(promotions): check if item is discountable

* fix: return earl yonly if non discountable

* fix: update test

* chore: add integration test
This commit is contained in:
Frane Polić authored and GitHub committed 2025-06-12 10:23:06 +02:00
1 parent 6be5750fe8
commit bd6d9777c5
5 files changed
+175 -1

No files matched your search

@@ -180,6 +180,11 @@ export interface ComputeActionItemLine extends Record<string, unknown> {
*/
subtotal: BigNumberInput
/**
* Whether the line item is discountable.
*/
is_discountable: boolean
/**
* The adjustments applied before on the line item.
*/
@@ -201,7 +201,15 @@ function getValidItemsForPromotion(
}
return items.filter((item) => {
if (!item || !("subtotal" in item) || MathBN.lte(item.subtotal, 0)) {
if (!item) {
return false
}
if ("is_discountable" in item && !item.is_discountable) {
return false
}
if (!("subtotal" in item) || MathBN.lte(item.subtotal, 0)) {
return false
}