Skip to content

Build penalty tier calculator utility #292

Description

@Kingsman-99

Labels: complexity: high

Add a pure utility calculatePenalty(invoice, paymentTimestamp) that computes the penalty amount owed for a late payment based on the invoice's penalty_tiers configuration. This should run client-side without an RPC call.

Acceptance criteria:

  • Takes an Invoice object and a Unix timestamp
  • Returns { penaltyBps: number, penaltyAmount: bigint, tier: number | null }
  • Returns zero penalty when payment is before penalty_deadline
  • Matches contract on-chain penalty logic exactly
  • Unit tested with at least 5 cases including edge cases

Metadata

Metadata

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