Bug
contracts/credit_score/src/lib.rs — days_late is computed as:
let days_late = (paid_at - due_date) / SECS_PER_DAY;
Integer division truncates. A payment made 23 hours 59 minutes late is classified as days_late = 0 — identical to an on-time payment. A payment 25 hours late is days_late = 1. The 1-hour difference between "23:59 late" and "25:01 late" results in dramatically different credit outcomes.
Fix
Use ceiling division so any partial day counts as a full day late:
let secs_late = paid_at.saturating_sub(due_date);
let days_late = (secs_late + SECS_PER_DAY - 1) / SECS_PER_DAY;
Document the rounding policy in a comment. Also apply saturating_sub so on-time payments (where paid_at <= due_date) yield days_late = 0 without panic.
Acceptance Criteria
References
contracts/credit_score/src/lib.rs — days_late calculation, ~line 238
Bug
contracts/credit_score/src/lib.rs—days_lateis computed as:Integer division truncates. A payment made 23 hours 59 minutes late is classified as
days_late = 0— identical to an on-time payment. A payment 25 hours late isdays_late = 1. The 1-hour difference between "23:59 late" and "25:01 late" results in dramatically different credit outcomes.Fix
Use ceiling division so any partial day counts as a full day late:
Document the rounding policy in a comment. Also apply
saturating_subso on-time payments (wherepaid_at <= due_date) yielddays_late = 0without panic.Acceptance Criteria
days_late = 1(ceiling)days_late = 0days_late = 2References
contracts/credit_score/src/lib.rs—days_latecalculation, ~line 238