Skip to content

Add invoice payment velocity tracker#352

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
wendypetersondev:feat/invoice-velocity-tracker
Jun 27, 2026
Merged

Add invoice payment velocity tracker#352
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
wendypetersondev:feat/invoice-velocity-tracker

Conversation

@wendypetersondev

@wendypetersondev wendypetersondev commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Closes #143
Implements issue #143: Add invoice payment velocity tracker.

Adds SDK method to analyze how quickly payments are arriving for invoices, identifying fast-filling and stalled payment patterns.

Changes

  • src/velocityTracker.ts: New velocity tracking module

    • trackVelocity(address, client) fetches all invoices for creator and computes analytics
    • Calculates paymentsPerDay from actual payment timestamps
    • Classifies trend based on comparing first-half vs second-half payment rates
    • Supports three trend classifications: accelerating, steady, stalling
  • Type Exports: VelocityReport, InvoiceVelocity, PaymentTrend

    • VelocityReport: address and array of invoice velocity metrics
    • InvoiceVelocity: invoiceId, paymentsPerDay, trend
    • PaymentTrend: type union of trend classifications
  • Tests: 4 new tests covering:

    • paymentsPerDay calculation from timestamps
    • Stalling trend detection (early payment concentration)
    • Accelerating trend detection (late payment concentration)
    • Steady trend detection (even payment distribution)

Verification

✓ All 51 tests pass (47 existing + 4 new velocity tests)
✓ TypeScript strict mode (zero any types)
✓ trackVelocity function exported and fully typed
✓ VelocityReport and PaymentTrend types exported
✓ Trend classification verified with test data

Technical Details

  • Fetches all invoices for address with pagination support (50 items per page)
  • Filters payments to include only those with timestamps
  • Computes rate as payments per day over full time span
  • Trend analysis: splits payments into two halves, compares rates with 20% threshold
  • Gracefully handles invoices with 0-1 payments (classified as 'steady')

Usage Example

import { trackVelocity } from '@stellar-split/sdk';

const report = await trackVelocity(creatorAddress, client);
// report.invoices[0].trend === 'accelerating' | 'steady' | 'stalling'
// report.invoices[0].paymentsPerDay === 2.5

wendypetersondev and others added 2 commits June 27, 2026 02:47
- Add src/velocityTracker.ts with trackVelocity function
- Compute paymentsPerDay from actual payment timestamps
- Classify trends: accelerating, steady, stalling
- Compare first-half vs second-half payment rates for trend analysis
- Export VelocityReport, InvoiceVelocity, PaymentTrend types
- Add 4 new tests verifying velocity calculations and trend classification
- All 51 tests pass, TypeScript strict mode compliance
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@wendypetersondev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99 Kingsman-99 merged commit 2dfd9e9 into Stellar-split:main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add invoice payment velocity tracker

2 participants