Merge pull request 'aurora-1799 отображение ошибки в случае выбора только дт или кт в таблице' (#207) from fix/chessTable into main
This commit is contained in:
commit
da5cb9c222
@ -22,16 +22,19 @@ import type { CatalogueJurFormProps } from '../types/catalogueJur/catalogueJur';
|
||||
import type { CompanyGroupFormProps } from '../types/companyGroups/companyGroups';
|
||||
import type { CreateEntityKind, RelatedGroupFormType } from '../types/relatedGroup/relatedGroup';
|
||||
import { useNotificationApi } from '../utils/useNotification';
|
||||
import { ArchiveCompanyGroupModal } from '../widgets/ArchiveCompanyGroupModal/ArchiveCompanyGroupModal';
|
||||
import { CataloguGroupTabs, type CatalogueGroupTabKey } from '../widgets/CataloguGroupTabs/CataloguGroupTabs';
|
||||
import { CompanyGroupHeader } from '../widgets/CatalogueGroupHeader/CatalogueGroupHeader';
|
||||
import { CatalogueJurForm } from '../widgets/CatalogueJurForm/CatalogueJurForm';
|
||||
import { CatalogueJurTable } from '../widgets/CatalogueJurTable/CatalogueJurTable';
|
||||
import { CompanyGroupForm } from '../widgets/CompanyGroupForm/CompanyGroupForm';
|
||||
import { CompanyGroupsList } from '../widgets/CompanyGroupsList/CompanyGroupsList';
|
||||
import { ArchiveCompanyGroupModal } from '../widgets/CatalogueCompanyGroup/ArchiveCompanyGroupModal/ArchiveCompanyGroupModal';
|
||||
import { CompanyGroupHeader } from '../widgets/CatalogueCompanyGroup/CatalogueCompanyGroupHeader/CatalogueCompanyGroupHeader';
|
||||
import {
|
||||
type CatalogueCompanyGroupTabKey,
|
||||
CatalogueCompanyGroupTabs,
|
||||
} from '../widgets/CatalogueCompanyGroup/CatalogueCompanyGroupTabs/CatalogueCompanyGroupTabs';
|
||||
import { CompanyGroupForm } from '../widgets/CatalogueCompanyGroup/CompanyGroupForm/CompanyGroupForm';
|
||||
import { CompanyGroupsList } from '../widgets/CatalogueCompanyGroup/CompanyGroupsList/CompanyGroupsList';
|
||||
import { CatalogueJurForm } from '../widgets/CatalogueJur/CatalogueJurForm/CatalogueJurForm';
|
||||
import { CatalogueJurTable } from '../widgets/CatalogueJur/CatalogueJurTable/CatalogueJurTable';
|
||||
import { CreateEntityPickerModal } from '../widgets/CreateEntityPickerModal/CreateEntityPickerModal';
|
||||
import { RelatedGroupForm } from '../widgets/RelatedGroupForm/RelatedGroupForm';
|
||||
import { RelatedGroupTable } from '../widgets/RelatedGroupTable/RelatedGroupTable';
|
||||
import { RelatedGroupForm } from '../widgets/RelatedGroup/RelatedGroupForm/RelatedGroupForm';
|
||||
import { RelatedGroupTable } from '../widgets/RelatedGroup/RelatedGroupTable/RelatedGroupTable';
|
||||
|
||||
export function CatalogueGroup() {
|
||||
const dispatch = useAppDispatch();
|
||||
@ -45,7 +48,7 @@ export function CatalogueGroup() {
|
||||
const [companyGroupEditFormOpen, setCompanyGroupEditFormOpen] = useState(false);
|
||||
const [companyGroupDeleteOpen, setCompanyGroupDeleteOpen] = useState(false);
|
||||
const [companyGroupDeleteLoading, setCompanyGroupDeleteLoading] = useState(false);
|
||||
const [activeTab, setActiveTab] = useState<CatalogueGroupTabKey>('legal_entities');
|
||||
const [activeTab, setActiveTab] = useState<CatalogueCompanyGroupTabKey>('legal_entities');
|
||||
const [gskData, setGskData] = useState<RelatedGroupOut[]>([]);
|
||||
const [gszData, setGszData] = useState<RelatedGroupOut[]>([]);
|
||||
const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
|
||||
@ -201,7 +204,12 @@ export function CatalogueGroup() {
|
||||
<CatalogueJurTable
|
||||
outside_group={false}
|
||||
tabsComponent={
|
||||
<CataloguGroupTabs activeTab={activeTab} setActiveTab={(val) => setActiveTab(val)} gskData={gskData} gszData={gszData} />
|
||||
<CatalogueCompanyGroupTabs
|
||||
activeTab={activeTab}
|
||||
setActiveTab={(val) => setActiveTab(val)}
|
||||
gskData={gskData}
|
||||
gszData={gszData}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
@ -211,7 +219,12 @@ export function CatalogueGroup() {
|
||||
data={activeTab === 'gsz' ? gszData : gskData}
|
||||
getData={() => getRelatedGroupsHandler()}
|
||||
tabsComponent={
|
||||
<CataloguGroupTabs activeTab={activeTab} setActiveTab={(val) => setActiveTab(val)} gskData={gskData} gszData={gszData} />
|
||||
<CatalogueCompanyGroupTabs
|
||||
activeTab={activeTab}
|
||||
setActiveTab={(val) => setActiveTab(val)}
|
||||
gskData={gskData}
|
||||
gszData={gszData}
|
||||
/>
|
||||
}
|
||||
loading={relatedGroupLoading}
|
||||
/>
|
||||
|
||||
@ -6,8 +6,8 @@ import { createCatalogueJur } from '../services/api/directories/catalogue_jur';
|
||||
import { getCatalogueJurThunk } from '../store/slices/catalogueJurSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../store/store';
|
||||
import type { CatalogueJurFormProps } from '../types/catalogueJur/catalogueJur';
|
||||
import { CatalogueJurForm } from '../widgets/CatalogueJurForm/CatalogueJurForm';
|
||||
import { CatalogueJurTable } from '../widgets/CatalogueJurTable/CatalogueJurTable';
|
||||
import { CatalogueJurForm } from '../widgets/CatalogueJur/CatalogueJurForm/CatalogueJurForm';
|
||||
import { CatalogueJurTable } from '../widgets/CatalogueJur/CatalogueJurTable/CatalogueJurTable';
|
||||
|
||||
export function CatalogueJur() {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
@ -13,9 +13,9 @@ import type { VersionCard } from '../types/consolidations/version_members';
|
||||
import { CONS_STATUS_LABEL, canChangeStatus, consStatusDescription, isLockedBy } from '../utils/consolidations';
|
||||
import { quarterShortLabel } from '../utils/labels';
|
||||
import { statusColorMapping } from '../widgets/ConsoleTable/consts';
|
||||
import { ChessContent } from '../widgets/ConsolidatedChessContent/ConsolidatedChessContent';
|
||||
import { OsvTabs } from '../widgets/ConsolidatedOsv/OsvTabs';
|
||||
import { OsvContent } from '../widgets/ConsolidatedOsvContent/ConsolidatedOsvContent';
|
||||
import { ChessContent } from '../widgets/ConsolidationChess/ConsolidationChessContent/ConsolidatedChessContent';
|
||||
import ChangeStatusModal from '../widgets/StatusChangeModal/ChangeStatusModal';
|
||||
|
||||
function ReportContent() {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useMemo } from 'react';
|
||||
import PageTitle from '../components/PageTitle';
|
||||
import { useAppSelector } from '../store/store';
|
||||
import { CompanyGroupsTable } from '../widgets/CompanyGroupsTable/CompanyGroupsTable';
|
||||
import { CompanyGroupsTable } from '../widgets/CatalogueCompanyGroup/CompanyGroupsTable/CompanyGroupsTable';
|
||||
|
||||
export function GroupsLayout() {
|
||||
const totalGroupsNum = useAppSelector((state) => state.company_groups.total_groups);
|
||||
|
||||
17
web/src/utils/chessMatrixMode.test.ts
Normal file
17
web/src/utils/chessMatrixMode.test.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { chessMatrixMode } from './chessMatrixMode';
|
||||
|
||||
describe('chessMatrixMode', () => {
|
||||
it('фильтры пусты — полная матрица', () => {
|
||||
expect(chessMatrixMode([], [])).toBe('all');
|
||||
});
|
||||
it('выбраны Дт и Кт — ручной расчёт', () => {
|
||||
expect(chessMatrixMode(['62'], ['60'])).toBe('manual');
|
||||
});
|
||||
it('только Дт — одна сторона', () => {
|
||||
expect(chessMatrixMode(['62'], [])).toBe('half');
|
||||
});
|
||||
it('только Кт — одна сторона', () => {
|
||||
expect(chessMatrixMode([], ['60'])).toBe('half');
|
||||
});
|
||||
});
|
||||
16
web/src/utils/chessMatrixMode.ts
Normal file
16
web/src/utils/chessMatrixMode.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Режим запроса шахматки по фильтрам счетов:
|
||||
* - `all` — фильтры пусты, берём полную матрицу;
|
||||
* - `manual` — выбраны и Дт, и Кт, считаем по выбранным счетам;
|
||||
* - `half` — выбрана только одна сторона: запрос не шлём, показываем подсказку.
|
||||
*/
|
||||
export type ChessMatrixMode = 'all' | 'manual' | 'half';
|
||||
|
||||
/** Текст для состояния «выбрана одна сторона» — в таблице и у фильтров один и тот же (openspec intercompany-matrix-ui). */
|
||||
export const CHESS_HALF_FILTER_HINT = 'Для расчёта по счетам выберите счета и в Дт, и в Кт';
|
||||
|
||||
export const chessMatrixMode = (debit: readonly string[], credit: readonly string[]): ChessMatrixMode => {
|
||||
if (debit.length > 0 && credit.length > 0) return 'manual';
|
||||
if (debit.length === 0 && credit.length === 0) return 'all';
|
||||
return 'half';
|
||||
};
|
||||
@ -3,8 +3,8 @@ import { Button, Dropdown, Space } from 'antd';
|
||||
import Text from 'antd/es/typography/Text';
|
||||
import Title from 'antd/es/typography/Title';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAppSelector } from '../../store/store';
|
||||
import { pluralRu } from '../../utils/labels';
|
||||
import { useAppSelector } from '../../../store/store';
|
||||
import { pluralRu } from '../../../utils/labels';
|
||||
|
||||
interface CompanyGroupHeaderI {
|
||||
setDeleteConfirmOpen: (el: boolean) => void;
|
||||
@ -1,23 +1,23 @@
|
||||
import { Tabs } from 'antd';
|
||||
import { useAppSelector } from '../../store/store';
|
||||
import type { RelatedGroupOut } from '../../types/api';
|
||||
import './CataloguGroupTabs.css';
|
||||
interface CataloguGroupTabsI {
|
||||
activeTab: CatalogueGroupTabKey;
|
||||
setActiveTab: (val: CatalogueGroupTabKey) => void;
|
||||
import { useAppSelector } from '../../../store/store';
|
||||
import type { RelatedGroupOut } from '../../../types/api';
|
||||
import './CatalogueCompanyGroupTabs.css';
|
||||
interface CatalogueCompanyGroupTabsI {
|
||||
activeTab: CatalogueCompanyGroupTabKey;
|
||||
setActiveTab: (val: CatalogueCompanyGroupTabKey) => void;
|
||||
gskData: RelatedGroupOut[];
|
||||
gszData: RelatedGroupOut[];
|
||||
}
|
||||
|
||||
export type CatalogueGroupTabKey = 'legal_entities' | 'gsk' | 'gsz';
|
||||
export type CatalogueCompanyGroupTabKey = 'legal_entities' | 'gsk' | 'gsz';
|
||||
|
||||
export const CataloguGroupTabs = ({ activeTab, setActiveTab, gskData, gszData }: CataloguGroupTabsI) => {
|
||||
export const CatalogueCompanyGroupTabs = ({ activeTab, setActiveTab, gskData, gszData }: CatalogueCompanyGroupTabsI) => {
|
||||
const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={(key) => setActiveTab(key as CatalogueGroupTabKey)}
|
||||
onChange={(key) => setActiveTab(key as CatalogueCompanyGroupTabKey)}
|
||||
tabBarStyle={{ margin: 0, marginBottom: 0 }}
|
||||
style={{ marginBottom: 0 }}
|
||||
items={[
|
||||
@ -1,12 +1,12 @@
|
||||
import { Col, Form, Input, Modal, Row, Select } from 'antd';
|
||||
import type React from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { useMe } from '../../auth/useMe';
|
||||
import { fetchOneCompanyGroup } from '../../services/api/directories/company_groups';
|
||||
import type { CompanyGroupFormProps } from '../../types/companyGroups/companyGroups';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { loadOffices } from '../Admin/UsersTable';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { useMe } from '../../../auth/useMe';
|
||||
import { fetchOneCompanyGroup } from '../../../services/api/directories/company_groups';
|
||||
import type { CompanyGroupFormProps } from '../../../types/companyGroups/companyGroups';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
import { loadOffices } from '../../Admin/UsersTable';
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
@ -1,12 +1,12 @@
|
||||
import { FolderOpenOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { Checkbox, Empty, Input, List, Spin, Tag, Typography } from 'antd';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useVirtualList } from '../../hooks/useVirtualList';
|
||||
import { setActiveCompanyGroup } from '../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { setIsGettingArchive } from '../../store/slices/companyGroupsSlice/companyGroupsSlice';
|
||||
import { visibleCompanyGroups } from '../../store/slices/companyGroupsSlice/selectors';
|
||||
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/store';
|
||||
import { useVirtualList } from '../../../hooks/useVirtualList';
|
||||
import { setActiveCompanyGroup } from '../../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { setIsGettingArchive } from '../../../store/slices/companyGroupsSlice/companyGroupsSlice';
|
||||
import { visibleCompanyGroups } from '../../../store/slices/companyGroupsSlice/selectors';
|
||||
import { getCompanyGroupsThunk } from '../../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/store';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@ -3,11 +3,11 @@ import { Button, Input, Space, Tooltip } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useVisibleColumns } from '../../components/GenericTable';
|
||||
import { useTableFilters } from '../../components/GenericTable/useTableFilters';
|
||||
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/store';
|
||||
import type { ICompanyGroup } from '../../types/companyGroups/companyGroups';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useVisibleColumns } from '../../../components/GenericTable';
|
||||
import { useTableFilters } from '../../../components/GenericTable/useTableFilters';
|
||||
import { getCompanyGroupsThunk } from '../../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/store';
|
||||
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
|
||||
import { groupsConfig } from './config';
|
||||
|
||||
export function CompanyGroupsTable() {
|
||||
@ -1,5 +1,5 @@
|
||||
import type { TableConfig } from '../../components/GenericTable';
|
||||
import type { ICompanyGroup } from '../../types/companyGroups/companyGroups';
|
||||
import type { TableConfig } from '../../../components/GenericTable';
|
||||
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
|
||||
|
||||
export const groupsConfig: TableConfig<ICompanyGroup> = {
|
||||
rowKey: 'id',
|
||||
@ -1,14 +1,14 @@
|
||||
import { Col, Form, Input, Modal, Row, Select } from 'antd';
|
||||
import type React from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../services/api/directories/catalogue_jur';
|
||||
import { fetchRelatedGroups } from '../../services/api/directories/company_groups';
|
||||
import { useAppSelector } from '../../store/store';
|
||||
import type { RelatedGroupOut } from '../../types/api';
|
||||
import type { CatalogueJurFormProps } from '../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { loadOffices } from '../Admin/UsersTable';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../../services/api/directories/catalogue_jur';
|
||||
import { fetchRelatedGroups } from '../../../services/api/directories/company_groups';
|
||||
import { useAppSelector } from '../../../store/store';
|
||||
import type { RelatedGroupOut } from '../../../types/api';
|
||||
import type { CatalogueJurFormProps } from '../../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
import { loadOffices } from '../../Admin/UsersTable';
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
@ -3,12 +3,12 @@ import FormItem from 'antd/es/form/FormItem';
|
||||
import dayjs from 'dayjs';
|
||||
import type React from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../services/api/directories/catalogue_jur';
|
||||
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/store';
|
||||
import type { MoveCatalogueJurProps } from '../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../../services/api/directories/catalogue_jur';
|
||||
import { getCompanyGroupsThunk } from '../../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/store';
|
||||
import type { MoveCatalogueJurProps } from '../../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
|
||||
type FormValues = {
|
||||
name: string;
|
||||
@ -11,26 +11,25 @@ import { Button, Checkbox, Dropdown, Input, Space } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { type ReactNode, useEffect, useMemo, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useVisibleColumns } from '../../components/GenericTable';
|
||||
import { useTableFilters } from '../../components/GenericTable/useTableFilters';
|
||||
import { editCatalogueJur, moveCatalogueJur, withdrawCatalogueJur } from '../../services/api/directories/catalogue_jur';
|
||||
import { setIsGettingArchive, setRelatedGroupFilter } from '../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { getCatalogueJurThunk } from '../../store/slices/catalogueJurSlice/thunks';
|
||||
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/store';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useTableFilters, useVisibleColumns } from '../../../components/GenericTable';
|
||||
import { editCatalogueJur, moveCatalogueJur, withdrawCatalogueJur } from '../../../services/api/directories/catalogue_jur';
|
||||
import { setIsGettingArchive, setRelatedGroupFilter } from '../../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { getCatalogueJurThunk } from '../../../store/slices/catalogueJurSlice/thunks';
|
||||
import { getCompanyGroupsThunk } from '../../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/store';
|
||||
import {
|
||||
type CatalogueJurFormProps,
|
||||
type ICatalogueJur,
|
||||
type MoveCatalogueJurProps,
|
||||
type WithdrawCatalogueJurProps,
|
||||
toCatalogueJurRow,
|
||||
} from '../../types/catalogueJur/catalogueJur';
|
||||
import { pluralRu } from '../../utils/labels';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
} from '../../../types/catalogueJur/catalogueJur';
|
||||
import { pluralRu } from '../../../utils/labels';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
import { CatalogueJurForm } from '../CatalogueJurForm/CatalogueJurForm';
|
||||
import { MoveCatalogueJurForm } from '../MoveCatalogueJurForm/MoveCatalogueJurForm';
|
||||
import { WithdrawCatalogueJurForm } from '../WithdrawCatalogueJurForm/WithdrawCatalogueJurForm';
|
||||
import { MoveCatalogueJurForm } from '../CatalogueJurMoveForm/CatalogueJurMoveForm';
|
||||
import { WithdrawCatalogueJurForm } from '../CatalogueJurWithdrawForm/CatalogueJurWithdrawForm';
|
||||
import { catalogueJurConfig, companyGroupJurConfig } from './config';
|
||||
|
||||
interface CatalogueJurTableI {
|
||||
@ -1,7 +1,7 @@
|
||||
import type { TableConfig } from '../../components/GenericTable';
|
||||
import { TableTag } from '../../components/TableTag/TableTag';
|
||||
import { TAG_PRESETS } from '../../components/TableTag/presets';
|
||||
import type { ICatalogueJur } from '../../types/catalogueJur/catalogueJur';
|
||||
import type { TableConfig } from '../../../components/GenericTable';
|
||||
import { TableTag } from '../../../components/TableTag/TableTag';
|
||||
import { TAG_PRESETS } from '../../../components/TableTag/presets';
|
||||
import type { ICatalogueJur } from '../../../types/catalogueJur/catalogueJur';
|
||||
|
||||
/** ЮЛ вне ГК (монозаёмщики): в ГСК/ГСЗ они не входят, колонок членства нет. */
|
||||
export const catalogueJurConfig: TableConfig<ICatalogueJur> = {
|
||||
@ -4,10 +4,10 @@ import TextArea from 'antd/es/input/TextArea';
|
||||
import dayjs from 'dayjs';
|
||||
import type React from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../services/api/directories/catalogue_jur';
|
||||
import type { WithdrawCatalogueJurProps } from '../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { fetchOneCatalogueJur } from '../../../services/api/directories/catalogue_jur';
|
||||
import type { WithdrawCatalogueJurProps } from '../../../types/catalogueJur/catalogueJur';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
|
||||
interface FormValues extends WithdrawCatalogueJurProps {
|
||||
name: string;
|
||||
@ -2,7 +2,7 @@ import { DownloadOutlined, FullscreenExitOutlined, FullscreenOutlined } from '@a
|
||||
import { Button, ConfigProvider } from 'antd';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import {
|
||||
exportChessConsolidationsResult,
|
||||
exportChessTableAll,
|
||||
@ -10,11 +10,12 @@ import {
|
||||
fetchChessConsolidations,
|
||||
fetchChessConsolidationsManual,
|
||||
fetchChessConsolidationsResult,
|
||||
} from '../../services/api/intercompanyMatrix';
|
||||
import type { IntercompanyMatrixResponse, IntercompanyMatrixResultResponse } from '../../types/api';
|
||||
import type { VersionCard } from '../../types/consolidations/version_members';
|
||||
import { saveBlob, xlsxFilename } from '../../utils/download';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
} from '../../../services/api/intercompanyMatrix';
|
||||
import type { IntercompanyMatrixResponse, IntercompanyMatrixResultResponse } from '../../../types/api';
|
||||
import type { VersionCard } from '../../../types/consolidations/version_members';
|
||||
import { chessMatrixMode } from '../../../utils/chessMatrixMode';
|
||||
import { saveBlob, xlsxFilename } from '../../../utils/download';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
import { ConsolidationChessFormatTableFilter } from '../ConsolidationChessFormatTableFilter/ConsolidationChessFormatTableFilter';
|
||||
import { ConsolidationChessResTable } from '../ConsolidationChessResTable/ConsolidationChessResTable';
|
||||
import { ConsolidationChessTable } from '../ConsolidationChessTable/ConsolidationChessTable';
|
||||
@ -72,18 +73,15 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
return () => document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
||||
}, []);
|
||||
|
||||
const isHalfFiltered = (debit.length > 0 && credit.length === 0) || (debit.length === 0 && credit.length > 0);
|
||||
const matrixMode = chessMatrixMode(debit, credit);
|
||||
const isHalfFiltered = matrixMode === 'half';
|
||||
|
||||
const loadData = useCallback(
|
||||
async (vId: string, dIds: string[], cIds: string[], isActual: () => boolean) => {
|
||||
if (isHalfFiltered) {
|
||||
notification.info({ description: 'Для сравнений по Дт и Кт нужно заполнить оба фильтра' });
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
let res: IntercompanyMatrixResponse;
|
||||
if (dIds?.length && cIds?.length) {
|
||||
if (chessMatrixMode(dIds, cIds) === 'manual') {
|
||||
res = await fetchChessConsolidationsManual(vId, { debit_account_ids: dIds, credit_account_ids: cIds });
|
||||
} else {
|
||||
res = await fetchChessConsolidations(vId);
|
||||
@ -101,7 +99,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
[notification, isHalfFiltered],
|
||||
[notification],
|
||||
);
|
||||
const loadResData = useCallback(
|
||||
async (vid: string) => {
|
||||
@ -128,7 +126,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
}
|
||||
setMatrixExportLoading(true);
|
||||
try {
|
||||
if (debit?.length && credit?.length) {
|
||||
if (matrixMode === 'manual') {
|
||||
const { blob, filename } = await exportChessTableManual(version_id, { debit_account_ids: debit, credit_account_ids: credit });
|
||||
saveBlob(blob, filename ?? xlsxFilename('Шахматка', versionInfo));
|
||||
} else {
|
||||
@ -171,7 +169,8 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
}, [data, companies]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!version_id) return;
|
||||
// выбрана только одна сторона Дт/Кт — запрос не шлём, таблица показывает подсказку
|
||||
if (!version_id || isHalfFiltered) return;
|
||||
|
||||
let isMounted = true;
|
||||
const isActual = () => isMounted;
|
||||
@ -182,7 +181,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
isMounted = false;
|
||||
setLoading(false);
|
||||
};
|
||||
}, [version_id, debit, credit, loadData]);
|
||||
}, [version_id, debit, credit, isHalfFiltered, loadData]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!version_id) return;
|
||||
@ -217,6 +216,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
decimals={decimals}
|
||||
units={units}
|
||||
isFullscreen={isChessFullscreen}
|
||||
isHalfFiltered={isHalfFiltered}
|
||||
toolbar={
|
||||
<div
|
||||
style={{
|
||||
@ -1,11 +1,11 @@
|
||||
.chessTable .ant-table-summary {
|
||||
.chessResTable .ant-table-summary {
|
||||
border-end-end-radius: 8px !important;
|
||||
border-end-start-radius: 8px !important;
|
||||
}
|
||||
|
||||
.chessTable .ant-table-cell-fix {
|
||||
.chessResTable .ant-table-cell-fix {
|
||||
background-color: #f8fafc !important;
|
||||
}
|
||||
.chessTable .resRow {
|
||||
.chessResTable .resRow {
|
||||
background-color: #e6f4ea !important ;
|
||||
}
|
||||
@ -2,10 +2,10 @@ import { Table, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import type { IntercompanyMatrixResultResponse, MatrixResCell } from '../../types/api';
|
||||
import type { IntercompanyMatrixResultResponse, MatrixResCell } from '../../../types/api';
|
||||
import './ConsolidatedChessResTable.css';
|
||||
import { chessTableCellFormatValue } from '../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../utils/money';
|
||||
import { chessTableCellFormatValue } from '../../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../../utils/money';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@ -81,7 +81,7 @@ export const ConsolidationChessResTable: React.FC<ConsolidationChessResTableI> =
|
||||
|
||||
return (
|
||||
<Table<MatrixResCell>
|
||||
className='chessTable'
|
||||
className='chessResTable'
|
||||
dataSource={data?.articles || []}
|
||||
columns={columns}
|
||||
rowKey='code'
|
||||
@ -16,3 +16,7 @@
|
||||
.chessTable .resRow {
|
||||
background-color: #e6f4ea !important ;
|
||||
}
|
||||
|
||||
.chessTable.customHeight .ant-table-container {
|
||||
min-height: 550px;
|
||||
}
|
||||
@ -3,10 +3,11 @@ import { Table, Tooltip, Typography } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import type { IntercompanyMatrixResponse, MatrixCell, MatrixCompany } from '../../types/api';
|
||||
import type { IntercompanyMatrixResponse, MatrixCell, MatrixCompany } from '../../../types/api';
|
||||
import './ConsolidatedChessTable.css';
|
||||
import { chessTableCellFormatValue } from '../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../utils/money';
|
||||
import { CHESS_HALF_FILTER_HINT } from '../../../utils/chessMatrixMode';
|
||||
import { chessTableCellFormatValue } from '../../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../../utils/money';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@ -17,6 +18,7 @@ interface ConsolidationChessTableI {
|
||||
units: string;
|
||||
toolbar?: React.ReactNode;
|
||||
isFullscreen?: boolean;
|
||||
isHalfFiltered?: boolean;
|
||||
}
|
||||
|
||||
type TotalRow = {
|
||||
@ -32,6 +34,7 @@ export const ConsolidationChessTable: React.FC<ConsolidationChessTableI> = ({
|
||||
units,
|
||||
toolbar,
|
||||
isFullscreen = false,
|
||||
isHalfFiltered = false,
|
||||
}) => {
|
||||
const matrixData = useMemo(() => {
|
||||
if (!data?.cells) return {};
|
||||
@ -116,13 +119,13 @@ export const ConsolidationChessTable: React.FC<ConsolidationChessTableI> = ({
|
||||
return totalRow as MatrixCompany;
|
||||
}, [data?.companies, matrixData]);
|
||||
|
||||
const scrollY = isFullscreen ? 'calc(100vh - 150px)' : 436;
|
||||
const scrollY = isFullscreen ? 'calc(100vh - 200px)' : 436;
|
||||
|
||||
return (
|
||||
<Table<MatrixCompany>
|
||||
className='chessTable'
|
||||
dataSource={data?.companies || []}
|
||||
columns={columns}
|
||||
className={isHalfFiltered && !isFullscreen ? 'chessTable customHeight' : 'chessTable'}
|
||||
dataSource={isHalfFiltered ? [] : data?.companies || []}
|
||||
columns={isHalfFiltered ? [] : columns}
|
||||
rowKey='id'
|
||||
pagination={false}
|
||||
loading={loading}
|
||||
@ -130,26 +133,35 @@ export const ConsolidationChessTable: React.FC<ConsolidationChessTableI> = ({
|
||||
size='small'
|
||||
bordered
|
||||
title={() => toolbar}
|
||||
locale={{
|
||||
emptyText: isHalfFiltered ? (
|
||||
<div style={{ padding: '40px 0', color: '#8c8c8c', fontSize: 16 }}>{CHESS_HALF_FILTER_HINT}</div>
|
||||
) : (
|
||||
'Нет данных'
|
||||
),
|
||||
}}
|
||||
summary={() => {
|
||||
if (!totalRowData) return null;
|
||||
|
||||
return (
|
||||
<Table.Summary fixed>
|
||||
<Table.Summary.Row className='resRow'>
|
||||
<Table.Summary.Cell className='resRow' index={0} align='left'>
|
||||
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
||||
<Text strong>Итого</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
|
||||
{data?.companies.map((company, index) => (
|
||||
<Table.Summary.Cell className='resRow' key={company.id} index={index + 1} align='right'>
|
||||
<div>
|
||||
<Text strong>{chessTableCellFormatValue((totalRowData as TotalRow)[company.id], units, decimals) || '—'}</Text>
|
||||
{!isHalfFiltered && (
|
||||
<Table.Summary.Row className='resRow'>
|
||||
<Table.Summary.Cell className='resRow' index={0} align='left'>
|
||||
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
||||
<Text strong>Итого</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
))}
|
||||
</Table.Summary.Row>
|
||||
|
||||
{data?.companies.map((company, index) => (
|
||||
<Table.Summary.Cell className='resRow' key={company.id} index={index + 1} align='right'>
|
||||
<div>
|
||||
<Text strong>{chessTableCellFormatValue((totalRowData as TotalRow)[company.id], units, decimals) || '—'}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
))}
|
||||
</Table.Summary.Row>
|
||||
)}
|
||||
</Table.Summary>
|
||||
);
|
||||
}}
|
||||
@ -1,11 +1,12 @@
|
||||
import { Button, Select, Space } from 'antd';
|
||||
import type React from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ApiError, api } from '../../api/client';
|
||||
import { type OptionType, TreeFilterDropdown } from '../../components/TreeFilterDropdown/TreeFilterDropdown';
|
||||
import type { Account, MatrixCompany, Quarter } from '../../types/api';
|
||||
import { quarterShortLabel } from '../../utils/labels';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { ApiError, api } from '../../../api/client';
|
||||
import { type OptionType, TreeFilterDropdown } from '../../../components/TreeFilterDropdown/TreeFilterDropdown';
|
||||
import type { Account, MatrixCompany, Quarter } from '../../../types/api';
|
||||
import { CHESS_HALF_FILTER_HINT, chessMatrixMode } from '../../../utils/chessMatrixMode';
|
||||
import { quarterShortLabel } from '../../../utils/labels';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
|
||||
interface ConsolidationChessTableFilterI {
|
||||
companies: string[];
|
||||
@ -109,7 +110,8 @@ export const ConsolidationChessTableFilter: React.FC<ConsolidationChessTableFilt
|
||||
loadAccounts();
|
||||
}, [notification]);
|
||||
|
||||
const warningBlock = <span style={{ color: '#d46b08', fontSize: 13 }}>Выберите счета по Дт и Кт для фильтрации</span>;
|
||||
const warningBlock =
|
||||
chessMatrixMode(debit, credit) === 'half' ? <span style={{ color: '#d46b08', fontSize: 13 }}>{CHESS_HALF_FILTER_HINT}</span> : null;
|
||||
|
||||
return (
|
||||
<Space size='middle' wrap>
|
||||
@ -3,12 +3,12 @@ import FormItem from 'antd/es/form/FormItem';
|
||||
import dayjs from 'dayjs';
|
||||
import type React from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { fetchRelatedGroup } from '../../services/api/directories/company_groups';
|
||||
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../store/store';
|
||||
import type { RelatedGroupFormType } from '../../types/relatedGroup/relatedGroup';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { fetchRelatedGroup } from '../../../services/api/directories/company_groups';
|
||||
import { getCompanyGroupsThunk } from '../../../store/slices/companyGroupsSlice/thunks';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/store';
|
||||
import type { RelatedGroupFormType } from '../../../types/relatedGroup/relatedGroup';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
@ -2,13 +2,13 @@ import { DeleteOutlined, EditOutlined, EllipsisOutlined } from '@ant-design/icon
|
||||
import { Button, Dropdown, Space } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { type ReactNode, useMemo, useState } from 'react';
|
||||
import { ApiError } from '../../api/client';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useVisibleColumns } from '../../components/GenericTable';
|
||||
import { useTableFilters } from '../../components/GenericTable/useTableFilters';
|
||||
import { deleteRelatedGroup, editRelatedGroup } from '../../services/api/directories/related-groups';
|
||||
import type { RelatedGroupOut } from '../../types/api';
|
||||
import type { RelatedGroupFormType } from '../../types/relatedGroup/relatedGroup';
|
||||
import { useNotificationApi } from '../../utils/useNotification';
|
||||
import { ApiError } from '../../../api/client';
|
||||
import { ColumnSettings, DataTable, useFilteredRows, useVisibleColumns } from '../../../components/GenericTable';
|
||||
import { useTableFilters } from '../../../components/GenericTable/useTableFilters';
|
||||
import { deleteRelatedGroup, editRelatedGroup } from '../../../services/api/directories/related-groups';
|
||||
import type { RelatedGroupOut } from '../../../types/api';
|
||||
import type { RelatedGroupFormType } from '../../../types/relatedGroup/relatedGroup';
|
||||
import { useNotificationApi } from '../../../utils/useNotification';
|
||||
import { DeleteRelatedGroupModal } from '../DeleteRelatedGroupModal/DeleteRelatedGroupModal';
|
||||
import { RelatedGroupForm } from '../RelatedGroupForm/RelatedGroupForm';
|
||||
import { relateGroupConfig } from './config';
|
||||
@ -1,9 +1,9 @@
|
||||
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
||||
import { Button } from 'antd';
|
||||
import type { TableConfig } from '../../components/GenericTable';
|
||||
import { setRelatedGroupFilter } from '../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { store } from '../../store/store';
|
||||
import type { RelatedGroupOut } from '../../types/api';
|
||||
import type { TableConfig } from '../../../components/GenericTable';
|
||||
import { setRelatedGroupFilter } from '../../../store/slices/catalogueJurSlice/catalogueJurSlice';
|
||||
import { store } from '../../../store/store';
|
||||
import type { RelatedGroupOut } from '../../../types/api';
|
||||
export const relateGroupConfig: TableConfig<RelatedGroupOut> = {
|
||||
rowKey: 'id',
|
||||
searchableKeys: ['code', 'crm_id', 'name', 'members_count', 'created_date'],
|
||||
Loading…
x
Reference in New Issue
Block a user