feat: Implement PriceList and extend MoneyAmount (#1152)
* 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>
This commit is contained in:
co-authored by
Philip Korsholm
Sebastian Rindom
parent
23f8399c16
commit
5300926db8
@@ -36,17 +36,17 @@ module.exports = async (connection, data = {}) => {
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
const customer5 = manager.create(Customer, {
|
||||
const customer5 = await manager.create(Customer, {
|
||||
id: "test-customer-5",
|
||||
email: "test5@email.com",
|
||||
})
|
||||
|
||||
const customer6 = manager.create(Customer, {
|
||||
const customer6 = await manager.create(Customer, {
|
||||
id: "test-customer-6",
|
||||
email: "test6@email.com",
|
||||
})
|
||||
|
||||
const customer7 = manager.create(Customer, {
|
||||
const customer7 = await manager.create(Customer, {
|
||||
id: "test-customer-7",
|
||||
email: "test7@email.com",
|
||||
})
|
||||
@@ -78,13 +78,13 @@ module.exports = async (connection, data = {}) => {
|
||||
name: "test-group-4",
|
||||
})
|
||||
|
||||
const c_group_5 = manager.create(CustomerGroup, {
|
||||
const c_group_5 = await manager.create(CustomerGroup, {
|
||||
id: "test-group-5",
|
||||
name: "test-group-5",
|
||||
})
|
||||
await manager.save(c_group_5)
|
||||
|
||||
const c_group_6 = manager.create(CustomerGroup, {
|
||||
const c_group_6 = await manager.create(CustomerGroup, {
|
||||
id: "test-group-6",
|
||||
name: "test-group-6",
|
||||
})
|
||||
@@ -99,7 +99,7 @@ module.exports = async (connection, data = {}) => {
|
||||
customer7.groups = [c_group_5, c_group_6]
|
||||
await manager.save(customer7)
|
||||
|
||||
const c_group_delete = manager.create(CustomerGroup, {
|
||||
const c_group_delete = await manager.create(CustomerGroup, {
|
||||
id: "test-group-delete",
|
||||
name: "test-group-delete",
|
||||
})
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user