feat(pricing) Add Price Set Rule Type (#4977)
* initial * initial service * update pricing module service * add integration test for rule-type * update pricing-module integration tests * update pricing service interface * feat(pricing): PriceSets as entry point to pricing module * chore: add price set money amount * chore: add price set money amount * chore: change name of test * chore: added changeset * chore: use filterable props from money amount in price sets * chore: update migrations * test update integration test * fix weird behavior * Update packages/pricing/integration-tests/__fixtures__/rule-type/index.ts Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> * Apply suggestions from code review Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> * move rule-type to common * chore: reset migration * chore: remove incorrect conflicts * chore: address review * chore: remove ghost price list * Apply suggestions from code review Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> * update id prefix * use persist not persistAndflush * rename key_value to rule_attribute * more renaming --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -2,3 +2,4 @@ export { default as Currency } from "./currency"
|
||||
export { default as MoneyAmount } from "./money-amount"
|
||||
export { default as PriceSet } from "./price-set"
|
||||
export { default as PriceSetMoneyAmount } from "./price-set-money-amount"
|
||||
export { default as RuleType } from "./rule-type"
|
||||
|
||||
@@ -19,10 +19,15 @@ export default class PriceSetMoneyAmount {
|
||||
@Property({ columnType: "text" })
|
||||
title!: string
|
||||
|
||||
@ManyToOne(() => PriceSet, { onDelete: "cascade" })
|
||||
@ManyToOne(() => PriceSet, {
|
||||
onDelete: "cascade",
|
||||
index: "IDX_price_set_money_amount_price_set_id",
|
||||
})
|
||||
price_set?: PriceSet
|
||||
|
||||
@ManyToOne(() => MoneyAmount, {})
|
||||
@ManyToOne(() => MoneyAmount, {
|
||||
index: "IDX_price_set_money_amount_money_amount_id",
|
||||
})
|
||||
money_amount?: MoneyAmount
|
||||
|
||||
@BeforeCreate()
|
||||
|
||||
34
packages/pricing/src/models/rule-type.ts
Normal file
34
packages/pricing/src/models/rule-type.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { generateEntityId } from "@medusajs/utils"
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
|
||||
type OptionalFields = "default_priority"
|
||||
|
||||
@Entity()
|
||||
class RuleType {
|
||||
[OptionalProps]?: OptionalFields
|
||||
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id!: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
name: string
|
||||
|
||||
@Property({ columnType: "text", index: "IDX_rule_type_rule_attribute" })
|
||||
rule_attribute: string
|
||||
|
||||
@Property({ columnType: "integer", default: 0 })
|
||||
default_priority: number
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "rul-typ")
|
||||
}
|
||||
}
|
||||
|
||||
export default RuleType
|
||||
Reference in New Issue
Block a user