Skip to content

Fix: Fetch Full Batch Results for Historical Receipt Downloads #704

Description

@jahrulezfrancis

Problem

Downloading a receipt from batch history produces a file with no
recipients, amounts, or transaction hashes — despite the UI presenting it
as a real receipt for a completed batch.

Severity: Medium
Location: lib/batch-history-adapter.ts:64-79, components/dashboard/HistoryExportCenter.tsx:130-146

Description

getBatchHistory converts job summaries fetched from /api/batch-history
into BatchResult objects with results: [] — the code even comments on
this directly: // Summary view doesn't include individual results.
HistoryExportCenter's handleDownloadBatchReceipt and
handleDownloadBatchCsv pass that summary-only object straight into the
HTML/CSV receipt generators with no intermediate fetch of the full job
data. Both generators derive every payment row from results, so the
downloaded file has an empty payment table despite the batch having real,
completed payments on record.

Steps to Reproduce

  1. Complete a batch and later reload the dashboard's history view.
  2. The adapter constructs a summary object with results: [] for that job.
  3. Click "Receipt" or "CSV" under Recent Batch Receipts.
  4. The downloaded file contains no recipients, amounts, statuses, or
    transaction hashes.

Expected Behavior

A historical receipt download should contain the same recipients, amounts,
assets, statuses, and transaction hashes as the original completed job.

Suggested Fix Approach

Fetch the full, owner-scoped job result (not just the summary) before
enabling the download action, or add a dedicated history-receipt endpoint
that returns the immutable per-payment detail alongside the summary.

Acceptance Criteria

  • Downloaded history receipts contain full recipient/amount/status/hash
    detail, not an empty results array
  • Test covers downloading a receipt for a job fetched via the history
    list (not the just-completed in-session job)
  • No regression to the in-session (non-history) receipt download flow

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions