import { DocValue, DocValueMap } from 'fyo/core/types'; import SystemSettings from 'fyo/models/SystemSettings'; import { FieldType, Schema, SelectOption } from 'schemas/types'; import { QueryFilter } from 'utils/db/types'; import { Router } from 'vue-router'; import { Doc } from './doc'; /** * The functions below are used for dynamic evaluation * and setting of field types. * * Since they are set directly on the doc, they can * access the doc by using `this`. * * - `Formula`: Async function used for obtaining a computed value such as amount (rate * qty). * - `Default`: Regular function used to dynamically set the default value, example new Date(). * - `Validation`: Async function that throw an error if the value is invalid. * - `Required`: Regular function used to decide if a value is mandatory (there are !notnul in the db). */ export type FormulaReturn = DocValue | DocValueMap[] | undefined | Doc[]; export type Formula = () => Promise | FormulaReturn; export type FormulaConfig = { dependsOn?: string[]; formula: Formula }; export type Default = () => DocValue; export type Validation = (value: DocValue) => Promise | void; export type Required = () => boolean; export type Hidden = () => boolean; export type ReadOnly = () => 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