diff --git a/frappe/core/docHandler.ts b/frappe/core/docHandler.ts index 8896a929..bdf40063 100644 --- a/frappe/core/docHandler.ts +++ b/frappe/core/docHandler.ts @@ -1,5 +1,5 @@ import Doc from 'frappe/model/doc'; -import { DocMap, ModelMap } from 'frappe/model/types'; +import { DocMap, ModelMap, SinglesMap } from 'frappe/model/types'; import { coreModels } from 'frappe/models'; import { getRandomString } from 'frappe/utils'; import Observable from 'frappe/utils/observable'; @@ -8,7 +8,7 @@ import { DocValue, DocValueMap } from './types'; export class DocHandler { frappe: Frappe; - singles: DocMap = {}; + singles: SinglesMap = {}; docs: Observable = new Observable(); models: ModelMap = {}; diff --git a/frappe/index.ts b/frappe/index.ts index a0ce0030..398ed0a4 100644 --- a/frappe/index.ts +++ b/frappe/index.ts @@ -15,7 +15,6 @@ import { format } from './utils/format'; import { t, T } from './utils/translation'; import { ErrorLog } from './utils/types'; - export class Frappe { t = t; T = T; @@ -36,6 +35,9 @@ export class Frappe { methods?: Record; temp?: Record; + currencyFormatter?: Intl.NumberFormat; + currencySymbols: Record = {}; + constructor(DatabaseDemux?: DatabaseDemuxConstructor) { /** * `DatabaseManager` can be passed as the `DatabaseDemux` for @@ -84,6 +86,7 @@ export class Frappe { await this.#initializeMoneyMaker(); this.doc.registerModels(models, regionalModels); + await this.doc.getSingle('SystemSettings'); this._initialized = true; } diff --git a/frappe/model/doc.ts b/frappe/model/doc.ts index 37b4f116..dd09ae8c 100644 --- a/frappe/model/doc.ts +++ b/frappe/model/doc.ts @@ -28,6 +28,7 @@ import { import { setName } from './naming'; import { Action, + CurrenciesMap, DefaultMap, DependsOnMap, EmptyMessageMap, @@ -705,6 +706,7 @@ export default class Doc extends Observable { required: RequiredMap = {}; hidden: HiddenMap = {}; dependsOn: DependsOnMap = {}; + getCurrencies: CurrenciesMap = {}; static lists: ListsMap = {}; static filters: FiltersMap = {}; diff --git a/frappe/model/types.ts b/frappe/model/types.ts index 9b0a8c78..215bf0d3 100644 --- a/frappe/model/types.ts +++ b/frappe/model/types.ts @@ -1,4 +1,5 @@ import { DocValue, DocValueMap } from 'frappe/core/types'; +import SystemSettings from 'frappe/models/SystemSettings'; import { FieldType } from 'schemas/types'; import { QueryFilter } from 'utils/db/types'; import { Router } from 'vue-router'; @@ -22,11 +23,13 @@ export type Default = () => DocValue; export type Validation = (value: DocValue) => Promise; export type Required = () => boolean; export type Hidden = () => boolean; +export type GetCurrency = () => string; export type FormulaMap = Record; export type DefaultMap = Record; export type ValidationMap = Record; export type RequiredMap = Record; +export type CurrenciesMap = Record; export type HiddenMap = Record