Skip to content

Commit 1fe31dc

Browse files
Copilothotlong
andcommitted
Implement Money field type with multi-currency support
- Add 'money' to FieldType enum - Create MoneyConfigSchema with precision, currencyMode, and defaultCurrency - Create MoneyValueSchema for runtime value structure - Extend FieldSchema with optional moneyConfig property - Add Field.money() helper factory function - Add comprehensive tests (71 total field tests, all passing) - Generate JSON schemas and documentation - All 1638 tests passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 4bb5d21 commit 1fe31dc

File tree

16 files changed

+510
-7
lines changed

16 files changed

+510
-7
lines changed

content/docs/references/data/field/Field.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: Field Schema Reference
99
| :--- | :--- | :--- | :--- |
1010
| **name** | `string` | optional | Machine name (snake_case) |
1111
| **label** | `string` | optional | Human readable label |
12-
| **type** | `Enum<'text' \| 'textarea' \| 'email' \| 'url' \| 'phone' \| 'password' \| 'markdown' \| 'html' \| 'richtext' \| 'number' \| 'currency' \| 'percent' \| 'date' \| 'datetime' \| 'time' \| 'boolean' \| 'select' \| 'lookup' \| 'master_detail' \| 'image' \| 'file' \| 'avatar' \| 'formula' \| 'summary' \| 'autonumber' \| 'location' \| 'geolocation' \| 'address' \| 'code' \| 'color' \| 'rating' \| 'slider' \| 'signature' \| 'qrcode'>` || Field Data Type |
12+
| **type** | `Enum<'text' \| 'textarea' \| 'email' \| 'url' \| 'phone' \| 'password' \| 'markdown' \| 'html' \| 'richtext' \| 'number' \| 'currency' \| 'percent' \| 'money' \| 'date' \| 'datetime' \| 'time' \| 'boolean' \| 'select' \| 'lookup' \| 'master_detail' \| 'image' \| 'file' \| 'avatar' \| 'formula' \| 'summary' \| 'autonumber' \| 'location' \| 'geolocation' \| 'address' \| 'code' \| 'color' \| 'rating' \| 'slider' \| 'signature' \| 'qrcode'>` || Field Data Type |
1313
| **description** | `string` | optional | Tooltip/Help text |
1414
| **format** | `string` | optional | Format string (e.g. email, phone) |
1515
| **required** | `boolean` | optional | Is required |
@@ -49,6 +49,7 @@ description: Field Schema Reference
4949
| **qrErrorCorrection** | `Enum<'L' \| 'M' \| 'Q' \| 'H'>` | optional | QR code error correction level (L=7%, M=15%, Q=25%, H=30%). Only applicable when barcodeFormat is "qr" |
5050
| **displayValue** | `boolean` | optional | Display human-readable value below barcode/QR code |
5151
| **allowScanning** | `boolean` | optional | Enable camera scanning for barcode/QR code input |
52+
| **moneyConfig** | `object` | optional | Configuration for money field type |
5253
| **hidden** | `boolean` | optional | Hidden from default UI |
5354
| **readonly** | `boolean` | optional | Read-only in UI |
5455
| **encryption** | `boolean` | optional | Encrypt at rest |

content/docs/references/data/field/FieldType.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ description: FieldType Schema Reference
1717
* `number`
1818
* `currency`
1919
* `percent`
20+
* `money`
2021
* `date`
2122
* `datetime`
2223
* `time`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: MoneyConfig
3+
description: MoneyConfig Schema Reference
4+
---
5+
6+
## Properties
7+
8+
| Property | Type | Required | Description |
9+
| :--- | :--- | :--- | :--- |
10+
| **precision** | `integer` | optional | Decimal precision (default: 2) |
11+
| **currencyMode** | `Enum<'dynamic' \| 'fixed'>` | optional | Currency mode: dynamic (user selectable) or fixed (single currency) |
12+
| **defaultCurrency** | `string` | optional | Default or fixed currency code (ISO 4217, e.g., USD, CNY, EUR) |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: MoneyValue
3+
description: MoneyValue Schema Reference
4+
---
5+
6+
## Properties
7+
8+
| Property | Type | Required | Description |
9+
| :--- | :--- | :--- | :--- |
10+
| **value** | `number` || Monetary amount |
11+
| **currency** | `string` || Currency code (ISO 4217) |

content/docs/references/ui/action/ActionParam.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ description: ActionParam Schema Reference
99
| :--- | :--- | :--- | :--- |
1010
| **name** | `string` || |
1111
| **label** | `string` || |
12-
| **type** | `Enum<'text' \| 'textarea' \| 'email' \| 'url' \| 'phone' \| 'password' \| 'markdown' \| 'html' \| 'richtext' \| 'number' \| 'currency' \| 'percent' \| 'date' \| 'datetime' \| 'time' \| 'boolean' \| 'select' \| 'lookup' \| 'master_detail' \| 'image' \| 'file' \| 'avatar' \| 'formula' \| 'summary' \| 'autonumber' \| 'location' \| 'geolocation' \| 'address' \| 'code' \| 'color' \| 'rating' \| 'slider' \| 'signature' \| 'qrcode'>` || |
12+
| **type** | `Enum<'text' \| 'textarea' \| 'email' \| 'url' \| 'phone' \| 'password' \| 'markdown' \| 'html' \| 'richtext' \| 'number' \| 'currency' \| 'percent' \| 'money' \| 'date' \| 'datetime' \| 'time' \| 'boolean' \| 'select' \| 'lookup' \| 'master_detail' \| 'image' \| 'file' \| 'avatar' \| 'formula' \| 'summary' \| 'autonumber' \| 'location' \| 'geolocation' \| 'address' \| 'code' \| 'color' \| 'rating' \| 'slider' \| 'signature' \| 'qrcode'>` || |
1313
| **required** | `boolean` | optional | |
1414
| **options** | `object[]` | optional | |

packages/spec/json-schema/data/Field.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"number",
2929
"currency",
3030
"percent",
31+
"money",
3132
"date",
3233
"datetime",
3334
"time",
@@ -303,6 +304,36 @@
303304
"type": "boolean",
304305
"description": "Enable camera scanning for barcode/QR code input"
305306
},
307+
"moneyConfig": {
308+
"type": "object",
309+
"properties": {
310+
"precision": {
311+
"type": "integer",
312+
"minimum": 0,
313+
"maximum": 10,
314+
"default": 2,
315+
"description": "Decimal precision (default: 2)"
316+
},
317+
"currencyMode": {
318+
"type": "string",
319+
"enum": [
320+
"dynamic",
321+
"fixed"
322+
],
323+
"default": "dynamic",
324+
"description": "Currency mode: dynamic (user selectable) or fixed (single currency)"
325+
},
326+
"defaultCurrency": {
327+
"type": "string",
328+
"minLength": 3,
329+
"maxLength": 3,
330+
"default": "CNY",
331+
"description": "Default or fixed currency code (ISO 4217, e.g., USD, CNY, EUR)"
332+
}
333+
},
334+
"additionalProperties": false,
335+
"description": "Configuration for money field type"
336+
},
306337
"hidden": {
307338
"type": "boolean",
308339
"default": false,

packages/spec/json-schema/data/FieldType.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"number",
1717
"currency",
1818
"percent",
19+
"money",
1920
"date",
2021
"datetime",
2122
"time",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$ref": "#/definitions/MoneyConfig",
3+
"definitions": {
4+
"MoneyConfig": {
5+
"type": "object",
6+
"properties": {
7+
"precision": {
8+
"type": "integer",
9+
"minimum": 0,
10+
"maximum": 10,
11+
"default": 2,
12+
"description": "Decimal precision (default: 2)"
13+
},
14+
"currencyMode": {
15+
"type": "string",
16+
"enum": [
17+
"dynamic",
18+
"fixed"
19+
],
20+
"default": "dynamic",
21+
"description": "Currency mode: dynamic (user selectable) or fixed (single currency)"
22+
},
23+
"defaultCurrency": {
24+
"type": "string",
25+
"minLength": 3,
26+
"maxLength": 3,
27+
"default": "CNY",
28+
"description": "Default or fixed currency code (ISO 4217, e.g., USD, CNY, EUR)"
29+
}
30+
},
31+
"additionalProperties": false
32+
}
33+
},
34+
"$schema": "http://json-schema.org/draft-07/schema#"
35+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$ref": "#/definitions/MoneyValue",
3+
"definitions": {
4+
"MoneyValue": {
5+
"type": "object",
6+
"properties": {
7+
"value": {
8+
"type": "number",
9+
"description": "Monetary amount"
10+
},
11+
"currency": {
12+
"type": "string",
13+
"minLength": 3,
14+
"maxLength": 3,
15+
"description": "Currency code (ISO 4217)"
16+
}
17+
},
18+
"required": [
19+
"value",
20+
"currency"
21+
],
22+
"additionalProperties": false
23+
}
24+
},
25+
"$schema": "http://json-schema.org/draft-07/schema#"
26+
}

packages/spec/json-schema/data/Object.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"number",
6969
"currency",
7070
"percent",
71+
"money",
7172
"date",
7273
"datetime",
7374
"time",
@@ -343,6 +344,36 @@
343344
"type": "boolean",
344345
"description": "Enable camera scanning for barcode/QR code input"
345346
},
347+
"moneyConfig": {
348+
"type": "object",
349+
"properties": {
350+
"precision": {
351+
"type": "integer",
352+
"minimum": 0,
353+
"maximum": 10,
354+
"default": 2,
355+
"description": "Decimal precision (default: 2)"
356+
},
357+
"currencyMode": {
358+
"type": "string",
359+
"enum": [
360+
"dynamic",
361+
"fixed"
362+
],
363+
"default": "dynamic",
364+
"description": "Currency mode: dynamic (user selectable) or fixed (single currency)"
365+
},
366+
"defaultCurrency": {
367+
"type": "string",
368+
"minLength": 3,
369+
"maxLength": 3,
370+
"default": "CNY",
371+
"description": "Default or fixed currency code (ISO 4217, e.g., USD, CNY, EUR)"
372+
}
373+
},
374+
"additionalProperties": false,
375+
"description": "Configuration for money field type"
376+
},
346377
"hidden": {
347378
"type": "boolean",
348379
"default": false,

0 commit comments

Comments
 (0)