Skip to content

Feat: implement loan installment due date tracking#41

Merged
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Oluwatos94:feat/loan-installment-due-date-tracking
Jun 28, 2026
Merged

Feat: implement loan installment due date tracking#41
EmeditWeb merged 1 commit into
StepFi-app:mainfrom
Oluwatos94:feat/loan-installment-due-date-tracking

Conversation

@Oluwatos94

Copy link
Copy Markdown
Contributor

Closes #22

Description

Completes loan installment due-date tracking in the creditline contract. Adds an
is_on_time() helper to RepaymentInstallment and enforces that every installment
carries a concrete, future due date before a loan can be activated. (The due_date
and paid_at fields, paid_at captures on repayment, and timing-based reputation
updates were already present; this PR fills the remaining gaps.)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changes Made

  • types.rs: Add RepaymentInstallment::is_on_time() → returns paid && paid_at <= due_date
    (paying exactly on the due date counts as on time; unpaid installments are never on time).
  • errors.rs: Add InvalidDueDate = 27 error variant.
  • lib.rs: approve_loan now rejects loans with an empty schedule or any installment whose
    due_date is 0 (unset) or already in the past. Caller-supplied schedules are preserved —
    nothing is overwritten. The check runs after the existing status/auth checks, so those errors
    still take precedence.

Testing

  • Tests pass locally — cargo test -p creditline-contract: 113 passed, 0 failed
  • New tests added (if applicable)
    • test_installment_is_on_time — early / exact / late / unpaid cases
    • test_repay_installment_on_time_reflected_by_is_on_time
    • test_repay_installment_late_reflected_by_is_on_time
    • test_approve_loan_rejects_zero_due_date
    • test_approve_loan_rejects_past_due_date
Screenshot 2026-06-28 194708

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex code
  • Documentation updated — n/a (no user-facing docs affected)
  • No new warnings generated — cargo clippy -p creditline-contract is clean

@Oluwatos94

Copy link
Copy Markdown
Contributor Author

@EmeditWeb, This is ready for review. Thanks!

@EmeditWeb EmeditWeb merged commit 7bfda62 into StepFi-app:main Jun 28, 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.

core: implement loan installment due date tracking

2 participants