fix(medisa): Deleting price list should use remove (#1540)
This commit is contained in:
@@ -945,6 +945,19 @@ describe("/admin/price-lists", () => {
|
|||||||
object: "price-list",
|
object: "price-list",
|
||||||
deleted: true,
|
deleted: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
await api.get("/admin/price-lists/pl_no_customer_groups", {
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer test_token",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
expect(error.response.status).toBe(404)
|
||||||
|
expect(error.response.data.message).toEqual(
|
||||||
|
"Price list with id: pl_no_customer_groups was not found"
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import {
|
|||||||
UpdatePriceListInput,
|
UpdatePriceListInput,
|
||||||
} from "../types/price-list"
|
} from "../types/price-list"
|
||||||
import { formatException } from "../utils/exception-formatter"
|
import { formatException } from "../utils/exception-formatter"
|
||||||
import RegionService from "./region"
|
|
||||||
import ProductService from "./product"
|
import ProductService from "./product"
|
||||||
|
import RegionService from "./region"
|
||||||
|
|
||||||
type PriceListConstructorProps = {
|
type PriceListConstructorProps = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
@@ -232,11 +232,12 @@ class PriceListService extends BaseService {
|
|||||||
const priceListRepo = manager.getCustomRepository(this.priceListRepo_)
|
const priceListRepo = manager.getCustomRepository(this.priceListRepo_)
|
||||||
|
|
||||||
const priceList = await priceListRepo.findOne({ where: { id: id } })
|
const priceList = await priceListRepo.findOne({ where: { id: id } })
|
||||||
|
|
||||||
if (!priceList) {
|
if (!priceList) {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
await priceListRepo.delete(priceList)
|
await priceListRepo.remove(priceList)
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user