Skip to content

Commit 20d64a3

Browse files
committed
chore(platform-objects): designer help text names the currency result in all four locales; changeset
Claude-Session: https://claude.ai/code/session_016njDy8ozy9B9Ns5Y8kAWEK Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4f12195 commit 20d64a3

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@objectstack/spec": minor
3+
"@objectstack/formula": minor
4+
"@objectstack/platform-objects": patch
5+
---
6+
7+
A formula field can declare a currency result: `returnType: 'currency'`, with its currency in its own `currencyConfig`
8+
9+
Clause-②: yes (widening)
10+
11+
- **What is new in `@objectstack/spec`.** `FieldSchema.returnType` accepts `'currency'` beside `'number'`, `'text'`, `'boolean'` and `'date'`. A `currency` result is an amount of money. Its value is a bare number, as a currency field's is. Its currency is the formula field's own `currencyConfig`, the same `CurrencyConfigSchema` a currency field carries, with the same defaults and the same refusals: no `currencyConfig` means dynamic mode (the tenant default currency), and `{ currencyMode: 'fixed', defaultCurrency: 'USD' }` fixes it. Nothing is read at display time from the fields the expression references: the currency is a declaration on the formula.
12+
- **Readers.** The filter doors judge a formula returning `currency` as the currency field it reads like: a text operator on it is refused (`INVALID_FILTER`), and the number door judges its comparands. A formula is still not title-eligible unless it returns `text`, and is still refused for `sum` / `avg` / `min` / `max` (it has no stored column).
13+
- **Designer forms.** The field designer and the object designer's field grid both offer Currency as a return type. The field designer shows its Currency Config row for a formula whose return type is Currency, as it does for a currency field.
14+
- **What is new in `@objectstack/formula`.** `inferFormulaReturn(expression, fields)` returns the declaration authoring stamps onto a formula field, judged over the host object's declared field map: `{ returnType: 'currency' }` when the expression is provably an amount of money, plus `currencyConfig: { currencyMode: 'fixed', defaultCurrency }` when its source amounts are in one fixed currency. "Provably money" is unit checking over the expression: amounts in one currency added, subtracted, scaled by a number or a percent, divided by a number, rounded, or picked by `min` / `max` / `coalesce` / a ternary. Two different currencies, an amount multiplied by an amount, or an amount plus a plain quantity are not money. For everything it cannot prove to be money it answers exactly what `inferExpressionType` answers, so a numeric formula stays `number`. Its types `FormulaReturnDeclaration` and `FormulaSourceField` are exported with it. `inferExpressionType` is unchanged.
15+
- **`@objectstack/platform-objects`.** The designer help text for the return type and the currency config rows names the currency result, in all four locales.
16+
- **Nothing to migrate.** Every value accepted before is accepted now. To declare a formula over money as money, declare `returnType: 'currency'` and copy the source currency field's `currencyConfig` onto the formula, or run `inferFormulaReturn` and write what it returns.

‎packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
594594
},
595595
currencyConfig: {
596596
label: "Currency Config",
597-
helpText: "Which currency this field is in. Unset: dynamic mode. The stored value is a bare number in either mode."
597+
helpText: "Which currency this field is in — a currency field, or a formula whose return type is Currency. Unset: dynamic mode. The value is a bare number in either mode."
598598
},
599599
"currencyConfig.currencyMode": {
600600
label: "Currency Mode",
@@ -744,7 +744,7 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
744744
},
745745
returnType: {
746746
label: "Return Type",
747-
helpText: "Declared value type of the formula, stamped from the inferred CEL type. Consumers read it instead of re-parsing the expression."
747+
helpText: "Declared value type of the formula, stamped from the inferred CEL type. Consumers read it instead of re-parsing the expression. Currency: an amount of money, in the currency the Currency Config of this field declares (dynamic when unset)."
748748
},
749749
summaryOperations: {
750750
label: "Summary Operations",

‎packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
594594
},
595595
currencyConfig: {
596596
label: "Configuración de moneda",
597-
helpText: "En qué moneda está este campo. Sin definir: modo dynamic. En ambos modos el valor almacenado es un número sin más."
597+
helpText: "En qué moneda está este campo: un campo de moneda, o una fórmula cuyo tipo de retorno es Moneda. Sin definir: modo dynamic. En ambos modos el valor es un número sin más."
598598
},
599599
"currencyConfig.currencyMode": {
600600
label: "Modo de moneda",
@@ -744,7 +744,7 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
744744
},
745745
returnType: {
746746
label: "Tipo de retorno",
747-
helpText: "Tipo de valor declarado de la fórmula, registrado a partir del tipo CEL inferido. Los consumidores lo leen en vez de volver a analizar la expresión."
747+
helpText: "Tipo de valor declarado de la fórmula, registrado a partir del tipo CEL inferido. Los consumidores lo leen en vez de volver a analizar la expresión. Moneda: un importe, en la moneda que declara la configuración de moneda de este campo (dynamic si no se define)."
748748
},
749749
summaryOperations: {
750750
label: "Operaciones de resumen",

‎packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export const jaJPMetadataForms: NonNullable<TranslationData['metadataForms']> =
594594
},
595595
currencyConfig: {
596596
label: "通貨設定",
597-
helpText: "このフィールドの通貨。未設定の場合は dynamic モードです。どちらのモードでも、保存される値は単なる数値です。"
597+
helpText: "このフィールドの通貨(通貨フィールド、または戻り値型が「通貨」の数式フィールド)。未設定の場合は dynamic モードです。どちらのモードでも、値は単なる数値です。"
598598
},
599599
"currencyConfig.currencyMode": {
600600
label: "通貨モード",
@@ -744,7 +744,7 @@ export const jaJPMetadataForms: NonNullable<TranslationData['metadataForms']> =
744744
},
745745
returnType: {
746746
label: "数式の戻り値型",
747-
helpText: "数式が宣言する値の型。推論された CEL の型から記録され、利用側は式を解析し直さずにこの値を読みます。"
747+
helpText: "数式が宣言する値の型。推論された CEL の型から記録され、利用側は式を解析し直さずにこの値を読みます。通貨:金額で、その通貨はこのフィールドの通貨設定が宣言します(未設定の場合は dynamic)。"
748748
},
749749
summaryOperations: {
750750
label: "集計操作",

‎packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export const zhCNMetadataForms: NonNullable<TranslationData['metadataForms']> =
594594
},
595595
currencyConfig: {
596596
label: "货币配置",
597-
helpText: "此字段使用哪种货币。未设置时为 dynamic 模式。两种模式下存储的值都是一个纯数字。"
597+
helpText: "此字段使用哪种货币——货币字段,或返回类型为“货币”的公式字段。未设置时为 dynamic 模式。两种模式下值都是一个纯数字。"
598598
},
599599
"currencyConfig.currencyMode": {
600600
label: "货币模式",
@@ -744,7 +744,7 @@ export const zhCNMetadataForms: NonNullable<TranslationData['metadataForms']> =
744744
},
745745
returnType: {
746746
label: "公式返回类型",
747-
helpText: "公式声明的值类型,按推断出的 CEL 类型写入。消费方直接读它,无需重新解析表达式。"
747+
helpText: "公式声明的值类型,按推断出的 CEL 类型写入。消费方直接读它,无需重新解析表达式。货币:一笔金额,其货币由此字段的货币配置声明(未设置时为 dynamic)。"
748748
},
749749
summaryOperations: {
750750
label: "汇总操作",

0 commit comments

Comments
 (0)