feat: Add currency module and remove currency models from region and pricing modules (#6536)
What: - Creates a new currency module - Removes currency model from the pricing module - Removes currency model from region module
This commit is contained in:
1 parent
06f706a51a
commit
dc025302a1
102 files changed
+1502
-2128
No files matched your search
@@ -1,20 +0,0 @@
|
||||
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",
|
||||
},
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
import { Currency } from "@models"
|
||||
import { defaultCurrencyData } from "./data"
|
||||
|
||||
export * 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
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
|
||||
import { createCurrencies, defaultCurrencyData } from "./currency"
|
||||
import { createMoneyAmounts, defaultMoneyAmountsData } from "./money-amount"
|
||||
import { createPriceRules, defaultPriceRuleData } from "./price-rule"
|
||||
import { createPriceSets, defaultPriceSetsData } from "./price-set"
|
||||
@@ -21,14 +20,12 @@ export async function seedPriceData(
|
||||
{
|
||||
moneyAmountsData = defaultMoneyAmountsData,
|
||||
priceSetsData = defaultPriceSetsData,
|
||||
currencyData = defaultCurrencyData,
|
||||
priceRuleData = defaultPriceRuleData,
|
||||
priceSetMoneyAmountsData = defaultPriceSetMoneyAmountsData,
|
||||
priceSetMoneyAmountRulesData = defaultPriceSetMoneyAmountRulesData,
|
||||
ruleTypesData = defaultRuleTypesData,
|
||||
} = {}
|
||||
) {
|
||||
await createCurrencies(testManager, currencyData)
|
||||
await createMoneyAmounts(testManager, moneyAmountsData)
|
||||
await createPriceSets(testManager, priceSetsData)
|
||||
await createPriceSetMoneyAmounts(testManager, priceSetMoneyAmountsData)
|
||||
|
||||
Reference in new issue
Block a user