fix(pricing, types): update calculatePrices return type to match actual type (#5709)
* initial type fix * add changeset * update changeset * update tsdocs --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
3 files changed
+17
-8
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/pricing": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(pricing, types): update pricingModule.calculateprices return type to match actual type
|
||||||
@@ -14,12 +14,12 @@ import {
|
|||||||
RuleTypeDTO,
|
RuleTypeDTO,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
|
groupBy,
|
||||||
InjectManager,
|
InjectManager,
|
||||||
InjectTransactionManager,
|
InjectTransactionManager,
|
||||||
MedusaContext,
|
MedusaContext,
|
||||||
MedusaError,
|
MedusaError,
|
||||||
PriceListType,
|
PriceListType,
|
||||||
groupBy,
|
|
||||||
removeNullish,
|
removeNullish,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ export default class PricingModuleService<
|
|||||||
pricingFilters: PricingFilters,
|
pricingFilters: PricingFilters,
|
||||||
pricingContext: PricingContext = { context: {} },
|
pricingContext: PricingContext = { context: {} },
|
||||||
@MedusaContext() sharedContext: Context = {}
|
@MedusaContext() sharedContext: Context = {}
|
||||||
): Promise<PricingTypes.CalculatedPriceSetDTO> {
|
): Promise<PricingTypes.CalculatedPriceSet[]> {
|
||||||
const results = await this.pricingRepository_.calculatePrices(
|
const results = await this.pricingRepository_.calculatePrices(
|
||||||
pricingFilters,
|
pricingFilters,
|
||||||
pricingContext,
|
pricingContext,
|
||||||
@@ -149,7 +149,8 @@ export default class PricingModuleService<
|
|||||||
|
|
||||||
const pricesSetPricesMap = groupBy(results, "price_set_id")
|
const pricesSetPricesMap = groupBy(results, "price_set_id")
|
||||||
|
|
||||||
const calculatedPrices = pricingFilters.id.map(
|
const calculatedPrices: PricingTypes.CalculatedPriceSet[] =
|
||||||
|
pricingFilters.id.map(
|
||||||
(priceSetId: string): PricingTypes.CalculatedPriceSet => {
|
(priceSetId: string): PricingTypes.CalculatedPriceSet => {
|
||||||
// This is where we select prices, for now we just do a first match based on the database results
|
// This is where we select prices, for now we just do a first match based on the database results
|
||||||
// which is prioritized by number_rules first for exact match and then deafult_priority of the rule_type
|
// which is prioritized by number_rules first for exact match and then deafult_priority of the rule_type
|
||||||
@@ -184,8 +185,10 @@ export default class PricingModuleService<
|
|||||||
money_amount_id: calculatedPrice?.id || null,
|
money_amount_id: calculatedPrice?.id || null,
|
||||||
price_list_id: calculatedPrice?.price_list_id || null,
|
price_list_id: calculatedPrice?.price_list_id || null,
|
||||||
price_list_type: calculatedPrice?.price_list_type || null,
|
price_list_type: calculatedPrice?.price_list_type || null,
|
||||||
min_quantity: parseInt(calculatedPrice?.min_quantity || "") || null,
|
min_quantity:
|
||||||
max_quantity: parseInt(calculatedPrice?.max_quantity || "") || null,
|
parseInt(calculatedPrice?.min_quantity || "") || null,
|
||||||
|
max_quantity:
|
||||||
|
parseInt(calculatedPrice?.max_quantity || "") || null,
|
||||||
},
|
},
|
||||||
|
|
||||||
original_price: {
|
original_price: {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
AddPriceListPricesDTO,
|
AddPriceListPricesDTO,
|
||||||
AddPricesDTO,
|
AddPricesDTO,
|
||||||
AddRulesDTO,
|
AddRulesDTO,
|
||||||
CalculatedPriceSetDTO,
|
CalculatedPriceSet,
|
||||||
CreateCurrencyDTO,
|
CreateCurrencyDTO,
|
||||||
CreateMoneyAmountDTO,
|
CreateMoneyAmountDTO,
|
||||||
CreatePriceListDTO,
|
CreatePriceListDTO,
|
||||||
@@ -62,7 +62,7 @@ export interface IPricingModuleService {
|
|||||||
* The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value
|
* The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value
|
||||||
* will be retrieved.
|
* will be retrieved.
|
||||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||||
* @returns {Promise<CalculatedPriceSetDTO>} The calculated price matching the context and filters provided.
|
* @returns {Promise<CalculatedPriceSet[]>} The calculated prices matching the context and filters provided.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* When you calculate prices, you must at least specify the currency code:
|
* When you calculate prices, you must at least specify the currency code:
|
||||||
@@ -137,7 +137,7 @@ export interface IPricingModuleService {
|
|||||||
filters: PricingFilters,
|
filters: PricingFilters,
|
||||||
context?: PricingContext,
|
context?: PricingContext,
|
||||||
sharedContext?: Context
|
sharedContext?: Context
|
||||||
): Promise<CalculatedPriceSetDTO>
|
): Promise<CalculatedPriceSet[]>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to retrieve a price set by its ID.
|
* This method is used to retrieve a price set by its ID.
|
||||||
|
|||||||
Reference in new issue
Block a user