// DTO API arm-core (/api/v1). Повторяют arm-core/api/src/schemas/; Decimal и даты — строки. export type Quarter = 'Q1' | 'Q2' | 'Q3' | 'Q4'; export type DocumentType = 'BALANCE' | 'INCOME' | 'OSV' | 'DISCLOSURE' | 'OTHER'; export type DocumentStatus = 'RECOGNIZED' | 'NEEDS_CHECK' | 'CONFIRMED' | 'ERROR'; export type FileStatus = 'UPLOADED' | 'PROCESSING' | 'PROCESSED' | 'ERROR' | 'SUPERSEDED'; export interface Page { items: T[]; total: number; limit: number; offset: number; } export interface AcceptedOut { file_id: string; job_id: string; name: string; } export interface RejectedOut { name: string; code: string; message: string; file_id?: string | null; } export interface UploadResult { accepted: AcceptedOut[]; rejected: RejectedOut[]; } export type RecognitionStatus = string; // pending | processing | done | error | timeout | dlq — только для показа export interface JobBrief { id: string; status: RecognitionStatus; error_code: string | null; error_message: string | null; mapping_error: string | null; warnings: string[]; mapping_warnings: string[]; finished_at: string | null; } export type CheckResult = 'MATCH' | 'MISMATCH' | 'UNKNOWN'; export interface DocumentBrief { id: string; document_type: DocumentType; osv_account_code: string | null; period_year: number | null; period_quarter: Quarter | null; is_cumulative: boolean | null; status: DocumentStatus; period_check: CheckResult | null; counterparty_check: CheckResult | null; locator: string | null; comments_count: number; } export type FileType = 'XLS' | 'XLSX' | 'XLSB' | 'PDF' | 'PNG' | 'JPG'; export interface FileOut { id: string; legal_entity_id: string; original_name: string | null; file_type: FileType; status: FileStatus; version_no: number; size_bytes: number | null; uploaded_at: string | null; job: JobBrief | null; documents: DocumentBrief[]; } export interface DocumentOut extends DocumentBrief { file_id: string; legal_entity_id: string; confirmed_by: string | null; confirmed_at: string | null; warnings: string[]; } /** Уровень строки ОСВ (DBML `osv_group_type`). */ export type OsvGroupType = 'ACCOUNT' | 'DEPARTMENT' | 'COUNTERPARTY' | 'CONTRACT' | 'OTHER'; export interface EntryOut { id: string; row_number: number | null; level: number | null; parent_entry_id: string | null; row_value: string | null; group_type: OsvGroupType | null; group_name: string | null; account_code: string | null; counterparty_name: string | null; counterparty_inn: string | null; opening_debit: string | null; opening_credit: string | null; turnover_debit: string | null; turnover_credit: string | null; closing_debit: string | null; closing_credit: string | null; } export interface HeaderFieldOut { value: string | null; original_value: string | null; confidence?: string | null; verified: boolean | null; modified: boolean | null; } export interface StatementHeaderOut { inn: HeaderFieldOut; report_date: HeaderFieldOut; units: HeaderFieldOut; organization_name: string | null; okud: string | null; okpo: string | null; okopf: string | null; okfs: string | null; address: string | null; } export interface ColumnOut { id: string; column_index: number; label: string | null; period_date: string | null; is_current: boolean | null; } export interface ValueOut { id: string; column_id: string; column_index: number; amount: string | null; string_value: string | null; confidence: string | null; is_recognized: boolean | null; is_modified: boolean; original_amount: string | null; } export interface LineOut { id: string; line_code: string | null; line_name: string | null; values: ValueOut[]; } export interface FailedCheckOut { column_index: number; relation: string; expected: string; actual: string; } export interface ChecksOut { failed: FailedCheckOut[]; soft_failed: FailedCheckOut[]; cross_form: FailedCheckOut | null; accepted: { by: string; at: string; comment: string } | null; } export interface StatementOut { document: { id: string; document_type: DocumentType; status: DocumentStatus; period_year: number | null; period_quarter: Quarter | null; reporting_date: string | null; counterparty_check: CheckResult | null; locator: string | null; file_id: string; }; edition: string | null; header: StatementHeaderOut; columns: ColumnOut[]; lines: LineOut[]; checks: ChecksOut; } export interface StatementPatch { header?: { inn?: string; report_date?: string; units?: string }; values?: { line_id: string; column_id: string; amount: string | null }[]; } export type CounterpartyType = 'GSK' | 'GK' | 'EXTERNAL'; export type MatchKind = 'INN' | 'NAME' | 'ALIAS' | 'MANUAL' | 'PROPAGATED'; export interface ConsolidatedRowOut { entry_ids: string[]; legal_entity_id: string; legal_entity_name: string; legal_entity_inn: string; account_code: string | null; account_root: string | null; period: string; is_cumulative: boolean; counterparty_name: string | null; counterparty_inn: string | null; counterparty_id: string | null; counterparty_entity_name: string | null; counterparty_type: CounterpartyType; match_kind: MatchKind | null; opening_debit: string | null; opening_credit: string | null; turnover_debit: string | null; turnover_credit: string | null; closing_debit: string | null; closing_credit: string | null; warnings: string[]; } export interface GapOut { legal_entity_id: string; legal_entity_name: string; account_code: string; missing_quarters: Quarter[]; } export interface OsvSummaryOut { rows_total: number; unmapped_total: number; auto_matched_total: number; documents_total: number; gaps: GapOut[]; } export interface OsvFilters { legal_entity_id?: string; account_root?: string; counterparty_type?: CounterpartyType; unmapped?: boolean; q?: string; } export interface ConsolidationCreate { company_group_id: string; related_group_id: string; year: number; quarter: Quarter; legal_entity_ids: string[]; } export interface RelatedGroupOut { id: string; code: string; company_group_id: string; kind: 'gsk' | 'gsz'; name: string; created_date: string | null; members_count: number; } export interface RelatedGroupMemberOut { legal_entity_id: string; inn: string; name: string; valid_from: string; } export interface RelatedGroupDetail extends RelatedGroupOut { members: RelatedGroupMemberOut[]; } export interface LegalEntityBrief { id: string; name: string; inn: string; }