feat(pricing, utils, types): adds money amount to pricing module (#4909)
What: - Adds money amount service / repo / model - Adds money amount to entry service - Adds tests for services - Refreshes schema - Update joiner config to include money amounts RESOLVES CORE-1478 RESOLVES CORE-1479 Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com> Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
27 files changed
+1481
-112
No files matched your search
@@ -0,0 +1,23 @@
|
||||
export const defaultMoneyAmountsData = [
|
||||
{
|
||||
id: "money-amount-USD",
|
||||
currency_code: "USD",
|
||||
amount: 500,
|
||||
min_quantity: 1,
|
||||
max_quantity: 10,
|
||||
},
|
||||
{
|
||||
id: "money-amount-EUR",
|
||||
currency_code: "EUR",
|
||||
amount: 400,
|
||||
min_quantity: 1,
|
||||
max_quantity: 5,
|
||||
},
|
||||
{
|
||||
id: "money-amount-CAD",
|
||||
currency_code: "CAD",
|
||||
amount: 600,
|
||||
min_quantity: 1,
|
||||
max_quantity: 8,
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { MoneyAmount } from "@models"
|
||||
import { defaultMoneyAmountsData } from "./data"
|
||||
|
||||
export async function createMoneyAmounts(
|
||||
manager: SqlEntityManager,
|
||||
moneyAmountsData: any[] = defaultMoneyAmountsData
|
||||
): Promise<MoneyAmount[]> {
|
||||
const moneyAmounts: MoneyAmount[] = []
|
||||
|
||||
for (let moneyAmountData of moneyAmountsData) {
|
||||
const moneyAmount = manager.create(MoneyAmount, moneyAmountData)
|
||||
|
||||
moneyAmounts.push(moneyAmount)
|
||||
}
|
||||
|
||||
await manager.persistAndFlush(moneyAmounts)
|
||||
|
||||
return moneyAmounts
|
||||
}
|
||||
Reference in new issue
Block a user