fix(medusa): Allow de-selecting configurations in price lists (#1596)

This commit is contained in:
Philip Korsholm authored and GitHub committed 2022-05-30 19:34:34 +02:00
1 parent d0c679fc7e
commit 3f23edea23
4 files changed
+104 -68

No files matched your search

@@ -128,10 +128,10 @@ export class AdminPostPriceListsPriceListPriceListReq {
description?: string
@IsOptional()
starts_at?: Date
starts_at?: Date | null
@IsOptional()
ends_at?: Date
ends_at?: Date | null
@IsOptional()
@IsEnum(PriceListStatus)
+2 -2
View File
@@ -31,10 +31,10 @@ export class PriceList extends SoftDeletableEntity {
type: resolveDbType("timestamptz"),
nullable: true,
})
starts_at: Date
starts_at: Date | null
@Column({ type: resolveDbType("timestamptz"), nullable: true })
ends_at: Date
ends_at: Date | null
@JoinTable({
name: "price_list_customer_groups",
+10 -6
View File
@@ -146,12 +146,6 @@ class PriceListService extends TransactionBaseService<PriceListService> {
const { prices, customer_groups, ...rest } = update
for (const [key, value] of Object.entries(rest)) {
priceList[key] = value
}
await priceListRepo.save(priceList)
if (prices) {
const prices_ = await this.addCurrencyFromRegion(prices)
await moneyAmountRepo.updatePriceListPrices(id, prices_)
@@ -161,6 +155,16 @@ class PriceListService extends TransactionBaseService<PriceListService> {
await this.upsertCustomerGroups_(id, customer_groups)
}
for (const [key, value] of Object.entries(rest)) {
if (typeof value === "undefined") {
continue
}
priceList[key] = value
}
await priceListRepo.save(priceList)
return await this.retrieve(id, {
relations: ["prices", "customer_groups"],
})