feat(core-flows,pricing,medusa,pricing,types,utils): Price List Prices can have their own rules (#5752)
**What** - Add price-rules for prices in price-lists - make rules object optional when creating prices **Why** - more price granularity Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
co-authored by
Philip Korsholm
parent
f05c20695e
commit
079f0da83f
@@ -65,7 +65,7 @@ export interface PriceListDTO {
|
||||
/**
|
||||
* The number of rules associated with this price list.
|
||||
*/
|
||||
number_rules?: number
|
||||
rules_count?: number
|
||||
/**
|
||||
* The associated price set money amounts.
|
||||
*
|
||||
@@ -111,8 +111,22 @@ export interface PriceListPriceDTO extends CreateMoneyAmountDTO {
|
||||
* The ID of the associated price set.
|
||||
*/
|
||||
price_set_id: string
|
||||
/**
|
||||
* The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
*/
|
||||
rules?: CreatePriceSetPriceRules
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
* The price rules to be set for each price in the price set.
|
||||
*
|
||||
* Each key of the object is a rule type's `rule_attribute`, and its value
|
||||
* is the values of the rule.
|
||||
*/
|
||||
export interface CreatePriceSetPriceRules extends Record<string, string> {}
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
@@ -154,7 +168,7 @@ export interface CreatePriceListDTO {
|
||||
/**
|
||||
* The number of rules associated with the price list.
|
||||
*/
|
||||
number_rules?: number
|
||||
rules_count?: number
|
||||
/**
|
||||
* The rules to be created and associated with the price list.
|
||||
*/
|
||||
@@ -194,7 +208,7 @@ export interface UpdatePriceListDTO {
|
||||
/**
|
||||
* The number of rules associated with the price list.
|
||||
*/
|
||||
number_rules?: number
|
||||
rules_count?: number
|
||||
/**
|
||||
* The rules to be created and associated with the price list.
|
||||
*/
|
||||
@@ -227,7 +241,7 @@ export interface FilterablePriceListProps
|
||||
/**
|
||||
* The number of rules to filter price lists by.
|
||||
*/
|
||||
number_rules?: number[]
|
||||
rules_count?: number[]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { PriceSetDTO } from "./price-set"
|
||||
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
|
||||
import { RuleTypeDTO } from "./rule-type"
|
||||
|
||||
/**
|
||||
@@ -56,24 +57,38 @@ export interface PriceRuleDTO {
|
||||
* A price rule to create.
|
||||
*/
|
||||
export interface CreatePriceRuleDTO {
|
||||
/**
|
||||
* The ID of the price rule.
|
||||
*/
|
||||
id: string
|
||||
/**
|
||||
* The ID of the associated price set.
|
||||
*/
|
||||
price_set_id: string
|
||||
price_set_id?: string
|
||||
/**
|
||||
* The ID or object of the associated price set.
|
||||
*/
|
||||
price_set?: string | PriceSetDTO
|
||||
/**
|
||||
* The ID of the associated rule type.
|
||||
*/
|
||||
rule_type_id: string
|
||||
rule_type_id?: string
|
||||
/**
|
||||
* The ID of the associated rule type.
|
||||
*/
|
||||
rule_type?: string | RuleTypeDTO
|
||||
/**
|
||||
* The value of the price rule.
|
||||
*/
|
||||
value: string
|
||||
/**
|
||||
* The priority of the price rule in comparison to other applicable price rules.
|
||||
*/
|
||||
priority?: number
|
||||
price_set_money_amount_id: string
|
||||
/**
|
||||
* The ID of the associated price set money amount.
|
||||
*/
|
||||
price_set_money_amount_id?: string
|
||||
/**
|
||||
* The ID or object of the associated price set money amount.
|
||||
*/
|
||||
price_set_money_amount?: string | PriceSetMoneyAmountDTO
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,13 +20,13 @@ export interface PriceSetMoneyAmountDTO {
|
||||
title?: string
|
||||
/**
|
||||
* The price set associated with the price set money amount.
|
||||
*
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
price_set?: PriceSetDTO
|
||||
/**
|
||||
* The price list associated with the price set money amount.
|
||||
*
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
price_list?: PriceListDTO
|
||||
@@ -36,13 +36,13 @@ export interface PriceSetMoneyAmountDTO {
|
||||
price_set_id?: string
|
||||
/**
|
||||
* The price rules associated with the price set money amount.
|
||||
*
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
price_rules?: PriceRuleDTO[]
|
||||
/**
|
||||
* The money amount associated with the price set money amount.
|
||||
*
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
money_amount?: MoneyAmountDTO
|
||||
@@ -60,6 +60,7 @@ export interface CreatePriceSetMoneyAmountDTO {
|
||||
price_set?: PriceSetDTO | string
|
||||
price_list?: PriceListDTO | string
|
||||
money_amount?: MoneyAmountDTO | string
|
||||
rules_count?: number
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { BaseFilterable } from "../../dal";
|
||||
import { CreateMoneyAmountDTO, FilterableMoneyAmountProps, MoneyAmountDTO } from "./money-amount";
|
||||
import { RuleTypeDTO } from "./rule-type";
|
||||
import { CreatePriceSetPriceRules } from "./price-list";
|
||||
|
||||
/**
|
||||
* @interface
|
||||
@@ -52,7 +53,7 @@ export interface PriceSetDTO {
|
||||
* @interface
|
||||
*
|
||||
* A calculated price set's data.
|
||||
*
|
||||
*
|
||||
* @privateRemarks
|
||||
* Do we still need this type? Shouldn't we use CalculatedPriceSet instead?
|
||||
*/
|
||||
@@ -93,7 +94,7 @@ export interface CalculatedPriceSetDTO {
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
*
|
||||
* The calculated price for a specific price set and context.
|
||||
*/
|
||||
export interface CalculatedPriceSet {
|
||||
@@ -102,7 +103,7 @@ export interface CalculatedPriceSet {
|
||||
*/
|
||||
id: string
|
||||
/**
|
||||
* Whether the calculated price is associated with a price list. During the calculation process, if no valid price list is found,
|
||||
* Whether the calculated price is associated with a price list. During the calculation process, if no valid price list is found,
|
||||
* the calculated price is set to the original price, which doesn't belong to a price list. In that case, the value of this property is `false`.
|
||||
*/
|
||||
is_calculated_price_price_list?: boolean
|
||||
@@ -112,7 +113,7 @@ export interface CalculatedPriceSet {
|
||||
calculated_amount: number | null
|
||||
|
||||
/**
|
||||
* Whether the original price is associated with a price list. During the calculation process, if the price list of the calculated price is of type override,
|
||||
* Whether the original price is associated with a price list. During the calculation process, if the price list of the calculated price is of type override,
|
||||
* the original price will be the same as the calculated price. In that case, the value of this property is `true`.
|
||||
*/
|
||||
is_original_price_price_list?: boolean
|
||||
@@ -192,7 +193,7 @@ export interface AddRulesDTO {
|
||||
/**
|
||||
* The rules to add to a price set.
|
||||
*/
|
||||
rules: {
|
||||
rules: {
|
||||
/**
|
||||
* The value of the rule's `rule_attribute` attribute.
|
||||
*/
|
||||
@@ -209,7 +210,7 @@ export interface CreatePricesDTO extends CreateMoneyAmountDTO {
|
||||
/**
|
||||
* The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
*/
|
||||
rules: Record<string, string>
|
||||
rules?: CreatePriceSetPriceRules
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +254,7 @@ export interface CreatePriceSetDTO {
|
||||
/**
|
||||
* The rules to associate with the price set.
|
||||
*/
|
||||
rules?: {
|
||||
rules?: {
|
||||
/**
|
||||
* the value of the rule's `rule_attribute` attribute.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface CreatePriceListDTO {
|
||||
starts_at?: string
|
||||
ends_at?: string
|
||||
status?: PriceListStatus
|
||||
number_rules?: number
|
||||
rules_count?: number
|
||||
rules?: PriceListRuleDTO[]
|
||||
prices?: {
|
||||
amount: number
|
||||
@@ -63,7 +63,7 @@ export interface CreatePriceListWorkflowDTO {
|
||||
starts_at?: string
|
||||
ends_at?: string
|
||||
status?: PriceListStatus
|
||||
number_rules?: number
|
||||
rules_count?: number
|
||||
prices: InputPrice[]
|
||||
rules?: CreatePriceListRules
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user