feat(pricing,utils,types): add operator field to price rule (#10315)

what:

- adds an operator field to price rule with specific operator fields

RESOLVES CMRC-746
This commit is contained in:
Riqwan Thamir
2024-11-28 09:23:26 +00:00
committed by GitHub
parent 2838100efc
commit 3b1a63eca7
8 changed files with 91 additions and 6 deletions
@@ -1,13 +1,16 @@
import { DAL } from "@medusajs/framework/types"
import { DAL, PricingRuleOperatorValues } from "@medusajs/framework/types"
import {
createPsqlIndexStatementHelper,
DALUtils,
generateEntityId,
PricingRuleOperator,
} from "@medusajs/framework/utils"
import {
BeforeCreate,
Entity,
Enum,
Filter,
Index,
ManyToOne,
OnInit,
OptionalProps,
@@ -28,7 +31,7 @@ const PriceRuleDeletedAtIndex = createPsqlIndexStatementHelper({
const PriceRulePriceIdIndex = createPsqlIndexStatementHelper({
tableName: tableName,
columns: ["price_id", "attribute"],
columns: ["price_id", "attribute", "operator"],
where: "deleted_at IS NULL",
unique: true,
})
@@ -44,6 +47,10 @@ export default class PriceRule {
@Property({ columnType: "text" })
attribute: string
@Index({ name: "IDX_price_rule_operator" })
@Enum({ items: () => PricingRuleOperator, default: PricingRuleOperator.EQ })
operator: PricingRuleOperatorValues = PricingRuleOperator.EQ
@Property({ columnType: "text" })
value: string