* init * added buld id validation to repo * admin done * updated price reqs * intial implementation of PriceList * integration tests for price lists * updated admin/product integration tests * update updateVariantPrices method * remove comment from error handler * add integration test for batch deleting prices associated with price list * make update to prices through variant service limited to default prices * update store/products.js snapshot * add api unit tests and update product integration tests to validate that prices from Price List are ignored * fix product test * requested changes * cascade * ensure delete variant cascades to MoneyAmount * addresses PR feedback * removed unused endpoint * update mock * fix failing store integration tests * remove medusajs ressource * re add env.template * Update integration-tests/api/__tests__/admin/price-list.js Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> * Update integration-tests/api/__tests__/admin/price-list.js Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> * fix: update snapshots Co-authored-by: Sebastian Rindom <skrindom@gmail.com> Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
const { PriceList, MoneyAmount } = require("@medusajs/medusa")
|
|
|
|
module.exports = async (connection, data = {}) => {
|
|
const manager = connection.manager
|
|
|
|
const priceListNoCustomerGroups = await manager.create(PriceList, {
|
|
id: "pl_no_customer_groups",
|
|
name: "VIP winter sale",
|
|
description: "Winter sale for VIP customers. 25% off selected items.",
|
|
type: "sale",
|
|
status: "active",
|
|
starts_at: "2022-07-01T00:00:00.000Z",
|
|
ends_at: "2022-07-31T00:00:00.000Z",
|
|
})
|
|
|
|
await manager.save(priceListNoCustomerGroups)
|
|
|
|
const moneyAmount1 = await 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, {
|
|
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, {
|
|
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)
|
|
}
|