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:
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:
CollectionWorkflowStateStates: 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:
DebtorWorkflowStateStates: 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
TimeZoneIdfor displayHoliday 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