ngx-t-forms-types 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/interfaces/Form/index.d.ts +2 -2
- package/dist/interfaces/FormBuilder/DefaultEelement.js +2 -2
- package/dist/interfaces/FormBuilder/inputConfig/ElementEditConfig.js +25 -3
- package/dist/interfaces/environment/IStoreFunctions.d.ts +42 -2
- package/dist/interfaces/environment/environment.d.ts +156 -0
- package/dist/interfaces/environment/environment.js +12 -1
- package/dist/interfaces/environment/index.d.ts +2 -2
- package/dist/interfaces/environment/index.js +2 -1
- package/dist/interfaces/formInput/BasicFormInputInterface.d.ts +15 -0
- package/dist/interfaces/formInput/IMscoaAccount.d.ts +41 -0
- package/dist/interfaces/formInput/calculatedFieldRules.d.ts +31 -1
- package/dist/interfaces/formInput/calculatedFieldRules.js +16 -1
- package/dist/interfaces/formInput/index.d.ts +2 -2
- package/dist/interfaces/formInput/index.js +2 -1
- package/dist/schemas/CalculatedFieldRulesSchema.js +2 -1
- package/dist/schemas/FormInputSchema.js +3 -1
- package/dist/schemas/MscoaConfigSchema.d.ts +6 -0
- package/dist/schemas/MscoaConfigSchema.js +16 -2
- package/dist/schemas/tests/FormInputValidator.spec.js +27 -0
- package/dist/skillet/extra-members.d.ts +1 -1
- package/dist/skillet/input-members.d.ts +4 -1
- package/dist/skillet/input-members.js +1 -1
- package/dist/skillet/members/calculated-field.d.ts +4 -4
- package/dist/skillet/members/calculated-field.js +6 -5
- package/dist/skillet/members/mscoa.d.ts +11 -0
- package/dist/skillet/members/mscoa.js +2 -0
- package/dist/skillet/members/table.d.ts +1 -1
- package/dist/skillet/shared-types.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgxTFormsConfig } from "../environment/environment.js";
|
|
1
|
+
import { ImportTemplateConfig, NgxTFormsConfig } from "../environment/environment.js";
|
|
2
2
|
import { FormColumnInputs } from "../formInput/BasicFormInputInterface.js";
|
|
3
3
|
import { FormInterfaceMigration, IAllInputs, OLD_FormInterface } from "../upgradeFunctions/interfaces/init-form.js";
|
|
4
4
|
import { IArrayFunction } from "./ArrayFunctions.js";
|
|
@@ -9,5 +9,5 @@ import { IFormActions, InClassFormUtilsInterface, InClassFormUtilsWithSectionsIn
|
|
|
9
9
|
import { FormInterface, DatabaseFormInterface, MainFormInterface } from "./formInterface.js";
|
|
10
10
|
import { FormSubmissionHandleInterface, IReportDataSources } from "./formSubmissionHandleInterface.js";
|
|
11
11
|
import { FormListSection, FormStateErrors, IFormsInitStateInterface, LocalFormStateSelectorInterface } from "./IFormsInitStateInterface.js";
|
|
12
|
-
export { CustomConfigInterface, InClassFormUtilsInterface, InClassFormUtilsWithSectionsInterface, FormInterface, MainFormInterface, DatabaseFormInterface, FormSubmissionHandleInterface, FormColumnInputs, IFormActions, NgxTFormsConfig, FileUploadFn, FileData, FormListSection, LocalFormStateSelectorInterface, IFormsInitStateInterface, FormStateErrors, IArrayFunction, OLD_FormInterface, FormInterfaceMigration, IAllInputs, IFormChangeHistory, IReportDataSources };
|
|
12
|
+
export { CustomConfigInterface, InClassFormUtilsInterface, InClassFormUtilsWithSectionsInterface, FormInterface, MainFormInterface, DatabaseFormInterface, FormSubmissionHandleInterface, FormColumnInputs, IFormActions, NgxTFormsConfig, ImportTemplateConfig, FileUploadFn, FileData, FormListSection, LocalFormStateSelectorInterface, IFormsInitStateInterface, FormStateErrors, IArrayFunction, OLD_FormInterface, FormInterfaceMigration, IAllInputs, IFormChangeHistory, IReportDataSources };
|
|
13
13
|
export { FunctionTypes } from "./ArrayFunctions.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CurrenciesList } from "../../../Configs/currencies.js";
|
|
2
2
|
import { DatePipeOptions } from "../../../Configs/datePipes.js";
|
|
3
3
|
import { AdjudicationSteps, AutocompleteOptions, ElementTypes, InputDataTypes, InputPipeTypes, InputTypes } from "../../formInput/index.js";
|
|
4
|
+
import { ROUNDING_MODES, ROUNDING_MODE_LABELS } from "../../formInput/calculatedFieldRules.js";
|
|
4
5
|
import { DataSources } from "../../formInput/APIDataFetchingConfigurationInterface.js";
|
|
5
6
|
import { OptionSelectTypes } from "../../formInput/BasicFormInputInterface.js";
|
|
6
7
|
import { InputFileType } from "../../formInput/FileUploadInputInterface.js";
|
|
@@ -1130,8 +1131,8 @@ export var ElementConfig = {
|
|
|
1130
1131
|
{
|
|
1131
1132
|
name: SpecialElementKeys.Default,
|
|
1132
1133
|
editType: ElementEditorTypes.ChipSelect,
|
|
1133
|
-
label: '
|
|
1134
|
-
hint: "
|
|
1134
|
+
label: 'Number format',
|
|
1135
|
+
hint: "How the number is presented. Currency, decimal and integer also set the precision the value is kept at: it is rounded when typed, imported or calculated, and the rounded value is what is saved and shown. The other formats only change the display.",
|
|
1135
1136
|
deepBind: ['pipe', 'pipeType'],
|
|
1136
1137
|
additionalTest: [
|
|
1137
1138
|
{
|
|
@@ -1147,6 +1148,7 @@ export var ElementConfig = {
|
|
|
1147
1148
|
editType: ElementEditorTypes.OptionSelect,
|
|
1148
1149
|
deepBind: ['pipe', 'param'],
|
|
1149
1150
|
label: 'Select currency to apply',
|
|
1151
|
+
hint: "Amounts are kept to the currency's minor unit (2 decimals for ZAR) and rounded half to even — banker's rounding — unless you choose another rounding below.",
|
|
1150
1152
|
options: CurrenciesList,
|
|
1151
1153
|
id: "209d2295-cbaa-4f99-98d2-15c4515581b8",
|
|
1152
1154
|
additionalTest: [
|
|
@@ -1177,7 +1179,8 @@ export var ElementConfig = {
|
|
|
1177
1179
|
{
|
|
1178
1180
|
name: SpecialElementKeys.Default,
|
|
1179
1181
|
editType: ElementEditorTypes.Input,
|
|
1180
|
-
label: 'Decimal
|
|
1182
|
+
label: 'Decimal places',
|
|
1183
|
+
hint: 'How many decimal places to keep, for example 2. The value is rounded to this precision when typed, imported or calculated, and the rounded value is saved.',
|
|
1181
1184
|
deepBind: ['pipe', 'param'],
|
|
1182
1185
|
additionalTest: [
|
|
1183
1186
|
{
|
|
@@ -1191,6 +1194,25 @@ export var ElementConfig = {
|
|
|
1191
1194
|
],
|
|
1192
1195
|
id: "d0771f0e-eaec-457c-a2f4-e454fd9092c7"
|
|
1193
1196
|
},
|
|
1197
|
+
{
|
|
1198
|
+
name: SpecialElementKeys.Default,
|
|
1199
|
+
editType: ElementEditorTypes.ChipSelect,
|
|
1200
|
+
label: 'Rounding',
|
|
1201
|
+
hint: "Which way a value past the precision rounds. Banker's sends a tie (…5) to the even neighbour and is the default for currency; Nearest sends a tie away from zero and is the default otherwise; Round down and Round up always move toward the lower or the higher value.",
|
|
1202
|
+
deepBind: ['pipe', 'rounding'],
|
|
1203
|
+
options: ROUNDING_MODES.map((mode) => ({ label: ROUNDING_MODE_LABELS[mode], value: mode })),
|
|
1204
|
+
additionalTest: [
|
|
1205
|
+
{
|
|
1206
|
+
expression: `type === ${InputTypes.Number}`,
|
|
1207
|
+
deepBind: ['type'],
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
expression: `pipeType === ${InputPipeTypes.Currency} || pipeType === ${InputPipeTypes.Decimal} || pipeType === ${InputPipeTypes.Integer}`,
|
|
1211
|
+
deepBind: ['pipe', 'pipeType'],
|
|
1212
|
+
},
|
|
1213
|
+
],
|
|
1214
|
+
id: "5f3c9b1e-2a74-4d08-b6e1-9c0d7a4f28e3"
|
|
1215
|
+
},
|
|
1194
1216
|
{
|
|
1195
1217
|
name: SpecialElementKeys.Default,
|
|
1196
1218
|
editType: ElementEditorTypes.Input,
|
|
@@ -6,7 +6,7 @@ import { FormListSection } from "../Form/IFormsInitStateInterface.js";
|
|
|
6
6
|
import { IUserSignature, PointGroup } from "../formInput/userSignature.js";
|
|
7
7
|
import { IWorkflowDocListCols, IWorkflowStepOption } from "../FormBuilder/workflowSelectionConfig.js";
|
|
8
8
|
import { IDocumentPage, IDocumentQueryRequest } from "../formInput/WorkflowDocumentPicker.js";
|
|
9
|
-
import {
|
|
9
|
+
import { GlobalVariables } from "./environment.js";
|
|
10
10
|
export interface DialogConfig {
|
|
11
11
|
title: string;
|
|
12
12
|
message: string;
|
|
@@ -49,7 +49,47 @@ export interface IStoreFunctions {
|
|
|
49
49
|
toastError: (message: string) => void;
|
|
50
50
|
workflows: () => Observable<IWorkflowOption[]>;
|
|
51
51
|
getWorkflowCols: (workflowId: string) => Observable<IWorkflowDocListCols[]>;
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Values the application injects into every form as read-only system inputs —
|
|
54
|
+
* the current financial cycle, the open transaction's id, the signed-in user's
|
|
55
|
+
* department, anything a form may need to read or a formula may need to use
|
|
56
|
+
* without asking the user for it. Replaces `getFinacialCycles`, which fixed
|
|
57
|
+
* the set of variables to financial cycles.
|
|
58
|
+
*
|
|
59
|
+
* Each entry becomes one system input whose control name is the key, placed in
|
|
60
|
+
* the form's first section and listed in the builder's pickers under a
|
|
61
|
+
* "System:" label, so an author can reference it in formulas, conditions,
|
|
62
|
+
* required-input rules and submission payloads like any other control.
|
|
63
|
+
*
|
|
64
|
+
* Keys are control names: letters, digits and underscores, not starting with a
|
|
65
|
+
* digit (`^[A-Za-z_][A-Za-z0-9_]*$`). Prefer SCREAMING_SNAKE_CASE — an authored
|
|
66
|
+
* control is lowerCamelCase, so the two can never collide. A key an open form
|
|
67
|
+
* already uses for an authored control is not injected: the authored control
|
|
68
|
+
* wins. A key outside the pattern is not injected either.
|
|
69
|
+
*
|
|
70
|
+
* Values decide the input: a `Date` or a `DateLike` (a Moment, a Day.js
|
|
71
|
+
* instance — anything with `toDate()`) becomes a date picker; a number a
|
|
72
|
+
* number input; a boolean a toggle; a string a text input. `null`,
|
|
73
|
+
* `undefined`, an empty string, a non-finite number and an invalid date mean
|
|
74
|
+
* "no value" and the input is not injected. Nested objects and arrays are not
|
|
75
|
+
* accepted — a system input is a single form control.
|
|
76
|
+
*
|
|
77
|
+
* The engine reads the FIRST emission when a form initialises and keeps it for
|
|
78
|
+
* that form's life; the builder follows every emission. The observable must
|
|
79
|
+
* emit at least once or the form never finishes initialising. A failure is
|
|
80
|
+
* tolerated: the form renders with no system inputs.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* getGlobalVariables: () =>
|
|
84
|
+
* combineLatest([org$, route$]).pipe(map(([org, route]) => ({
|
|
85
|
+
* CURRENT_FINANCIAL_CYCLE: org.cycleLabel, // text
|
|
86
|
+
* CURRENT_FINANCIAL_CYCLE_START_DATE: org.cycleStart, // Moment → date picker
|
|
87
|
+
* CURRENT_TRANSACTION_ID: route.docId, // null off the detail screen → not injected
|
|
88
|
+
* IS_PILOT_ORGANISATION: org.pilot, // toggle
|
|
89
|
+
* VAT_RATE: 0.15, // number
|
|
90
|
+
* })))
|
|
91
|
+
*/
|
|
92
|
+
getGlobalVariables: () => Observable<GlobalVariables>;
|
|
53
93
|
getCurrentFormAvailableInputOptions: () => Observable<Array<FormColumnInputs>>;
|
|
54
94
|
getSelectedDocument: (documentId: string) => Observable<any>;
|
|
55
95
|
getScoaTree: () => Observable<IGetTreeResponse>;
|
|
@@ -1,6 +1,39 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
1
2
|
import { IStoreFunctions } from "./IStoreFunctions.js";
|
|
2
3
|
import { Moment } from 'moment';
|
|
3
4
|
import type { FormSubmissionHandleInterface } from "../Form/formSubmissionHandleInterface.js";
|
|
5
|
+
import type { RoundingMode } from "../formInput/calculatedFieldRules.js";
|
|
6
|
+
/**
|
|
7
|
+
* Anything that yields a JavaScript `Date` — a Moment, a Day.js instance, or any
|
|
8
|
+
* object with a `toDate()` method. The library calls `toDate()` once and keeps
|
|
9
|
+
* the `Date` it returns; an invalid date (`NaN` time) counts as no value.
|
|
10
|
+
*/
|
|
11
|
+
export interface DateLike {
|
|
12
|
+
toDate(): Date;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One value the application injects as a system input. Only scalars and dates:
|
|
16
|
+
* a system input is a form control the engine renders, so there is nothing a
|
|
17
|
+
* nested object or an array could become. `null` and `undefined` mean "no value"
|
|
18
|
+
* and the input is not injected at all.
|
|
19
|
+
*/
|
|
20
|
+
export type GlobalVariableValue = string | number | boolean | Date | DateLike | null | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Values the application injects into every form as read-only system inputs,
|
|
23
|
+
* keyed by control name. See `IStoreFunctions.getGlobalVariables` for the rules
|
|
24
|
+
* the keys and values follow and for how each entry becomes an input.
|
|
25
|
+
*/
|
|
26
|
+
export type GlobalVariables = Readonly<Record<string, GlobalVariableValue>>;
|
|
27
|
+
/**
|
|
28
|
+
* The financial-cycle variables the first consuming application injects.
|
|
29
|
+
*
|
|
30
|
+
* @deprecated Since the `getGlobalVariables` contract the library no longer
|
|
31
|
+
* reads these keys by name: they are ordinary global variables like any other,
|
|
32
|
+
* and this shape is kept only so an application that still builds its
|
|
33
|
+
* financial-cycle bundle can type it. It is assignable to `GlobalVariables`
|
|
34
|
+
* (a `Moment` is a `DateLike`), so `getGlobalVariables` may return it as-is or
|
|
35
|
+
* spread it together with any other variables.
|
|
36
|
+
*/
|
|
4
37
|
export interface IFinancialCycles {
|
|
5
38
|
CURRENT_FINANCIAL_CYCLE: string;
|
|
6
39
|
CURRENT_FINANCIAL_CYCLE_START_DATE: Moment;
|
|
@@ -14,6 +47,94 @@ export interface IFinancialCycles {
|
|
|
14
47
|
PREVIOUS_FINANCIAL_CYCLE_START_DATE: Moment;
|
|
15
48
|
PREVIOUS_FINANCIAL_CYCLE_END_DATE: Moment;
|
|
16
49
|
}
|
|
50
|
+
/** Days a calendar week may start on, named the way the organisation schema names them. */
|
|
51
|
+
export declare const FORMS_WEEK_DAYS: readonly ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
|
52
|
+
/** One of {@link FORMS_WEEK_DAYS}. */
|
|
53
|
+
export type FormsWeekDay = (typeof FORMS_WEEK_DAYS)[number];
|
|
54
|
+
/**
|
|
55
|
+
* How a plain date is written wherever the library prints one — a table cell, a
|
|
56
|
+
* document-picker column, a printout, the calendar input. `locale` keeps each
|
|
57
|
+
* surface's own locale-appropriate default; the patterns are Angular date formats.
|
|
58
|
+
*/
|
|
59
|
+
export declare const FORMS_DATE_FORMATS: readonly ["locale", "dd/MM/yyyy", "MM/dd/yyyy", "yyyy-MM-dd", "d MMM yyyy"];
|
|
60
|
+
/** One of {@link FORMS_DATE_FORMATS}. */
|
|
61
|
+
export type FormsDateFormat = (typeof FORMS_DATE_FORMATS)[number];
|
|
62
|
+
/** The clock a time of day is written in. `locale` lets the locale decide. */
|
|
63
|
+
export declare const FORMS_TIME_FORMATS: readonly ["locale", "24h", "12h"];
|
|
64
|
+
/** One of {@link FORMS_TIME_FORMATS}. */
|
|
65
|
+
export type FormsTimeFormat = (typeof FORMS_TIME_FORMATS)[number];
|
|
66
|
+
/** How a currency is named next to an amount: its symbol (`R`), the narrow symbol, or the code (`ZAR`). */
|
|
67
|
+
export declare const FORMS_CURRENCY_DISPLAYS: readonly ["symbol", "narrowSymbol", "code"];
|
|
68
|
+
/** One of {@link FORMS_CURRENCY_DISPLAYS}. */
|
|
69
|
+
export type FormsCurrencyDisplay = (typeof FORMS_CURRENCY_DISPLAYS)[number];
|
|
70
|
+
/** Money, as the consuming application keeps it. See {@link NgxTFormsLocalization.currency}. */
|
|
71
|
+
export interface NgxTFormsCurrencyLocalization {
|
|
72
|
+
/**
|
|
73
|
+
* ISO 4217 code, upper case, e.g. `ZAR`. The builder writes it into `pipe.param`
|
|
74
|
+
* the moment an author sets a number's format to currency (the form schema
|
|
75
|
+
* requires a code), so the column is in the organisation's money without a
|
|
76
|
+
* further pick; the author can still choose another currency. It is also the
|
|
77
|
+
* code every amount is formatted in when a stored column names none. Default `ZAR`.
|
|
78
|
+
*/
|
|
79
|
+
code?: string;
|
|
80
|
+
/** How the currency is written next to the amount. Default `symbol`. */
|
|
81
|
+
display?: FormsCurrencyDisplay;
|
|
82
|
+
/**
|
|
83
|
+
* Fraction digits amounts in `code` are kept and shown at, 0–4. Unset → the
|
|
84
|
+
* currency's minor unit (`ZAR` 2, `JPY` 0, read from `Intl`). Applies to a column
|
|
85
|
+
* in this currency only; a column whose author picked another currency keeps that
|
|
86
|
+
* currency's minor unit. A column's own calculated-field precision still wins.
|
|
87
|
+
*/
|
|
88
|
+
decimals?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Rounding strategy for a currency column whose author chose none. Default
|
|
91
|
+
* `HALF_EVEN` (banker's). The organisation schema's `halfExpand` is `ROUND` here.
|
|
92
|
+
*/
|
|
93
|
+
rounding?: RoundingMode;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Regional rules the library presents and keeps values under. Codes are the
|
|
97
|
+
* platform standards (`Intl` accepts them as-is). Every member is optional and an
|
|
98
|
+
* unreadable value falls back to the library default, so a half-typed admin setting
|
|
99
|
+
* never breaks a form.
|
|
100
|
+
*/
|
|
101
|
+
export interface NgxTFormsLocalization {
|
|
102
|
+
/**
|
|
103
|
+
* BCP 47 tag, e.g. `en-ZA` — digit grouping, decimal mark, month names and the
|
|
104
|
+
* calendar input's own format. Default `en-ZA`. Angular ships only English data:
|
|
105
|
+
* register anything else with `registerLocaleData`, or amounts format as `en-US`.
|
|
106
|
+
*/
|
|
107
|
+
locale?: string;
|
|
108
|
+
/**
|
|
109
|
+
* IANA zone, e.g. `Africa/Johannesburg`, that times of day are displayed in.
|
|
110
|
+
* Unset → the browser's zone. Calendar days are never moved: a date-only value
|
|
111
|
+
* prints as the day it was captured whatever the zone.
|
|
112
|
+
*/
|
|
113
|
+
timeZone?: string;
|
|
114
|
+
/** The day the calendar grid starts on. Unset → the locale's own. */
|
|
115
|
+
firstDayOfWeek?: FormsWeekDay;
|
|
116
|
+
/** How plain dates are written. Default `locale`. */
|
|
117
|
+
dateFormat?: FormsDateFormat;
|
|
118
|
+
/** The clock times of day are written in. Default `locale`. */
|
|
119
|
+
timeFormat?: FormsTimeFormat;
|
|
120
|
+
/** Money. */
|
|
121
|
+
currency?: NgxTFormsCurrencyLocalization;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Either a fixed localization or a stream of it. An application whose organisation
|
|
125
|
+
* loads after bootstrap, or can be switched, hands the library the stream; the
|
|
126
|
+
* library follows every emission and uses its defaults until the first one.
|
|
127
|
+
*/
|
|
128
|
+
export type NgxTFormsLocalizationSource = NgxTFormsLocalization | Observable<NgxTFormsLocalization>;
|
|
129
|
+
/** Tuning for the spreadsheet import template — see `NgxTFormsConfig.importTemplate`. */
|
|
130
|
+
export interface ImportTemplateConfig {
|
|
131
|
+
/**
|
|
132
|
+
* The most options the template lists for one choice input — a select's options, a table's
|
|
133
|
+
* rows, a document picker's transactions (most recent first). A longer list is cut to this
|
|
134
|
+
* many and marked partial; the import still accepts anything the form offers. Default 500.
|
|
135
|
+
*/
|
|
136
|
+
maxOptionsPerInput?: number;
|
|
137
|
+
}
|
|
17
138
|
export interface NgxTFormsConfig {
|
|
18
139
|
base_url?: string;
|
|
19
140
|
formBuilder: IStoreFunctions;
|
|
@@ -49,5 +170,40 @@ export interface NgxTFormsConfig {
|
|
|
49
170
|
* })
|
|
50
171
|
*/
|
|
51
172
|
defaultSubmissionHandle?: FormSubmissionHandleInterface;
|
|
173
|
+
/**
|
|
174
|
+
* Tuning for the spreadsheet import template `TFormImportController.buildFormImportTemplate`
|
|
175
|
+
* builds. Omit it for the defaults.
|
|
176
|
+
*/
|
|
177
|
+
importTemplate?: ImportTemplateConfig;
|
|
178
|
+
/**
|
|
179
|
+
* Regional rules the library presents and keeps values under: the currency a
|
|
180
|
+
* money column defaults to (and is pre-selected with in the builder), the locale
|
|
181
|
+
* amounts and dates are written in, the zone times of day are shown in, the day the
|
|
182
|
+
* calendar starts on, and the date and time formats. Omit it for the library
|
|
183
|
+
* defaults — `en-ZA`, `ZAR`, the browser's zone — which are exactly what the
|
|
184
|
+
* library did before this member existed.
|
|
185
|
+
*
|
|
186
|
+
* Pass an `Observable` when the values come from the signed-in organisation: the
|
|
187
|
+
* token is bound once at bootstrap, long before the organisation is known.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* provideNgxTForms({
|
|
191
|
+
* formBuilder: myStoreFunctions,
|
|
192
|
+
* localization: orgSettings$.pipe(map(({ localization, currencyFormat }) => ({
|
|
193
|
+
* locale: localization.locale,
|
|
194
|
+
* timeZone: localization.timeZone,
|
|
195
|
+
* firstDayOfWeek: localization.firstDayOfWeek,
|
|
196
|
+
* dateFormat: localization.dateFormat,
|
|
197
|
+
* timeFormat: localization.timeFormat,
|
|
198
|
+
* currency: {
|
|
199
|
+
* code: currencyFormat.currencyCode,
|
|
200
|
+
* display: currencyFormat.display,
|
|
201
|
+
* decimals: currencyFormat.decimals,
|
|
202
|
+
* rounding: currencyFormat.rounding === 'halfExpand' ? 'ROUND' : 'HALF_EVEN',
|
|
203
|
+
* },
|
|
204
|
+
* }))),
|
|
205
|
+
* })
|
|
206
|
+
*/
|
|
207
|
+
localization?: NgxTFormsLocalizationSource;
|
|
52
208
|
[key: string]: string | Object | undefined;
|
|
53
209
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/** Days a calendar week may start on, named the way the organisation schema names them. */
|
|
2
|
+
export const FORMS_WEEK_DAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
3
|
+
/**
|
|
4
|
+
* How a plain date is written wherever the library prints one — a table cell, a
|
|
5
|
+
* document-picker column, a printout, the calendar input. `locale` keeps each
|
|
6
|
+
* surface's own locale-appropriate default; the patterns are Angular date formats.
|
|
7
|
+
*/
|
|
8
|
+
export const FORMS_DATE_FORMATS = ['locale', 'dd/MM/yyyy', 'MM/dd/yyyy', 'yyyy-MM-dd', 'd MMM yyyy'];
|
|
9
|
+
/** The clock a time of day is written in. `locale` lets the locale decide. */
|
|
10
|
+
export const FORMS_TIME_FORMATS = ['locale', '24h', '12h'];
|
|
11
|
+
/** How a currency is named next to an amount: its symbol (`R`), the narrow symbol, or the code (`ZAR`). */
|
|
12
|
+
export const FORMS_CURRENCY_DISPLAYS = ['symbol', 'narrowSymbol', 'code'];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ActionButton, BasisValidationError, DialogConfig, IStoreFunctions, MscoaValuetValidationErrors } from "./IStoreFunctions.js";
|
|
2
|
-
import { IFinancialCycles } from "./environment.js";
|
|
3
|
-
export { IStoreFunctions, ActionButton, DialogConfig, IFinancialCycles, MscoaValuetValidationErrors, BasisValidationError, };
|
|
2
|
+
import { DateLike, FORMS_CURRENCY_DISPLAYS, FORMS_DATE_FORMATS, FORMS_TIME_FORMATS, FORMS_WEEK_DAYS, FormsCurrencyDisplay, FormsDateFormat, FormsTimeFormat, FormsWeekDay, GlobalVariables, GlobalVariableValue, IFinancialCycles, NgxTFormsCurrencyLocalization, NgxTFormsLocalization, NgxTFormsLocalizationSource } from "./environment.js";
|
|
3
|
+
export { IStoreFunctions, FORMS_CURRENCY_DISPLAYS, FORMS_DATE_FORMATS, FORMS_TIME_FORMATS, FORMS_WEEK_DAYS, FormsCurrencyDisplay, FormsDateFormat, FormsTimeFormat, FormsWeekDay, NgxTFormsCurrencyLocalization, NgxTFormsLocalization, NgxTFormsLocalizationSource, ActionButton, DialogConfig, IFinancialCycles, DateLike, GlobalVariables, GlobalVariableValue, MscoaValuetValidationErrors, BasisValidationError, };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { FORMS_CURRENCY_DISPLAYS, FORMS_DATE_FORMATS, FORMS_TIME_FORMATS, FORMS_WEEK_DAYS, } from "./environment.js";
|
|
2
|
+
export { FORMS_CURRENCY_DISPLAYS, FORMS_DATE_FORMATS, FORMS_TIME_FORMATS, FORMS_WEEK_DAYS, };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export type MatFormFieldAppearance = 'fill' | 'outline';
|
|
7
7
|
import { IFileUploadInput, IMatrixInput, IScoaInput, IMultiple, IToggleInput, IWorkflowAdjudicationInput } from ".";
|
|
8
8
|
import { ConditionalInputRule } from "./ConditionalInputRule.js";
|
|
9
|
+
import type { RoundingMode } from "./calculatedFieldRules.js";
|
|
9
10
|
import { IDateRangePickerInput } from "./DateRangePickerInput.js";
|
|
10
11
|
import { FormControlCustomValidatorsInterface } from "./FormControlCustomValidatorsInterface.js";
|
|
11
12
|
import { MatDataOptionsInterface } from "./MatDataOptionsInterface.js";
|
|
@@ -121,9 +122,23 @@ export interface IBasicFormInput extends IFormElementTemplate {
|
|
|
121
122
|
readonly?: boolean;
|
|
122
123
|
id: string;
|
|
123
124
|
sectionId: string;
|
|
125
|
+
/**
|
|
126
|
+
* Number / date presentation, and for the numeric formats the precision the
|
|
127
|
+
* value is kept at.
|
|
128
|
+
*
|
|
129
|
+
* `currency`, `decimal` and `integer` round the value itself — typed,
|
|
130
|
+
* imported, seeded or calculated — to their precision, so what is saved is
|
|
131
|
+
* what is shown: currency to the currency's minor unit (2 for ZAR) with
|
|
132
|
+
* `HALF_EVEN` unless `rounding` says otherwise; `decimal` to `param`
|
|
133
|
+
* places (a plain integer such as `"2"`); `integer` to none. Every other
|
|
134
|
+
* pipe type is presentation only and leaves the stored value unchanged.
|
|
135
|
+
*/
|
|
124
136
|
pipe?: {
|
|
125
137
|
pipeType: InputPipeTypes;
|
|
138
|
+
/** Currency code for `currency`, decimal places for `decimal`, date format for `date` / `time`. */
|
|
126
139
|
param: string;
|
|
140
|
+
/** Rounding strategy for the numeric formats. Unset → `HALF_EVEN` for `currency`, `ROUND` otherwise. */
|
|
141
|
+
rounding?: RoundingMode;
|
|
127
142
|
};
|
|
128
143
|
hintLabel?: string;
|
|
129
144
|
temporaryHint?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MscoaValuetValidationErrors } from "../environment/IStoreFunctions.js";
|
|
2
2
|
import { IBasicFormInput } from "./BasicFormInputInterface.js";
|
|
3
|
+
import { MinInputMapInput } from "./MinimumInputRequiredInterface.js";
|
|
3
4
|
import { ScoaInnerInput } from "./MscoaInput.js";
|
|
4
5
|
export interface IVersion {
|
|
5
6
|
versionNumber: number;
|
|
@@ -120,6 +121,34 @@ export interface IIncludedSegmentConfig {
|
|
|
120
121
|
additionalAccounts: string[];
|
|
121
122
|
segmentExtension: boolean;
|
|
122
123
|
id: string;
|
|
124
|
+
/**
|
|
125
|
+
* Optional account-path limit for the picker: a colon-separated path into this
|
|
126
|
+
* segment's branch of the account tree, e.g.
|
|
127
|
+
* `Net Assets:Reserves and Funds:Revaluation Reserve`. When set, the account
|
|
128
|
+
* picker shows only that branch — its ancestors stay visible as context but
|
|
129
|
+
* cannot be selected — so only accounts at or beneath it can be chosen.
|
|
130
|
+
*
|
|
131
|
+
* Absent or empty means every branch of the segment is selectable, which is
|
|
132
|
+
* exactly how every segment saved before this member existed behaves. A path
|
|
133
|
+
* the loaded tree does not contain is ignored the same way, so a stale limit
|
|
134
|
+
* can never lock a segment out of every account.
|
|
135
|
+
*/
|
|
136
|
+
limitToChildOfAccount?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Optional dynamic source for {@link IIncludedSegmentConfig.limitToChildOfAccount}:
|
|
139
|
+
* another form input whose CURRENT value supplies the account path at the
|
|
140
|
+
* moment the picker opens. Shaped exactly like a required-input `mapTo`
|
|
141
|
+
* binding ({@link MinInputMapInput}); the runtime reads the input by `inputId`
|
|
142
|
+
* from the form the MSCOA field belongs to (an account-level custom input of
|
|
143
|
+
* the same MSCOA field is reachable too).
|
|
144
|
+
*
|
|
145
|
+
* The mapped value is honoured when it is a string — or an array of strings,
|
|
146
|
+
* one per level — naming a branch that exists in the segment tree. Otherwise
|
|
147
|
+
* the fixed `limitToChildOfAccount` applies when it resolves, and failing that
|
|
148
|
+
* every branch stays selectable. The mapping can therefore never lock the
|
|
149
|
+
* segment on its own, and an unfilled source input falls back gracefully.
|
|
150
|
+
*/
|
|
151
|
+
limitToChildOfAccountMapTo?: MinInputMapInput;
|
|
123
152
|
}
|
|
124
153
|
/**
|
|
125
154
|
* How the {@link IDualCashExclusionConfig.rules} combine into one verdict.
|
|
@@ -198,6 +227,18 @@ export interface IScoaInputConfig {
|
|
|
198
227
|
* non-Dual accounting bases.
|
|
199
228
|
*/
|
|
200
229
|
dualCashExclusion?: IDualCashExclusionConfig;
|
|
230
|
+
/**
|
|
231
|
+
* Opt-in: lets the user pick an account at ANY level of the tree, not only a
|
|
232
|
+
* posting-level one (`PostingLevel === 'Y'`, plus `BreakDownAllowed === 'Y'`
|
|
233
|
+
* on the PROJECT segment). Absent or `false` keeps the posting-level
|
|
234
|
+
* restriction every input had before this member existed.
|
|
235
|
+
*
|
|
236
|
+
* The restriction is enforced by the picker alone — nothing downstream
|
|
237
|
+
* re-validates posting level — so enabling it widens what a form can capture,
|
|
238
|
+
* and a consumer that posts the captured account to a ledger must be prepared
|
|
239
|
+
* for a group-level account.
|
|
240
|
+
*/
|
|
241
|
+
allowNonPostingLevelAccount?: boolean;
|
|
201
242
|
}
|
|
202
243
|
export interface IGetTreeResponse {
|
|
203
244
|
message: string;
|
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
import { calculationVariableInterface } from "./calculationVariableInterface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every rounding strategy the library understands, in the order the editors
|
|
4
|
+
* list them.
|
|
5
|
+
*
|
|
6
|
+
* One list backs the {@link RoundingMode} type, the Joi schemas, the Skillet
|
|
7
|
+
* enumeration and both editors (the calculated-field rules editor and the
|
|
8
|
+
* number pipe), so a strategy added here reaches every surface at once.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ROUNDING_MODES: readonly ["ROUND", "FLOOR", "CEIL", "HALF_EVEN"];
|
|
11
|
+
/**
|
|
12
|
+
* How a numeric value is rounded at its precision.
|
|
13
|
+
*
|
|
14
|
+
* - `ROUND` — nearest; a tie (…5) rounds away from zero: 2.345 → 2.35, −2.345 → −2.35.
|
|
15
|
+
* - `FLOOR` — down, toward −∞: 2.349 → 2.34, −2.341 → −2.35.
|
|
16
|
+
* - `CEIL` — up, toward +∞: 2.341 → 2.35, −2.349 → −2.34.
|
|
17
|
+
* - `HALF_EVEN` — banker's rounding (IEEE 754 roundTiesToEven); a tie rounds to
|
|
18
|
+
* the even neighbour: 2.345 → 2.34, 2.355 → 2.36. The default for currency,
|
|
19
|
+
* because it does not drift a column of totals upward.
|
|
20
|
+
*/
|
|
21
|
+
export type RoundingMode = (typeof ROUNDING_MODES)[number];
|
|
22
|
+
/** Editor label for each {@link RoundingMode}. */
|
|
23
|
+
export declare const ROUNDING_MODE_LABELS: Record<RoundingMode, string>;
|
|
2
24
|
export interface CalculatedFieldRules {
|
|
3
25
|
formula: string;
|
|
4
26
|
variables: calculationVariableInterface[];
|
|
27
|
+
/**
|
|
28
|
+
* Decimal places the result is rounded to. Unset → the column's number format
|
|
29
|
+
* (`pipe`) decides; with neither, the result is not rounded.
|
|
30
|
+
*/
|
|
5
31
|
decimalPlaces?: number;
|
|
6
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Rounding strategy at `decimalPlaces`. Unset → `HALF_EVEN` for a column whose
|
|
34
|
+
* number format is currency, `ROUND` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
roundingMode?: RoundingMode;
|
|
7
37
|
getFormulaFromAFormInput?: boolean;
|
|
8
38
|
formControlWithFormula?: string;
|
|
9
39
|
}
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Every rounding strategy the library understands, in the order the editors
|
|
3
|
+
* list them.
|
|
4
|
+
*
|
|
5
|
+
* One list backs the {@link RoundingMode} type, the Joi schemas, the Skillet
|
|
6
|
+
* enumeration and both editors (the calculated-field rules editor and the
|
|
7
|
+
* number pipe), so a strategy added here reaches every surface at once.
|
|
8
|
+
*/
|
|
9
|
+
export const ROUNDING_MODES = ['ROUND', 'FLOOR', 'CEIL', 'HALF_EVEN'];
|
|
10
|
+
/** Editor label for each {@link RoundingMode}. */
|
|
11
|
+
export const ROUNDING_MODE_LABELS = {
|
|
12
|
+
ROUND: 'Nearest',
|
|
13
|
+
FLOOR: 'Round down',
|
|
14
|
+
CEIL: 'Round up',
|
|
15
|
+
HALF_EVEN: "Banker's (half to even)",
|
|
16
|
+
};
|
|
@@ -21,9 +21,9 @@ import { ITextareaProperties } from "./TextAreaInput.js";
|
|
|
21
21
|
import { IToggleInput } from "./ToggleInputInterface.js";
|
|
22
22
|
import { AdjResponseReviewColumnMapping, AdjudicationSteps, IWorkflowAdjudicationInput, WorkflowAdjudicationMicroFlowReviewValue, WorkflowAdjudicationResponseElectedSupplierSelectionValue, WorkflowAdjudicationScoreSheetValue } from "./WorkflowAdjudication.js";
|
|
23
23
|
import { DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, DocumentPickerFilterOperator, DocumentPickerFilterValueSource, DocumentPickerFilterValueType, IDocumentPage, IDocumentPickerFilter, IDocumentQueryRequest, IDocumentReference, IWorkflowDocumentPicker, IWorkflowDocumentPickerConfig, IWorkflowDocumentStepFilter, workflowStepStatus } from "./WorkflowDocumentPicker.js";
|
|
24
|
-
import { CalculatedFieldRules } from "./calculatedFieldRules.js";
|
|
24
|
+
import { CalculatedFieldRules, ROUNDING_MODES, ROUNDING_MODE_LABELS, RoundingMode } from "./calculatedFieldRules.js";
|
|
25
25
|
import { CalculationFunctions, calculationVariableInterface } from "./calculationVariableInterface.js";
|
|
26
26
|
import { IRichTextEditor, RichTextEditorType } from "./RichTextEditorInput.js";
|
|
27
27
|
import { ValidationError, ValidationOptions } from "./schema.js";
|
|
28
28
|
import { IUserSignature } from "./userSignature.js";
|
|
29
|
-
export { ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, IFormElementTemplate, IBasicFormInput, IFileUploadInput, ConditionalInputRule, IDateRangePickerInput, ITextareaProperties, IToggleInput, IMatrixInput, IMultiple, IMultipleInputCal, IScoaInput, TableConfigurationsInterface, TableColumnConfigInterface, FormControlCustomValidatorsInterface, InputObservedForChange, DraftFormControlCustomValidator, IFormValidationOverride, MinimumInputRequiredInterface, MinInputMapInput, CalculatedFieldRules, calculationVariableInterface, APIDataFetchingConfigurationInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode, HeaderTemplate, HeaderTemplateValue, QueryTemplate, QueryTemplateValue, IGetTreeResponse, CalculationFunctions, TreeNode, IPostmanCollection, IFolderItem, FileUploadInputValueInterface, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, IScoaAccount, IScoaInputConfig, ITableScoaSelectionRow, ScoaSegmentValue, ScoaSegmentValueBag, IIncludedSegmentConfig, AccountingBasis, DualCashExclusionMatchMode, IDualCashExclusionConfig, IDualCashExclusionRule, ScoaAccountTree, IUserSignature, ValidationOptions, ValidationError, MatDataOptionsInterface, MongoDbPipeLineConfigInterface, InputAPIDataId, FormInputBasicOptionInterface, ScoaInterface, ScoaInnerInput, IAccountSegmentTreeKeys, IWorkflowDocumentPicker, IWorkflowDocumentPickerConfig, IWorkflowDocumentStepFilter, IDocumentPickerFilter, IDocumentPage, IDocumentQueryRequest, IDocumentReference, DocumentPickerFilterOperator, DocumentPickerFilterValueSource, DocumentPickerFilterValueType, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, IWorkflowDocListCols, IWorkflowStepOption, JsDataTypes, AdjudicationSteps, IWorkflowAdjudicationInput, WorkflowAdjudicationScoreSheetValue, WorkflowAdjudicationMicroFlowReviewValue, WorkflowAdjudicationResponseElectedSupplierSelectionValue, ScoreSheetItem, AdjResponseReviewColumnMapping, OptionSelectTypes, ISelectInputInterface, MultipleInputAvailableOperations, RichTextEditorType, IRichTextEditor, };
|
|
29
|
+
export { ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, IFormElementTemplate, IBasicFormInput, IFileUploadInput, ConditionalInputRule, IDateRangePickerInput, ITextareaProperties, IToggleInput, IMatrixInput, IMultiple, IMultipleInputCal, IScoaInput, TableConfigurationsInterface, TableColumnConfigInterface, FormControlCustomValidatorsInterface, InputObservedForChange, DraftFormControlCustomValidator, IFormValidationOverride, MinimumInputRequiredInterface, MinInputMapInput, CalculatedFieldRules, ROUNDING_MODES, ROUNDING_MODE_LABELS, RoundingMode, calculationVariableInterface, APIDataFetchingConfigurationInterface, PayloadTemplate, PayloadTemplateValue, RequestBodyMode, HeaderTemplate, HeaderTemplateValue, QueryTemplate, QueryTemplateValue, IGetTreeResponse, CalculationFunctions, TreeNode, IPostmanCollection, IFolderItem, FileUploadInputValueInterface, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, IScoaAccount, IScoaInputConfig, ITableScoaSelectionRow, ScoaSegmentValue, ScoaSegmentValueBag, IIncludedSegmentConfig, AccountingBasis, DualCashExclusionMatchMode, IDualCashExclusionConfig, IDualCashExclusionRule, ScoaAccountTree, IUserSignature, ValidationOptions, ValidationError, MatDataOptionsInterface, MongoDbPipeLineConfigInterface, InputAPIDataId, FormInputBasicOptionInterface, ScoaInterface, ScoaInnerInput, IAccountSegmentTreeKeys, IWorkflowDocumentPicker, IWorkflowDocumentPickerConfig, IWorkflowDocumentStepFilter, IDocumentPickerFilter, IDocumentPage, IDocumentQueryRequest, IDocumentReference, DocumentPickerFilterOperator, DocumentPickerFilterValueSource, DocumentPickerFilterValueType, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, IWorkflowDocListCols, IWorkflowStepOption, JsDataTypes, AdjudicationSteps, IWorkflowAdjudicationInput, WorkflowAdjudicationScoreSheetValue, WorkflowAdjudicationMicroFlowReviewValue, WorkflowAdjudicationResponseElectedSupplierSelectionValue, ScoreSheetItem, AdjResponseReviewColumnMapping, OptionSelectTypes, ISelectInputInterface, MultipleInputAvailableOperations, RichTextEditorType, IRichTextEditor, };
|
|
@@ -5,6 +5,7 @@ import { JsDataTypes, MinInputTypes } from "./MinimumInputRequiredInterface.js";
|
|
|
5
5
|
import { MultipleInputAvailableOperations } from "./MultipleInterface.js";
|
|
6
6
|
import { AdjudicationSteps } from "./WorkflowAdjudication.js";
|
|
7
7
|
import { DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, } from "./WorkflowDocumentPicker.js";
|
|
8
|
+
import { ROUNDING_MODES, ROUNDING_MODE_LABELS } from "./calculatedFieldRules.js";
|
|
8
9
|
import { CalculationFunctions } from "./calculationVariableInterface.js";
|
|
9
10
|
import { RichTextEditorType } from "./RichTextEditorInput.js";
|
|
10
11
|
// H-018b (Worker T-C): `OLD_FormInterface` and `FormInterfaceMigration` are
|
|
@@ -14,4 +15,4 @@ import { RichTextEditorType } from "./RichTextEditorInput.js";
|
|
|
14
15
|
// would otherwise trigger TS2300 "Duplicate identifier".
|
|
15
16
|
export {
|
|
16
17
|
///ENUMS
|
|
17
|
-
ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, CalculationFunctions, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, AccountingBasis, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, JsDataTypes, AdjudicationSteps, OptionSelectTypes, MultipleInputAvailableOperations, RichTextEditorType, };
|
|
18
|
+
ElementTypes, InputTypes, InputPipeTypes, AutocapitalizeOptions, AutocompleteOptions, InputDataTypes, MinInputTypes, ROUNDING_MODES, ROUNDING_MODE_LABELS, CalculationFunctions, AllDocumentFileExtensions, AllImageFileExtensions, UploadTypes, InputFileType, AccountingBasis, DOCUMENT_PICKER_FILTER_OPERATORS, DOCUMENT_PICKER_FILTER_VALUE_SOURCES, DOCUMENT_PICKER_FILTER_VALUE_TYPES, workflowStepStatus, JsDataTypes, AdjudicationSteps, OptionSelectTypes, MultipleInputAvailableOperations, RichTextEditorType, };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
|
+
import { ROUNDING_MODES } from '../interfaces/formInput/calculatedFieldRules.js';
|
|
2
3
|
const calculationVariableSchema = Joi.object({
|
|
3
4
|
formControlName: Joi.string().required(),
|
|
4
5
|
label: Joi.string().required(),
|
|
@@ -19,7 +20,7 @@ export const calculatedFieldRulesSchema = Joi.object({
|
|
|
19
20
|
variables: Joi.array().items(calculationVariableSchema).required(),
|
|
20
21
|
getFormulaFromAFormInput: Joi.boolean().optional(),
|
|
21
22
|
decimalPlaces: Joi.number().optional(),
|
|
22
|
-
roundingMode: Joi.string().valid(
|
|
23
|
+
roundingMode: Joi.string().valid(...ROUNDING_MODES).optional(),
|
|
23
24
|
formControlWithFormula: Joi.string().optional()
|
|
24
25
|
});
|
|
25
26
|
export function validateCalculatedFieldRules(value) {
|
|
@@ -7,6 +7,7 @@ import { AdjudicationSteps, AutocapitalizeOptions, AutocompleteOptions, ElementT
|
|
|
7
7
|
// import { calculatedFieldRulesSchema } from './CalculatedFieldRulesSchema.js';
|
|
8
8
|
// import { MatDataOptionsSchema } from './MatOptionsSchema.js';
|
|
9
9
|
import { formControlCustomValidatorSchema } from './customValidationSchema.js';
|
|
10
|
+
import { ROUNDING_MODES } from '../interfaces/formInput/calculatedFieldRules.js';
|
|
10
11
|
import { InputFileType } from '../interfaces/formInput/FileUploadInputInterface.js';
|
|
11
12
|
import { LabelPosition } from '../interfaces/formInput/ToggleInputInterface.js';
|
|
12
13
|
import { calculatedFieldRulesSchema } from './CalculatedFieldRulesSchema.js';
|
|
@@ -103,7 +104,8 @@ export const baseFormColumnInputsSchema = Joi.object({
|
|
|
103
104
|
[AllFormInputPrimaryKeys.Pipe]: Joi.object({
|
|
104
105
|
_id: Joi.string().optional(),
|
|
105
106
|
pipeType: Joi.string().valid(...Object.values(InputPipeTypes)).required(),
|
|
106
|
-
param: Joi.string().required()
|
|
107
|
+
param: Joi.string().required(),
|
|
108
|
+
rounding: Joi.string().valid(...ROUNDING_MODES).optional()
|
|
107
109
|
}).optional(),
|
|
108
110
|
[AllFormInputPrimaryKeys.Script]: Joi.object().optional(),
|
|
109
111
|
[AllFormInputPrimaryKeys.Validators]: Joi.array().items(Joi.alternatives().try(Joi.string(), formControlCustomValidatorSchema)).optional(),
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
|
+
/**
|
|
3
|
+
* Joi shape of the `MinInputMapInput` a segment may name as the dynamic source
|
|
4
|
+
* of its account-path limit. `inputId` is the only member the runtime reads;
|
|
5
|
+
* the other three are the descriptive half the builder stamps alongside it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AccountPathLimitSourceSchema: Joi.ObjectSchema<any>;
|
|
2
8
|
export declare const IncludedSegmentConfigSchema: Joi.ObjectSchema<any>;
|
|
3
9
|
export declare const DualCashExclusionRuleSchema: Joi.ObjectSchema<any>;
|
|
4
10
|
export declare const DualCashExclusionConfigSchema: Joi.ObjectSchema<any>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
2
|
import { AccountingBasis } from '../interfaces/formInput/IMscoaAccount.js';
|
|
3
|
+
/**
|
|
4
|
+
* Joi shape of the `MinInputMapInput` a segment may name as the dynamic source
|
|
5
|
+
* of its account-path limit. `inputId` is the only member the runtime reads;
|
|
6
|
+
* the other three are the descriptive half the builder stamps alongside it.
|
|
7
|
+
*/
|
|
8
|
+
export const AccountPathLimitSourceSchema = Joi.object({
|
|
9
|
+
inputId: Joi.string().required(),
|
|
10
|
+
formControlName: Joi.string().allow('').optional(),
|
|
11
|
+
dataType: Joi.string().allow('').optional(),
|
|
12
|
+
element: Joi.string().allow('').optional()
|
|
13
|
+
});
|
|
3
14
|
export const IncludedSegmentConfigSchema = Joi.object({
|
|
4
15
|
segment: Joi.string(),
|
|
5
16
|
customSegment: Joi.string().optional(),
|
|
@@ -10,7 +21,9 @@ export const IncludedSegmentConfigSchema = Joi.object({
|
|
|
10
21
|
inheritValueFromAccrual: Joi.boolean().optional(),
|
|
11
22
|
vatSelectonActive: Joi.boolean().optional(),
|
|
12
23
|
segmentExtension: Joi.boolean().required(),
|
|
13
|
-
id: Joi.string().required()
|
|
24
|
+
id: Joi.string().required(),
|
|
25
|
+
limitToChildOfAccount: Joi.string().allow('').optional(),
|
|
26
|
+
limitToChildOfAccountMapTo: AccountPathLimitSourceSchema.optional()
|
|
14
27
|
});
|
|
15
28
|
export const DualCashExclusionRuleSchema = Joi.object({
|
|
16
29
|
id: Joi.string().optional(),
|
|
@@ -32,7 +45,8 @@ export const MscoaInputConfigSchema = Joi.object({
|
|
|
32
45
|
accountingBasis: Joi.string().valid(...Object.values(AccountingBasis)).optional(),
|
|
33
46
|
extensionAccountsForSegments: Joi.array().items(Joi.string()).optional(),
|
|
34
47
|
showAllSegments: Joi.boolean().required(),
|
|
35
|
-
dualCashExclusion: DualCashExclusionConfigSchema.optional()
|
|
48
|
+
dualCashExclusion: DualCashExclusionConfigSchema.optional(),
|
|
49
|
+
allowNonPostingLevelAccount: Joi.boolean().optional()
|
|
36
50
|
});
|
|
37
51
|
export function validateMscoaInputConfig(value) {
|
|
38
52
|
const { error, value: validatedValue } = MscoaInputConfigSchema.validate(value);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AllFormInputPrimaryKeys, } from '../../interfaces/FormBuilder/index.js';
|
|
2
2
|
import { ElementTypes, InputDataTypes, InputPipeTypes, InputTypes } from '../../interfaces/formInput/index.js';
|
|
3
|
+
import { validateCalculatedFieldRules } from '../CalculatedFieldRulesSchema.js';
|
|
3
4
|
import { formColumnInputsSchema } from '../FormInputSchema.js';
|
|
4
5
|
//ng test ngx-t-forms --include='projects/ngx-t-forms/src/lib/schemas/tests/FormInputValidator.spec.ts'
|
|
5
6
|
describe('FormInputValidator', () => {
|
|
@@ -60,4 +61,30 @@ describe('FormInputValidator', () => {
|
|
|
60
61
|
const result = formColumnInputsSchema.validate(invalidEnumInput);
|
|
61
62
|
expect(result.error).toBeDefined();
|
|
62
63
|
});
|
|
64
|
+
describe('number precision', () => {
|
|
65
|
+
const amount = (rounding) => ({
|
|
66
|
+
[AllFormInputPrimaryKeys.Element]: ElementTypes.Input,
|
|
67
|
+
[AllFormInputPrimaryKeys.ColSize]: 6,
|
|
68
|
+
[AllFormInputPrimaryKeys.Label]: 'Amount',
|
|
69
|
+
[AllFormInputPrimaryKeys.FormControlName]: 'amount',
|
|
70
|
+
[AllFormInputPrimaryKeys.Appearance]: 'outline',
|
|
71
|
+
[AllFormInputPrimaryKeys.Required]: false,
|
|
72
|
+
[AllFormInputPrimaryKeys.DataType]: InputDataTypes.Number,
|
|
73
|
+
[AllFormInputPrimaryKeys.Type]: InputTypes.Number,
|
|
74
|
+
[AllFormInputPrimaryKeys.Pipe]: { pipeType: InputPipeTypes.Currency, param: 'ZAR', rounding },
|
|
75
|
+
});
|
|
76
|
+
it('accepts every rounding strategy on the number pipe', () => {
|
|
77
|
+
for (const rounding of ['ROUND', 'FLOOR', 'CEIL', 'HALF_EVEN']) {
|
|
78
|
+
expect(formColumnInputsSchema.validate(amount(rounding)).error).toBeUndefined();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
it('rejects a rounding strategy the library does not know', () => {
|
|
82
|
+
expect(formColumnInputsSchema.validate(amount('HALF_DOWN')).error).toBeDefined();
|
|
83
|
+
});
|
|
84
|
+
it('accepts banker\'s rounding on calculated-field rules', () => {
|
|
85
|
+
const rules = { formula: '{a} * 2', variables: [], decimalPlaces: 2, roundingMode: 'HALF_EVEN' };
|
|
86
|
+
expect(validateCalculatedFieldRules(rules).error).toBeUndefined();
|
|
87
|
+
expect(validateCalculatedFieldRules({ ...rules, roundingMode: 'TRUNCATE' }).error).toBeDefined();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
63
90
|
});
|
|
@@ -90,7 +90,7 @@ export declare const extraDraftMemberSchemas: {
|
|
|
90
90
|
tableCell: boolean | null;
|
|
91
91
|
}>>;
|
|
92
92
|
decimalPlaces: import("@hashbrownai/core/src/schema/base").SchemaForUnion<number | null>;
|
|
93
|
-
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"FLOOR" | "CEIL" | "
|
|
93
|
+
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"ROUND" | "FLOOR" | "CEIL" | "HALF_EVEN" | null>;
|
|
94
94
|
getFormulaFromAFormInput: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
95
95
|
formControlWithFormula: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
96
96
|
}>;
|
|
@@ -191,7 +191,7 @@ export declare const draftMemberSchemas: {
|
|
|
191
191
|
tableCell: boolean | null;
|
|
192
192
|
}>>;
|
|
193
193
|
decimalPlaces: import("@hashbrownai/core/src/schema/base").SchemaForUnion<number | null>;
|
|
194
|
-
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"FLOOR" | "CEIL" | "
|
|
194
|
+
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"ROUND" | "FLOOR" | "CEIL" | "HALF_EVEN" | null>;
|
|
195
195
|
getFormulaFromAFormInput: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
196
196
|
formControlWithFormula: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
197
197
|
}>;
|
|
@@ -237,6 +237,7 @@ export declare const draftMemberSchemas: {
|
|
|
237
237
|
inheritValueFromAccrual: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
238
238
|
vatSelectonActive: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
239
239
|
segmentExtension: s.BooleanType;
|
|
240
|
+
limitToChildOfAccount: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
240
241
|
}>>;
|
|
241
242
|
cashSegments: import("@hashbrownai/core/src/schema/base").SchemaForUnion<{
|
|
242
243
|
segment: string;
|
|
@@ -248,9 +249,11 @@ export declare const draftMemberSchemas: {
|
|
|
248
249
|
inheritValueFromAccrual: boolean | null;
|
|
249
250
|
vatSelectonActive: boolean | null;
|
|
250
251
|
segmentExtension: boolean;
|
|
252
|
+
limitToChildOfAccount: string | null;
|
|
251
253
|
}[] | null>;
|
|
252
254
|
accountValueLabel: s.EnumType<string[]>;
|
|
253
255
|
showAllSegments: s.BooleanType;
|
|
256
|
+
allowNonPostingLevelAccount: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
254
257
|
extensionAccountsForSegments: s.ArrayType<s.StringType>;
|
|
255
258
|
dualCashExclusion: import("@hashbrownai/core/src/schema/base").SchemaForUnion<{
|
|
256
259
|
rules: {
|
|
@@ -166,7 +166,7 @@ export const inputMemberSchemas = {
|
|
|
166
166
|
[AllFormInputPrimaryKeys.Accept]: s.string(describe('Accepted upload types as an HTML accept attribute, for example ".pdf,.docx" or "image/*". Match it to the documents actually expected, and name the accepted types in the hint as well.', AllFormInputPrimaryKeys.Accept)),
|
|
167
167
|
[AllFormInputPrimaryKeys.HandleLabel]: s.string(describe("The text of the button that adds a row to an item list. Name the action — 'Add item', 'Add attendee' — not the default 'Add to list'.", AllFormInputPrimaryKeys.HandleLabel)),
|
|
168
168
|
// --- display transform ----------------------------------------------------
|
|
169
|
-
[AllFormInputPrimaryKeys.Pipe]: s.object(describe(
|
|
169
|
+
[AllFormInputPrimaryKeys.Pipe]: s.object(describe("How the value is presented: currency for an amount, percent for a rate, date for a date. The numeric formats also fix the precision the value is kept at — currency rounds to the currency's minor unit with banker's rounding, decimal to the given places, integer to none — and that rounded value is what is saved; every other format is presentation only.", AllFormInputPrimaryKeys.Pipe), {
|
|
170
170
|
pipeType: inputPipeTypeSchema,
|
|
171
171
|
param: s.string('The pipe argument, such as a date format like "dd MMM yyyy" or a currency code like "ZAR".'),
|
|
172
172
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s } from '@hashbrownai/core';
|
|
2
|
-
import type
|
|
2
|
+
import { type CalculatedFieldRules } from '../../interfaces/formInput/calculatedFieldRules.js';
|
|
3
3
|
import { CalculationFunctions } from '../../interfaces/formInput/calculationVariableInterface.js';
|
|
4
4
|
/**
|
|
5
5
|
* The `calculatedFieldRules` member: a value computed from other fields rather
|
|
@@ -43,8 +43,8 @@ import { CalculationFunctions } from '../../interfaces/formInput/calculationVari
|
|
|
43
43
|
* annotates the same `parentInputId` + `function` pair as "Multiple-input
|
|
44
44
|
* (list) bindings", which is the distinction drawn.
|
|
45
45
|
*/
|
|
46
|
-
/**
|
|
47
|
-
export declare const ROUNDING_MODE_VALUES: readonly ["FLOOR", "CEIL", "
|
|
46
|
+
/** The rounding strategies, from the one list `roundingMode` is typed by. */
|
|
47
|
+
export declare const ROUNDING_MODE_VALUES: readonly ["ROUND", "FLOOR", "CEIL", "HALF_EVEN"];
|
|
48
48
|
interface VariableCommonDraft {
|
|
49
49
|
/** The token this variable is referenced by inside `formula`. */
|
|
50
50
|
variable: string;
|
|
@@ -126,7 +126,7 @@ export declare const calculatedFieldRulesDraftSchema: s.ObjectType<{
|
|
|
126
126
|
tableCell: boolean | null;
|
|
127
127
|
}>>;
|
|
128
128
|
decimalPlaces: import("@hashbrownai/core/src/schema/base").SchemaForUnion<number | null>;
|
|
129
|
-
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"FLOOR" | "CEIL" | "
|
|
129
|
+
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"ROUND" | "FLOOR" | "CEIL" | "HALF_EVEN" | null>;
|
|
130
130
|
getFormulaFromAFormInput: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
131
131
|
formControlWithFormula: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
132
132
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { s } from '@hashbrownai/core';
|
|
2
|
+
import { ROUNDING_MODES } from '../../interfaces/formInput/calculatedFieldRules.js';
|
|
2
3
|
import { CalculationFunctions } from '../../interfaces/formInput/calculationVariableInterface.js';
|
|
3
|
-
import { enumValues,
|
|
4
|
+
import { enumValues, optional } from '../internal/coupling.js';
|
|
4
5
|
/**
|
|
5
6
|
* The `calculatedFieldRules` member: a value computed from other fields rather
|
|
6
7
|
* than typed by the user.
|
|
@@ -43,8 +44,8 @@ import { enumValues, exhaustive, optional } from '../internal/coupling.js';
|
|
|
43
44
|
* annotates the same `parentInputId` + `function` pair as "Multiple-input
|
|
44
45
|
* (list) bindings", which is the distinction drawn.
|
|
45
46
|
*/
|
|
46
|
-
/**
|
|
47
|
-
export const ROUNDING_MODE_VALUES =
|
|
47
|
+
/** The rounding strategies, from the one list `roundingMode` is typed by. */
|
|
48
|
+
export const ROUNDING_MODE_VALUES = ROUNDING_MODES;
|
|
48
49
|
// --- schema -----------------------------------------------------------------
|
|
49
50
|
const variableToken = s.string('The name this variable is referenced by inside the formula. Keep it short and lower case, and spell it identically in the formula.', { pattern: '^[a-zA-Z][a-zA-Z0-9_]*$' });
|
|
50
51
|
const variableLabel = s.string('A human-readable name for this variable, shown when the formula is explained back to an administrator.');
|
|
@@ -88,8 +89,8 @@ export const calculationVariableDraftSchema = s.anyOf([
|
|
|
88
89
|
export const calculatedFieldRulesDraftSchema = s.object('How this field computes its value from other fields on the form, so the user never types a figure the system can work out: a line total, VAT, an age. Whenever a total, average, minimum, maximum or count over an item list is used anywhere else — a decision gate, a validator, another formula, a list column, the next person — it must be a calculated field like this one on the form itself, aggregating the list; the roll-up shown beneath the list is for the user only.', {
|
|
89
90
|
formula: s.string('The arithmetic expression, written using the variable names declared below and nothing else. Every name in the formula must be declared as a variable, and every declared variable should appear in the formula.'),
|
|
90
91
|
variables: s.array('The fields the formula reads, one entry per variable name used in it.', calculationVariableDraftSchema, { minItems: 1 }),
|
|
91
|
-
decimalPlaces: optional(s.integer('How many decimal places the result is rounded to: 2 for money, 0 for a count.', { minimum: 0 })),
|
|
92
|
-
roundingMode: optional(s.enumeration("How the result is rounded at that precision
|
|
92
|
+
decimalPlaces: optional(s.integer('How many decimal places the result is rounded to: 2 for money, 0 for a count. The rounded result is what is saved and shown.', { minimum: 0 })),
|
|
93
|
+
roundingMode: optional(s.enumeration("How the result is rounded at that precision. 'HALF_EVEN' is banker's rounding (a tie goes to the even neighbour), the default for money and what a currency-formatted field uses when this is unset; 'ROUND' rounds a tie away from zero; 'FLOOR' or 'CEIL' only when the business rule says round down or up.", [...ROUNDING_MODE_VALUES])),
|
|
93
94
|
getFormulaFromAFormInput: optional(s.boolean('Whether the formula is read from another field on the form at runtime instead of being fixed here. Leave unset unless the form genuinely lets a user supply the formula.')),
|
|
94
95
|
formControlWithFormula: optional(s.string('The formControlName of the field supplying the formula. Only meaningful when the formula is read from a form input.')),
|
|
95
96
|
});
|
|
@@ -58,6 +58,12 @@ import { AssertNever } from '../internal/coupling.js';
|
|
|
58
58
|
* `string | undefined`. The builder's segment form declares it
|
|
59
59
|
* `Validators.required`, so a row without one cannot be saved by hand either.
|
|
60
60
|
* Narrower than the interface is the permitted direction; wider is not.
|
|
61
|
+
*
|
|
62
|
+
* `limitToChildOfAccountMapTo` — the run-time binding that reads a segment's
|
|
63
|
+
* account-path limit off another form input — is not offered, for the reason
|
|
64
|
+
* `inputs` is not: it cross-references an input by id, and ids are stamped by
|
|
65
|
+
* the builder after generation. The fixed `limitToChildOfAccount` path IS
|
|
66
|
+
* offered; the binding is authored in the builder's segment editor.
|
|
61
67
|
*/
|
|
62
68
|
export interface MscoaSegmentDraft {
|
|
63
69
|
segment: string;
|
|
@@ -69,6 +75,7 @@ export interface MscoaSegmentDraft {
|
|
|
69
75
|
inheritValueFromAccrual: boolean | null;
|
|
70
76
|
vatSelectonActive: boolean | null;
|
|
71
77
|
segmentExtension: boolean;
|
|
78
|
+
limitToChildOfAccount: string | null;
|
|
72
79
|
}
|
|
73
80
|
export interface MscoaDualCashExclusionRuleDraft {
|
|
74
81
|
pattern: string;
|
|
@@ -89,6 +96,7 @@ export interface MscoaConfigDraft {
|
|
|
89
96
|
extensionAccountsForSegments: string[];
|
|
90
97
|
showAllSegments: boolean;
|
|
91
98
|
dualCashExclusion: MscoaDualCashExclusionDraft | null;
|
|
99
|
+
allowNonPostingLevelAccount: boolean | null;
|
|
92
100
|
}
|
|
93
101
|
/**
|
|
94
102
|
* `DualCashExclusionMatchMode` is a string-union type with no runtime object to
|
|
@@ -130,6 +138,7 @@ export declare const mscoaConfigSchema: s.ObjectType<{
|
|
|
130
138
|
inheritValueFromAccrual: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
131
139
|
vatSelectonActive: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
132
140
|
segmentExtension: s.BooleanType;
|
|
141
|
+
limitToChildOfAccount: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
133
142
|
}>>;
|
|
134
143
|
cashSegments: import("@hashbrownai/core/src/schema/base").SchemaForUnion<{
|
|
135
144
|
segment: string;
|
|
@@ -141,9 +150,11 @@ export declare const mscoaConfigSchema: s.ObjectType<{
|
|
|
141
150
|
inheritValueFromAccrual: boolean | null;
|
|
142
151
|
vatSelectonActive: boolean | null;
|
|
143
152
|
segmentExtension: boolean;
|
|
153
|
+
limitToChildOfAccount: string | null;
|
|
144
154
|
}[] | null>;
|
|
145
155
|
accountValueLabel: s.EnumType<string[]>;
|
|
146
156
|
showAllSegments: s.BooleanType;
|
|
157
|
+
allowNonPostingLevelAccount: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
147
158
|
extensionAccountsForSegments: s.ArrayType<s.StringType>;
|
|
148
159
|
dualCashExclusion: import("@hashbrownai/core/src/schema/base").SchemaForUnion<{
|
|
149
160
|
rules: {
|
|
@@ -57,6 +57,7 @@ const segmentSchema = s.object('One segment of the chart of accounts the user pi
|
|
|
57
57
|
// form already persisted with it.
|
|
58
58
|
vatSelectonActive: optional(s.boolean('Adds the VAT-status column to the account chart. It applies to the ITEM segment, which is the only one carrying a VAT treatment; leave null elsewhere.')),
|
|
59
59
|
segmentExtension: s.boolean('True for an extra level authored under a segment rather than a segment of the published chart. An extension row is keyed by customSegment and may reuse a segment key another row already claims; an ordinary row may not.'),
|
|
60
|
+
limitToChildOfAccount: optional(s.string('Optional colon-separated path into this segment\'s branch of the chart, such as "Net Assets:Reserves and Funds:Revaluation Reserve". When set, the user can only pick accounts at or beneath that branch; the levels above it are shown for context but cannot be selected. Use it when the form captures one known category — a specific reserve, one asset class — and the account must not fall outside it. Leave null to offer the whole segment, which is the usual case. A path the chart does not contain is ignored and the whole segment is offered anyway, so guess nothing: name a branch only when the request states it.')),
|
|
60
61
|
});
|
|
61
62
|
/**
|
|
62
63
|
* One cash-exclusion rule.
|
|
@@ -104,6 +105,7 @@ export const mscoaConfigSchema = s.object(describe('How this control asks the us
|
|
|
104
105
|
cashSegments: optional(s.array('The segments captured on the cash side. Only meaningful when the accounting basis is cash or dual; leave null for an accrual-only input. A cash row that mirrors an accrual one should normally set inheritValueFromAccrual rather than ask the user twice.', segmentSchema)),
|
|
105
106
|
accountValueLabel: s.enumeration(`Which field of the account identifies it to the user, everywhere this control shows one. Choose the field an administrator would read back in the chart of accounts. ${ACCOUNT_VALUE_LABEL_GLOSS}.`, ACCOUNT_VALUE_LABEL_ENTRIES),
|
|
106
107
|
showAllSegments: s.boolean('True reflects every segment of the loaded account tree, read-only, instead of only the ones listed here — the application reconciles the list against the tree, so segments authored here are kept but not exclusive. False shows exactly the segments listed and nothing else, which is the usual choice.'),
|
|
108
|
+
allowNonPostingLevelAccount: optional(s.boolean('True lets the user pick an account at any level of the chart, not only a posting-level account. Leave null — posting-level accounts only, the default every existing input has — unless the request says a group account must be selectable, such as a budget captured at a summary line.')),
|
|
107
109
|
extensionAccountsForSegments: s.array('Names of extra account columns this control offers on top of the ordinary account, each becoming a column on the chart. A segment opts into one by naming it in its own additionalAccounts. Leave empty when the control captures ordinary accounts only.', s.string('An extension-account name, such as a counter-account this form also captures.')),
|
|
108
110
|
dualCashExclusion: optional(s.object('Dual basis only: when the cash side is NOT required, despite the basis asking for both. Leave null to require both sides always, which is the default behaviour and the right answer unless the form has a stated exception.', {
|
|
109
111
|
rules: optional(s.array('The conditions tested against the accounts the user selected on the accrual side. A rule whose pattern does not compile never matches, so it can never suppress the cash side by accident.', dualCashExclusionRuleSchema)),
|
|
@@ -130,7 +130,7 @@ export declare const tableConfigSchema: s.ObjectType<{
|
|
|
130
130
|
tableCell: boolean | null;
|
|
131
131
|
}>>;
|
|
132
132
|
decimalPlaces: import("@hashbrownai/core/src/schema/base").SchemaForUnion<number | null>;
|
|
133
|
-
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"FLOOR" | "CEIL" | "
|
|
133
|
+
roundingMode: import("@hashbrownai/core/src/schema/base").SchemaForUnion<"ROUND" | "FLOOR" | "CEIL" | "HALF_EVEN" | null>;
|
|
134
134
|
getFormulaFromAFormInput: import("@hashbrownai/core/src/schema/base").SchemaForUnion<boolean | null>;
|
|
135
135
|
formControlWithFormula: import("@hashbrownai/core/src/schema/base").SchemaForUnion<string | null>;
|
|
136
136
|
}>;
|
|
@@ -58,7 +58,7 @@ export const TEXTAREA_WRAP_VALUES = exhaustive()([
|
|
|
58
58
|
'soft',
|
|
59
59
|
]);
|
|
60
60
|
export const textareaWrapSchema = s.enumeration(describe("How a textarea wraps long lines when the form is submitted. 'soft' leaves the text unchanged; 'hard' inserts real newlines at the wrap points.", 'wrap'), [...TEXTAREA_WRAP_VALUES]);
|
|
61
|
-
export const inputPipeTypeSchema = s.enumeration(describe(
|
|
61
|
+
export const inputPipeTypeSchema = s.enumeration(describe("How the value is presented. 'currency', 'decimal' and 'integer' also round the stored value to their precision (currency with banker's rounding); the other transforms are presentation only.", 'pipe', 'pipeType'), enumValues(InputPipeTypes));
|
|
62
62
|
export const richTextEditorTypeSchema = s.enumeration(describe('Which rich-text editor library backs an editor element.', 'richTextEditorLibrary'), enumValues(RichTextEditorType));
|
|
63
63
|
export const inputFileTypeSchema = s.enumeration(describe("The kind of upload a file control accepts: 'file' for a document such as a quote, an invoice or a certificate; 'captureImage' for a photo taken on the phone camera; 'image' for a picture from disk.", 'fileType'), enumValues(InputFileType));
|
|
64
64
|
// --- Data sourcing ----------------------------------------------------------
|