arm-web/src/widgets/FilesDrawer/consolidationLabel.ts
Andrey Epifancev 5b7b02a3f2 store: консолидация открытой версии и подпись консолидации у файла (#26)
Чистые функции findCurrentConsolidation, isInWork, consolidationLabel и хук
useCurrentConsolidation; FileOut.consolidation_id; тесты vitest.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-10 00:52:33 +04:00

15 lines
841 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.

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)}` : 'другая консолидация';
}