Чистые функции findCurrentConsolidation, isInWork, consolidationLabel и хук useCurrentConsolidation; FileOut.consolidation_id; тесты vitest. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
15 lines
841 B
TypeScript
15 lines
841 B
TypeScript
import type { IConsolidation } from '../../types/consolidations/consolidations';
|
||
import { quarterShortLabel } from '../../utils/labels';
|
||
|
||
/** Подпись консолидации у файла в режиме «Все документы организации» (design D-4): null — файл текущей консоли. */
|
||
export function consolidationLabel(
|
||
fileConsolidationId: string | null,
|
||
consolidations: IConsolidation[],
|
||
currentConsolidationId: string | null,
|
||
): string | null {
|
||
if (fileConsolidationId === null) return 'вне консолидации';
|
||
if (fileConsolidationId === currentConsolidationId) return null;
|
||
const found = consolidations.find((c) => c.consolidation_id === fileConsolidationId);
|
||
return found ? `${found.year} ${quarterShortLabel(found.quarter)}` : 'другая консолидация';
|
||
}
|