Fix(medusa): make shipping option requirements tax inclusive if the shipping option is (#2544)
**What** - validate shipping option requirements including tax if the shipping option is tax inclusive **Testing** - " given a cart with total above min-threshold and subtotal below min-threshold shipping option with tax inclusive pricing is available and can be applied" - "given a cart with total above max-threshold and subtotal below max-threshold shipping option with tax inclusive pricing is not available" Fixes CORE-752
This commit is contained in:
1 parent
a68af8a474
commit
434b11af46
4 files changed
+316
-145
No files matched your search
@@ -3,9 +3,18 @@ const { Region, ShippingProfile, ShippingOption } = require("@medusajs/medusa")
|
|||||||
|
|
||||||
const setupServer = require("../../../helpers/setup-server")
|
const setupServer = require("../../../helpers/setup-server")
|
||||||
const { useApi } = require("../../../helpers/use-api")
|
const { useApi } = require("../../../helpers/use-api")
|
||||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
const { useDb } = require("../../../helpers/use-db")
|
||||||
const cartSeeder = require("../../helpers/cart-seeder")
|
const cartSeeder = require("../../helpers/cart-seeder")
|
||||||
const swapSeeder = require("../../helpers/swap-seeder")
|
const swapSeeder = require("../../helpers/swap-seeder")
|
||||||
|
const {
|
||||||
|
simpleRegionFactory,
|
||||||
|
simpleShippingOptionFactory,
|
||||||
|
simpleCartFactory,
|
||||||
|
simpleProductFactory,
|
||||||
|
} = require("../../factories")
|
||||||
|
const {
|
||||||
|
default: startServerWithEnvironment,
|
||||||
|
} = require("../../../helpers/start-server-with-environment")
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -13,76 +22,235 @@ describe("/store/shipping-options", () => {
|
|||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
|
|
||||||
beforeAll(async () => {
|
describe("tax exclusive", () => {
|
||||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
beforeAll(async () => {
|
||||||
dbConnection = await initDb({ cwd })
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||||
medusaProcess = await setupServer({ cwd })
|
const [process, conn] = await startServerWithEnvironment({
|
||||||
})
|
cwd,
|
||||||
|
env: { MEDUSA_FF_TAX_INCLUSIVE_PRICING: true },
|
||||||
afterAll(async () => {
|
|
||||||
const db = useDb()
|
|
||||||
await db.shutdown()
|
|
||||||
medusaProcess.kill()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("POST /store/shipping-options", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
const manager = dbConnection.manager
|
|
||||||
await manager.query(
|
|
||||||
`ALTER SEQUENCE order_display_id_seq RESTART WITH 111`
|
|
||||||
)
|
|
||||||
|
|
||||||
await manager.insert(Region, {
|
|
||||||
id: "region",
|
|
||||||
name: "Test Region",
|
|
||||||
currency_code: "usd",
|
|
||||||
tax_rate: 0,
|
|
||||||
})
|
})
|
||||||
await manager.insert(Region, {
|
medusaProcess = process
|
||||||
|
dbConnection = conn
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
const db = useDb()
|
||||||
|
await db.shutdown()
|
||||||
|
medusaProcess.kill()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("POST /store/shipping-options", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
const manager = dbConnection.manager
|
||||||
|
await manager.query(
|
||||||
|
`ALTER SEQUENCE order_display_id_seq RESTART WITH 111`
|
||||||
|
)
|
||||||
|
|
||||||
|
await manager.insert(Region, {
|
||||||
|
id: "region",
|
||||||
|
name: "Test Region",
|
||||||
|
currency_code: "usd",
|
||||||
|
tax_rate: 0,
|
||||||
|
})
|
||||||
|
await manager.insert(Region, {
|
||||||
|
id: "region2",
|
||||||
|
name: "Test Region 2",
|
||||||
|
currency_code: "usd",
|
||||||
|
tax_rate: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||||
|
type: "default",
|
||||||
|
})
|
||||||
|
|
||||||
|
await manager.insert(ShippingOption, {
|
||||||
|
id: "test-out",
|
||||||
|
name: "Test out",
|
||||||
|
profile_id: defaultProfile.id,
|
||||||
|
region_id: "region",
|
||||||
|
provider_id: "test-ful",
|
||||||
|
data: {},
|
||||||
|
price_type: "flat_rate",
|
||||||
|
amount: 2000,
|
||||||
|
is_return: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
await manager.insert(ShippingOption, {
|
||||||
|
id: "test-return",
|
||||||
|
name: "Test ret",
|
||||||
|
profile_id: defaultProfile.id,
|
||||||
|
region_id: "region",
|
||||||
|
provider_id: "test-ful",
|
||||||
|
data: {},
|
||||||
|
price_type: "flat_rate",
|
||||||
|
amount: 1000,
|
||||||
|
is_return: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
await manager.insert(ShippingOption, {
|
||||||
|
id: "test-region2",
|
||||||
|
name: "Test region 2",
|
||||||
|
profile_id: defaultProfile.id,
|
||||||
|
region_id: "region2",
|
||||||
|
provider_id: "test-ful",
|
||||||
|
data: {},
|
||||||
|
price_type: "flat_rate",
|
||||||
|
amount: 1000,
|
||||||
|
is_return: false,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
const db = useDb()
|
||||||
|
await db.teardown()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("retrieves all shipping options", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get("/store/shipping-options")
|
||||||
|
.catch((err) => {
|
||||||
|
return err.response
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.shipping_options.length).toEqual(3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("creates a return with shipping method", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get("/store/shipping-options?is_return=true")
|
||||||
|
.catch((err) => {
|
||||||
|
return err.response
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.shipping_options.length).toEqual(1)
|
||||||
|
expect(response.data.shipping_options[0].id).toEqual("test-return")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("creates a return with shipping method", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get("/store/shipping-options?region_id=region2")
|
||||||
|
.catch((err) => {
|
||||||
|
return err.response
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.shipping_options.length).toEqual(1)
|
||||||
|
expect(response.data.shipping_options[0].id).toEqual("test-region2")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("GET /store/shipping-options/:cart_id", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await cartSeeder(dbConnection)
|
||||||
|
await swapSeeder(dbConnection)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
const db = useDb()
|
||||||
|
await db.teardown()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("given a default cart, when user retrieves its shipping options, then should return a list of shipping options", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get("/store/shipping-options/test-cart-2")
|
||||||
|
.catch((err) => {
|
||||||
|
return err.response
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.shipping_options).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ id: "test-option", amount: 1000 }),
|
||||||
|
expect.objectContaining({ id: "test-option-2", amount: 500 }),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("given a cart with custom shipping options, when user retrieves its shipping options, then should return the list of custom shipping options", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const response = await api
|
||||||
|
.get("/store/shipping-options/test-cart-rma")
|
||||||
|
.catch((err) => {
|
||||||
|
return err.response
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toEqual(200)
|
||||||
|
expect(response.data.shipping_options).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "test-option",
|
||||||
|
amount: 0,
|
||||||
|
name: "test-option",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("Tax inclusive GET /store/shipping-options/:cart_id", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||||
|
const [process, conn] = await startServerWithEnvironment({
|
||||||
|
cwd,
|
||||||
|
env: { MEDUSA_FF_TAX_INCLUSIVE_PRICING: true },
|
||||||
|
})
|
||||||
|
medusaProcess = process
|
||||||
|
dbConnection = conn
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
const db = useDb()
|
||||||
|
await db.shutdown()
|
||||||
|
medusaProcess.kill()
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await simpleRegionFactory(dbConnection, {
|
||||||
id: "region2",
|
id: "region2",
|
||||||
name: "Test Region 2",
|
name: "Test Region 2",
|
||||||
currency_code: "usd",
|
currency_code: "usd",
|
||||||
tax_rate: 0,
|
tax_rate: 10,
|
||||||
|
includes_tax: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
await simpleShippingOptionFactory(dbConnection, {
|
||||||
type: "default",
|
|
||||||
})
|
|
||||||
|
|
||||||
await manager.insert(ShippingOption, {
|
|
||||||
id: "test-out",
|
|
||||||
name: "Test out",
|
|
||||||
profile_id: defaultProfile.id,
|
|
||||||
region_id: "region",
|
|
||||||
provider_id: "test-ful",
|
|
||||||
data: {},
|
|
||||||
price_type: "flat_rate",
|
|
||||||
amount: 2000,
|
|
||||||
is_return: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
await manager.insert(ShippingOption, {
|
|
||||||
id: "test-return",
|
|
||||||
name: "Test ret",
|
|
||||||
profile_id: defaultProfile.id,
|
|
||||||
region_id: "region",
|
|
||||||
provider_id: "test-ful",
|
|
||||||
data: {},
|
|
||||||
price_type: "flat_rate",
|
|
||||||
amount: 1000,
|
|
||||||
is_return: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
await manager.insert(ShippingOption, {
|
|
||||||
id: "test-region2",
|
|
||||||
name: "Test region 2",
|
|
||||||
profile_id: defaultProfile.id,
|
|
||||||
region_id: "region2",
|
region_id: "region2",
|
||||||
provider_id: "test-ful",
|
includes_tax: true,
|
||||||
data: {},
|
price: 100,
|
||||||
price_type: "flat_rate",
|
requirements: [{ type: "min_subtotal", amount: 100 }],
|
||||||
amount: 1000,
|
})
|
||||||
is_return: false,
|
await simpleShippingOptionFactory(dbConnection, {
|
||||||
|
region_id: "region2",
|
||||||
|
includes_tax: true,
|
||||||
|
price: 150,
|
||||||
|
requirements: [{ type: "max_subtotal", amount: 150 }],
|
||||||
|
})
|
||||||
|
|
||||||
|
await simpleProductFactory(dbConnection, {
|
||||||
|
variants: [
|
||||||
|
{ id: "variant-1", prices: [{ currency: "usd", amount: 95 }] },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
await simpleProductFactory(dbConnection, {
|
||||||
|
variants: [
|
||||||
|
{ id: "variant-2", prices: [{ currency: "usd", amount: 145 }] },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
const cart = await simpleCartFactory(dbConnection, {
|
||||||
|
id: "test-cart",
|
||||||
|
region: "region2",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -91,91 +259,86 @@ describe("/store/shipping-options", () => {
|
|||||||
await db.teardown()
|
await db.teardown()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("retrieves all shipping options", async () => {
|
it("given a cart with total above min-threshold and subtotal below min-threshold shipping option with tax inclusive pricing is available and can be applied", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
|
|
||||||
const response = await api.get("/store/shipping-options").catch((err) => {
|
// create line item
|
||||||
return err.response
|
const { data } = await api.post(`/store/carts/test-cart/line-items`, {
|
||||||
|
variant_id: "variant-1",
|
||||||
|
quantity: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(data.cart.subtotal).toEqual(95)
|
||||||
expect(response.data.shipping_options.length).toEqual(3)
|
expect(data.cart.total).toEqual(105)
|
||||||
})
|
|
||||||
|
|
||||||
it("creates a return with shipping method", async () => {
|
const res = await api.get(`/store/shipping-options/test-cart`)
|
||||||
const api = useApi()
|
|
||||||
|
|
||||||
const response = await api
|
expect(res.data.shipping_options.length).toEqual(2)
|
||||||
.get("/store/shipping-options?is_return=true")
|
expect(res.data.shipping_options).toEqual(
|
||||||
.catch((err) => {
|
|
||||||
return err.response
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
|
||||||
expect(response.data.shipping_options.length).toEqual(1)
|
|
||||||
expect(response.data.shipping_options[0].id).toEqual("test-return")
|
|
||||||
})
|
|
||||||
|
|
||||||
it("creates a return with shipping method", async () => {
|
|
||||||
const api = useApi()
|
|
||||||
|
|
||||||
const response = await api
|
|
||||||
.get("/store/shipping-options?region_id=region2")
|
|
||||||
.catch((err) => {
|
|
||||||
return err.response
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
|
||||||
expect(response.data.shipping_options.length).toEqual(1)
|
|
||||||
expect(response.data.shipping_options[0].id).toEqual("test-region2")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("GET /store/shipping-options/:cart_id", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await cartSeeder(dbConnection)
|
|
||||||
await swapSeeder(dbConnection)
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
const db = useDb()
|
|
||||||
await db.teardown()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("given a default cart, when user retrieves its shipping options, then should return a list of shipping options", async () => {
|
|
||||||
const api = useApi()
|
|
||||||
|
|
||||||
const response = await api
|
|
||||||
.get("/store/shipping-options/test-cart-2")
|
|
||||||
.catch((err) => {
|
|
||||||
return err.response
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
|
||||||
expect(response.data.shipping_options).toEqual(
|
|
||||||
expect.arrayContaining([
|
|
||||||
expect.objectContaining({ id: "test-option", amount: 1000 }),
|
|
||||||
expect.objectContaining({ id: "test-option-2", amount: 500 }),
|
|
||||||
])
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("given a cart with custom shipping options, when user retrieves its shipping options, then should return the list of custom shipping options", async () => {
|
|
||||||
const api = useApi()
|
|
||||||
|
|
||||||
const response = await api
|
|
||||||
.get("/store/shipping-options/test-cart-rma")
|
|
||||||
.catch((err) => {
|
|
||||||
return err.response
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
|
||||||
expect(response.data.shipping_options).toEqual(
|
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: "test-option",
|
requirements: [
|
||||||
amount: 0,
|
expect.objectContaining({
|
||||||
name: "test-option",
|
type: "min_subtotal",
|
||||||
|
amount: 100,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res.data.shipping_options).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
requirements: [
|
||||||
|
expect.objectContaining({
|
||||||
|
type: "max_subtotal",
|
||||||
|
amount: 150,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
const shippingOption = res.data.shipping_options.find(
|
||||||
|
(so) => !!so.requirements.find((r) => r.type === "min_subtotal")
|
||||||
|
)
|
||||||
|
|
||||||
|
const addShippingMethodRes = await api.post(
|
||||||
|
`/store/carts/test-cart/shipping-methods`,
|
||||||
|
{
|
||||||
|
option_id: shippingOption.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(addShippingMethodRes.status).toEqual(200)
|
||||||
|
expect(addShippingMethodRes.data.cart.shipping_methods.length).toEqual(1)
|
||||||
|
expect(
|
||||||
|
addShippingMethodRes.data.cart.shipping_methods[0].shipping_option_id
|
||||||
|
).toEqual(shippingOption.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("given a cart with total above max-threshold and subtotal below max-threshold shipping option with tax inclusive pricing is not available", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
// create line item
|
||||||
|
const { data } = await api.post(`/store/carts/test-cart/line-items`, {
|
||||||
|
variant_id: "variant-2",
|
||||||
|
quantity: 1,
|
||||||
|
})
|
||||||
|
expect(data.cart.subtotal).toEqual(145)
|
||||||
|
expect(data.cart.total).toEqual(160)
|
||||||
|
|
||||||
|
const res = await api.get(`/store/shipping-options/test-cart`)
|
||||||
|
expect(res.data.shipping_options.length).toEqual(1)
|
||||||
|
expect(res.data.shipping_options).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
requirements: [
|
||||||
|
expect.objectContaining({
|
||||||
|
type: "min_subtotal",
|
||||||
|
amount: 100,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
ShippingOption,
|
ShippingOption,
|
||||||
ShippingOptionPriceType,
|
ShippingOptionPriceType,
|
||||||
|
ShippingOptionRequirement,
|
||||||
ShippingProfile,
|
ShippingProfile,
|
||||||
ShippingProfileType,
|
ShippingProfileType,
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
@@ -17,6 +18,12 @@ export type ShippingOptionFactoryData = {
|
|||||||
price_type?: ShippingOptionPriceType
|
price_type?: ShippingOptionPriceType
|
||||||
includes_tax?: boolean
|
includes_tax?: boolean
|
||||||
data?: object
|
data?: object
|
||||||
|
requirements: ShippingOptionRequirementData[]
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShippingOptionRequirementData = {
|
||||||
|
type: 'min_subtotal' | 'max_subtotal'
|
||||||
|
amount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const simpleShippingOptionFactory = async (
|
export const simpleShippingOptionFactory = async (
|
||||||
@@ -46,6 +53,7 @@ export const simpleShippingOptionFactory = async (
|
|||||||
profile_id: data.is_giftcard ? gcProfile.id : defaultProfile.id,
|
profile_id: data.is_giftcard ? gcProfile.id : defaultProfile.id,
|
||||||
price_type: data.price_type ?? ShippingOptionPriceType.FLAT_RATE,
|
price_type: data.price_type ?? ShippingOptionPriceType.FLAT_RATE,
|
||||||
data: data.data ?? {},
|
data: data.data ?? {},
|
||||||
|
requirements: (data.requirements || []) as ShippingOptionRequirement[],
|
||||||
amount: typeof data.price !== "undefined" ? data.price : 500,
|
amount: typeof data.price !== "undefined" ? data.price : 500,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1755,7 +1755,7 @@ class CartService extends TransactionBaseService {
|
|||||||
return await this.atomicPhase_(
|
return await this.atomicPhase_(
|
||||||
async (transactionManager: EntityManager) => {
|
async (transactionManager: EntityManager) => {
|
||||||
const cart = await this.retrieve(cartId, {
|
const cart = await this.retrieve(cartId, {
|
||||||
select: ["subtotal"],
|
select: ["subtotal", "total"],
|
||||||
relations: [
|
relations: [
|
||||||
"shipping_methods",
|
"shipping_methods",
|
||||||
"discounts",
|
"discounts",
|
||||||
|
|||||||
@@ -370,15 +370,15 @@ class ShippingOptionService extends TransactionBaseService {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const subtotal = cart.subtotal as number
|
const amount = (option.includes_tax ? cart.total : cart.subtotal) as number
|
||||||
|
|
||||||
const requirementResults: boolean[] = option.requirements.map(
|
const requirementResults: boolean[] = option.requirements.map(
|
||||||
(requirement) => {
|
(requirement) => {
|
||||||
switch (requirement.type) {
|
switch (requirement.type) {
|
||||||
case "max_subtotal":
|
case "max_subtotal":
|
||||||
return requirement.amount > subtotal
|
return requirement.amount > amount
|
||||||
case "min_subtotal":
|
case "min_subtotal":
|
||||||
return requirement.amount <= subtotal
|
return requirement.amount <= amount
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user