From 0c5f09946beec01a62c78b0cb90acf03d49dbb3e Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 8 Oct 2025 16:50:33 +0500 Subject: [PATCH] Process should respect property type Signed-off-by: Denis Bykhov --- .../process-resources/src/functions.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/server-plugins/process-resources/src/functions.ts b/server-plugins/process-resources/src/functions.ts index 32fb0da34d1..67b792b4eae 100644 --- a/server-plugins/process-resources/src/functions.ts +++ b/server-plugins/process-resources/src/functions.ts @@ -26,7 +26,9 @@ import core, { Relation, splitMixinUpdate, Tx, - TxProcessor + TxProcessor, + Type, + TypeNumber } from '@hcengineering/core' import process, { Execution, @@ -164,6 +166,24 @@ export async function AddRelation ( } } +function respectAttributeType (attrType: Type, value: any): any { + switch (attrType._class) { + case core.class.TypeNumber: { + const type = attrType as TypeNumber + const { min, max, digits } = type + let res = value + if (min !== undefined && res < min) res = min + if (max !== undefined && res > max) res = max + if (digits !== undefined) { + return Number(Number(res).toFixed(digits)) + } + return res + } + default: + return value + } +} + export async function UpdateCard ( params: MethodParams, execution: Execution, @@ -180,7 +200,12 @@ export async function UpdateCard ( for (const key in params) { const prevKey = checkMixinKey(key, _process.masterTag, hierarchy) prevValue[key] = getObjectValue(prevKey, target) - update[key] = (params as any)[key] + const attr = hierarchy.findAttribute(_process.masterTag, key) + if (attr === undefined) { + update[key] = (params as any)[key] + } else { + update[key] = respectAttributeType(attr.type, (params as any)[key]) + } } const res: Tx[] = []