Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/35498-standard-unit-setting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/spec': patch
'@objectstack/platform-objects': patch
'@objectstack/plugin-security': patch
'@objectstack/cli': patch
---

feat(platform-objects): an organization sets how many decimal places each standard unit of measure displays with (`sys_standard_unit_setting`, ADR-0158 U6)

Clause-②: yes (widening)
Metadata-protocol: none

An organization administrator can now give any standard unit of measure (UN/ECE Recommendation 20 codes such as `KGM` or `H87`) its own display decimal places, for example 3 for grams at a jeweller or 0 for kilograms at a gravel yard. The value lives in the new organization-owned object `sys_standard_unit_setting` (Setup → Configuration → Standard Unit Settings): one row per standard code, `decimal_places` a whole number from 0 to 12. Deleting the row clears the setting. The organization's own units keep their decimal places on their own `sys_unit` row.

- Every member reads the settings (`member_default`, read only); organization administrators and owners create, edit and delete them (`organization_admin`). External members get no read, as with `sys_unit`.
- `organization_id` is injected and stamped on every row. Under the `isolated` tenancy posture the tenant wall (ADR-0095 D1) confines every read and write to the caller's organization, so another organization's setting is never read. As with every organization-owned object (ADR-0105 D1), the `single` posture raises no wall, and the `group` posture walls by membership, so a member of several organizations can read each one's settings.
- Every set, change and clear is written to `sys_audit_log`, with field history on both columns.
- The value is a display default only (ADR-0158 L4): a field's own `scale` stays the storage ceiling, and nothing is rounded at write by it. No reader ships in this change; the quantity display card (#35490) will read it.
- Like an exchange rate, a setting is a record the organization owns, so an organization delete is refused (`DELETE_RESTRICTED`) until its settings are deleted.
5 changes: 5 additions & 0 deletions packages/cli/src/utils/organization-ownership-inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ export const ORGANIZATION_OWNERSHIP_INVENTORY: readonly InventoryEntry[] = [
// organization's administrators author its own units; the platform ships no
// row, and no parent row anchors a unit.
{ object: 'sys_unit', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] },
// Standard unit settings (`@objectstack/platform-objects`, ADR-0158 U6 and
// Open item 10): an organization's administrators set the display decimal
// places of a standard unit; the platform ships no row, and no parent row
// anchors a setting.
{ object: 'sys_standard_unit_setting', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] },
// Tasks and notes (`@objectstack/platform-objects` `work/`): members write
// them, and the organization column is stamped from the writing context; no
// parent row anchors a task or a note (step 1 links neither to a record).
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/test/connect-agent-both-halves-wire.pin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,15 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
// +2, `group_apps` and `nav_packages`; 37 until #33933 moved the
// Knowledge entry, `nav_settings_knowledge`, to
// `@objectstack/service-knowledge`, which contributes it only where the
// knowledge service is mounted.)
// knowledge service is mounted; 36 until the Standard Unit Settings
// entry, `nav_standard_unit_settings`, joined Configuration, ADR-0158
// Open item 10.)
// `nav_settings_branding` is not among them, and not because of a
// tenancy wall (this harness boots none): since #24766 it is
// contributed by `@objectstack/service-settings` together with the
// `branding` namespace, offered only where no organization wall stands,
// and this harness composes platform-objects and the MCP bundle alone.
expect(allowedIds).toHaveLength(36);
expect(allowedIds).toHaveLength(37);
expect(allowedIds).toContain('nav_packages');
expect(groupChildren(setupAllowed.body?.item, 'group_apps')).toEqual(['nav_packages']);
expect(allowedIds).toContain('nav_public_forms');
Expand All @@ -300,6 +302,7 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
expect(allowedIds).not.toContain('nav_settings_knowledge');
expect(allowedIds).toContain('nav_recycle_bin');
expect(allowedIds).toContain('nav_units_of_measure');
expect(allowedIds).toContain('nav_standard_unit_settings');
expect(allowedIds).not.toContain('nav_settings_branding');
// The two per-user stores are reached from the User record page, not
// from Setup's menu (#23803).
Expand All @@ -322,8 +325,8 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
expect(withAccountHalf.statusCode).toBe(200);
expect(withoutAccountHalf.statusCode).toBe(200);
expect(navIds(withAccountHalf.body?.item)).toEqual(navIds(withoutAccountHalf.body?.item));
// 36: the composition the count in the test above states.
expect(navIds(withAccountHalf.body?.item)).toHaveLength(36);
// 37: the composition the count in the test above states.
expect(navIds(withAccountHalf.body?.item)).toHaveLength(37);

// The mechanism behind the invariance, asserted rather than assumed:
// the bundle aims exactly one contribution at `setup` and one at
Expand Down
2 changes: 2 additions & 0 deletions packages/platform-objects/scripts/i18n-extract.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ import {
SysMigration,
SysExchangeRate,
SysUnit,
SysStandardUnitSetting,
SysWorkCalendar,
SysWorkCalendarException,
} from '../src/system/index.js';
Expand Down Expand Up @@ -368,6 +369,7 @@ const config: ObjectStackDefinition = defineStack({
SysMigration,
SysExchangeRate,
SysUnit,
SysStandardUnitSetting,
SysWorkCalendar,
SysWorkCalendarException,
SysTask,
Expand Down
4 changes: 4 additions & 0 deletions packages/platform-objects/src/apps/setup-nav.contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export const SETUP_NAV_CONTRIBUTIONS: NavigationContribution[] = [
// `requiredPermissions`: the object grant decides (every member reads,
// organization admins write), and Setup itself already needs `setup.access`.
{ id: 'nav_units_of_measure', type: 'object', label: 'Units of Measure', objectName: 'sys_unit', viewName: 'all_units', icon: 'ruler' },
// [ADR-0158 U6, Open item 10] The decimal places each standard unit
// displays with in the organization, next to the organization's own
// units. No `requiredPermissions`, for the same reason as the entry above.
{ id: 'nav_standard_unit_settings', type: 'object', label: 'Standard Unit Settings', objectName: 'sys_standard_unit_setting', viewName: 'all_settings', icon: 'ruler' },
// [ADR-0157 D1, D3] Working calendars and their holidays, beside the
// other organization reference data Localization governs. The exceptions
// get their own entry because their list page is the import door for a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4505,6 +4505,42 @@ export const arObjects: NonNullable<TranslationData['objects']> = {
}
}
},
sys_standard_unit_setting: {
label: "Standard Unit Setting",
pluralLabel: "Standard Unit Settings",
description: "How many decimal places a quantity in a standard unit of measure (KGM, H87, …) displays with in this organization — one row per standard unit the organization has set.",
fields: {
id: {
label: "ID"
},
code: {
label: "Standard Unit",
help: "The standard unit code (UN/ECE Recommendation 20) in exact uppercase, for example KGM for kilogram, GRM for gram or H87 for piece. The organization's own units carry their decimal places on the unit itself, under Units of Measure. The code cannot be changed after the setting is created."
},
decimal_places: {
label: "Decimal Places",
help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored and shown. Delete the setting to clear it."
}
},
_views: {
all_settings: {
label: "All",
description: "Decimal places a quantity in a standard unit displays with in this organization. A field's own decimal places still limit what is stored and shown.",
emptyState: {
title: "No standard unit settings yet",
message: "Standard units display with the decimal places of the field that holds the quantity. Add a setting to give a standard unit, such as grams or kilograms, its own number of decimal places."
}
}
},
_validations: {
standard_unit_setting_code_standard: {
message: "Enter a standard unit code in exact uppercase, for example KGM or H87. An organization's own unit carries its decimal places on the unit itself, under Units of Measure."
},
standard_unit_setting_code_immutable: {
message: "A setting's unit cannot be changed after it is created. Delete it and add a setting for the other unit instead."
}
}
},
sys_work_calendar: {
label: "تقويم العمل",
pluralLabel: "تقويمات العمل",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ export const arGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider._actions.register_sso_provider.params.tokenEndpoint.label": "7cba958c95cef146",
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_standard_unit_setting._validations.standard_unit_setting_code_immutable.message": "30dca7b5af0102a7",
"objects.sys_standard_unit_setting._validations.standard_unit_setting_code_standard.message": "b8d744ecf7e2fd14",
"objects.sys_standard_unit_setting._views.all_settings.description": "b2c6e313dfbaab6f",
"objects.sys_standard_unit_setting._views.all_settings.emptyState.message": "4973c431bef4fb16",
"objects.sys_standard_unit_setting._views.all_settings.emptyState.title": "c744be790895b52b",
"objects.sys_standard_unit_setting._views.all_settings.label": "6d6f653f8264ab17",
"objects.sys_standard_unit_setting.description": "8be70d71b4824c8a",
"objects.sys_standard_unit_setting.fields.code.help": "171e0116c9d1a103",
"objects.sys_standard_unit_setting.fields.code.label": "8101f71ea11455f1",
"objects.sys_standard_unit_setting.fields.decimal_places.help": "8f87ae85775e6bb4",
"objects.sys_standard_unit_setting.fields.decimal_places.label": "c376c70ccdda79b3",
"objects.sys_standard_unit_setting.fields.id.label": "00b0385c9c152888",
"objects.sys_standard_unit_setting.label": "97ace8a464552c96",
"objects.sys_standard_unit_setting.pluralLabel": "507e2db8f56dcaf0",
"objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2",
"objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228",
"objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60",
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const ar: TranslationData = {
nav_settings_localization: { label: 'الترجمة والإعدادات المحلية' },
nav_exchange_rates: { label: 'أسعار الصرف' },
nav_units_of_measure: { label: 'وحدات القياس' },
nav_standard_unit_settings: { label: 'إعدادات الوحدات القياسية' },
nav_work_calendars: { label: 'تقويمات العمل' },
nav_work_calendar_exceptions: { label: 'استثناءات التقويم' },
nav_settings_company: { label: 'الشركة' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const OWNED_OBJECTS = new Set([
// metadata (sys_view_definition retired as inert, ADR-0131 D13)
'sys_metadata', 'sys_metadata_history', 'sys_metadata_audit', 'sys_metadata_commit',
// system
'sys_setting', 'sys_platform_setting', 'sys_secret', 'sys_setting_audit', 'sys_platform_setting_audit', 'sys_migration', 'sys_exchange_rate', 'sys_unit',
'sys_setting', 'sys_platform_setting', 'sys_secret', 'sys_setting_audit', 'sys_platform_setting_audit', 'sys_migration', 'sys_exchange_rate', 'sys_unit', 'sys_standard_unit_setting',
'sys_work_calendar', 'sys_work_calendar_exception',
// work — the built-in tasks and notes
'sys_task', 'sys_note',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4505,6 +4505,42 @@ export const deObjects: NonNullable<TranslationData['objects']> = {
}
}
},
sys_standard_unit_setting: {
label: "Standard Unit Setting",
pluralLabel: "Standard Unit Settings",
description: "How many decimal places a quantity in a standard unit of measure (KGM, H87, …) displays with in this organization — one row per standard unit the organization has set.",
fields: {
id: {
label: "ID"
},
code: {
label: "Standard Unit",
help: "The standard unit code (UN/ECE Recommendation 20) in exact uppercase, for example KGM for kilogram, GRM for gram or H87 for piece. The organization's own units carry their decimal places on the unit itself, under Units of Measure. The code cannot be changed after the setting is created."
},
decimal_places: {
label: "Decimal Places",
help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored and shown. Delete the setting to clear it."
}
},
_views: {
all_settings: {
label: "All",
description: "Decimal places a quantity in a standard unit displays with in this organization. A field's own decimal places still limit what is stored and shown.",
emptyState: {
title: "No standard unit settings yet",
message: "Standard units display with the decimal places of the field that holds the quantity. Add a setting to give a standard unit, such as grams or kilograms, its own number of decimal places."
}
}
},
_validations: {
standard_unit_setting_code_standard: {
message: "Enter a standard unit code in exact uppercase, for example KGM or H87. An organization's own unit carries its decimal places on the unit itself, under Units of Measure."
},
standard_unit_setting_code_immutable: {
message: "A setting's unit cannot be changed after it is created. Delete it and add a setting for the other unit instead."
}
}
},
sys_work_calendar: {
label: "Arbeitskalender",
pluralLabel: "Arbeitskalender",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ export const deGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.id.label": "00b0385c9c152888",
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_standard_unit_setting._validations.standard_unit_setting_code_immutable.message": "30dca7b5af0102a7",
"objects.sys_standard_unit_setting._validations.standard_unit_setting_code_standard.message": "b8d744ecf7e2fd14",
"objects.sys_standard_unit_setting._views.all_settings.description": "b2c6e313dfbaab6f",
"objects.sys_standard_unit_setting._views.all_settings.emptyState.message": "4973c431bef4fb16",
"objects.sys_standard_unit_setting._views.all_settings.emptyState.title": "c744be790895b52b",
"objects.sys_standard_unit_setting._views.all_settings.label": "6d6f653f8264ab17",
"objects.sys_standard_unit_setting.description": "8be70d71b4824c8a",
"objects.sys_standard_unit_setting.fields.code.help": "171e0116c9d1a103",
"objects.sys_standard_unit_setting.fields.code.label": "8101f71ea11455f1",
"objects.sys_standard_unit_setting.fields.decimal_places.help": "8f87ae85775e6bb4",
"objects.sys_standard_unit_setting.fields.decimal_places.label": "c376c70ccdda79b3",
"objects.sys_standard_unit_setting.fields.id.label": "00b0385c9c152888",
"objects.sys_standard_unit_setting.label": "97ace8a464552c96",
"objects.sys_standard_unit_setting.pluralLabel": "507e2db8f56dcaf0",
"objects.sys_task.fields.status.label": "64a420165247654b",
"objects.sys_team.fields.name.label": "5274417ff1ccaf01",
"objects.sys_team.label": "42b87165ac826b2b",
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const de: TranslationData = {
nav_settings_localization: { label: 'Lokalisierung' },
nav_exchange_rates: { label: 'Wechselkurse' },
nav_units_of_measure: { label: 'Maßeinheiten' },
nav_standard_unit_settings: { label: 'Standardeinheiten-Einstellungen' },
nav_work_calendars: { label: 'Arbeitskalender' },
nav_work_calendar_exceptions: { label: 'Kalenderausnahmen' },
nav_settings_company: { label: 'Unternehmen' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4505,6 +4505,42 @@ export const enObjects: NonNullable<TranslationData['objects']> = {
}
}
},
sys_standard_unit_setting: {
label: "Standard Unit Setting",
pluralLabel: "Standard Unit Settings",
description: "How many decimal places a quantity in a standard unit of measure (KGM, H87, …) displays with in this organization — one row per standard unit the organization has set.",
fields: {
id: {
label: "ID"
},
code: {
label: "Standard Unit",
help: "The standard unit code (UN/ECE Recommendation 20) in exact uppercase, for example KGM for kilogram, GRM for gram or H87 for piece. The organization's own units carry their decimal places on the unit itself, under Units of Measure. The code cannot be changed after the setting is created."
},
decimal_places: {
label: "Decimal Places",
help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored and shown. Delete the setting to clear it."
}
},
_views: {
all_settings: {
label: "All",
description: "Decimal places a quantity in a standard unit displays with in this organization. A field's own decimal places still limit what is stored and shown.",
emptyState: {
title: "No standard unit settings yet",
message: "Standard units display with the decimal places of the field that holds the quantity. Add a setting to give a standard unit, such as grams or kilograms, its own number of decimal places."
}
}
},
_validations: {
standard_unit_setting_code_standard: {
message: "Enter a standard unit code in exact uppercase, for example KGM or H87. An organization's own unit carries its decimal places on the unit itself, under Units of Measure."
},
standard_unit_setting_code_immutable: {
message: "A setting's unit cannot be changed after it is created. Delete it and add a setting for the other unit instead."
}
}
},
sys_work_calendar: {
label: "Working Calendar",
pluralLabel: "Working Calendars",
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const en: TranslationData = {
nav_settings_localization: { label: 'Localization' },
nav_exchange_rates: { label: 'Exchange Rates' },
nav_units_of_measure: { label: 'Units of Measure' },
nav_standard_unit_settings: { label: 'Standard Unit Settings' },
nav_work_calendars: { label: 'Working Calendars' },
nav_work_calendar_exceptions: { label: 'Calendar Exceptions' },
nav_settings_company: { label: 'Company' },
Expand Down
Loading
Loading