diff --git a/.changeset/swift-lizards-fetch.md b/.changeset/swift-lizards-fetch.md
new file mode 100644
index 0000000000..76f6600ad0
--- /dev/null
+++ b/.changeset/swift-lizards-fetch.md
@@ -0,0 +1,6 @@
+---
+"@medusajs/dashboard": patch
+"@medusajs/pricing": patch
+---
+
+fix(pricing,dashboard): update min_quantity/max_quantity to decimal in price model
diff --git a/integration-tests/http/__tests__/order-edits/order-edits.spec.ts b/integration-tests/http/__tests__/order-edits/order-edits.spec.ts
index a8d0e29590..34e10b3817 100644
--- a/integration-tests/http/__tests__/order-edits/order-edits.spec.ts
+++ b/integration-tests/http/__tests__/order-edits/order-edits.spec.ts
@@ -487,6 +487,31 @@ medusaIntegrationTestRunner({
}),
])
+ // Update item with decimal quantity
+ result = (
+ await api.post(
+ `/admin/order-edits/${orderId}/items/item/${item.id}`,
+ {
+ quantity: 2.5,
+ unit_price: 30,
+ },
+ adminHeaders
+ )
+ ).data.order_preview
+
+ expect(result.summary.current_order_total).toEqual(111.4)
+ expect(result.summary.original_order_total).toEqual(60)
+
+ const decimalUpdatedItem = result.items.find((i) => i.id === item.id)
+ expect(decimalUpdatedItem.actions[3]).toEqual(
+ expect.objectContaining({
+ details: expect.objectContaining({
+ quantity: 2.5,
+ unit_price: 30,
+ quantity_diff: 0.5,
+ }),
+ })
+ )
// Remove the item by setting the quantity to 0
result = (
await api.post(
@@ -542,7 +567,7 @@ medusaIntegrationTestRunner({
)
).data.order_changes
- expect(result[0].actions).toHaveLength(5)
+ expect(result[0].actions).toHaveLength(6)
expect(result[0].status).toEqual("confirmed")
expect(result[0].confirmed_by).toEqual(expect.stringContaining("user_"))
})
diff --git a/integration-tests/http/__tests__/shipping-option/admin/shipping-option.spec.ts b/integration-tests/http/__tests__/shipping-option/admin/shipping-option.spec.ts
index a9a0496188..0c4bb96521 100644
--- a/integration-tests/http/__tests__/shipping-option/admin/shipping-option.spec.ts
+++ b/integration-tests/http/__tests__/shipping-option/admin/shipping-option.spec.ts
@@ -196,7 +196,7 @@ medusaIntegrationTestRunner({
name: "Test shipping option",
price_type: "flat",
prices: expect.arrayContaining([
- {
+ expect.objectContaining({
id: expect.any(String),
amount: 1000,
currency_code: "usd",
@@ -215,8 +215,8 @@ medusaIntegrationTestRunner({
updated_at: expect.any(String),
deleted_at: null,
price_rules: [],
- },
- {
+ }),
+ expect.objectContaining({
id: expect.any(String),
amount: 500,
currency_code: "usd",
@@ -246,7 +246,7 @@ medusaIntegrationTestRunner({
created_at: expect.any(String),
updated_at: expect.any(String),
deleted_at: null,
- },
+ }),
]),
provider_id: "manual_test-provider",
provider: expect.objectContaining({
diff --git a/integration-tests/modules/__tests__/price-lists/admin/price-lists.spec.ts b/integration-tests/modules/__tests__/price-lists/admin/price-lists.spec.ts
index 43a1d8000f..4836460ba3 100644
--- a/integration-tests/modules/__tests__/price-lists/admin/price-lists.spec.ts
+++ b/integration-tests/modules/__tests__/price-lists/admin/price-lists.spec.ts
@@ -122,7 +122,7 @@ medusaIntegrationTestRunner({
"customer.groups.id": [customerGroup.id],
},
prices: [
- {
+ expect.objectContaining({
id: expect.any(String),
currency_code: "usd",
amount: 5000,
@@ -143,7 +143,7 @@ medusaIntegrationTestRunner({
value: "5000",
precision: 20,
}),
- },
+ }),
],
},
])
@@ -289,7 +289,7 @@ medusaIntegrationTestRunner({
"customer.groups.id": [customerGroup.id],
},
prices: [
- {
+ expect.objectContaining({
id: expect.any(String),
currency_code: "usd",
amount: 5000,
@@ -310,7 +310,7 @@ medusaIntegrationTestRunner({
rules: {
region_id: region.id,
},
- },
+ }),
],
})
)
diff --git a/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-item.tsx b/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-item.tsx
index 126239bb81..0fcd959cfc 100644
--- a/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-item.tsx
+++ b/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-item.tsx
@@ -180,6 +180,7 @@ function OrderEditItem({ item, currencyCode, orderId }: OrderEditItemProps) {
{
+ this.addSql(`drop index if exists "IDX_price_currency_code_price_set_id_min_quantity";`);
+
+ this.addSql(`alter table if exists "price" add column if not exists "raw_min_quantity" jsonb null, add column if not exists "raw_max_quantity" jsonb null;`);
+ this.addSql(`alter table if exists "price" alter column "min_quantity" type numeric using ("min_quantity"::numeric);`);
+ this.addSql(`alter table if exists "price" alter column "max_quantity" type numeric using ("max_quantity"::numeric);`);
+ }
+
+ override async down(): Promise {
+ this.addSql(`alter table if exists "price" drop column if exists "raw_min_quantity", drop column if exists "raw_max_quantity";`);
+
+ this.addSql(`alter table if exists "price" alter column "min_quantity" type integer using ("min_quantity"::integer);`);
+ this.addSql(`alter table if exists "price" alter column "max_quantity" type integer using ("max_quantity"::integer);`);
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_price_currency_code_price_set_id_min_quantity" ON "price" (currency_code, price_set_id, min_quantity) WHERE deleted_at IS NULL;`);
+ }
+
+}
diff --git a/packages/modules/pricing/src/models/price.ts b/packages/modules/pricing/src/models/price.ts
index e445cb5a59..7543b9c92e 100644
--- a/packages/modules/pricing/src/models/price.ts
+++ b/packages/modules/pricing/src/models/price.ts
@@ -9,8 +9,8 @@ const Price = model
title: model.text().nullable(),
currency_code: model.text(),
amount: model.bigNumber(),
- min_quantity: model.number().nullable(),
- max_quantity: model.number().nullable(),
+ min_quantity: model.bigNumber().nullable(),
+ max_quantity: model.bigNumber().nullable(),
rules_count: model.number().default(0).nullable(),
price_set: model.belongsTo(() => PriceSet, {
mappedBy: "prices",
diff --git a/packages/modules/pricing/src/services/pricing-module.ts b/packages/modules/pricing/src/services/pricing-module.ts
index 6b2798c163..9fc3fd5259 100644
--- a/packages/modules/pricing/src/services/pricing-module.ts
+++ b/packages/modules/pricing/src/services/pricing-module.ts
@@ -535,16 +535,16 @@ export default class PricingModuleService
id: calculatedPrice?.id || null,
price_list_id: calculatedPrice?.price_list_id || null,
price_list_type: calculatedPrice?.price_list_type || null,
- min_quantity: parseInt(calculatedPrice?.min_quantity || "") || null,
- max_quantity: parseInt(calculatedPrice?.max_quantity || "") || null,
+ min_quantity: parseFloat(calculatedPrice?.min_quantity || "") || null,
+ max_quantity: parseFloat(calculatedPrice?.max_quantity || "") || null,
},
original_price: {
id: originalPrice?.id || null,
price_list_id: originalPrice?.price_list_id || null,
price_list_type: originalPrice?.price_list_type || null,
- min_quantity: parseInt(originalPrice?.min_quantity || "") || null,
- max_quantity: parseInt(originalPrice?.max_quantity || "") || null,
+ min_quantity: parseFloat(originalPrice?.min_quantity || "") || null,
+ max_quantity: parseFloat(originalPrice?.max_quantity || "") || null,
},
}