import { URLPayload } from '../../../commonPayloadTypes/urlPayload'; import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod'; import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload'; import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState'; import { ZeniAPIResponse } from '../../../responsePayload'; import { type BatchDetails, type BatchFile, type BatchFileStatus, type BatchListItem, type BatchStatus, type BatchSummary, type ManualSearchResult } from '../types/missingReceiptsViewState'; export interface MissingReceiptsQueryPayload { end_date: string; is_attachment_missing_only: boolean; sort_by: string; sort_order: string; start_date: string; total_amount_min: number; } interface MissingReceiptsPayload { query: MissingReceiptsQueryPayload; transactions: TransactionPayload[]; } export type MissingReceiptsResponse = ZeniAPIResponse; export interface BatchListQueryPayload { end_date: string; sort_order: string; start_date: string; } export interface BulkUploadResponsePayload { batch_id: string; status: string; total_files: number; } export type BulkUploadResponse = ZeniAPIResponse; export interface BatchListResponsePayload { batches: BatchListItemPayload[]; } export interface BatchListItemPayload { batch_id: string; created_at: string; failed_count: number; matched_count: number; no_match_count: number; possible_matches_count: number; status: string; total_files: number; user_id: string; } export type BatchListResponse = ZeniAPIResponse; export interface MatchedTransactionPayload { amount: number; currency_code: string; transaction_date: string | null; transaction_id: string; vendor_name: string; transaction_type?: string; vendor_logo?: URLPayload | null; } export interface MatchCandidatePayload extends MatchedTransactionPayload { match_score: number; } /** * Wire payload for a batch file row. `status` may use legacy aliases (`matched`, `un_matched`, * `possible_match`, `possible_matches`, etc.) until the backend is fully migrated; canonical * values are applied in {@link parseBatchFileStatus} via {@link toBatchFile}. */ export interface BatchFilePayload { attachment_id: string; file_id: string; file_preview_url: string | null; filename: string; status: string; candidates?: MatchCandidatePayload[]; match_source?: string; matched_transaction?: MatchedTransactionPayload; } export interface BatchDetailsResponsePayload { batch_id: string; created_at: string; files: BatchFilePayload[]; status: string; summary: { failed: number; matched: number; no_match: number; possible_matches: number; total: number; }; /** Uploader — used to scope automatching UI to the user who submitted the batch. */ user_id?: string; } export type BatchDetailsResponse = ZeniAPIResponse; /** * Maps batch-details API `files[].status` strings to canonical {@link BatchFileStatus}. * Legacy aliases are supported during rollout; unknown strings map to `failed` so Redux never * holds untyped status values. */ export declare function parseBatchFileStatus(raw: string): BatchFileStatus; export declare function toBatchFile(payload: BatchFilePayload, filesEndPoint?: string): BatchFile; export declare function extractTransactionPayloadsFromBatchFiles(files: BatchFilePayload[]): SupportedTransactionPayload[]; export declare function toBatchSummary(payload: BatchDetailsResponsePayload['summary']): BatchSummary; export declare function toBatchDetails(payload: BatchDetailsResponsePayload, filesEndPoint?: string): BatchDetails; /** Batch is still in-flight for automatching (GET /batches/:id while not completed). */ export declare function isBatchDetailsStatusPendingOrProcessing(status: string): boolean; /** Batch list `status` is a string from the API — compare case-insensitively. */ export declare function isBatchListStatusCompleted(status: string): boolean; /** * Subset of the get-all-batches (`/batches?query=...`) list that is eligible for * `GET /batches/:batchId` details fetches. The stored list may include pending, failed, or other * statuses for UI; only `completed` rows should trigger batch-details requests. */ export declare function filterBatchListItemsForBatchDetailsFetch(batches: BatchListItem[]): BatchListItem[]; /** * Batch details API response `status` field — only completed payloads should be stored from * multi-batch fetch paths (list can be briefly stale vs. live processing state). */ export declare function isBatchDetailsApiStatusCompleted(status: string): boolean; export declare function findBatchListItemForBatchId(batchListByPeriod: Record, batchId: string): BatchListItem | undefined; /** * Whether it is appropriate to call `GET .../batches/:id` for details. * Skips when live batch status or batch list row indicates the batch is not completed yet. * When status is unknown in both sources, allows the request (e.g. dispatch before list refresh). */ export declare function shouldFetchBatchDetailsForBatchId(batchStatusById: Record, batchListByPeriod: Record, batchId: string): boolean; export declare function toBatchListItem(payload: BatchListItemPayload): BatchListItem; /** Maps expense-automation transaction rows to manual-search list rows (Unmatched tab). */ export declare function supportedTransactionPayloadToManualSearchResult(payload: SupportedTransactionPayload): ManualSearchResult; export interface CompletedTransactionsQueryPayload { end_date?: string; match_type?: string; page_size?: number; page_token?: string | null; sort_by?: string; sort_order?: string; start_date?: string; } export interface CompletedTransactionsResponsePayload { next_page_token: string | null; total_count: number; transactions: SupportedTransactionPayload[]; } export type CompletedTransactionsResponse = ZeniAPIResponse; export {};