Calculating LTARV and LTC
- March 8, 2025
- 1 reply
- 1675 views
I'm trying to utilize scripts to calculate the LTV, LTARV and LTC as percentages in this pdf. It's not returning values for LTARV and LTC. The LTV calculation is only returning an error if the TransactionType field contains "Purchase" and the PurchasePrice field is left blank (which is correct). I've attached the form for reference.
Here's the formula that chat gpt advised for the LTARV:
// Get the values from the fields
var loanAmount = this.getField("LoanAmount").value;
var asRepairedValue = this.getField("AsRepairedValue").value;
var loanType = this.getField("LoanType").value;
// Initialize the LTARV result
var ltarvResult = "";
// Check the LoanType and calculate LTARV or set the value to "N/A"
if (loanType === "Bridge w/ Rehab" || loanType === "Ground Up Construction") {
if (asRepairedValue != 0) {
ltarvResult = loanAmount / asRepairedValue;
} else {
ltarvResult = "N/A";
}
} else if (loanType === "Stabilized Bridge" || loanType === "DSCR") {
ltarvResult = "N/A";
}
// Set the value of LTARV field
event.value = ltarvResult;
The formula that was advised for the LTC is:
var loanAmount = this.getField("LoanAmount").value; var costBasis = this.getField("costBasis").value; var LTC; if (!isNaN(loanAmount) && !isNaN(costBasis)) { LTC = laonAmount / costBasis; } else { event.value = "Error"; } if (costBasis !== 0) { // Avoid division by zero event.value = loanAmount / costBasis; } else { event.value = "Infinity or Error"; }
