jn-devops / mortgage
Homeful Mortgage Package
                                    Fund package maintenance!
                                                                            
                                                                                                                                        Homeful
                                                                                    
                                                                
Installs: 3 011
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
pkg:composer/jn-devops/mortgage
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- jn-devops/borrower: ^1.0
- jn-devops/common: ^1.1
- jn-devops/payment: ^1.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
- dev-main
- v1.2.86
- v1.2.85
- v1.2.84
- v1.2.83
- v1.2.82
- v1.2.81
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-7
- dev-dependabot/github_actions/actions/checkout-5
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-6
This package is auto-updated.
Last update: 2025-10-13 23:11:46 UTC
README
This package encapsulates the mortgage loan processing logic of the Homeful platform. It manages everything from borrower evaluation to monthly amortization, income requirements, and cash-out computations. The design is modular, chainable, and test-driven.
Installation
composer require homeful/mortgage
โจ Features Overview
- Encapsulated MortgageClass: Central to processing and configuring a mortgage loan.
- Modular Traits: Responsibilities are split across focused, reusable traits.
- Supports Add-on & Deductible Fees: MRI, Fire Insurance, Consulting, Processing fees, etc.
- Dynamic GMI & PV-based Eligibility: Computes present value from disposable income.
- Test-driven: Includes comprehensive real-world loan scenarios with expected outputs.
- Fluent API: Chainable configuration methods (setX()->setY()).
๐ง Trait Responsibilities
๐ข Financial Computation
- HasContractPrice: Manages TCP (Total Contract Price)
- HasDownPayment: Computes down payment and amortization
- HasMiscellaneousFees: Additional fees (computed or set)
- HasMultipliers: Interest rates, income multipliers
- HasTerms: Manages loan balance terms
๐ธ Cash Flow Management
- HasCashOuts: Abstract layer for any outgoing cash items
- HasAddOnFeesToLoanAmortization: Adds MRI & Fire Insurance to monthly amortization
๐ฅ Parties
- HasProperty: Assigns & syncs- Propertyinstance
- HasBorrower: Assigns borrower & GMI rules
๐ Promotions
- HasPromos: Low-cash-out promo logic
- isPromotional(): Detects promotional packages
โ๏ธ Static Config
- HasConfig: Reads default term, interest rate, borrower age from config
๐งฎ Computation Flow
- Validation: Inputs validated using Laravel validator
- Defaults: Loaded from PropertyandBorrowerif not provided
- Processing:
- Down Payment
- Balance Payment
- Miscellaneous Fees
- Cash Outs
- Loan Details (term, interest, income requirement)
 
๐ Formula Highlights
- Balance Payment = TCP โ Down Payment
- Loan Principal = Balance Payment + Balance Misc. Fees
- Loan Amortization = Payment + (MRI + Fire Insurance if applicable)
โ Eligibility Tools
- getLoanDifference(): Checks if borrower can afford based on income
- getPresentValueFromMonthlyDisposableIncomePayments(): PV computation using borrower income
- getJointBorrowerDisposableMonthlyIncome(): Computes combined disposable income
๐งช Test Coverage
Includes over 15 real-world scenarios such as:
- โ Agapeya 70/50 Duplex @ 20, 25, and 30 years
- โ Ter-Je 2BR 40sqm @ 20, 25, 30 years
- โ Low-income housing simulation with โฑ750K TCP
- โ Relaxed GMI multiplier cases (30% vs 35%)
- โ Promo: zero down payment + waived fees
- โ Add-on MRI + Fire Insurance added to monthly amortization
- โ Present Value edge cases
- โ GMI-based maximum loan calculations
- โ
 Full simulation using createWithTypicalBorrower(...)
Each test checks:
- Down Payment (amount + amortization)
- Balance Payment
- Miscellaneous Fees (partial & full)
- Loan Amount
- Loan Amortization
- GMI / Disposable Income & Present Value eligibility
- Add-on and deductible fee mechanics
- Cash out summaries
- Promo eligibility flags
๐ง Design Insights
- Event Driven: Traits dispatch events on update
- Chainable API: Fluent configuration methods
- Precision Math: Uses Brick\Money+Whitecube\Price
- Compliance Ready: Validates ranges for fees, DP, terms
- Fully Tested: Aligns with PMT,PVfinancial functions for accuracy
๐ Key Integrations
- Homeful\Payment\Payment: Loan logic & computation
- Homeful\Property\Property: Provides TCP, MF %, etc.
- Homeful\Borrower\Borrower: Age, income, region
- Homeful\Common\Classes: Shared value object helpers
๐งฐ Usage
use Homeful\Mortgage\Mortgage; use Homeful\Borrower\Borrower; use Homeful\Property\Property; use Homeful\Common\Classes\Input; use Homeful\Mortgage\Data\MortgageData; use Illuminate\Support\Carbon; use Whitecube\Price\Price; $params = [ Input::WAGES => 50000, Input::TCP => 2500000, Input::PERCENT_DP => 5 / 100, Input::DP_TERM => 12, Input::BP_INTEREST_RATE => 7 / 100, Input::PERCENT_MF => 8.5 / 100, Input::BP_TERM => 20, ]; $property = (new Property) ->setTotalContractPrice(Price::of($params[Input::TCP], 'PHP')) ->setAppraisedValue(Price::of($params[Input::TCP], 'PHP')); $borrower = (new Borrower($property)) ->setBirthdate(Carbon::parse('1999-03-17')) ->setGrossMonthlyIncome($params[Input::WAGES]); $mortgage = new Mortgage(property: $property, borrower: $borrower, params: $params); $data = MortgageData::fromObject($mortgage); dd($data->toArray());
๐ Summary
The Mortgage package serves as the computation core for:
- Housing affordability simulations
- Loan qualification engines
- Down payment amortization planners
- Present value loan caps
- Promotional packages with waived fees
- Cross-segment real estate products
Behold, a new you awaits โ with well-structured mortgage processing ๐กโจ