Skip to content

Build invoice payment reconciler #117

@Kingsman-99

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

The funded amount on an invoice may drift from the sum of individual payment records due to edge cases. This issue adds reconcilePayments(invoiceId) that fetches both the invoice state and all payment events, detects discrepancies, and returns a typed reconciliation report.

Technical Context

Involves a new src/reconciler.ts. Fetch invoice via getInvoice and payments via getPayments. Sum payment amounts and compare to invoice.funded. Define ReconciliationReport = { invoiceId: string; invoiceFunded: bigint; paymentsSum: bigint; discrepancy: bigint; reconciled: boolean }.

Acceptance Criteria

  • reconcilePayments(invoiceId: string): Promise<ReconciliationReport> exported
  • reconciled: true when invoiceFunded === paymentsSum
  • discrepancy is absolute difference between the two values
  • ReconciliationReport type exported from src/index.ts
  • Test verifies discrepancy detected when values differ
  • All existing tests pass
  • TypeScript strict mode — zero any types

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions