Remove redundant methods from pricing module (#7597)

This commit is contained in:
Harminder Virk
2024-06-04 16:33:06 +05:30
committed by GitHub
parent 41df24e2dc
commit 8d9d78029b
4 changed files with 1 additions and 146 deletions
@@ -167,68 +167,6 @@ moduleIntegrationTestRunner({
})
})
describe("update", () => {
const id = "price-list-rule-2"
it("should update the value of the priceListRule successfully", async () => {
await service.updatePriceListRules([
{
id,
price_list_id: "price-list-2",
rule_type_id: "rule-type-2",
},
])
const priceList = await service.retrievePriceListRule(id, {
relations: ["price_list", "rule_type"],
})
expect(priceList.price_list.id).toEqual("price-list-2")
expect(priceList.rule_type.id).toEqual("rule-type-2")
})
it("should throw an error when a id does not exist", async () => {
let error
try {
await service.updatePriceListRules([
{
id: "does-not-exist",
},
])
} catch (e) {
error = e
}
expect(error.message).toEqual(
'PriceListRule with id "does-not-exist" not found'
)
})
})
describe("create", () => {
it("should create a priceListRule successfully", async () => {
const [created] = await service.createPriceListRules([
{
price_list_id: "price-list-2",
rule_type_id: "rule-type-2",
},
])
const [priceListRule] = await service.listPriceListRules(
{
id: [created.id],
},
{
relations: ["price_list", "rule_type"],
}
)
expect(priceListRule.price_list.id).toEqual("price-list-2")
expect(priceListRule.rule_type.id).toEqual("rule-type-2")
})
})
describe("setPriceListRules", () => {
it("should add a price list rule to a price list", async () => {
await createRuleTypes(testManager, [
@@ -649,45 +649,6 @@ export default class PricingModuleService<
)
}
@InjectManager("baseRepository_")
async createPriceListRules(
data: PricingTypes.CreatePriceListRuleDTO[],
@MedusaContext() sharedContext: Context = {}
): Promise<PricingTypes.PriceListRuleDTO[]> {
const priceLists = await this.createPriceListRules_(data, sharedContext)
return await this.baseRepository_.serialize<
PricingTypes.PriceListRuleDTO[]
>(priceLists, {
populate: true,
})
}
@InjectTransactionManager("baseRepository_")
async createPriceListRules_(
data: PricingTypes.CreatePriceListRuleDTO[],
@MedusaContext() sharedContext: Context = {}
) {
return await this.priceListRuleService_.create(data, sharedContext)
}
@InjectTransactionManager("baseRepository_")
async updatePriceListRules(
data: PricingTypes.UpdatePriceListRuleDTO[],
@MedusaContext() sharedContext: Context = {}
): Promise<PricingTypes.PriceListRuleDTO[]> {
const priceLists = await this.priceListRuleService_.update(
data,
sharedContext
)
return await this.baseRepository_.serialize<
PricingTypes.PriceListRuleDTO[]
>(priceLists, {
populate: true,
})
}
@InjectManager("baseRepository_")
async updatePriceListPrices(
data: PricingTypes.UpdatePriceListPricesDTO[],