import { EntityRecommendationPayload } from '../../../commonPayloadTypes/recommendationPayload'; import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload'; import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState'; import { ZeniAPIResponse } from '../../../responsePayload'; import { CompletedSubTab } from '../types/completedSubTab'; import { TransactionGroup } from '../types/transactionGroup'; export interface TransactionCategorizationQueryPayload { auto_categorized: boolean; end_date: string | null; page_size: number; page_token: string | null; search_text: string | null; sort_by: string; sort_order: string; start_date: string | null; /** * Required. For the Completed (`auto_categorized=true`) listing, scopes the * returned page + `total_count` to one of the Completed sub-tabs. For the * Review listing it is forced to `'all'` to preserve parent-tab semantics * on the backend. */ sub_tab: CompletedSubTab; /** * When `false`, the backend scopes the search to the active tab's * categorization status (respects `auto_categorized`). When `true` or * omitted, the backend searches across all statuses — the legacy behaviour * that the Receipts manual-match flow relies on. */ search_all_statuses?: boolean; /** * Statement-level scope (`'expense' | 'income' | 'all'`). Always sent by the * list epics. The backend `is_revenue_automation_enabled` gate is * authoritative: when it is off the backend ignores this and returns the * legacy expense scope regardless of the value, so there is no need to gate * the send on the client (the gate isn't available to the redux epics anyway * — it's a Statsig/React-side flag, not a tenant field). Optional only for * wire/back-compat tolerance. */ transaction_group?: TransactionGroup; } export interface TransactionCategorizationPayload { next_page_token: string | null; query: TransactionCategorizationQueryPayload; total_count: number; transactions: SupportedTransactionPayload[]; /** * Count of transactions for the entire parent tab (Review or Completed), * regardless of which sub-tab the listing was scoped to. Used solely to * drive the parent tab badge counts on the UI; pagination, list-level * counts, and sub-tab chips continue to consume {@link total_count}. * * Optional at the wire boundary so that any version-skew scenario * (delayed BE rollout, cached SW response, hotfix without the BE change) * deserializes cleanly. Consumers are expected to fall back to * {@link total_count} when this is absent — see * `fetchTransactionCategorizationEpic` for the canonical fallback. */ parent_tab_total_count?: number; } export type TransactionCategorizationResponse = ZeniAPIResponse; export interface EntityRelatedUpdatesPayload { entity_id: string | null; entity_type: string; is_bulk_update: boolean; recommendations: EntityRecommendationPayload; updated_entity_id: string | undefined; vendor_name?: string; } export interface UpdateTransactionCategorizationPayload { transaction: Partial; transaction_id: string; transaction_type: string; entity_related_updates?: EntityRelatedUpdatesPayload[]; } export interface UpdateTransactionCategorization { line_ids: string[]; transaction_id: string; } export interface UpdateTransactionCategorizationResponsePayload { transactions_update_failed: UpdateTransactionCategorization[]; transactions_update_success: UpdateTransactionCategorization[]; } export type TransactionCategorizationUpdateResponse = ZeniAPIResponse; export interface MarkAsReviewTransactionCategorizationPayload { transactions_reviewed_failed: UpdateTransactionCategorization[]; transactions_reviewed_success: UpdateTransactionCategorization[]; } export type MarkAsReviewTransactionCategorizationPayloadResponse = ZeniAPIResponse;