Files
request-portal/src/webparts/requestPortal/shared/requestCode.ts
T
Тимур Городецкий 8578653c16 feat: changed get time logic to approvers
2026-08-13 10:01:08 +05:00

14 lines
770 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Уникальный код заявки: {prefix}-{YY}{MM}-{itemId}.
* prefix — по умолчанию числовой id типа заявки (approval-route API,
* GET /api/request-types), но может быть и строкой-меткой формы (напр. «1С»
* для заявок в отдел 1С). YY/MM — год и месяц подачи, itemId — Id элемента.
* Примеры: 1-2608-12, 1С-2608-12.
*/
export function buildRequestUniqueCode(prefix: number | string, itemId: number, submittedAt: Date): string {
const yy = String(submittedAt.getFullYear()).slice(-2);
const month = submittedAt.getMonth() + 1;
const mm = month < 10 ? `0${month}` : String(month);
return `${prefix}-${yy}${mm}-${itemId}`;
}