fix(medusa): allow price list prices update when region_id is provided (#1472)

This commit is contained in:
Frane Polić
2022-05-11 07:43:19 +02:00
committed by GitHub
parent 327614e126
commit 03c5617896
4 changed files with 279 additions and 4 deletions
@@ -1,4 +1,4 @@
const { PriceList, MoneyAmount } = require("@medusajs/medusa")
const { Region, PriceList, MoneyAmount } = require("@medusajs/medusa")
module.exports = async (connection, data = {}) => {
const manager = connection.manager
@@ -15,6 +15,13 @@ module.exports = async (connection, data = {}) => {
await manager.save(priceListNoCustomerGroups)
await manager.insert(Region, {
id: "region-pl",
name: "Test Region",
currency_code: "eur",
tax_rate: 0,
})
const moneyAmount1 = await manager.create(MoneyAmount, {
id: "ma_test_1",
amount: 100,
@@ -50,4 +57,27 @@ module.exports = async (connection, data = {}) => {
})
await manager.save(moneyAmount3)
const moneyAmount4 = await 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, {
id: "pl_with_some_ma",
name: "Weeken sale",
description: "Desc. of the list",
type: "sale",
status: "active",
starts_at: "2022-07-01T00:00:00.000Z",
ends_at: "2022-07-31T00:00:00.000Z",
})
priceListWithMA.prices = [moneyAmount4]
await manager.save(priceListWithMA)
}