Design the Approval Logic
By the end of this lesson, you'll be able to:
- Design a Loan_Application__c object and the approval rules it needs to enforce
- Translate a lending policy into precise, testable conditions
- Recognize this module's shift toward formal, automated testing from the start
Prerequisites: Module 31: "Apex Testing"
What we're building
"Given a loan application's requested amount, the applicant's annual
income, and their credit score, automatically calculate a monthly
payment and decide whether to pre-approve, refer for manual review,
or decline — following a fixed lending policy."
Modules 26, 27, and 30 each ended with a "Test the Feature" lesson doing manual Execute Anonymous verification. This module folds Module 31's toolkit in from the start — every lesson from here on either builds logic or writes real @isTest coverage for it.
The data model
Loan_Application__c
- Requested_Amount__c (Currency)
- Annual_Income__c (Currency)
- Credit_Score__c (Number)
- Interest_Rate__c (Percent, calculated)
- Monthly_Payment__c (Currency, calculated)
- Status__c (Picklist: Pre-Approved, Manual Review, Declined)
Module 12's "find the nouns" technique applied once more: the object holds what's asked for and what's known about the applicant; Interest_Rate__c, Monthly_Payment__c, and Status__c are all computed by Apex, not entered by hand.
Translating the lending policy into precise conditions
A real lending policy, stated precisely enough to code against directly:
- Credit score 700+ and loan amount ≤ 40% of annual income → Pre-Approved.
- Credit score 600-699 → always Manual Review, regardless of amount.
- Credit score below 600 → Declined.
Stating these as three clean, mutually exclusive conditions now — rather than discovering ambiguity mid-implementation — is exactly Module 26's "Design the Requirement" discipline, applied to a genuinely more complex rule set.
Exercise
As a comment, classify each scenario using the policy above: (1) credit score 720, loan is 30% of income, (2) credit score 650, loan is 10% of income, (3) credit score 580.
Show hint
Apply the three rules in order.
Design the Approval Logic Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
This module builds a loan pre-approval engine — and unlike every previous project, tests it formally with @isTest from the very beginning, rather than manual verification followed by a testing lesson at the end.