import { StatusCodeWithLabelPayload } from '../../../commonPayloadTypes/statusPayload'; import { ID } from '../../../commonStateTypes/common'; import { AccountPayload } from '../../../entity/account/accountPayload'; import { ReconciliationDataPayload, StatementMetaDataPayload } from '../../../entity/accountRecon/accountReconPayload'; import { FilePayload } from '../../../entity/file/filePayload'; import { MatchedTransactionPayload } from '../../../entity/transaction/payloadTypes/reconciliationTransactionPayloads'; import { UserPayload } from '../../../entity/user/userPayload'; import { ZeniAPIResponse, ZeniAPIStatus } from '../../../responsePayload'; import { ConfirmStatementMappingConflict, ConfirmedCombinedStatementUpload, ParsedStatementData, ReconciliationViewSummary, StatementDateConflict, StatementUpdateLocalData, StatementUpdateLocalDataPayload } from '../types/reconciliationViewState'; export interface DetectionInfoPayload { account_id: string; bank_balance: number | null; cleared_balance: number | null; variance: number | null; currency_code?: string; currency_symbol?: string; } export interface AccountAndPaymentAccountPayload extends AccountPayload { payment_account_id: string | null; detection_info?: DetectionInfoPayload; detection_reason?: string; } interface ExclusionInfoPayload { bank_balance: number | null; cleared_balance: number | null; variance: number | null; } export interface ExcludedAccountPayload extends AccountAndPaymentAccountPayload { exclusion_info: ExclusionInfoPayload; } export interface ReconciliationProgressBarPayload { ai_percentage_share: number; complete_percentage: number; human_percentage_share: number; remaining_percentage: number; } export interface ReconciliationSummaryPayload { accounts: { done: number; failed: number; in_progress: number; total: number; }; accounts_to_connect_count: number; auto_matched: { matched_txns: number; total_txns: number; }; needs_review: { account_count: number; txn_count: number; }; time_saved_percentage: number; progress_bar?: ReconciliationProgressBarPayload; } export declare function toReconciliationViewSummary(payload: ReconciliationSummaryPayload): ReconciliationViewSummary; export interface ReconciliationPayload { accounts: AccountAndPaymentAccountPayload[]; files: FilePayload[]; reconciliation: ReconciliationDataPayload[]; users: UserPayload[]; detection_info?: DetectionInfoPayload; detection_reason?: string; excluded_accounts?: ExcludedAccountPayload[]; summary?: ReconciliationSummaryPayload; } export type ReconciliationResponse = ZeniAPIResponse; export interface SaveReconciliationReviewPayload { reconciliation: MatchedTransactionPayload; } export type SaveReconciliationReviewResponse = ZeniAPIResponse; export interface ExcludeAccountFromReconciliationRequestPayload { account_id: ID; bank_balance: number; cleared_balance: number; variance: number; } export interface ExcludedAccountFromReconciliationPayload { account_id: ID; bank_balance: number | null; cleared_balance: number | null; variance: number | null; currency_code?: string; currency_symbol?: string; } export interface ExcludeAccountFromReconciliationResponsePayload { excluded_account: ExcludedAccountFromReconciliationPayload; } export type ExcludeAccountFromReconciliationResponse = ZeniAPIResponse; export interface IncludeAccountInReconciliationResponsePayload { reconciliation: ReconciliationDataPayload; } export type IncludeAccountInReconciliationResponse = ZeniAPIResponse; export interface DeleteStatementResponsePayload { statement_upload: { statement_data_status: StatusCodeWithLabelPayload; statement_meta_data: StatementMetaDataPayload | null; statement_status: StatusCodeWithLabelPayload; }; } export type DeleteStatementResponse = ZeniAPIResponse; export interface DeleteCombinedStatementResponsePayload extends DeleteStatementResponsePayload { deleted_statement_upload_ids: ID[]; } export type DeleteCombinedStatementResponse = ZeniAPIResponse; export interface UploadStatementDocumentAIPayload { files: FilePayload[]; processor_run_id: string; } export type UploadStatementDocumentAIResponse = ZeniAPIResponse; export interface StatementUploadSummaryPayload { account_type: string; statement_data_status: StatusCodeWithLabelPayload; statement_end_date: string; statement_start_date: string; statement_status: StatusCodeWithLabelPayload; statement_upload_id: string; combined_statement_group_id?: string | null; is_combined_statement?: boolean | null; is_combined_statement_anchor?: boolean | null; } export interface UploadStatementResponsePayload { file: FilePayload; statement_upload: StatementUploadSummaryPayload; } export type UploadStatementResponse = ZeniAPIResponse; export interface PolygonPointPayload { x: number; y: number; } export interface CitationPayload { page: number; page_height: number; page_width: number; polygon: PolygonPointPayload[]; reference_text: string; } export interface StatementTransactionPayload { amount: number; citation: CitationPayload[]; is_user_added: boolean; is_user_edited: boolean; statement_transaction_id: string; transaction_date: string; transaction_direction: 'debit' | 'credit'; transaction_memo: string; } export interface ReconciliationMetaPayload { end_date: string; reconciliation_id: string; start_date: string; status: string; } export interface StatementMetaPayload { closing_balance: number; opening_balance: number; statement_data_status: StatusCodeWithLabelPayload; statement_end_date: string; statement_start_date: string; statement_status: StatusCodeWithLabelPayload; statement_upload_id: string; total_deposits: number; total_payments: number; balance_source?: string | null; combined_statement_group_id?: string | null; is_combined_statement?: boolean | null; is_combined_statement_anchor?: boolean | null; } export interface AccountInfoPayload { account_id: string; account_name: string; account_type: string; currency_code: string; last_4_digits: string | null; } export interface FileInfoPayload { file_id: string; file_name: string; signed_url: string; } export interface AiSummaryFieldPayload { code: string; label: string; } export interface PreviousReconciliationInfoPayload { end_date: string; reconciled_at: string; reconciled_by_user_id: string; reconciliation_id: string; start_date: string; } export interface AiSummaryChainStatusPayload { code: string; expected_start_date: string | null; label: string; previous_reconciliation_info: PreviousReconciliationInfoPayload | null; } export interface AiSummaryPayload { account_identified: string | null; chain_status: AiSummaryChainStatusPayload; exceptions_detected: number; fields_captured: AiSummaryFieldPayload[]; transactions_extracted: number; } export interface CombinedStatementAccountSuggestionPayload { account_id: string; account_name: string; match_confidence: number; matched_by: string; } export interface CombinedStatementAccountPayload { account_name: string; account_type: string; closing_balance: number; is_upload_context: boolean; ledger_identifier: string; masked_account_number: string; opening_balance: number; transaction_count: number; existing_statement_status?: StatusCodeWithLabelPayload | null; suggestion?: CombinedStatementAccountSuggestionPayload | null; } export interface ConfirmedCombinedStatementUploadPayload { account_id: string; is_combined_statement_anchor: boolean; ledger_identifiers: string[]; statement_upload_id: string; } export interface CombinedStatementDetailsPayload { accounts: CombinedStatementAccountPayload[]; combined_statement_group_id: string; is_mapping_confirmed: boolean; statement_uploads: ConfirmedCombinedStatementUploadPayload[]; } export interface StatementUploadPayload { account: AccountInfoPayload; file: FileInfoPayload | null; statement_meta: StatementMetaPayload; statement_transactions: StatementTransactionPayload[]; ai_summary?: AiSummaryPayload | null; combined_statement_details?: CombinedStatementDetailsPayload | null; } /** Single-account parse GET — unchanged. */ export interface ParseStatementSingleResponsePayload { reconciliation: ReconciliationMetaPayload | null; statement_upload: StatementUploadPayload; } /** Combined multi-account parse GET (after mapping confirm). */ export interface ParseStatementCombinedResponsePayload { reconciliation: ReconciliationMetaPayload | null; statement_uploads: StatementUploadPayload[]; } export type ParseStatementResponsePayload = ParseStatementSingleResponsePayload | ParseStatementCombinedResponsePayload; export declare function isParseStatementCombinedResponsePayload(payload: ParseStatementResponsePayload): payload is ParseStatementCombinedResponsePayload; /** Batch GET …/combined-statement-groups/ — one entry per mapped account. */ export interface CombinedStatementGroupUploadEntryPayload { reconciliation: ReconciliationMetaPayload | null; statement_upload: StatementUploadPayload; } export interface CombinedStatementGroupResponsePayload { combined_statement_group_id: string; statement_uploads: CombinedStatementGroupUploadEntryPayload[]; } export type CombinedStatementGroupResponse = ZeniAPIResponse; export interface ConfirmStatementMappingRequestPayload { account_mappings: Array<{ account_id: string; ledger_identifier: string; }>; } export interface ConfirmStatementMappingResponsePayload { statement_uploads: ConfirmedCombinedStatementUploadPayload[]; } export type ConfirmStatementMappingSuccessResponse = ZeniAPIResponse; export interface ConfirmStatementMappingConflictResponse extends ZeniAPIResponse { status: ZeniAPIStatus & { code: 409; }; colliding_account_id?: string | null; colliding_ledger_identifiers?: string[] | null; previous_reconciliation_info?: PreviousReconciliationInfoPayload | null; } export type ConfirmStatementMappingResponse = ConfirmStatementMappingSuccessResponse | ConfirmStatementMappingConflictResponse; export interface ReparseStatementResponsePayload { statement_upload: StatementUploadSummaryPayload; } export type ParseStatementResponse = ZeniAPIResponse; export type ReparseStatementResponse = ZeniAPIResponse; /** * Statement period chain validation (Confirm & Save). * * - 200 (auto-trim): the BE trimmed the start date and returns a * `date_adjustment` block alongside the usual reconciliation / * statement_upload data. * - 409: the upload was rejected (total overlap or gap). The error fields * (`error_code`, `expected_start_date`, `previous_reconciliation_info`) * live at the top level of the response, next to `status`. */ export type StatementChainErrorCode = 'STATEMENT_RANGE_ALREADY_RECONCILED' | 'STATEMENT_RANGE_HAS_GAP'; export interface StatementDateAdjustmentPayload { adjusted_start_date: string; original_start_date: string; previous_reconciliation_info: PreviousReconciliationInfoPayload; reason: string; } /** Single-account Confirm & Save response — unchanged. */ export interface UpdateStatementInfoSingleResponsePayload { reconciliation: ReconciliationMetaPayload; statement_upload: StatementUploadPayload; date_adjustment?: StatementDateAdjustmentPayload | null; } /** One account's result inside a combined Confirm & Save response. */ export interface UpdateStatementInfoCombinedUploadItemPayload { reconciliation: ReconciliationMetaPayload; statement_upload: StatementUploadPayload; date_adjustment?: StatementDateAdjustmentPayload | null; } /** Combined multi-account bulk Confirm & Save response. */ export interface UpdateStatementInfoCombinedResponsePayload { combined_statement_group_id: string; statement_uploads: UpdateStatementInfoCombinedUploadItemPayload[]; } export type UpdateStatementInfoResponsePayload = UpdateStatementInfoSingleResponsePayload | UpdateStatementInfoCombinedResponsePayload; export declare function isUpdateStatementInfoCombinedResponsePayload(payload: UpdateStatementInfoResponsePayload): payload is UpdateStatementInfoCombinedResponsePayload; export interface BulkStatementUpdateUploadPayload { statement_meta: StatementUpdateLocalDataPayload['statement_meta']; statement_transactions: StatementUpdateLocalDataPayload['statement_transactions']; statement_upload_id: string; } export interface BulkStatementUpdateRequestPayload { statement_uploads: BulkStatementUpdateUploadPayload[]; } /** 2xx Confirm & Save — carries parsed statement data, no chain-validation errors. */ export interface UpdateStatementInfoSuccessResponse extends ZeniAPIResponse { error_code?: undefined; expected_start_date?: undefined; previous_reconciliation_info?: undefined; } /** 409 Confirm & Save — chain validation rejected the statement period. */ export interface UpdateStatementInfoConflictResponse extends ZeniAPIResponse { error_code: StatementChainErrorCode; status: ZeniAPIStatus & { code: 409; }; expected_start_date?: string | null; previous_reconciliation_info?: PreviousReconciliationInfoPayload | null; } export type UpdateStatementInfoResponse = UpdateStatementInfoSuccessResponse | UpdateStatementInfoConflictResponse; export declare function isStatementDateConflictResponse(response: UpdateStatementInfoResponse): response is UpdateStatementInfoConflictResponse; /** * Builds date-conflict state from a 409 Confirm & Save response. * Returns null for non-409 responses or 409s without a recognized error code. */ export declare function transformStatementDateConflictToState(response: UpdateStatementInfoResponse): StatementDateConflict | null; export declare function transformParseStatementPayloadToState(payload: ParseStatementResponsePayload): ParsedStatementData; export declare function transformCombinedStatementGroupPayloadToState(payload: CombinedStatementGroupResponsePayload): ParsedStatementData; export declare function isConfirmStatementMappingConflictResponse(response: ConfirmStatementMappingResponse): response is ConfirmStatementMappingConflictResponse; export declare function transformConfirmStatementMappingPayloadToState(payload: ConfirmStatementMappingResponsePayload): ConfirmedCombinedStatementUpload[]; export declare function transformConfirmStatementMappingConflictToState(response: ConfirmStatementMappingResponse): ConfirmStatementMappingConflict | null; export declare function transformUpdateStatementInfoPayloadToState(payload: UpdateStatementInfoResponsePayload): ParsedStatementData; export declare function transformStatementUpdateStateToPayload(localData: StatementUpdateLocalData): StatementUpdateLocalDataPayload; /** API request body for PUT statement-uploads; cast lives here for putAndGetJSON. */ export declare function toStatementUpdateRequestBody(localData: StatementUpdateLocalData): Record; export declare function transformBulkStatementUpdateStateToPayload(updates: Array<{ localData: StatementUpdateLocalData; statementUploadId: string; }>): BulkStatementUpdateRequestPayload; /** Bulk PUT body for combined multi-account Confirm & Save. */ export declare function toBulkStatementUpdateRequestBody(updates: Array<{ localData: StatementUpdateLocalData; statementUploadId: string; }>): Record; export {};