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
Labels: complexity: high
Add a pure utility
calculatePenalty(invoice, paymentTimestamp)that computes the penalty amount owed for a late payment based on the invoice'spenalty_tiersconfiguration. This should run client-side without an RPC call.Acceptance criteria:
Invoiceobject and a Unix timestamp{ penaltyBps: number, penaltyAmount: bigint, tier: number | null }penalty_deadline