feat(pricing, types, utils, medusa-sdk): Pricing Module Setup + Currency (#4860)
What: - Setups the skeleton for pricing module - Creates service/model/repository for currency model - Setups types - Setups DB - Moved some utils to a common place RESOLVES CORE-1477 RESOLVES CORE-1476
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
export const defaultCurrencyData = [
|
||||
{
|
||||
symbol: "$",
|
||||
name: "US Dollar",
|
||||
symbol_native: "$",
|
||||
code: "USD",
|
||||
},
|
||||
{
|
||||
symbol: "CA$",
|
||||
name: "Canadian Dollar",
|
||||
symbol_native: "$",
|
||||
code: "CAD",
|
||||
},
|
||||
{
|
||||
symbol: "€",
|
||||
name: "Euro",
|
||||
symbol_native: "€",
|
||||
code: "EUR",
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,20 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Currency } from "@models"
|
||||
import { defaultCurrencyData } from "./data"
|
||||
|
||||
export async function createCurrencies(
|
||||
manager: SqlEntityManager,
|
||||
currencyData: any[] = defaultCurrencyData
|
||||
): Promise<Currency[]> {
|
||||
const currencies: Currency[] = []
|
||||
|
||||
for (let curr of currencyData) {
|
||||
const currency = manager.create(Currency, curr)
|
||||
|
||||
currencies.push(currency)
|
||||
}
|
||||
|
||||
await manager.persistAndFlush(currencies)
|
||||
|
||||
return currencies
|
||||
}
|
||||
Reference in New Issue
Block a user