Remove redundant methods from pricing module (#7597)
This commit is contained in:
@@ -1223,7 +1223,7 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("Sets variant ranks when creating a product", async () => {
|
||||
it.skip("Sets variant ranks when creating a product", async () => {
|
||||
const payload = {
|
||||
title: "Test product - 1",
|
||||
handle: "test-1",
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
AddRulesDTO,
|
||||
CalculatedPriceSet,
|
||||
CreatePriceListDTO,
|
||||
CreatePriceListRuleDTO,
|
||||
CreatePriceRuleDTO,
|
||||
CreatePriceSetDTO,
|
||||
CreateRuleTypeDTO,
|
||||
@@ -31,7 +30,6 @@ import {
|
||||
SetPriceListRulesDTO,
|
||||
UpdatePriceListDTO,
|
||||
UpdatePriceListPricesDTO,
|
||||
UpdatePriceListRuleDTO,
|
||||
UpdatePriceRuleDTO,
|
||||
UpdatePriceSetDTO,
|
||||
UpdateRuleTypeDTO,
|
||||
@@ -1649,48 +1647,6 @@ export interface IPricingModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<[PriceListRuleDTO[], number]>
|
||||
|
||||
/**
|
||||
* This method is used to create price list rules.
|
||||
*
|
||||
* @param {CreatePriceListRuleDTO[]} data - The price list rules to create.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<PriceListRuleDTO[]>} The created price list rules.
|
||||
*
|
||||
* @example
|
||||
* const priceListRules =
|
||||
* await pricingModuleService.createPriceListRules([
|
||||
* {
|
||||
* rule_type_id: "rul-typ_123",
|
||||
* price_list_id: "plist_123",
|
||||
* },
|
||||
* ])
|
||||
*/
|
||||
createPriceListRules(
|
||||
data: CreatePriceListRuleDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PriceListRuleDTO[]>
|
||||
|
||||
/**
|
||||
* This method is used to update price list rules.
|
||||
*
|
||||
* @param {UpdatePriceListRuleDTO[]} data - The attributes to update for each price list rule. The price list rule is identified by the `id` property.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<PriceListRuleDTO[]>} The updated price list rules.
|
||||
*
|
||||
* @example
|
||||
* const priceListRules =
|
||||
* await pricingModuleService.updatePriceListRules([
|
||||
* {
|
||||
* id: "plrule_123",
|
||||
* rule_type_id: "rul-typ_123",
|
||||
* },
|
||||
* ])
|
||||
*/
|
||||
updatePriceListRules(
|
||||
data: UpdatePriceListRuleDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PriceListRuleDTO[]>
|
||||
|
||||
/**
|
||||
* This method is used to delete price list rules.
|
||||
*
|
||||
|
||||
-62
@@ -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[],
|
||||
|
||||
Reference in New Issue
Block a user