refactor: migrate pricing entities to DML models (#10335)

Fixes: FRMW-2810

## Breaking changes
There is only one breaking change

- The `min_quantity` and `max_quantity` properties are now consistently typed as numbers. Earlier, it was [typed as numbers](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L68-L69) in some API responses and as [string in others](https://github.com/medusajs/medusa/blob/develop/integration-tests/http/__tests__/price-list/admin/price-list.spec.ts#L186-L187). I did not go to the bottom of this inconsistency, but the tests reveals them.

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Harminder Virk
2024-12-02 09:44:41 +00:00
committed by GitHub
co-authored by Adrien de Peretti
parent b4d6a4b3f0
commit 913cf15e2b
18 changed files with 387 additions and 726 deletions
@@ -2,6 +2,7 @@ import { PriceRule } from "@models"
import { CreatePriceRuleDTO } from "@medusajs/framework/types"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import { toMikroORMEntity } from "@medusajs/framework/utils"
import { defaultPriceRuleData } from "./data"
export * from "./data"
@@ -20,7 +21,10 @@ export async function createPriceRules(
priceRuleDataClone.attribute = priceRuleDataClone.attribute
priceRuleDataClone.price_id = priceRuleDataClone.price_id
const priceRule = manager.create(PriceRule, priceRuleDataClone)
const priceRule = manager.create(
toMikroORMEntity(PriceRule),
priceRuleDataClone
)
priceRules.push(priceRule)
}