aurora-1544 обновленна таблицы гудвил и вынесена в отдельный компонент фильтр единиц и знаков после запятой
This commit is contained in:
parent
70802d788c
commit
a1054f08c9
@ -1,14 +1,14 @@
|
|||||||
import { Select, Space } from 'antd';
|
import { Select, Space } from 'antd';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
|
|
||||||
interface ConsolidationChessFormatTableFilterI {
|
interface ConsolidationFormatTableFilterI {
|
||||||
decimals: number;
|
decimals: number;
|
||||||
onDecimalsChange: (val: number) => void;
|
onDecimalsChange: (val: number) => void;
|
||||||
units: string;
|
units: string;
|
||||||
onUnitsChange: (val: string) => void;
|
onUnitsChange: (val: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ConsolidationChessFormatTableFilter: React.FC<ConsolidationChessFormatTableFilterI> = ({
|
export const ConsolidationFormatTableFilter: React.FC<ConsolidationFormatTableFilterI> = ({
|
||||||
decimals,
|
decimals,
|
||||||
onDecimalsChange,
|
onDecimalsChange,
|
||||||
units,
|
units,
|
||||||
@ -32,7 +32,7 @@ function ReportContent() {
|
|||||||
osv: <OsvContent card={card} onSummaryChange={setOsvSummary} />,
|
osv: <OsvContent card={card} onSummaryChange={setOsvSummary} />,
|
||||||
|
|
||||||
chess: <ChessContent card={card} />,
|
chess: <ChessContent card={card} />,
|
||||||
goodwill: <GoodwillContent />,
|
goodwill: <GoodwillContent card={card} />,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ActiveTab = TAB_COMPONENTS[tab as string] ?? null;
|
const ActiveTab = TAB_COMPONENTS[tab as string] ?? null;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { GoodwillTableResponse, GoodwillRow, GoodwillRowPayload, GoodwillSettingsPayload } from '../types/goodwill/goodwill';
|
import type { GoodwillTableResponse, GoodwillRow, GoodwillRowPayload, GoodwillSettingsPayload } from '../../types/goodwill/goodwill';
|
||||||
import { api, apiFetchBlob } from '../api/client';
|
import { api, apiFetchBlob } from '../../api/client';
|
||||||
|
|
||||||
export function fetchGoodwillTable(versionId: string): Promise<GoodwillTableResponse> {
|
export function fetchGoodwillTable(versionId: string): Promise<GoodwillTableResponse> {
|
||||||
return api.get<GoodwillTableResponse>(`/consolidations/versions/${versionId}/goodwill`);
|
return api.get<GoodwillTableResponse>(`/consolidations/versions/${versionId}/goodwill`);
|
||||||
@ -34,10 +34,20 @@ export interface GoodwillTableResponse {
|
|||||||
totals: GoodwillTotals;
|
totals: GoodwillTotals;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Для дерева Ant Design (с добавлением группировки)
|
|
||||||
export type GoodwillTreeRow = GoodwillRow & {
|
export type GoodwillTreeRow = GoodwillRow & {
|
||||||
key: string;
|
key: string;
|
||||||
children?: GoodwillTreeRow[];
|
children?: GoodwillTreeRow[];
|
||||||
isGroup?: boolean;
|
isGroup?: boolean;
|
||||||
isTotal?: boolean;
|
isTotal?: boolean;
|
||||||
|
isGroupTotal?:boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface GoodwillRowPayload {
|
||||||
|
ownership_share: string;
|
||||||
|
include_in_kfo: boolean;
|
||||||
|
comment: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GoodwillSettingsPayload {
|
||||||
|
goodwill_enabled: boolean;
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@ import type { VersionCard } from '../../../types/consolidations/version_members'
|
|||||||
import { chessMatrixMode } from '../../../utils/chessMatrixMode';
|
import { chessMatrixMode } from '../../../utils/chessMatrixMode';
|
||||||
import { saveBlob, xlsxFilename } from '../../../utils/download';
|
import { saveBlob, xlsxFilename } from '../../../utils/download';
|
||||||
import { useNotificationApi } from '../../../utils/useNotification';
|
import { useNotificationApi } from '../../../utils/useNotification';
|
||||||
import { ConsolidationChessFormatTableFilter } from '../ConsolidationChessFormatTableFilter/ConsolidationChessFormatTableFilter';
|
import { ConsolidationFormatTableFilter } from '../../../components/ConsolidationFormatTableFilter/ConsolidationFormatTableFilter';
|
||||||
import { ConsolidationChessResTable } from '../ConsolidationChessResTable/ConsolidationChessResTable';
|
import { ConsolidationChessResTable } from '../ConsolidationChessResTable/ConsolidationChessResTable';
|
||||||
import { ConsolidationChessTable } from '../ConsolidationChessTable/ConsolidationChessTable';
|
import { ConsolidationChessTable } from '../ConsolidationChessTable/ConsolidationChessTable';
|
||||||
import { ConsolidationChessTableFilter } from '../ConsolidationChessTableFilter/ConsolidationChessTableFilter';
|
import { ConsolidationChessTableFilter } from '../ConsolidationChessTableFilter/ConsolidationChessTableFilter';
|
||||||
@ -245,7 +245,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
|||||||
backgroundColor: '#e5e7eb',
|
backgroundColor: '#e5e7eb',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ConsolidationChessFormatTableFilter
|
<ConsolidationFormatTableFilter
|
||||||
decimals={decimals}
|
decimals={decimals}
|
||||||
units={units}
|
units={units}
|
||||||
onDecimalsChange={setDecimals}
|
onDecimalsChange={setDecimals}
|
||||||
@ -294,7 +294,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
|||||||
gap: 16,
|
gap: 16,
|
||||||
}}>
|
}}>
|
||||||
<div style={{ display: 'flex', alignItems: 'flex-start', flexWrap: 'wrap', gap: 16, flex: '1 1 auto' }}>
|
<div style={{ display: 'flex', alignItems: 'flex-start', flexWrap: 'wrap', gap: 16, flex: '1 1 auto' }}>
|
||||||
<ConsolidationChessFormatTableFilter
|
<ConsolidationFormatTableFilter
|
||||||
decimals={chessResDecimals}
|
decimals={chessResDecimals}
|
||||||
units={chessResUnits}
|
units={chessResUnits}
|
||||||
onDecimalsChange={setChessResDecimals}
|
onDecimalsChange={setChessResDecimals}
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
import { EditOutlined, FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
|
import { DownloadOutlined, EditOutlined, FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
|
||||||
import { Alert, Button, ConfigProvider, Select, Space, Tooltip } from 'antd';
|
import { Alert, Button, ConfigProvider, Select, Space, Tooltip } from 'antd';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import type { GoodwillRow, GoodwillTableResponse } from '../../../types/goodwill/goodwill';
|
import type { GoodwillRow, GoodwillTableResponse, GoodwillTreeRow, GoodwillRowPayload } from '../../../types/goodwill/goodwill';
|
||||||
import { useNotificationApi } from '../../../utils/useNotification';
|
import { useNotificationApi } from '../../../utils/useNotification';
|
||||||
import { ConsolidationChessFormatTableFilter } from '../../ConsolidationChess/ConsolidationChessFormatTableFilter/ConsolidationChessFormatTableFilter';
|
import { ConsolidationFormatTableFilter } from '../../../components/ConsolidationFormatTableFilter/ConsolidationFormatTableFilter';
|
||||||
import { ConsolidationGoodwillTable } from '../ConsolidationGoodwillTable/ConsolidationGoodwillTable';
|
import { ConsolidationGoodwillTable } from '../ConsolidationGoodwillTable/ConsolidationGoodwillTable';
|
||||||
import { getGoodwillColumns } from '../ConsolidationGoodwillTable/config';
|
import { getGoodwillColumns } from '../ConsolidationGoodwillTable/config';
|
||||||
import { ColumnSettings, useVisibleColumns } from '../../../components/GenericTable';
|
import { ColumnDef, ColumnSettings, useVisibleColumns } from '../../../components/GenericTable';
|
||||||
import { ApiError } from '../../../api/client';
|
import { ApiError } from '../../../api/client';
|
||||||
|
import { saveBlob, xlsxFilename } from '../../../utils/download';
|
||||||
|
import { VersionCard } from '../../../types/consolidations/version_members';
|
||||||
|
import { exportGoodwillTable, fetchGoodwillTable, saveGoodwillRow } from '../../../services/api/goodwill';
|
||||||
|
|
||||||
// --- ТЕСТОВЫЕ ДАННЫЕ ---
|
// #TODO --- ТЕСТОВЫЕ ДАННЫЕ ---
|
||||||
const MOCK_DATA: GoodwillTableResponse = {
|
const MOCK_DATA: GoodwillTableResponse = {
|
||||||
version_id: '30d45049-4dd6-4479-9cf7-33f4e71301ef',
|
version_id: '30d45049-4dd6-4479-9cf7-33f4e71301ef',
|
||||||
goodwill_enabled: true,
|
goodwill_enabled: true,
|
||||||
@ -95,9 +98,8 @@ const MOCK_DATA: GoodwillTableResponse = {
|
|||||||
goodwill_in_kfo_amount: '11817.85',
|
goodwill_in_kfo_amount: '11817.85',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// ------------------------
|
|
||||||
|
|
||||||
export const GoodwillContent = () => {
|
export const GoodwillContent = ({ card }: { card: VersionCard | null }) => {
|
||||||
const { version_id } = useParams<{ version_id: string }>();
|
const { version_id } = useParams<{ version_id: string }>();
|
||||||
const notification = useNotificationApi();
|
const notification = useNotificationApi();
|
||||||
|
|
||||||
@ -113,9 +115,11 @@ export const GoodwillContent = () => {
|
|||||||
const goodwillTableRef = useRef<HTMLDivElement>(null);
|
const goodwillTableRef = useRef<HTMLDivElement>(null);
|
||||||
const [isGoodwillFullscreen, setIsGoodwillFullscreen] = useState(false);
|
const [isGoodwillFullscreen, setIsGoodwillFullscreen] = useState(false);
|
||||||
const [goodwillFilter, setGoodwillFilter] = useState('allValue');
|
const [goodwillFilter, setGoodwillFilter] = useState('allValue');
|
||||||
|
const [exportLoading, setExportLoading] = useState(false);
|
||||||
|
const versionInfo = card ? { groupName: card.company_group.name, year: card.year, quarter: card.quarter } : null;
|
||||||
|
|
||||||
const handleRowEdit = useCallback(
|
const handleRowEdit = useCallback(
|
||||||
(rowKey: string, field: keyof GoodwillRow, value: any) => {
|
(rowKey: string, field: keyof GoodwillRow, value: boolean | string) => {
|
||||||
const isParent = rowKey.startsWith('head-') && !rowKey.includes('-sub-');
|
const isParent = rowKey.startsWith('head-') && !rowKey.includes('-sub-');
|
||||||
|
|
||||||
if (isParent && field === 'include_in_kfo') {
|
if (isParent && field === 'include_in_kfo') {
|
||||||
@ -126,7 +130,7 @@ export const GoodwillContent = () => {
|
|||||||
const next = { ...prev };
|
const next = { ...prev };
|
||||||
children.forEach((child) => {
|
children.forEach((child) => {
|
||||||
const childKey = `${headId}-${child.subsidiary_legal_entity.id}`;
|
const childKey = `${headId}-${child.subsidiary_legal_entity.id}`;
|
||||||
next[childKey] = { ...next[childKey], include_in_kfo: value };
|
next[childKey] = { ...next[childKey], include_in_kfo: value as boolean };
|
||||||
});
|
});
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
@ -140,12 +144,13 @@ export const GoodwillContent = () => {
|
|||||||
},
|
},
|
||||||
[data?.rows],
|
[data?.rows],
|
||||||
);
|
);
|
||||||
|
|
||||||
const columns = useMemo(() => {
|
const columns = useMemo(() => {
|
||||||
return getGoodwillColumns({ units, decimals, isEditMode, editedRows, onRowEdit: handleRowEdit });
|
return getGoodwillColumns({ units, decimals, isEditMode, editedRows, onRowEdit: handleRowEdit });
|
||||||
}, [units, decimals, isEditMode, editedRows, handleRowEdit]);
|
}, [units, decimals, isEditMode, editedRows, handleRowEdit]);
|
||||||
|
|
||||||
const groupsConfig = useMemo(() => {
|
const groupsConfig = useMemo(() => {
|
||||||
return { rowKey: 'key' as any, columns: columns as any };
|
return { rowKey: 'key' as const, columns: columns as ColumnDef<GoodwillTreeRow>[] };
|
||||||
}, [columns]);
|
}, [columns]);
|
||||||
|
|
||||||
const { visibleKeys, setVisibleKeys } = useVisibleColumns(groupsConfig);
|
const { visibleKeys, setVisibleKeys } = useVisibleColumns(groupsConfig);
|
||||||
@ -164,18 +169,19 @@ export const GoodwillContent = () => {
|
|||||||
notification.error({ description: e instanceof Error ? e.message : 'Ошибка' });
|
notification.error({ description: e instanceof Error ? e.message : 'Ошибка' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dropFiltersHandler = () => {
|
const dropFiltersHandler = () => {
|
||||||
setGoodwillFilter('allValue');
|
setGoodwillFilter('allValue');
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async (vId: string) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
const res = await fetchGoodwillTable(vId);
|
||||||
setData(MOCK_DATA);
|
setData(res);
|
||||||
|
|
||||||
const initialEdited: Record<string, Partial<GoodwillRow>> = {};
|
const initialEdited: Record<string, Partial<GoodwillRow>> = {};
|
||||||
MOCK_DATA.rows.forEach((row) => {
|
res.rows.forEach((row) => {
|
||||||
if (row.include_in_kfo) {
|
if (row.include_in_kfo) {
|
||||||
const key = `${row.head_legal_entity.id}-${row.subsidiary_legal_entity.id}`;
|
const key = `${row.head_legal_entity.id}-${row.subsidiary_legal_entity.id}`;
|
||||||
initialEdited[key] = {
|
initialEdited[key] = {
|
||||||
@ -196,13 +202,35 @@ export const GoodwillContent = () => {
|
|||||||
}, [notification]);
|
}, [notification]);
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
|
if (!version_id || !data) return;
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 800));
|
const promises = Object.keys(editedRows).map((rowKey) => {
|
||||||
notification.success({ description: 'Изменения сохранены (тестовый режим)' });
|
const changes = editedRows[rowKey];
|
||||||
|
const originalRow = data.rows.find(
|
||||||
|
(r) => `${r.head_legal_entity.id}-${r.subsidiary_legal_entity.id}` === rowKey
|
||||||
|
);
|
||||||
|
if (!originalRow) return;
|
||||||
|
|
||||||
|
const payload: GoodwillRowPayload = {
|
||||||
|
ownership_share: String(changes.ownership_share ?? originalRow.ownership_share ?? ''),
|
||||||
|
include_in_kfo: changes.include_in_kfo ?? originalRow.include_in_kfo,
|
||||||
|
comment: changes.comment !== undefined ? changes.comment : (originalRow.comment ?? null),
|
||||||
|
};
|
||||||
|
|
||||||
|
return saveGoodwillRow(
|
||||||
|
version_id,
|
||||||
|
originalRow.head_legal_entity.id,
|
||||||
|
originalRow.subsidiary_legal_entity.id,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all(promises);
|
||||||
|
notification.success({ description: 'Изменения сохранены' });
|
||||||
setEditedRows({});
|
setEditedRows({});
|
||||||
setIsEditMode(false);
|
setIsEditMode(false);
|
||||||
loadData();
|
loadData(version_id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ApiError) {
|
if (e instanceof ApiError) {
|
||||||
notification.error({ description: e.message });
|
notification.error({ description: e.message });
|
||||||
@ -211,6 +239,24 @@ export const GoodwillContent = () => {
|
|||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const download = async () => {
|
||||||
|
if (!version_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setExportLoading(true);
|
||||||
|
try {
|
||||||
|
const { blob, filename } = await exportGoodwillTable(version_id);
|
||||||
|
saveBlob(blob, filename ?? xlsxFilename('Гудвил', versionInfo));
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ApiError) {
|
||||||
|
notification.error({ description: e.message });
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setExportLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const filteredData = useMemo(() => {
|
const filteredData = useMemo(() => {
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
if (goodwillFilter === 'allValue') return data;
|
if (goodwillFilter === 'allValue') return data;
|
||||||
@ -245,8 +291,10 @@ export const GoodwillContent = () => {
|
|||||||
}, [editedRows, isEditMode]);
|
}, [editedRows, isEditMode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadData();
|
if (version_id) {
|
||||||
}, [loadData]);
|
loadData(version_id);
|
||||||
|
}
|
||||||
|
}, [version_id, loadData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigProvider getPopupContainer={() => (document.fullscreenElement as HTMLElement) || document.body}>
|
<ConfigProvider getPopupContainer={() => (document.fullscreenElement as HTMLElement) || document.body}>
|
||||||
@ -330,7 +378,7 @@ export const GoodwillContent = () => {
|
|||||||
backgroundColor: '#e5e7eb',
|
backgroundColor: '#e5e7eb',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ConsolidationChessFormatTableFilter
|
<ConsolidationFormatTableFilter
|
||||||
decimals={decimals}
|
decimals={decimals}
|
||||||
units={units}
|
units={units}
|
||||||
onDecimalsChange={setDecimals}
|
onDecimalsChange={setDecimals}
|
||||||
@ -346,6 +394,9 @@ export const GoodwillContent = () => {
|
|||||||
disabled={isEditMode || !data?.editable}>
|
disabled={isEditMode || !data?.editable}>
|
||||||
Редактировать
|
Редактировать
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button loading={exportLoading} onClick={() => download()} icon={<DownloadOutlined />}>
|
||||||
|
Экспорт
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => toggleFullscreen(goodwillTableRef, setIsGoodwillFullscreen)}
|
onClick={() => toggleFullscreen(goodwillTableRef, setIsGoodwillFullscreen)}
|
||||||
icon={isGoodwillFullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />}>
|
icon={isGoodwillFullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />}>
|
||||||
|
|||||||
@ -16,3 +16,8 @@
|
|||||||
.goodwillTable .resRow {
|
.goodwillTable .resRow {
|
||||||
background-color: #e6f4ea !important ;
|
background-color: #e6f4ea !important ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.goodwillTable .group-total-row td {
|
||||||
|
background-color: #ecfdf3 !important;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ interface ConsolidationGoodwillTableI {
|
|||||||
isFullscreen?: boolean;
|
isFullscreen?: boolean;
|
||||||
isEditMode: boolean;
|
isEditMode: boolean;
|
||||||
editedRows: Record<string, Partial<GoodwillRow>>;
|
editedRows: Record<string, Partial<GoodwillRow>>;
|
||||||
onRowEdit: (rowId: string, field: keyof GoodwillRow, value: any) => void;
|
onRowEdit: (rowId: string, field: keyof GoodwillRow, value: boolean | string) => void;
|
||||||
visibleKeys: string[];
|
visibleKeys: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,12 +73,44 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
tree.forEach(parent => {
|
tree.forEach((parent) => {
|
||||||
if (parent.children && parent.children.length > 0) {
|
if (parent.children && parent.children.length > 0) {
|
||||||
const allChecked = parent.children.every(child =>
|
const allChecked = parent.children.every((child) => editedRows[child.key]?.include_in_kfo ?? child.include_in_kfo);
|
||||||
editedRows[child.key]?.include_in_kfo ?? child.include_in_kfo
|
|
||||||
);
|
|
||||||
parent.include_in_kfo = allChecked;
|
parent.include_in_kfo = allChecked;
|
||||||
|
|
||||||
|
let totalFinInv = 0;
|
||||||
|
let totalParticipation = 0;
|
||||||
|
let totalCharter = 0;
|
||||||
|
let totalGoodwill = 0;
|
||||||
|
|
||||||
|
parent.children.forEach((child) => {
|
||||||
|
totalFinInv += Number(child.financial_investment_amount || 0);
|
||||||
|
totalParticipation += Number(child.participation_amount || 0);
|
||||||
|
totalCharter += Number(child.charter_capital_amount || 0);
|
||||||
|
totalGoodwill += Number(child.goodwill_amount || 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
const groupTotalRow: GoodwillTreeRow = {
|
||||||
|
key: `total-${parent.key}`,
|
||||||
|
head_legal_entity: parent.head_legal_entity,
|
||||||
|
subsidiary_legal_entity: { id: '', name: 'Всего' },
|
||||||
|
isGroupTotal: true,
|
||||||
|
isGroup: false,
|
||||||
|
|
||||||
|
financial_investment_amount: String(totalFinInv),
|
||||||
|
participation_amount: String(totalParticipation),
|
||||||
|
charter_capital_amount: String(totalCharter),
|
||||||
|
goodwill_amount: String(totalGoodwill),
|
||||||
|
|
||||||
|
ownership_share: null,
|
||||||
|
additional_capital_amount: '0',
|
||||||
|
include_in_kfo: false,
|
||||||
|
comment: null,
|
||||||
|
updated_at: null,
|
||||||
|
updated_by: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
parent.children.push(groupTotalRow);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,7 +122,7 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
}, [units, decimals, isEditMode, editedRows, onRowEdit]);
|
}, [units, decimals, isEditMode, editedRows, onRowEdit]);
|
||||||
|
|
||||||
const visibleColumns = useMemo(() => {
|
const visibleColumns = useMemo(() => {
|
||||||
return columns.filter(col => visibleKeys.includes(col.key as string));
|
return columns.filter((col) => visibleKeys.includes(col.key as string));
|
||||||
}, [columns, visibleKeys]);
|
}, [columns, visibleKeys]);
|
||||||
|
|
||||||
const scrollY = isFullscreen ? 'calc(100vh - 200px)' : 'auto';
|
const scrollY = isFullscreen ? 'calc(100vh - 200px)' : 'auto';
|
||||||
@ -98,7 +130,7 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
const renderSummary = () => {
|
const renderSummary = () => {
|
||||||
if (!data?.totals) return null;
|
if (!data?.totals) return null;
|
||||||
|
|
||||||
const ownershipIndex = visibleColumns.findIndex(c => c.key === 'ownership_share');
|
const ownershipIndex = visibleColumns.findIndex((c) => c.key === 'ownership_share');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table.Summary fixed>
|
<Table.Summary fixed>
|
||||||
@ -106,7 +138,7 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
{visibleColumns.map((col, index) => {
|
{visibleColumns.map((col, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return (
|
return (
|
||||||
<Table.Summary.Cell key="total-label" index={0} colSpan={ownershipIndex > 0 ? ownershipIndex : 1} align='left'>
|
<Table.Summary.Cell key='total-label' index={0} colSpan={ownershipIndex > 0 ? ownershipIndex : 1} align='left'>
|
||||||
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
||||||
<Text strong>Итого по листу</Text>
|
<Text strong>Итого по листу</Text>
|
||||||
</div>
|
</div>
|
||||||
@ -117,7 +149,11 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
if (index < ownershipIndex) return null;
|
if (index < ownershipIndex) return null;
|
||||||
|
|
||||||
if (col.key === 'ownership_share') {
|
if (col.key === 'ownership_share') {
|
||||||
return <Table.Summary.Cell key={col.key} index={index} align='right'><Text strong>—</Text></Table.Summary.Cell>;
|
return (
|
||||||
|
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||||
|
<Text strong>—</Text>
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'financial_investment_amount') {
|
if (col.key === 'financial_investment_amount') {
|
||||||
@ -141,7 +177,11 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'charter_capital_amount') {
|
if (col.key === 'charter_capital_amount') {
|
||||||
return <Table.Summary.Cell key={col.key} index={index} align='right'><Text strong>—</Text></Table.Summary.Cell>;
|
return (
|
||||||
|
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||||
|
<Text strong>—</Text>
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'goodwill_amount') {
|
if (col.key === 'goodwill_amount') {
|
||||||
@ -155,7 +195,11 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (col.key === 'comment') {
|
if (col.key === 'comment') {
|
||||||
return <Table.Summary.Cell key={col.key} index={index} align='right'><Text strong>—</Text></Table.Summary.Cell>;
|
return (
|
||||||
|
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||||
|
<Text strong>—</Text>
|
||||||
|
</Table.Summary.Cell>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -179,6 +223,7 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
|||||||
title={() => toolbar}
|
title={() => toolbar}
|
||||||
expandable={{ defaultExpandAllRows: true }}
|
expandable={{ defaultExpandAllRows: true }}
|
||||||
summary={renderSummary}
|
summary={renderSummary}
|
||||||
|
rowClassName={(record) => (record.isGroupTotal ? 'group-total-row' : '')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -10,7 +10,7 @@ interface GetColumnsParams {
|
|||||||
decimals: number;
|
decimals: number;
|
||||||
isEditMode: boolean;
|
isEditMode: boolean;
|
||||||
editedRows: Record<string, Partial<GoodwillRow>>;
|
editedRows: Record<string, Partial<GoodwillRow>>;
|
||||||
onRowEdit: (rowId: string, field: keyof GoodwillRow, value: any) => void;
|
onRowEdit: (rowId: string, field: keyof GoodwillRow, value: boolean | string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGoodwillColumns = ({
|
export const getGoodwillColumns = ({
|
||||||
@ -32,6 +32,8 @@ export const getGoodwillColumns = ({
|
|||||||
width: 120,
|
width: 120,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: (_, row) => {
|
render: (_, row) => {
|
||||||
|
if (row.isGroupTotal) return null;
|
||||||
|
|
||||||
const isChecked = row.isGroup ? row.include_in_kfo : (editedRows[row.key]?.include_in_kfo ?? row.include_in_kfo);
|
const isChecked = row.isGroup ? row.include_in_kfo : (editedRows[row.key]?.include_in_kfo ?? row.include_in_kfo);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -131,7 +133,6 @@ export const getGoodwillColumns = ({
|
|||||||
const formatted = formatMoney(val);
|
const formatted = formatMoney(val);
|
||||||
if (formatted === '—') return <Text type='secondary'>—</Text>;
|
if (formatted === '—') return <Text type='secondary'>—</Text>;
|
||||||
|
|
||||||
|
|
||||||
const isNegative = String(val).trim().startsWith('-');
|
const isNegative = String(val).trim().startsWith('-');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user