Skip to main content

Deposit History

Deposit History

Component File: src/features/deposits/components/DepositHistory.tsx Route / navigation: Path /fund-accounting, Zustand accountingTool = deposit-history (via Deposits sub-hub). See 00-ACCOUNTING-HUB.md. Access Level: Parent Org and Fund Users with Accounting access (position-based) Last Updated: April 13, 2026

Recent Fixes

Fund-scoped amount + item visibility parity (Apr 13, 2026)

  • Problem: For tranched deposits (parent header + child-fund line items), fund-scoped history could include the batch row but still sum/show the full header amount and all active items.
  • Fix: get_deposit_history_page now computes a fund-scoped amount per row and uses it for:
  • row total_amount when p_org_id is set
  • summary stats (total_amount, today_amount)
  • nested items payload (filtered to the selected fund allocation)
  • Result: child-fund history no longer overstates totals or exposes unrelated mixed-batch lines.
  • Migration: 20260413190000_deposit_history_scoped_amounts_items.sql

Tranched deposits visible per fund (Mar 27, 2026)

  • Problem: Multi-fund batches store deposits.organization_id on the parent org. Fund-scoped history (p_org_id = fund) previously returned no rows for those batches.
  • Fix: get_deposit_history_page base CTE also matches deposits that have any deposit_itemsdonations.organization_id = p_org_id. Stats (total_count, today_*) use the same filter set.
  • Migration: 20260327200000_deposit_history_tranched_visibility.sql (applied to production via Supabase MCP for IFM).

Row-level check image & dialog details (Mar 23, 2026)

  • Row click: For any line that has a stored check image (deposit_items.check_image_url), the entire row opens the check image viewer (single-item deposits: the main row; multi-item deposits: each expanded sub-row). Hover uses hover:bg-muted/50 and cursor-pointer when an image exists. The batch row for multi-item deposits still only expands/collapses — it does not open an image.
  • Controls: Icon and View check links call stopPropagation() so they do not double-trigger; behavior matches row click.
  • Dialog: The viewer shows structured deposit context above the image: deposit date, check number (when present), line amount, payer, fund, status, deposit type, memo, and batch notes. State clears on close. Implementation uses a CheckImageViewContext object passed into openCheckImage() from DepositHistory.tsx.
  • Files: src/features/deposits/components/DepositHistory.tsx, documentation/pages/accounting/17-DEPOSIT-HISTORY.md

Table layout & single-item rows (Mar 20, 2026)

  • Styling guide: Table uses table-fixed w-full, a single flex column (Details / notes — no fixed width on lg), tiered w-[…px] on other heads, and an overflow-x-auto wrapper per STYLING-GUIDE.md § Table Content Integrity & Column Width Standard.
  • Single line item: Deposits with exactly one deposit_items row render as one flat row (no chevron, no expand). Payer, check #, memo, and batch notes are combined in Details; check image stays in the first column when present.
  • Multiple items: Chevron + expand/collapse unchanged; sub-rows include an icon-only control and a View check text control (where an image exists) for discoverability.
  • Edit / void / delete: Remain batch-level actions (3-dot menu). The domain model edits the whole deposit via RegularDepositManager / CheckDepositManager using sessionStorage.editDepositId — there is no per–line-item edit API.

Check Image Viewer (Mar 17, 2026; dialog content Mar 23, 2026)

  • Problem: Check images were uploaded and stored in deposit_items.check_image_url during deposit submission, but the Deposit History component never displayed them. Users had no way to view check images after a deposit was submitted.
  • Solution:
  • Image icon and View check controls where a check_image_url exists; row-level click opens the same viewer when applicable (see Mar 23, 2026 above).
  • Full-size image dialog with structured deposit/line-item details above the image (date, check #, amount, payer, fund, status, type, memo, batch notes).
  • Images are loaded via Supabase Storage signed URLs (1-hour expiry) from the receipts bucket
  • Signed URLs are cached in-memory to avoid re-generating on expand/collapse
  • Base64 fallback URLs (from upload failures) are handled transparently
  • Files Modified: src/features/deposits/components/DepositHistory.tsx, documentation/pages/accounting/17-DEPOSIT-HISTORY.md

Overview

The Deposit History tool allows users to view and search previously submitted deposits. It was built in response to a user request to verify whether a deposit had been entered on a given day. The tool provides a searchable, filterable table of all deposit batches with expandable rows showing individual line items.

UI Features

Summary Stats (3 cards, centered text, no icons)

1. Total Deposits — Count of deposits matching current filters 2. Total Amount — Sum of all amounts matching current filters (fund-scoped allocation for tranched batches) 3. Deposits Today — Count and amount of deposits with today's date

Filter Bar

  • Search — Debounced (300ms) search by payer name or deposit notes
  • Status Filter — Dropdown: All Statuses, Pending, Deposited, Cleared
  • Date Range Picker — Presets (All time, This month, Last month, etc.) + custom range

Deposits Table

  • Layout: table-fixed w-full, tiered column widths, one flex column (Details), overflow-x-auto wrapper
  • Columns: Chevron (multi-item only) / image slot, Date, Type (badge), Items count, Amount, Status (badge), Fund (hidden <md), Details (hidden <lg), Actions (if canWriteAccounting)
  • Single-item deposits — One row only; first column shows check image control when check_image_url is set; Details includes a View check link when applicable; clicking anywhere on the row opens the check viewer when an image exists
  • Multi-item deposits — Click the batch row to expand line items (payer, check #, amount, memo, bg-muted/30); each sub-row with an image is fully clickable plus icon / View check; View check where an image exists
  • Empty state — Icon + contextual message based on whether search is active
  • Loading state — SkeletonTable (8 rows × 6 columns)
  • Fetching indicator — Opacity fade while background-refreshing

Batch actions: Edit, void, delete

  • Actions column — 3-dot menu (DropdownMenu), only if canWriteAccounting
  • Edit depositBatch-level only (not per check line). Pending: navigates to check or regular deposit manager with editDepositId in sessionStorage. Deposited: confirmation dialog → voidDepositBatch() → same navigation to re-enter the batch. After successful re-entry submit, managers archive the source pending draft batch.
  • Void deposit (deposited) — Menu item → confirmation dialog; requires reason; voidDepositBatch() (reversing JE, void donations, revert to pending); toast shows voided donation count
  • Delete deposit (pending) — Menu item → confirmation; deleteDeposit() (cleanup donations/JE, remove deposit)
  • Cleared deposits — No action available
  • Confirmation dialog — Shows deposit date, amount, item count, and type before action

Data Layer

Database Function

// src/lib/db/deposits.ts
fetchDepositHistoryPage(entityId: EntityId, options?: {
  page?: number;
  pageSize?: number;
  status?: 'pending' | 'deposited' | 'cleared' | 'all';
  startDate?: string;
  endDate?: string;
  search?: string;
  statsDate?: string;
}): Promise<PaginatedDepositsWithItemsResult>
  • Uses RPC get_deposit_history_page (server-side pagination + search + stats)
  • Parent org users (getOrgId returns null) see deposits across all funds
  • Fund-scoped requests return fund-allocated amounts/items for tranched parent-header batches
  • Search is server-side on deposits.notes + active deposit_items.payer_name

React Query

  • Query key: ['deposit-history', selectedEntity, statusFilter, startDate, endDate, debouncedSearch]
  • Stale time: 30 seconds

Navigation

  • Breadcrumb: Fund Accounting → Deposits → Deposit History
  • Back navigation via breadcrumb clicks (sets accountingTool to null or 'deposits')

Dependencies

  • @tanstack/react-query — Data fetching and caching (useQuery, useQueryClient)
  • src/lib/db/deposits.tsfetchDepositHistoryPage(), voidDepositBatch(), deleteDeposit()
  • src/hooks/usePermissions.tscanWriteAccounting for action column visibility
  • src/lib/entityMapping.tsgetEntityId() for reverse org-UUID-to-entity-name mapping
  • src/lib/dateUtils.tstoLocalDateString() for date filter strings
  • src/components/ui/date-range-picker.tsx — DateRangePicker with presets
  • src/components/ui/skeleton-table.tsx — Loading state
  • src/components/ui/dialog.tsx — Check image viewer, void/delete, and edit confirmation dialogs
  • sonner — Toast notifications for action results

Related Documentation


Synced from IFMmvp-Frontend documentation: pages/accounting/17-DEPOSIT-HISTORY.md

Ready to Get Started?

See how Alignmint can simplify your nonprofit's operations. Schedule a free demo with our team and we'll walk you through everything.

Questions? Email us at steven@getalignmint.org

Ready to get started?Start Plus Trial