I have this do while look in JavaScript:
var dscr2 = 0.0;
var yield_on_debt = 0.0;
var interestCover = 0.0;
do {
loanAmount = loanAmount - 5000;
$scope.QuickQuoteData.LTV = loanAmount / propertyValue * 100.0;
if ($scope.QuickQuoteData.LTV <= 70.0) {
if ($scope.QuickQuoteData.LTV <= 55.0) {
$scope.minmargin = 5.5;
$scope.maxmargin = 6.0;
$scope.amortisation = 0.0;
}
else if ($scope.QuickQuoteData.LTV > 55.0 && $scope.QuickQuoteData.LTV <= 60.0) {
$scope.minmargin = 6.0;
$scope.maxmargin = 6.5;
$scope.amortisation = 1.0;
}
else if ($scope.QuickQuoteData.LTV > 60.0 && $scope.QuickQuoteData.LTV <= 65.0) {
$scope.minmargin = 6.5;
$scope.maxmargin = 7.0;
$scope.amortisation = 2.0;
}
else if ($scope.QuickQuoteData.LTV > 65.0 && $scope.QuickQuoteData.LTV >= 70.0) {
$scope.minmargin = 7.0;
$scope.maxmargin = 7.5;
$scope.amortisation = 3.0;
}
var annualInterest = loanAmount * (0 + $scope.maxmargin) / 100.0;
var annualAmortisation = loanAmount / $scope.maxmargin / 100.0;
interestCover = annualRent / annualInterest;
dscr2 = (annualRent - annualInterest) / annualAmortisation;
yield_on_debt = (annualRent / loanAmount) * 100;
}
}
while ($scope.QuickQuoteData.LTV >= 70.0 && interestCover < 1.3 && dscr2 < 1.1 && yield_on_debt < 10.0);
The while condition doesn't really work with multiple conditions.
So for example once LTV will reach value of 70, althought the interestCover is > 1.3 the while loop is done.
Am I missing anything?