UNPKG

@wealthx/borrow-capacity-lib

Version:
91 lines (90 loc) 4.28 kB
import { LVRCalculationParams, EquityCalculationParams, ExcessMonthlySurplusParams, PropertiesEstimatedValueParams, MortgageLoanParams, LenderInfoResult, EquityData, EquityFromAccountsParams, BuyingGoalParams, BuyingPowerParams } from "../types/calculations.types"; import { Account, Property } from "../types/finance.types"; export declare function calculateCashAvailable(accounts: Account[]): number; export declare function calculateLiability(accounts: Account[]): number; /** * Calculate Loan-to-Value Ratio (LVR) as a percentage * LVR = (Mortgage Loan / Properties Estimated Value) * 100 * * @param params.mortgageLoan - Total mortgage loan amount (positive number) * @param params.propertiesEstimatedValue - Total estimated value of properties * @returns LVR as percentage (0-100), returns 0 if no properties, 100 if mortgage >= property value */ export declare function calculateLVR(params: LVRCalculationParams): number; /** * Calculate property equity amount * Equity = Properties Estimated Value - Mortgage Loan Amount * * @param params.propertiesEstimatedValue - Total estimated value of properties * @param params.mortgageLoan - Total mortgage loan amount (positive number) * @returns Equity amount (minimum 0) */ export declare function calculateEquity(params: EquityCalculationParams): number; /** * Calculate excess monthly surplus * Excess Monthly Surplus = max(Total Income + Total Expense, 0) * Note: totalExpense is expected to be negative in the backend * * @param params.totalIncome - Total monthly income (positive) * @param params.totalExpense - Total monthly expense (negative value) * @returns Excess monthly surplus (minimum 0) */ export declare function calculateExcessMonthlySurplus(params: ExcessMonthlySurplusParams): number; /** * Calculate total estimated value of properties * * @param params.properties - Array of properties with estimate values * @returns Total estimated value of all properties */ export declare function calculatePropertiesEstimatedValue(params: PropertiesEstimatedValueParams): number; /** * Calculate total mortgage loan amount from accounts linked to properties * * @param params.accounts - Array of accounts with balance and type information * @param params.propertyLinkedAccountIds - Set of account IDs linked to properties * @returns Total mortgage loan amount (positive number) */ export declare function calculateMortgageLoan(params: MortgageLoanParams): number; /** * Extract lender information from mortgage accounts * * @param accounts - Array of account data * @returns Object containing lender names, short names, and interest rates */ export declare function getLenderInfo(accounts: Account[]): LenderInfoResult; /** * Get linked property account IDs from properties * * @param properties - Array of properties with accountIds * @returns Set of account IDs linked to properties */ export declare function getLinkedPropertyAccountIds(properties: Property[]): Set<string>; /** * Calculate comprehensive finance summary including equity, properties value, and mortgage loan * This combines property data with account data to calculate key financial metrics * * @param params.properties - Array of properties with estimates and linked account IDs * @param params.accounts - Array of accounts with balances and types * @returns Object containing equity, properties estimated value, and mortgage loan amount */ export declare function calculateEquityData(params: EquityFromAccountsParams): EquityData; /** * Calculate buying goal * Buying Goal = Cash Available + Equity + Desired Loan Amount * * @param params.cashAvailable - Cash available * @param params.equity - Equity * @param params.desiredLoanAmount - Desired loan amount * @returns Buying goal */ export declare function calculateBuyingGoal(params: BuyingGoalParams): number; /** * Calculate buying power * Buying Power = Cash Available + Equity + Max Loan Amount. * * @param params.cashAvailable - Cash available * @param params.equity - Equity * @param params.maxLoanAmount - Max loan amount * @returns Buying power */ export declare function calculateBuyingPower(params: BuyingPowerParams): number;