Collection App

🎯 Application Overview

This document demonstrates how to implement a comprehensive collection management system using the Flexbase framework, featuring domain models, workflow states, debt tracking, payment processing, installment management, and enterprise-grade role-based access control. This system is designed to be universally applicable across different collection scenarios including loans, subscriptions, invoices, utilities, memberships, and rent.


📋 Business Requirements

Core Entities:

  • Collection - A debt obligation that needs to be collected (Loans, Invoices, Subscriptions, Dues)

  • Debtor - Entity responsible for paying the debt (Customer, Borrower, Tenant, Subscriber)

  • Creditor - Entity owed the debt (Lender, Company, Landlord, Service Provider)

  • Installment - Scheduled payment due dates and amounts

  • Payment - Actual payment received against installments

  • CollectionAgent - Staff assigned to collect debts

  • CollectionCampaign - Outbound campaigns (calls, emails, letters)

  • PaymentPlan - Negotiated payment arrangements

  • WriteOff - Debt cancellation or settlement

  • Reminder - Automated payment reminders

Workflow Requirements:

  • Debt Origination - Creating collection records from various sources

  • Installment Generation - Automatic or manual schedule creation

  • Payment Application - Recording and matching payments to installments

  • Collection Management - Agent assignment, campaign tracking

  • Payment Negotiation - Creating flexible payment plans

  • Delinquency Handling - Escalation workflows for overdue debts

  • Write-Off Management - Bad debt cancellation process

  • Reporting & Analytics - Collection performance metrics

Role-Based Access Control:

  • Debtor - View own debts and payment history

  • CollectionAgent - Manage assigned collection accounts

  • CollectionManager - Oversee all collections and campaigns

  • Finance - Process payments, manage write-offs

  • Accounting - Review financial reports

  • Admin - Full system access

  • Legal - Manage disputes and settlements


🎯 Business Scenario Adaptations

This collection system is designed to be universally applicable. Here are example adaptations:

Business Scenario
Collection Type
Debtor
Creditor
Example

Banking

Personal Loan

Borrower

Bank

Auto loans, personal loans

Banking

Mortgage

Homeowner

Bank

Home mortgages

Retail

Layaway

Customer

Store

Purchase plans

Healthcare

Medical Bill

Patient

Clinic/Hospital

Treatment bills

Education

Tuition

Student/Parent

School

Semester fees

Utilities

Utility Bill

Customer

Utility Company

Electricity, water

Property

Rent

Tenant

Landlord

Monthly rent

Subscription

Membership

Member

Business

Gym, streaming

Business

Invoice

Client

Vendor

B2B invoices

Credit Cards

Credit Card Bill

Cardholder

Bank

Credit card debt


🧱 Core Collection Modules (In Depth)

1) Collections Module

CollectionsController Features

  • CreateCollection (POST) → Collection.CreateCollection()

  • UpdateCollection (PUT)

  • AssignAgent (POST) → Collection.AssignAgent()

  • PauseCollection (POST) → Collection.Pause()

  • ResumeCollection (POST) → Collection.Resume()

  • WriteOffCollection (POST) → Collection.WriteOff()

  • SettleCollection (POST) → Collection.Settle()

  • GetCollection(s) (GET)

Domain Object: Collection

  • Workflow: CollectionWorkflowState

  • States: Originated → Active → Delinquent → In Collections → Settled/WrittenOff

  • Types: Loan, Invoice, Subscription, Rent, Utility

  • RBAC:

    • Admin/Agent: Create, Update, Assign, Pause, WriteOff

    • Debtor: View own collections

    • Manager: Oversight and reporting


2) Debtors Module

DebtorsController Features

  • RegisterDebtor (POST) → Debtor.RegisterDebtor()

  • UpdateProfile (PUT)

  • Blacklist (POST) → Debtor.Blacklist()

  • Whitelist (POST) → Debtor.Whitelist()

Domain Object: Debtor

  • Workflow: DebtorWorkflowState

  • States: Registered → Active → Blacklisted

  • Profiles: Individual, Business


3) Installments Module

InstallmentsController Features

  • GenerateInstallments (POST) → Collection.GenerateInstallments()

  • UpdateInstallment (PUT)

  • MarkDue (POST) → Installment.MarkDue()

  • MarkOverdue (POST) → Installment.MarkOverdue()

Domain Object: Installment

  • Workflow: InstallmentWorkflowState (Scheduled → Due → Paid → Overdue/Partial)

  • Represents one payment due in a collection schedule


4) Payments Module

PaymentsController Features

  • RecordPayment (POST) → Payment.RecordPayment()

  • AllocatePayment (POST) → Payment.AllocateToInstallment()

  • RefundPayment (POST) → Payment.Refund()

  • GetPaymentHistory (GET)

Domain Object: Payment

  • Workflow: PaymentWorkflowState (Recorded → Allocated → Confirmed/Refunded)

  • Links payments to specific installments


5) Collection Campaigns Module

CampaignsController Features

  • CreateCampaign (POST) → CollectionCampaign.Create()

  • AssignContact (POST) → CollectionCampaign.AssignContact()

  • RecordContact (POST) → ContactRecord.Create()

  • CloseCampaign (POST) → CollectionCampaign.Close()

Domain Object: CollectionCampaign

  • Tracks collection efforts and agent activities

  • Maintains history of all contacts with debtor


6) Payment Plans Module

PaymentPlansController Features

  • CreatePlan (POST) → PaymentPlan.Create()

  • ProposePlan (POST) → PaymentPlan.Propose()

  • AcceptPlan (POST) → PaymentPlan.Accept()

  • RejectPlan (POST) → PaymentPlan.Reject()

Domain Object: PaymentPlan

  • Negotiated arrangements to pay debt over time

  • Different from original payment schedule


📊 Collection Tracking (Audit Trail)

Purpose: Track all changes to collection status, payments, and agent activities with full audit history.

Tracking Events


📚 Collection Calendar (Due Date Tracking)

Purpose: Track all payment due dates and overdue accounts with fast queries.

Data sources:

  • Installment (Scheduled → Due → Paid/Overdue)

  • Payment deadlines by collection/agent

  • Holiday/cutoff date tracking

Recommended schema:


📈 Collection Analytics (Performance Metrics)

Summary Dashboard

Purpose: Executive/operations view with daily/weekly metrics across agents, collection types, and payment performance.

New projection table:


💰 Loan Collection Example (Detailed)

Scenario: Personal Auto Loan

Initial Setup:

Installment Generation:

Payment Application:

Overdue Handling:

Collection Campaign:

Payment Plan Negotiation:


🎯 Key Implementation Notes

Timezone Handling

  • All due dates stored in UTC ticks for fast queries

  • Local dates maintained via TimeZoneId for display

  • Holiday calendars configured per creditor timezone

RBAC Examples

Reporting Endpoints


This design provides a flexible, enterprise-grade collection management system applicable to any debt collection scenario while maintaining clear workflows, role-based access, and comprehensive tracking.

Last updated