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:
co-authored by
Carlos R. L. Rodrigues
Oli Juhl
parent
3d68be2b6b
commit
5d10c46bb1
@@ -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",
|
||||
|
||||
@@ -196,28 +196,23 @@ describe("Price list import batch job", () => {
|
||||
expect(priceListRes.data.price_list.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
variant_id: "test-pl-variant",
|
||||
currency_code: "usd",
|
||||
amount: 1111,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-pl-variant",
|
||||
currency_code: "eur",
|
||||
region_id: "test-pl-region",
|
||||
amount: 2222,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-pl-variant",
|
||||
currency_code: "jpy",
|
||||
amount: 3333,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-pl-sku-variant",
|
||||
currency_code: "usd",
|
||||
amount: 4444,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
variant_id: "test-pl-sku-variant",
|
||||
currency_code: "eur",
|
||||
region_id: "test-pl-region",
|
||||
amount: 5555,
|
||||
|
||||
@@ -86,13 +86,13 @@ describe("Promotions", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
@@ -141,13 +141,13 @@ describe("Promotions", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
@@ -436,13 +436,13 @@ describe("Promotions", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
|
||||
@@ -804,13 +804,13 @@ describe("tax inclusive prices", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
@@ -859,13 +859,13 @@ describe("tax inclusive prices", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
@@ -1154,13 +1154,13 @@ describe("tax inclusive prices", () => {
|
||||
expect(variant.prices).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-price1",
|
||||
id: "test-price-1",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 120,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-price3",
|
||||
id: "test-price-3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
|
||||
@@ -32,6 +32,7 @@ const {
|
||||
const {
|
||||
simpleCustomerGroupFactory,
|
||||
} = require("../../../../factories/simple-customer-group-factory")
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -144,7 +145,6 @@ describe("/store/carts", () => {
|
||||
await dbConnection.manager.save(priceList1)
|
||||
|
||||
const ma_sale_1 = dbConnection.manager.create(MoneyAmount, {
|
||||
variant_id: prodSale.variants[0].id,
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
@@ -152,6 +152,12 @@ describe("/store/carts", () => {
|
||||
|
||||
await dbConnection.manager.save(ma_sale_1)
|
||||
|
||||
await dbConnection.manager.insert(ProductVariantMoneyAmount, {
|
||||
id: `${prodSale.variants[0].id}-${ma_sale_1.id}`,
|
||||
variant_id: prodSale.variants[0].id,
|
||||
money_amount_id: ma_sale_1.id,
|
||||
})
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
@@ -2289,7 +2295,7 @@ describe("/store/carts", () => {
|
||||
await cartSeeder(dbConnection)
|
||||
const manager = dbConnection.manager
|
||||
|
||||
const _cart = await manager.create(Cart, {
|
||||
const _cart = manager.create(Cart, {
|
||||
id: "test-cart-with-cso",
|
||||
customer_id: "some-customer",
|
||||
email: "some-customer@email.com",
|
||||
|
||||
@@ -3,7 +3,7 @@ const { Customer } = require("@medusajs/medusa")
|
||||
module.exports = async (connection) => {
|
||||
const manager = connection.manager
|
||||
|
||||
const customer = await manager.create(Customer, {
|
||||
const customer = manager.create(Customer, {
|
||||
id: "customer-1",
|
||||
email: "test1@email.com",
|
||||
first_name: "John",
|
||||
|
||||
@@ -5,9 +5,11 @@ import {
|
||||
PriceListStatus,
|
||||
PriceListType,
|
||||
} from "@medusajs/medusa"
|
||||
import faker from "faker"
|
||||
|
||||
import { DataSource } from "typeorm"
|
||||
import faker from "faker"
|
||||
import { simpleCustomerGroupFactory } from "./simple-customer-group-factory"
|
||||
import { ProductVariantMoneyAmount } from "@medusajs/medusa"
|
||||
|
||||
type ProductListPrice = {
|
||||
variant_id: string
|
||||
@@ -64,18 +66,27 @@ export const simplePriceListFactory = async (
|
||||
}
|
||||
|
||||
const toSave = manager.create(PriceList, toCreate)
|
||||
const toReturn = await manager.save(toSave)
|
||||
const toReturn = await manager.save(toSave) as PriceList
|
||||
|
||||
if (typeof data.prices !== "undefined") {
|
||||
for (const ma of data.prices) {
|
||||
toReturn.prices = await Promise.all(data.prices.map(async (ma) => {
|
||||
const factoryData = {
|
||||
...ma,
|
||||
price_list_id: listId,
|
||||
}
|
||||
const toSave = manager.create(MoneyAmount, factoryData)
|
||||
const toSave: MoneyAmount = manager.create(MoneyAmount, factoryData)
|
||||
await manager.save(toSave)
|
||||
}
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: `${ma.variant_id}-${toSave.id}`,
|
||||
variant_id: ma.variant_id,
|
||||
money_amount_id: toSave.id,
|
||||
})
|
||||
|
||||
return toSave
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
return toReturn
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export type ProductFactoryData = {
|
||||
type?: string
|
||||
tags?: string[]
|
||||
options?: { id: string; title: string }[]
|
||||
variants?: ProductVariantFactoryData[]
|
||||
variants?: Omit<ProductVariantFactoryData, "product_id">[]
|
||||
sales_channels?: SalesChannelFactoryData[]
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { DataSource } from "typeorm"
|
||||
import faker from "faker"
|
||||
import {
|
||||
MoneyAmount,
|
||||
ProductOptionValue,
|
||||
ProductVariant,
|
||||
ProductVariantMoneyAmount,
|
||||
} from "@medusajs/medusa"
|
||||
|
||||
import { DataSource } from "typeorm"
|
||||
import faker from "faker"
|
||||
|
||||
export type ProductVariantFactoryData = {
|
||||
product_id: string
|
||||
id?: string
|
||||
@@ -31,6 +33,7 @@ export const simpleProductVariantFactory = async (
|
||||
const manager = dataSource.manager
|
||||
|
||||
const id = data.id || `simple-variant-${Math.random() * 1000}`
|
||||
|
||||
const toSave = manager.create(ProductVariant, {
|
||||
id,
|
||||
product_id: data.product_id,
|
||||
@@ -61,13 +64,19 @@ export const simpleProductVariantFactory = async (
|
||||
|
||||
const prices = data.prices || [{ currency: "usd", amount: 100 }]
|
||||
for (const p of prices) {
|
||||
const ma_id = `${p.currency}-${p.amount}-${Math.random()}`
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: `${p.currency}-${p.amount}-${Math.random()}`,
|
||||
variant_id: id,
|
||||
id: ma_id,
|
||||
currency_code: p.currency,
|
||||
amount: p.amount,
|
||||
region_id: p.region_id,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: `${ma_id}-${id}-${Math.random()}`,
|
||||
money_amount_id: ma_id,
|
||||
variant_id: id,
|
||||
})
|
||||
}
|
||||
|
||||
return variant
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
const { MoneyAmount } = require("@medusajs/medusa")
|
||||
const {
|
||||
Region,
|
||||
Product,
|
||||
@@ -48,7 +50,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
const customer = await manager.create(Customer, {
|
||||
const customer = manager.create(Customer, {
|
||||
id: "test-customer",
|
||||
email: "john@doe.com",
|
||||
first_name: "John",
|
||||
@@ -58,7 +60,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
const customerGroup = await manager.create(CustomerGroup, {
|
||||
const customerGroup = manager.create(CustomerGroup, {
|
||||
id: "test-group",
|
||||
name: "test-group",
|
||||
})
|
||||
@@ -67,7 +69,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
customer.groups = [customerGroup]
|
||||
await manager.save(customer)
|
||||
|
||||
const priceListActive = await manager.create(PriceList, {
|
||||
const priceListActive = manager.create(PriceList, {
|
||||
id: "pl",
|
||||
name: "VIP sale",
|
||||
description: "All year sale for VIP customers.",
|
||||
@@ -77,7 +79,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(priceListActive)
|
||||
|
||||
const priceListExpired = await manager.create(PriceList, {
|
||||
const priceListExpired = manager.create(PriceList, {
|
||||
id: "pl_expired",
|
||||
name: "VIP summer sale",
|
||||
description: "Summer sale for VIP customers.",
|
||||
@@ -89,7 +91,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(priceListExpired)
|
||||
|
||||
const priceListWithCustomers = await manager.create(PriceList, {
|
||||
const priceListWithCustomers = manager.create(PriceList, {
|
||||
id: "pl_with_customers",
|
||||
name: "VIP winter sale",
|
||||
description: "Winter sale for VIP customers.",
|
||||
@@ -127,7 +129,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
product_id: "test-product",
|
||||
})
|
||||
|
||||
const variantMultiReg = await manager.create(ProductVariant, {
|
||||
const variantMultiReg = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
@@ -137,49 +139,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
upc: "test-upc",
|
||||
barcode: "test-barcode",
|
||||
product_id: "test-product",
|
||||
prices: [
|
||||
{
|
||||
id: "test-price-multi-usd",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 100,
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-multi-usd",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-expired-multi-usd",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
},
|
||||
{
|
||||
id: "test-price-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 100,
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-multi-eur-with-customer",
|
||||
currency_code: "eur",
|
||||
amount: 40,
|
||||
price_list_id: "pl_with_customers",
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-expired-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-reg",
|
||||
@@ -189,5 +148,94 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-multi-usd",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma",
|
||||
money_amount_id: "test-price-multi-usd",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-multi-usd",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma1",
|
||||
money_amount_id: "test-price-discount-multi-usd",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-expired-multi-usd",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma2",
|
||||
money_amount_id: "test-price-discount-expired-multi-usd",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma3",
|
||||
money_amount_id: "test-price-multi-eur",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma4",
|
||||
money_amount_id: "test-price-discount-multi-eur",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-multi-eur-with-customer",
|
||||
currency_code: "eur",
|
||||
amount: 40,
|
||||
price_list_id: "pl_with_customers",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma5",
|
||||
money_amount_id: "test-price-discount-multi-eur-with-customer",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-expired-multi-eur",
|
||||
currency_code: "eur",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma6",
|
||||
money_amount_id: "test-price-discount-expired-multi-eur",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.save(variantMultiReg)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
const { ProductOption } = require("@medusajs/medusa")
|
||||
const {
|
||||
Customer,
|
||||
Region,
|
||||
@@ -86,7 +88,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'dk'`
|
||||
)
|
||||
|
||||
const customer5 = await manager.create(Customer, {
|
||||
const customer5 = manager.create(Customer, {
|
||||
id: "test-customer-5",
|
||||
email: "test5@email.com",
|
||||
first_name: "John",
|
||||
@@ -97,7 +99,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
})
|
||||
await manager.save(customer5)
|
||||
|
||||
const c_group_5 = await manager.create(CustomerGroup, {
|
||||
const c_group_5 = manager.create(CustomerGroup, {
|
||||
id: "test-group-5",
|
||||
name: "test-group-5",
|
||||
})
|
||||
@@ -106,7 +108,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
customer5.groups = [c_group_5]
|
||||
await manager.save(customer5)
|
||||
|
||||
const priceList_customer = await manager.create(PriceList, {
|
||||
const priceList_customer = manager.create(PriceList, {
|
||||
id: "pl_customer",
|
||||
name: "VIP winter sale",
|
||||
description: "Winter sale for VIP customers.",
|
||||
@@ -221,7 +223,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
itemPerc15.rule = itemPerc15Rule
|
||||
await manager.save(itemPerc15)
|
||||
|
||||
const dUsageLimit = await manager.create(Discount, {
|
||||
const dUsageLimit = manager.create(Discount, {
|
||||
id: "test-discount-usage-limit",
|
||||
code: "SPENT",
|
||||
is_dynamic: false,
|
||||
@@ -230,7 +232,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
usage_count: 10,
|
||||
})
|
||||
|
||||
const drUsage = await manager.create(DiscountRule, {
|
||||
const drUsage = manager.create(DiscountRule, {
|
||||
id: "test-discount-rule-usage-limit",
|
||||
description: "Created",
|
||||
type: "fixed",
|
||||
@@ -243,14 +245,14 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(dUsageLimit)
|
||||
|
||||
const d = await manager.create(Discount, {
|
||||
const d = manager.create(Discount, {
|
||||
id: "test-discount",
|
||||
code: "CREATED",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
})
|
||||
|
||||
const dr = await manager.create(DiscountRule, {
|
||||
const dr = manager.create(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Created",
|
||||
type: "fixed",
|
||||
@@ -369,12 +371,12 @@ module.exports = async (dataSource, data = {}) => {
|
||||
email: "test@email.com",
|
||||
})
|
||||
|
||||
const c2 = await manager.create(Customer, {
|
||||
const c2 = manager.create(Customer, {
|
||||
id: "test-customer-2",
|
||||
email: "test-2@email.com",
|
||||
})
|
||||
|
||||
const cg = await manager.create(CustomerGroup, {
|
||||
const cg = manager.create(CustomerGroup, {
|
||||
id: "cgroup",
|
||||
name: "customer group",
|
||||
})
|
||||
@@ -422,7 +424,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
data: {},
|
||||
})
|
||||
|
||||
const priceList = await manager.create(PriceList, {
|
||||
const priceList = manager.create(PriceList, {
|
||||
id: "pl",
|
||||
name: "VIP winter sale",
|
||||
description: "Winter sale for VIP customers.",
|
||||
@@ -432,7 +434,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(priceList)
|
||||
|
||||
const priceList1 = await manager.create(PriceList, {
|
||||
const priceList1 = manager.create(PriceList, {
|
||||
id: "pl_current",
|
||||
name: "Past winter sale",
|
||||
description: "Winter sale for key accounts.",
|
||||
@@ -444,6 +446,12 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(priceList1)
|
||||
|
||||
const denomOp = manager.create(ProductOption, {
|
||||
id: "denom",
|
||||
title: "Denomination",
|
||||
})
|
||||
await manager.save(denomOp)
|
||||
|
||||
const giftCardProduct = manager.create(Product, {
|
||||
id: "giftcard-product",
|
||||
title: "Giftcard",
|
||||
@@ -451,11 +459,11 @@ module.exports = async (dataSource, data = {}) => {
|
||||
discountable: false,
|
||||
profile_id: gcProfile.id,
|
||||
profiles: [{ id: gcProfile.id }],
|
||||
options: [{ id: "denom", title: "Denomination" }],
|
||||
options: [denomOp],
|
||||
})
|
||||
await manager.save(Product, giftCardProduct)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
const denom = manager.create(ProductVariant, {
|
||||
id: "giftcard-denom",
|
||||
title: "1000",
|
||||
product_id: "giftcard-product",
|
||||
@@ -467,17 +475,36 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(denom)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_denom",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-denom",
|
||||
money_amount_id: "test-price_denom",
|
||||
variant_id: "giftcard-denom",
|
||||
})
|
||||
|
||||
const op_1 = manager.create(ProductOption, {
|
||||
id: "test-option",
|
||||
title: "Size",
|
||||
})
|
||||
await manager.save(op_1)
|
||||
|
||||
const testProduct = manager.create(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
profiles: [{ id: defaultProfile.id }],
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
options: [op_1],
|
||||
})
|
||||
await manager.save(Product, testProduct)
|
||||
await manager.save(testProduct)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
const quantityVariant = manager.create(ProductVariant, {
|
||||
id: "test-variant-quantity",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -490,7 +517,48 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.save(quantityVariant)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_quantity-1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-quantity-1",
|
||||
money_amount_id: "test-price_quantity-1",
|
||||
variant_id: "test-variant-quantity",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_quantity-2",
|
||||
currency_code: "usd",
|
||||
min_quantity: 10,
|
||||
max_quantity: 100,
|
||||
amount: 800,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-quantity-2",
|
||||
money_amount_id: "test-price_quantity-2",
|
||||
variant_id: "test-variant-quantity",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_quantity-3",
|
||||
currency_code: "usd",
|
||||
min_quantity: 100,
|
||||
amount: 700,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-quantity-3",
|
||||
money_amount_id: "test-price_quantity-3",
|
||||
variant_id: "test-variant-quantity",
|
||||
})
|
||||
|
||||
const variantSale = manager.create(ProductVariant, {
|
||||
id: "test-variant-sale",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -503,7 +571,34 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.save(variantSale)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_sale-1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-sale-1",
|
||||
money_amount_id: "test-price_sale-1",
|
||||
variant_id: "test-variant-sale",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-sale-2",
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-sale-2",
|
||||
money_amount_id: "test-price-sale-2",
|
||||
variant_id: "test-variant-sale",
|
||||
})
|
||||
|
||||
const variantSaleCustomer = manager.create(ProductVariant, {
|
||||
id: "test-variant-sale-customer",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -515,8 +610,47 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(variantSaleCustomer)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_sale-customer-1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-sale-customer-1",
|
||||
money_amount_id: "test-price_sale-customer-1",
|
||||
variant_id: "test-variant-sale-customer",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_sale-customer-2",
|
||||
currency_code: "usd",
|
||||
amount: 700,
|
||||
price_list_id: "pl_customer",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-sale-customer-2",
|
||||
money_amount_id: "test-price_sale-customer-2",
|
||||
variant_id: "test-variant-sale-customer",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-sale-customer-3",
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-sale-customer-3",
|
||||
money_amount_id: "test-price_sale-customer-3",
|
||||
variant_id: "test-variant-sale-customer",
|
||||
})
|
||||
|
||||
const testVariant = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -528,8 +662,33 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(testVariant)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-1",
|
||||
money_amount_id: "test-price-1",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-2",
|
||||
currency_code: "eur",
|
||||
amount: 2000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-2",
|
||||
money_amount_id: "test-price-2",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const variant2 = await manager.insert(ProductVariant, {
|
||||
id: "test-variant-2",
|
||||
title: "test variant 2",
|
||||
product_id: "test-product",
|
||||
@@ -542,107 +701,18 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
const ma = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-2-2",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 1000,
|
||||
})
|
||||
await manager.save(ma)
|
||||
|
||||
const maEur = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
currency_code: "eur",
|
||||
type: "default",
|
||||
amount: 2000,
|
||||
})
|
||||
await manager.save(maEur)
|
||||
|
||||
const ma_sale = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
await manager.save(ma_sale)
|
||||
|
||||
const ma_sale_1 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale",
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
})
|
||||
await manager.save(ma_sale_1)
|
||||
|
||||
const ma_sale_customer = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale-customer",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
await manager.save(ma_sale_customer)
|
||||
|
||||
const ma_sale_customer_1 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale-customer",
|
||||
currency_code: "usd",
|
||||
amount: 700,
|
||||
price_list_id: "pl_customer",
|
||||
})
|
||||
await manager.save(ma_sale_customer_1)
|
||||
|
||||
const ma_sale_customer_2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale-customer",
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
})
|
||||
await manager.save(ma_sale_customer_2)
|
||||
|
||||
const ma_quantity = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-quantity",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 1000,
|
||||
})
|
||||
await manager.save(ma_quantity)
|
||||
|
||||
const ma_quantity_1 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-quantity",
|
||||
currency_code: "usd",
|
||||
type: "sale",
|
||||
min_quantity: 10,
|
||||
max_quantity: 100,
|
||||
amount: 800,
|
||||
})
|
||||
|
||||
await manager.save(ma_quantity_1)
|
||||
|
||||
const ma_quantity_2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-quantity",
|
||||
currency_code: "usd",
|
||||
type: "sale",
|
||||
min_quantity: 100,
|
||||
amount: 700,
|
||||
})
|
||||
|
||||
await manager.save(ma_quantity_2)
|
||||
|
||||
const ma2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-2",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 8000,
|
||||
})
|
||||
|
||||
await manager.save(ma2)
|
||||
|
||||
const ma3 = manager.create(MoneyAmount, {
|
||||
variant_id: "giftcard-denom",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 1000,
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-2-1",
|
||||
money_amount_id: "test-price-2-2",
|
||||
variant_id: "test-variant-2",
|
||||
})
|
||||
|
||||
await manager.save(ma3)
|
||||
|
||||
const cart = manager.create(Cart, {
|
||||
id: "test-cart",
|
||||
customer_id: "some-customer",
|
||||
@@ -908,7 +978,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
})
|
||||
await manager.save(cart4)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
const variantSaleCG = manager.create(ProductVariant, {
|
||||
id: "test-variant-sale-cg",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -920,31 +990,46 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(variantSaleCG)
|
||||
|
||||
const ma_cg = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-sale-cg",
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-test-variant-sale-cg-1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
await manager.save(ma_cg)
|
||||
|
||||
const ma_sale_cg = manager.create(MoneyAmount, {
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-sale-cg-1",
|
||||
money_amount_id: "test-test-variant-sale-cg-1",
|
||||
variant_id: "test-variant-sale-cg",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-test-variant-sale-cg-2",
|
||||
currency_code: "usd",
|
||||
price_list_id: "pl",
|
||||
amount: 500,
|
||||
})
|
||||
await manager.save(ma_sale_cg)
|
||||
|
||||
const ma_sale_cg_new_region = manager.create(MoneyAmount, {
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-sale-cg-2",
|
||||
money_amount_id: "test-test-variant-sale-cg-2",
|
||||
variant_id: "test-variant-sale-cg",
|
||||
region_id: "test-region-multiple",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-test-variant-sale-cg-3",
|
||||
currency_code: "eur",
|
||||
amount: 700,
|
||||
})
|
||||
await manager.save(ma_sale_cg_new_region)
|
||||
|
||||
const li3 = await manager.create(LineItem, {
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-sale-cg-3",
|
||||
money_amount_id: "test-test-variant-sale-cg-3",
|
||||
variant_id: "test-variant-sale-cg",
|
||||
})
|
||||
|
||||
const li3 = manager.create(LineItem, {
|
||||
id: "test-item3",
|
||||
title: "Line Item",
|
||||
description: "Line Item Desc",
|
||||
|
||||
@@ -3,7 +3,7 @@ const { Customer, Address, CustomerGroup } = require("@medusajs/medusa")
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
|
||||
const testAddr = await manager.create(Address, {
|
||||
const testAddr = manager.create(Address, {
|
||||
id: "test-address",
|
||||
first_name: "Lebron",
|
||||
last_name: "James",
|
||||
@@ -11,7 +11,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(testAddr)
|
||||
|
||||
const customer = await manager.create(Customer, {
|
||||
const customer = manager.create(Customer, {
|
||||
id: "test-customer-1",
|
||||
email: "test1@email.com",
|
||||
})
|
||||
@@ -36,25 +36,25 @@ module.exports = async (dataSource, data = {}) => {
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
const customer5 = await manager.create(Customer, {
|
||||
const customer5 = manager.create(Customer, {
|
||||
id: "test-customer-5",
|
||||
email: "test5@email.com",
|
||||
})
|
||||
await manager.save(customer5)
|
||||
|
||||
const customer6 = await manager.create(Customer, {
|
||||
const customer6 = manager.create(Customer, {
|
||||
id: "test-customer-6",
|
||||
email: "test6@email.com",
|
||||
})
|
||||
await manager.save(customer6)
|
||||
|
||||
const customer7 = await manager.create(Customer, {
|
||||
const customer7 = manager.create(Customer, {
|
||||
id: "test-customer-7",
|
||||
email: "test7@email.com",
|
||||
})
|
||||
await manager.save(customer7)
|
||||
|
||||
const deletionCustomer = await manager.create(Customer, {
|
||||
const deletionCustomer = manager.create(Customer, {
|
||||
id: "test-customer-delete-cg",
|
||||
email: "test-deletetion-cg@email.com",
|
||||
})
|
||||
@@ -81,13 +81,13 @@ module.exports = async (dataSource, data = {}) => {
|
||||
name: "test-group-4",
|
||||
})
|
||||
|
||||
const c_group_5 = await manager.create(CustomerGroup, {
|
||||
const c_group_5 = manager.create(CustomerGroup, {
|
||||
id: "test-group-5",
|
||||
name: "test-group-5",
|
||||
})
|
||||
await manager.save(c_group_5)
|
||||
|
||||
const c_group_6 = await manager.create(CustomerGroup, {
|
||||
const c_group_6 = manager.create(CustomerGroup, {
|
||||
id: "test-group-6",
|
||||
name: "test-group-6",
|
||||
})
|
||||
@@ -102,7 +102,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
customer7.groups = [c_group_5, c_group_6]
|
||||
await manager.save(customer7)
|
||||
|
||||
const c_group_delete = await manager.create(CustomerGroup, {
|
||||
const c_group_delete = manager.create(CustomerGroup, {
|
||||
id: "test-group-delete",
|
||||
name: "test-group-delete",
|
||||
})
|
||||
|
||||
@@ -17,6 +17,8 @@ const {
|
||||
ShippingProfileType,
|
||||
} = require("@medusajs/medusa")
|
||||
const { simpleSalesChannelFactory } = require("../factories")
|
||||
const { ProductOption } = require("@medusajs/medusa")
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
@@ -30,12 +32,18 @@ module.exports = async (dataSource, data = {}) => {
|
||||
is_default: true,
|
||||
})
|
||||
|
||||
const op = manager.create(ProductOption, {
|
||||
id: "test-option",
|
||||
title: "Size",
|
||||
})
|
||||
|
||||
await manager.save(op)
|
||||
await manager.insert(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
profiles: [{ id: defaultProfile.id }],
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
options: [op],
|
||||
})
|
||||
|
||||
await manager.query(
|
||||
@@ -49,12 +57,18 @@ module.exports = async (dataSource, data = {}) => {
|
||||
country_code: "us",
|
||||
})
|
||||
|
||||
const op1 = manager.create(ProductOption, {
|
||||
id: "test-option-color",
|
||||
title: "Color",
|
||||
})
|
||||
await manager.save(op1)
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product-2",
|
||||
title: "test product 2",
|
||||
profile_id: defaultProfile.id,
|
||||
profiles: [{ id: defaultProfile.id }],
|
||||
options: [{ id: "test-option-color", title: "Color" }],
|
||||
options: [op1],
|
||||
})
|
||||
|
||||
await manager.query(
|
||||
@@ -74,7 +88,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
const pv1 = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -86,8 +100,21 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(pv1)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant",
|
||||
money_amount_id: "test-price",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const pv2 = manager.create(ProductVariant, {
|
||||
id: "test-variant-2",
|
||||
title: "test variant-2",
|
||||
product_id: "test-product-2",
|
||||
@@ -99,21 +126,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
],
|
||||
})
|
||||
await manager.save(pv2)
|
||||
|
||||
const ma = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
})
|
||||
await manager.save(ma)
|
||||
|
||||
const ma2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-2",
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-2",
|
||||
currency_code: "usd",
|
||||
amount: 10000,
|
||||
})
|
||||
|
||||
await manager.save(ma2)
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-variant-2",
|
||||
money_amount_id: "test-price-2",
|
||||
variant_id: "test-variant-2",
|
||||
})
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
|
||||
@@ -16,6 +16,8 @@ const {
|
||||
ShippingProfileType,
|
||||
} = require("@medusajs/medusa")
|
||||
const { simpleSalesChannelFactory } = require("../factories")
|
||||
const { ProductOption } = require("@medusajs/medusa")
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
@@ -34,14 +36,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
profiles: [{ id: defaultProfile.id }],
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
})
|
||||
|
||||
await manager.query(
|
||||
`insert into product_sales_channel values ('test-product', '${salesChannel.id}');`
|
||||
)
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.save(ProductOption, {
|
||||
id: "test-option",
|
||||
title: "Size",
|
||||
product_id: "test-product",
|
||||
})
|
||||
|
||||
const variant = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
title: "test variant",
|
||||
product_id: "test-product",
|
||||
@@ -54,7 +61,21 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
await manager.save(variant)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma",
|
||||
money_amount_id: "test-price",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const variant2 = manager.create(ProductVariant, {
|
||||
id: "test-variant-2",
|
||||
title: "Swap product",
|
||||
product_id: "test-product",
|
||||
@@ -67,19 +88,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
],
|
||||
})
|
||||
|
||||
const ma2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-2",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
})
|
||||
await manager.save(ma2)
|
||||
await manager.save(variant2)
|
||||
|
||||
const ma = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price_2",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
})
|
||||
await manager.save(ma)
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma4",
|
||||
money_amount_id: "test-price_2",
|
||||
variant_id: "test-variant-2",
|
||||
})
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
const { Region, PriceList, MoneyAmount } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
|
||||
const priceListNoCustomerGroups = await manager.create(PriceList, {
|
||||
const priceListNoCustomerGroups = manager.create(PriceList, {
|
||||
id: "pl_no_customer_groups",
|
||||
name: "VIP winter sale",
|
||||
description: "Winter sale for VIP customers. 25% off selected items.",
|
||||
@@ -22,52 +23,69 @@ module.exports = async (dataSource, data = {}) => {
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
const moneyAmount1 = await manager.create(MoneyAmount, {
|
||||
const moneyAmount1 = manager.create(MoneyAmount, {
|
||||
id: "ma_test_1",
|
||||
amount: 100,
|
||||
currency_code: "usd",
|
||||
min_quantity: 1,
|
||||
max_quantity: 100,
|
||||
variant_id: "test-variant",
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
})
|
||||
|
||||
await manager.save(moneyAmount1)
|
||||
|
||||
const moneyAmount2 = await manager.create(MoneyAmount, {
|
||||
const moneyAmount2 = manager.create(MoneyAmount, {
|
||||
id: "ma_test_2",
|
||||
amount: 80,
|
||||
currency_code: "usd",
|
||||
min_quantity: 101,
|
||||
max_quantity: 500,
|
||||
variant_id: "test-variant",
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
})
|
||||
|
||||
await manager.save(moneyAmount2)
|
||||
|
||||
const moneyAmount3 = await manager.create(MoneyAmount, {
|
||||
const moneyAmount3 = manager.create(MoneyAmount, {
|
||||
id: "ma_test_3",
|
||||
amount: 50,
|
||||
currency_code: "usd",
|
||||
min_quantity: 501,
|
||||
max_quantity: 1000,
|
||||
variant_id: "test-variant",
|
||||
price_list_id: "pl_no_customer_groups",
|
||||
})
|
||||
|
||||
await manager.save(moneyAmount3)
|
||||
|
||||
const moneyAmount4 = await manager.create(MoneyAmount, {
|
||||
const moneyAmount4 = manager.create(MoneyAmount, {
|
||||
id: "ma_test_4",
|
||||
amount: 70,
|
||||
currency_code: "usd",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.save(moneyAmount4)
|
||||
|
||||
const priceListWithMA = await manager.create(PriceList, {
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma1-pl",
|
||||
money_amount_id: "ma_test_1",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma2-pl",
|
||||
money_amount_id: "ma_test_2",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma3-pl",
|
||||
money_amount_id: "ma_test_3",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma4-pl",
|
||||
money_amount_id: "ma_test_4",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const priceListWithMA = manager.create(PriceList, {
|
||||
id: "pl_with_some_ma",
|
||||
name: "Weeken sale",
|
||||
description: "Desc. of the list",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,8 @@ const {
|
||||
ProductVariant,
|
||||
Image,
|
||||
ShippingProfileType,
|
||||
MoneyAmount,
|
||||
ProductVariantMoneyAmount,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
@@ -20,7 +22,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
},
|
||||
})
|
||||
|
||||
const coll = await manager.create(ProductCollection, {
|
||||
const coll = manager.create(ProductCollection, {
|
||||
id: "test-collection",
|
||||
handle: "test-collection",
|
||||
title: "Test collection",
|
||||
@@ -28,7 +30,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(coll)
|
||||
|
||||
const coll1 = await manager.create(ProductCollection, {
|
||||
const coll1 = manager.create(ProductCollection, {
|
||||
id: "test-collection1",
|
||||
handle: "test-collection1",
|
||||
title: "Test collection 1",
|
||||
@@ -36,7 +38,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(coll1)
|
||||
|
||||
const coll2 = await manager.create(ProductCollection, {
|
||||
const coll2 = manager.create(ProductCollection, {
|
||||
id: "test-collection2",
|
||||
handle: "test-collection2",
|
||||
title: "Test collection 2",
|
||||
@@ -44,35 +46,35 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(coll2)
|
||||
|
||||
const tag = await manager.create(ProductTag, {
|
||||
const tag = manager.create(ProductTag, {
|
||||
id: "tag1",
|
||||
value: "123",
|
||||
})
|
||||
|
||||
await manager.save(tag)
|
||||
|
||||
const tag3 = await manager.create(ProductTag, {
|
||||
const tag3 = manager.create(ProductTag, {
|
||||
id: "tag3",
|
||||
value: "1235",
|
||||
})
|
||||
|
||||
await manager.save(tag3)
|
||||
|
||||
const tag4 = await manager.create(ProductTag, {
|
||||
const tag4 = manager.create(ProductTag, {
|
||||
id: "tag4",
|
||||
value: "1234",
|
||||
})
|
||||
|
||||
await manager.save(tag4)
|
||||
|
||||
const type = await manager.create(ProductType, {
|
||||
const type = manager.create(ProductType, {
|
||||
id: "test-type",
|
||||
value: "test-type",
|
||||
})
|
||||
|
||||
await manager.save(type)
|
||||
|
||||
const type2 = await manager.create(ProductType, {
|
||||
const type2 = manager.create(ProductType, {
|
||||
id: "test-type-new",
|
||||
value: "test-type-new",
|
||||
})
|
||||
@@ -93,7 +95,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
const p = await manager.create(Product, {
|
||||
const p = manager.create(Product, {
|
||||
id: "test-product",
|
||||
handle: "test-product",
|
||||
title: "Test product",
|
||||
@@ -118,7 +120,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
product_id: "test-product",
|
||||
})
|
||||
|
||||
const variant1 = await manager.create(ProductVariant, {
|
||||
const variant1 = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
@@ -128,7 +130,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
upc: "test-upc",
|
||||
barcode: "test-barcode",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option",
|
||||
@@ -140,7 +141,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(variant1)
|
||||
|
||||
const sale = await manager.create(ProductVariant, {
|
||||
const ma = await manager.insert(MoneyAmount, {
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma0",
|
||||
money_amount_id: "test-price",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const sale = manager.create(ProductVariant, {
|
||||
id: "test-variant-sale",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
@@ -150,13 +163,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
upc: "test-upc-sale",
|
||||
barcode: "test-barcode-sale",
|
||||
product_id: "test-product",
|
||||
prices: [
|
||||
{
|
||||
id: "test-price-sale",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-sale",
|
||||
@@ -168,7 +174,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(sale)
|
||||
|
||||
const variant2 = await manager.create(ProductVariant, {
|
||||
const ma_sale = await manager.insert(MoneyAmount, {
|
||||
id: "test-price-sale",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma1",
|
||||
money_amount_id: "test-price-sale",
|
||||
variant_id: "test-variant-sale",
|
||||
})
|
||||
|
||||
const variant2 = manager.create(ProductVariant, {
|
||||
id: "test-variant_1",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (1)",
|
||||
@@ -178,7 +196,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
upc: "test-upc1",
|
||||
barcode: "test-barcode 1",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price1", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-1",
|
||||
@@ -190,7 +207,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(variant2)
|
||||
|
||||
const variant3 = await manager.create(ProductVariant, {
|
||||
const ma_1 = await manager.insert(MoneyAmount, {
|
||||
id: "test-price_1",
|
||||
currency_code: "usd",
|
||||
amount: 1000,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma2",
|
||||
money_amount_id: "test-price_1",
|
||||
variant_id: "test-variant_1",
|
||||
})
|
||||
|
||||
const variant3 = manager.create(ProductVariant, {
|
||||
id: "test-variant_2",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -199,7 +228,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
ean: "test-ean2",
|
||||
upc: "test-upc2",
|
||||
product_id: "test-product",
|
||||
prices: [{ id: "test-price2", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-2",
|
||||
@@ -211,7 +239,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(variant3)
|
||||
|
||||
const p1 = await manager.create(Product, {
|
||||
const ma_2 = await manager.insert(MoneyAmount, {
|
||||
id: "test-price_2",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma3",
|
||||
money_amount_id: "test-price_2",
|
||||
variant_id: "test-variant_2",
|
||||
})
|
||||
|
||||
const p1 = manager.create(Product, {
|
||||
id: "test-product1",
|
||||
handle: "test-product1",
|
||||
title: "Test product1",
|
||||
@@ -228,7 +268,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(p1)
|
||||
|
||||
const variant4 = await manager.create(ProductVariant, {
|
||||
const variant4 = manager.create(ProductVariant, {
|
||||
id: "test-variant_3",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -237,15 +277,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
ean: "test-ean3",
|
||||
upc: "test-upc3",
|
||||
product_id: "test-product1",
|
||||
prices: [
|
||||
{
|
||||
id: "test-price3",
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
type: "default",
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-3",
|
||||
@@ -257,7 +288,20 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(variant4)
|
||||
|
||||
const variant5 = await manager.create(ProductVariant, {
|
||||
const ma_3 = await manager.insert(MoneyAmount, {
|
||||
id: "test-price_3",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
region_id: "test-region",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma4",
|
||||
money_amount_id: "test-price_3",
|
||||
variant_id: "test-variant_3",
|
||||
})
|
||||
|
||||
const variant5 = manager.create(ProductVariant, {
|
||||
id: "test-variant_4",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -266,9 +310,6 @@ module.exports = async (dataSource, data = {}) => {
|
||||
ean: "test-ean4",
|
||||
upc: "test-upc4",
|
||||
product_id: "test-product1",
|
||||
prices: [
|
||||
{ id: "test-price4", currency_code: "usd", amount: 100, type: "default" },
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-4",
|
||||
@@ -280,7 +321,19 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(variant5)
|
||||
|
||||
const product1 = await manager.create(Product, {
|
||||
const ma_4 = await manager.insert(MoneyAmount, {
|
||||
id: "test-price_4",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma5",
|
||||
money_amount_id: "test-price_4",
|
||||
variant_id: "test-variant_4",
|
||||
})
|
||||
|
||||
const product1 = manager.create(Product, {
|
||||
id: "test-product_filtering_1",
|
||||
handle: "test-product_filtering_1",
|
||||
title: "Test product filtering 1",
|
||||
@@ -295,7 +348,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(product1)
|
||||
|
||||
const product2 = await manager.create(Product, {
|
||||
const product2 = manager.create(Product, {
|
||||
id: "test-product_filtering_2",
|
||||
handle: "test-product_filtering_2",
|
||||
title: "Test product filtering 2",
|
||||
@@ -310,7 +363,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(product2)
|
||||
|
||||
const product3 = await manager.create(Product, {
|
||||
const product3 = manager.create(Product, {
|
||||
id: "test-product_filtering_3",
|
||||
handle: "test-product_filtering_3",
|
||||
title: "Test product filtering 3",
|
||||
@@ -325,7 +378,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(product3)
|
||||
|
||||
const product4 = await manager.create(Product, {
|
||||
const product4 = manager.create(Product, {
|
||||
id: "test-product_filtering_4",
|
||||
handle: "test-product_filtering_4",
|
||||
title: "Test product filtering 4",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const { ProductVariantMoneyAmount } = require("@medusajs/medusa")
|
||||
const { MoneyAmount } = require("@medusajs/medusa")
|
||||
const {
|
||||
ProductCollection,
|
||||
ProductTag,
|
||||
@@ -26,7 +28,7 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
new Date()
|
||||
)
|
||||
|
||||
const priceList = await manager.create(PriceList, {
|
||||
const priceList = manager.create(PriceList, {
|
||||
id: "pl",
|
||||
name: "VIP winter sale",
|
||||
description: "Winter sale for VIP customers.",
|
||||
@@ -36,7 +38,7 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(priceList)
|
||||
|
||||
const priceList1 = await manager.create(PriceList, {
|
||||
const priceList1 = manager.create(PriceList, {
|
||||
id: "pl_expired",
|
||||
name: "Past winter sale",
|
||||
description: "Winter sale for key accounts.",
|
||||
@@ -152,7 +154,7 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
product_id: "test-product",
|
||||
})
|
||||
|
||||
const variant1 = await manager.create(ProductVariant, {
|
||||
const variant1 = manager.create(ProductVariant, {
|
||||
id: "test-variant",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant",
|
||||
@@ -162,21 +164,6 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
upc: "test-upc",
|
||||
barcode: "test-barcode",
|
||||
product_id: "test-product",
|
||||
prices: [
|
||||
{ id: "test-price", currency_code: "usd", type: "default", amount: 100 },
|
||||
{
|
||||
id: "test-price-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
},
|
||||
{
|
||||
id: "test-price-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option",
|
||||
@@ -188,7 +175,46 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(variant1)
|
||||
|
||||
const variant2 = await manager.create(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant-1",
|
||||
money_amount_id: "test-price",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant-2",
|
||||
money_amount_id: "test-price-discount",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant-3",
|
||||
money_amount_id: "test-price-discount-expired",
|
||||
variant_id: "test-variant",
|
||||
})
|
||||
|
||||
const variant2 = manager.create(ProductVariant, {
|
||||
id: "test-variant_1",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (1)",
|
||||
@@ -198,21 +224,6 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
upc: "test-upc1",
|
||||
barcode: "test-barcode 1",
|
||||
product_id: "test-product",
|
||||
prices: [
|
||||
{ id: "test-price1", currency_code: "usd", type: "default", amount: 100 },
|
||||
{
|
||||
id: "test-price1-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
},
|
||||
{
|
||||
id: "test-price1-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-1",
|
||||
@@ -224,7 +235,46 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(variant2)
|
||||
|
||||
const variant3 = await manager.create(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price1",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_1-1",
|
||||
money_amount_id: "test-price1",
|
||||
variant_id: "test-variant_1",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price1-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_1-2",
|
||||
money_amount_id: "test-price1-discount",
|
||||
variant_id: "test-variant_1",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price1-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_1-3",
|
||||
money_amount_id: "test-price1-discount-expired",
|
||||
variant_id: "test-variant_1",
|
||||
})
|
||||
|
||||
const variant3 = manager.create(ProductVariant, {
|
||||
id: "test-variant_2",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -233,21 +283,6 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
ean: "test-ean2",
|
||||
upc: "test-upc2",
|
||||
product_id: "test-product",
|
||||
prices: [
|
||||
{ id: "test-price2", currency_code: "usd", type: "default", amount: 100 },
|
||||
{
|
||||
id: "test-price2-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
},
|
||||
{
|
||||
id: "test-price2-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-2",
|
||||
@@ -259,6 +294,45 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(variant3)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price2",
|
||||
currency_code: "usd",
|
||||
type: "default",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_2-1",
|
||||
money_amount_id: "test-price2",
|
||||
variant_id: "test-variant_2",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price2-discount",
|
||||
currency_code: "usd",
|
||||
amount: 80,
|
||||
price_list_id: "pl",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_2-2",
|
||||
money_amount_id: "test-price2-discount",
|
||||
variant_id: "test-variant_2",
|
||||
})
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price2-discount-expired",
|
||||
currency_code: "usd",
|
||||
amount: 70,
|
||||
price_list_id: "pl_expired",
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_2-3",
|
||||
money_amount_id: "test-price2-discount-expired",
|
||||
variant_id: "test-variant_2",
|
||||
})
|
||||
|
||||
const p1 = manager.create(Product, {
|
||||
id: "test-product1",
|
||||
handle: "test-product1",
|
||||
@@ -277,7 +351,7 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(p1)
|
||||
|
||||
const variant4 = await manager.create(ProductVariant, {
|
||||
const variant4 = manager.create(ProductVariant, {
|
||||
id: "test-variant_3",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -286,7 +360,6 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
ean: "test-ean3",
|
||||
upc: "test-upc3",
|
||||
product_id: "test-product1",
|
||||
prices: [{ id: "test-price3", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-3",
|
||||
@@ -298,7 +371,19 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(variant4)
|
||||
|
||||
const variant5 = await manager.create(ProductVariant, {
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price3",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_3-1",
|
||||
money_amount_id: "test-price3",
|
||||
variant_id: "test-variant_3",
|
||||
})
|
||||
|
||||
const variant5 = manager.create(ProductVariant, {
|
||||
id: "test-variant_4",
|
||||
inventory_quantity: 10,
|
||||
title: "Test variant rank (2)",
|
||||
@@ -307,7 +392,6 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
ean: "test-ean4",
|
||||
upc: "test-upc4",
|
||||
product_id: "test-product1",
|
||||
prices: [{ id: "test-price4", currency_code: "usd", amount: 100 }],
|
||||
options: [
|
||||
{
|
||||
id: "test-variant-option-4",
|
||||
@@ -319,6 +403,18 @@ module.exports = async (dataSource, defaultSalesChannel) => {
|
||||
|
||||
await manager.save(variant5)
|
||||
|
||||
await manager.insert(MoneyAmount, {
|
||||
id: "test-price4",
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariantMoneyAmount, {
|
||||
id: "pvma-test-variant_4-1",
|
||||
money_amount_id: "test-price4",
|
||||
variant_id: "test-variant_4",
|
||||
})
|
||||
|
||||
const product1 = manager.create(Product, {
|
||||
id: "test-product_filtering_1",
|
||||
handle: "test-product_filtering_1",
|
||||
|
||||
@@ -264,7 +264,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
|
||||
await manager.save(li2)
|
||||
|
||||
const swapReturn = await manager.create(Return, {
|
||||
const swapReturn = manager.create(Return, {
|
||||
swap_id: swap.id,
|
||||
order_id: orderWithSwap.id,
|
||||
item_id: li.id,
|
||||
|
||||
@@ -14,7 +14,7 @@ expires_at.setDate(expires_at.getDate() + 8)
|
||||
module.exports = async (dataSource, data = {}) => {
|
||||
const manager = dataSource.manager
|
||||
|
||||
const memberUser = await manager.create(User, {
|
||||
const memberUser = manager.create(User, {
|
||||
id: "member-user",
|
||||
role: "member",
|
||||
email: "member@test.com",
|
||||
@@ -23,7 +23,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
})
|
||||
await manager.save(memberUser)
|
||||
|
||||
const memberInvite = await manager.create(Invite, {
|
||||
const memberInvite = manager.create(Invite, {
|
||||
id: "memberInvite",
|
||||
user_email: "invite-member@test.com",
|
||||
role: "member",
|
||||
@@ -37,7 +37,7 @@ module.exports = async (dataSource, data = {}) => {
|
||||
})
|
||||
await manager.save(memberInvite)
|
||||
|
||||
const adminInvite = await manager.create(Invite, {
|
||||
const adminInvite = manager.create(Invite, {
|
||||
id: "adminInvite",
|
||||
user_email: "invite-admin@test.com",
|
||||
role: "admin",
|
||||
|
||||
@@ -6,6 +6,7 @@ import setupServer from "../../../../environment-helpers/setup-server"
|
||||
import { setPort, useApi } from "../../../../environment-helpers/use-api"
|
||||
import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
import { simpleProductFactory } from "../../../../factories"
|
||||
import { ProductVariantMoneyAmount } from "@medusajs/medusa"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -125,7 +126,6 @@ describe("/store/carts", () => {
|
||||
await dbConnection.manager.save(priceList1)
|
||||
|
||||
const ma_sale_1 = dbConnection.manager.create(MoneyAmount, {
|
||||
variant_id: prodSale.variants[0].id,
|
||||
currency_code: "usd",
|
||||
amount: 800,
|
||||
price_list_id: "pl_current",
|
||||
@@ -133,6 +133,12 @@ describe("/store/carts", () => {
|
||||
|
||||
await dbConnection.manager.save(ma_sale_1)
|
||||
|
||||
await dbConnection.manager.insert(ProductVariantMoneyAmount, {
|
||||
id: 'pvma-test',
|
||||
variant_id: prodSale.variants[0].id,
|
||||
money_amount_id: ma_sale_1.id,
|
||||
})
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
|
||||
Reference in New Issue
Block a user