feat(medusa): Separate money amount and variant (#4906)
* initial changes * working test * final changes to product tests * update integration tests * update price list integration tests * update integration tests * update unit tests * update plugin integration tests * remove catch from integration test * undo change * add andWhere * update upsertCurrencyMoneyAmount method * undo line item changes * undo changes * update deprecated method * Update packages/medusa/src/migrations/1692953518123-drop_money_amount_constraints_for_pricing_module.ts Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com> * rename joinTable * update with joinTable entity * update load methods * remove await create * re-add context test * update price list behavior for prices * update price list snapshots * re-add admin seeder * pr feedback * fix unit tests * fix plugin integration tests * initial review changes * redo changes to variant creation --------- Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 80,
|
||||
@@ -34,7 +36,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 50,
|
||||
@@ -47,7 +51,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
],
|
||||
"starts_at": "2022-07-01T00:00:00.000Z",
|
||||
@@ -87,7 +93,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 80,
|
||||
@@ -100,7 +108,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 50,
|
||||
@@ -113,7 +123,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 85,
|
||||
@@ -126,7 +138,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant_1",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 10,
|
||||
@@ -139,7 +153,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
],
|
||||
"starts_at": "2022-09-01T00:00:00.000Z",
|
||||
@@ -161,7 +177,9 @@ Object {
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -178,7 +196,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 35,
|
||||
@@ -191,7 +211,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 25,
|
||||
@@ -204,7 +226,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
]
|
||||
`;
|
||||
@@ -222,7 +246,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 80,
|
||||
@@ -235,7 +261,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 50,
|
||||
@@ -248,7 +276,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 45,
|
||||
@@ -261,7 +291,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 35,
|
||||
@@ -274,7 +306,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
Object {
|
||||
"amount": 25,
|
||||
@@ -287,8 +321,9 @@ Array [
|
||||
"price_list_id": "pl_no_customer_groups",
|
||||
"region_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant": Any<Object>,
|
||||
"variant_id": "test-variant",
|
||||
"variants": Any<Array>,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
|
||||
@@ -1177,7 +1177,7 @@ describe("/admin/orders", () => {
|
||||
const manager = dbConnection.manager
|
||||
|
||||
// add a shipping method so we can fulfill the swap
|
||||
const sm = await manager.create(ShippingMethod, {
|
||||
const sm = manager.create(ShippingMethod, {
|
||||
id: "test-method-swap-cart",
|
||||
swap_id: sid,
|
||||
shipping_option_id: "test-option",
|
||||
@@ -1654,7 +1654,7 @@ describe("/admin/orders", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it.only("fails to lists all orders with an invalid status", async () => {
|
||||
it("fails to lists all orders with an invalid status", async () => {
|
||||
expect.assertions(3)
|
||||
const api = useApi()
|
||||
|
||||
|
||||
@@ -168,6 +168,8 @@ describe("/admin/price-lists", () => {
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -179,6 +181,8 @@ describe("/admin/price-lists", () => {
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -190,6 +194,8 @@ describe("/admin/price-lists", () => {
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
@@ -452,6 +458,8 @@ describe("/admin/price-lists", () => {
|
||||
region_id: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
deleted_at: null,
|
||||
},
|
||||
{
|
||||
@@ -461,6 +469,8 @@ describe("/admin/price-lists", () => {
|
||||
min_quantity: 101,
|
||||
max_quantity: 500,
|
||||
variant_id: "test-variant",
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
region_id: null,
|
||||
created_at: expect.any(String),
|
||||
@@ -474,6 +484,8 @@ describe("/admin/price-lists", () => {
|
||||
min_quantity: 501,
|
||||
max_quantity: 1000,
|
||||
variant_id: "test-variant",
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
region_id: null,
|
||||
created_at: expect.any(String),
|
||||
@@ -485,6 +497,8 @@ describe("/admin/price-lists", () => {
|
||||
amount: 85,
|
||||
currency_code: "usd",
|
||||
variant_id: "test-variant_1",
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
@@ -498,6 +512,8 @@ describe("/admin/price-lists", () => {
|
||||
amount: 10,
|
||||
currency_code: "usd",
|
||||
variant_id: "test-variant",
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
@@ -560,6 +576,8 @@ describe("/admin/price-lists", () => {
|
||||
region_id: null,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -690,6 +708,8 @@ describe("/admin/price-lists", () => {
|
||||
variant_id: "test-variant",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -701,6 +721,8 @@ describe("/admin/price-lists", () => {
|
||||
variant_id: "test-variant",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -712,6 +734,8 @@ describe("/admin/price-lists", () => {
|
||||
variant_id: "test-variant",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -723,6 +747,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 2000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -734,6 +760,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 3000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -745,6 +773,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 4000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
])
|
||||
})
|
||||
@@ -802,6 +832,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 2000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -813,6 +845,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 3000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
{
|
||||
id: expect.any(String),
|
||||
@@ -824,6 +858,8 @@ describe("/admin/price-lists", () => {
|
||||
max_quantity: 4000,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
variant: expect.any(Object),
|
||||
variants: expect.any(Array),
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -372,10 +372,10 @@ describe("/admin/products", () => {
|
||||
expect(expectedVariantPrices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price4",
|
||||
id: "test-price_4",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price_3",
|
||||
}),
|
||||
])
|
||||
)
|
||||
@@ -1665,6 +1665,7 @@ describe("/admin/products", () => {
|
||||
|
||||
it("successfully updates a variant's price by changing an existing price (given a region_id)", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const data = {
|
||||
prices: [
|
||||
{
|
||||
@@ -1745,6 +1746,7 @@ describe("/admin/products", () => {
|
||||
expect.objectContaining({
|
||||
amount: 100,
|
||||
currency_code: "usd",
|
||||
id: "test-price",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
amount: 4500,
|
||||
|
||||
@@ -222,14 +222,14 @@ describe("/admin/products [MEDUSA_FF_PRODUCT_CATEGORIES=true]", () => {
|
||||
})
|
||||
|
||||
const manager = dbConnection.manager
|
||||
categoryWithProduct = await manager.create(ProductCategory, {
|
||||
categoryWithProduct = manager.create(ProductCategory, {
|
||||
id: categoryWithProductId,
|
||||
name: "category with Product",
|
||||
products: [{ id: testProductId }],
|
||||
})
|
||||
await manager.save(categoryWithProduct)
|
||||
|
||||
categoryWithoutProduct = await manager.create(ProductCategory, {
|
||||
categoryWithoutProduct = manager.create(ProductCategory, {
|
||||
id: categoryWithoutProductId,
|
||||
name: "category without product",
|
||||
})
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const path = require("path")
|
||||
|
||||
import { ReturnReason, ShippingMethod } from "@medusajs/medusa"
|
||||
|
||||
import { createReturnableOrder } from "../claims"
|
||||
|
||||
const setupServer = require("../../../environment-helpers/setup-server")
|
||||
@@ -77,7 +79,7 @@ describe("/admin/returns", () => {
|
||||
const manager = dbConnection.manager
|
||||
|
||||
// add a shipping method so we can fulfill the swap
|
||||
const sm = await manager.create(ShippingMethod, {
|
||||
const sm = manager.create(ShippingMethod, {
|
||||
id: "test-method-swap-cart",
|
||||
swap_id: sid,
|
||||
shipping_option_id: "test-option",
|
||||
|
||||
Reference in New Issue
Block a user