tidy up calculate loan schedule validation.
This commit is contained in:
+17
-6
@@ -109,10 +109,6 @@ validation.msg.loan.transaction.id.is.invalid=Loan transaction identifier is inv
|
||||
validation.msg.loan.state.transition.date.cannot.be.blank=A date must be provided when transitioning the loan into this state.
|
||||
validation.msg.note.exceeds.max.length=The content of the note exceeds max length of 1000 characters.
|
||||
|
||||
validation.msg.loan.repayment.date.cannot.be.blank=The repayment date cannot be blank.
|
||||
validation.msg.loan.repayment.must.be.greater.than.zero=The repayment amount must be a number greater than zero.
|
||||
validation.msg.loan.adjustment.must.be.zero.or.greater=The repayment amount must be a number greater than or equal to zero.
|
||||
|
||||
# loan event and transactions screens
|
||||
label.loan.on=On:
|
||||
label.loan.action.note=Note:
|
||||
@@ -128,7 +124,6 @@ dialog.title.waive.loan=Waive outstanding amount
|
||||
label.loan.transaction.on=Repayment on:
|
||||
label.loan.transaction.amount=Amount:
|
||||
|
||||
|
||||
tab.client.account.loan.details=Details
|
||||
tab.client.account.loan.schedule=Schedule
|
||||
tab.client.account.loan.repayments=Repayments
|
||||
@@ -211,7 +206,23 @@ form.label.loan.interest.charged.from=Interest charged from:
|
||||
form.label.loan.expected.disbursement.date.on=Expected disbursement on:
|
||||
form.label.loan.first.repayment.on=First repayment on:
|
||||
|
||||
validation.msg.loan.expectedDisbursementDate.method.cannot.be.blank=Expected disbursement on field cannot be blank.
|
||||
validation.msg.loan.digitsAfterDecimal.cannot.be.blank=You must enter a number to represent number of digits after decimal to be supported for product.
|
||||
validation.msg.loan.digitsAfterDecimal.is.not.within.expected.range=Decimal places must be a number between {1} and {2} inclusive.
|
||||
validation.msg.loan.repaymentEvery.cannot.be.blank=Repaid every cannot be blank.
|
||||
validation.msg.loan.repaymentEvery.not.greater.than.zero=Repaid every must be greater than 0.
|
||||
validation.msg.loan.numberOfRepayments.cannot.be.blank=# of repayments cannot be blank.
|
||||
validation.msg.loan.numberOfRepayments.not.greater.than.zero=# of repayments must be greater than 0.
|
||||
validation.msg.loan.principal.cannot.be.blank=Loan amount cannot be blank.
|
||||
validation.msg.loan.inArrearsTolerance.cannot.be.blank=Arrears tolerance cannot be blank.
|
||||
validation.msg.loan.interestRatePerPeriod.cannot.be.blank=Nominal interest rate % cannot be blank.
|
||||
validation.msg.loan.principal.not.greater.than.zero=Loan amount must be greater than zero.
|
||||
validation.msg.loan.inArrearsTolerance.not.zero.or.greater=Arrears tolerance must be greater than or equal to zero.
|
||||
validation.msg.loan.interest.rate.per.period.amount.cannot.be.negative=Nominal interest rate % cannot be negative.
|
||||
validation.msg.loan.repayment.date.cannot.be.blank=The repayment date cannot be blank.
|
||||
validation.msg.loan.repayment.must.be.greater.than.zero=The repayment amount must be a number greater than zero.
|
||||
validation.msg.loan.adjustment.must.be.zero.or.greater=The repayment amount must be a number greater than or equal to zero.
|
||||
|
||||
validation.msg.loan.expectedDisbursementDate.cannot.be.blank=Expected disbursement on field cannot be blank.
|
||||
validation.msg.loan.expectedDisbursementDate.cannot.be.after.first.repayment.date=Expected disbursement date cannot be after the first repayment date.
|
||||
validation.msg.loan.interestCalculatedFromDate.must.be.entered.when.using.repayments.startfrom.field=The date interest is to be calculated from cannot be left blank when a date is provided for when repayments start from.
|
||||
validation.msg.loan.submitted.on.date.cannot.be.blank=Submitted on date cannot be blank.
|
||||
|
||||
+33
-21
@@ -55,9 +55,28 @@ $(document).ready(function() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
globalDate: function(localDateAsISOString) {
|
||||
globalDate: function(dateParts) {
|
||||
try {
|
||||
if (localDateAsISOString === null) return "";
|
||||
|
||||
if (dateParts === null || dateParts === '') return "";
|
||||
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
var day = dateParts[2];
|
||||
|
||||
var d = new Date();
|
||||
d.setFullYear(year,month,day);
|
||||
|
||||
return Globalize.format(d,"dd MMMM yyyy");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
},
|
||||
globalDateAsISOString: function(localDateAsISOString) {
|
||||
|
||||
try {
|
||||
if (localDateAsISOString === null || localDateAsISOString === '') return "";
|
||||
|
||||
var dateParts = localDateAsISOString.split("-")
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
@@ -177,13 +196,13 @@ $(document).ready(function() {
|
||||
};
|
||||
|
||||
function calculateAnnualPercentageRate() {
|
||||
var periodInterestRate = parseFloat($('#interestRatePerPeriodFormatted').val());
|
||||
var periodInterestRate = parseFloat($('#interestRatePerPeriod').val());
|
||||
if (isNaN(periodInterestRate)) {
|
||||
periodInterestRate = 0;
|
||||
}
|
||||
|
||||
var periodsInYear = 12;
|
||||
var periodType = $('#interestRateFrequencyMethod').val();
|
||||
var periodType = $('#interestRateFrequencyType').val();
|
||||
if (periodType == 3) {
|
||||
periodsInYear = 1;
|
||||
} else if (periodType == 2) {
|
||||
@@ -207,7 +226,6 @@ $(document).ready(function() {
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
@@ -228,7 +246,7 @@ $(document).ready(function() {
|
||||
calculateLoanSchedule();
|
||||
|
||||
// change detection
|
||||
$('#principalFormatted').change(function() {
|
||||
$('#principal').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
@@ -236,7 +254,7 @@ $(document).ready(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#repaymentFrequency').change(function() {
|
||||
$('#repaymentFrequencyType').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
@@ -244,37 +262,37 @@ $(document).ready(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#expectedDisbursementDateFormatted').change(function() {
|
||||
$('#expectedDisbursementDate').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#repaymentsStartingFromDateFormatted').change(function() {
|
||||
$('#repaymentsStartingFromDate').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#interestRatePerPeriodFormatted').change(function() {
|
||||
$('#interestRatePerPeriod').change(function() {
|
||||
calculateAnnualPercentageRate();
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#interestRateFrequencyMethod').change(function() {
|
||||
$('#interestRateFrequencyType').change(function() {
|
||||
calculateAnnualPercentageRate();
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#amortizationMethod').change(function() {
|
||||
$('#amortizationType').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#interestMethod').change(function() {
|
||||
$('#interestType').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#interestCalculationPeriodMethod').change(function() {
|
||||
$('#interestCalculationPeriodType').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
$('#interestCalculatedFromDateFormatted').change(function() {
|
||||
$('#interestChargedFromDate').change(function() {
|
||||
calculateLoanSchedule();
|
||||
});
|
||||
|
||||
@@ -302,7 +320,6 @@ $(document).ready(function() {
|
||||
var calculateLoanScheduleurl = baseApiUrl + 'loans?command=calculateLoanSchedule';
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr2 = $.ajax({
|
||||
url: calculateLoanScheduleurl,
|
||||
@@ -312,7 +329,6 @@ $(document).ready(function() {
|
||||
data: newFormData,
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
@@ -332,7 +348,6 @@ $(document).ready(function() {
|
||||
var submitLoanApplicationUrl = baseApiUrl + 'loans';
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr2 = $.ajax({
|
||||
url: submitLoanApplicationUrl,
|
||||
@@ -342,11 +357,9 @@ $(document).ready(function() {
|
||||
data: newFormData,
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
@@ -368,7 +381,6 @@ $(document).ready(function() {
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{{#each scheduledLoanInstallments}}
|
||||
<tr>
|
||||
<td>{{=$ctx.number(installmentNumber)}}</td>
|
||||
<td>{{=$ctx.globalDate(periodEnd)}}</td>
|
||||
<td>{{=$ctx.globalDateAsISOString(periodEnd)}}</td>
|
||||
<td>{{=$ctx.money(principalDue)}}</td>
|
||||
<td>{{=$ctx.money(interestDue)}}</td>
|
||||
<td>{{=$ctx.money(totalInstallmentDue)}}</td>
|
||||
@@ -54,7 +54,7 @@
|
||||
<form id="entityform">
|
||||
<div id="formerrors"></div>
|
||||
|
||||
<input type="hidden" id="applicantId" name="applicantId" value="{{=clientId}}" />
|
||||
<input type="hidden" id="clientId" name="clientId" value="{{=clientId}}" />
|
||||
<input type="hidden" id="currencyCode" name="currencyCode" value="{{=selectedProduct.principalMoney.currencyCode}}" />
|
||||
<input type="hidden" id="digitsAfterDecimal" name="digitsAfterDecimal" value="{{=$ctx.number(selectedProduct.principalMoney.currencyDigitsAfterDecimal)}}" />
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
<td style="text-align:right;vertical-align:bottom;width:50px;"> </td>
|
||||
<td valign="top">
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="submittedOnDateFormatted"><spring:message code="form.label.loan.submitted.on"/></label>
|
||||
<input id="submittedOnDateFormatted" name="submittedOnDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(submittedOnDate)}}" />
|
||||
<label for="submittedOnDate"><spring:message code="form.label.loan.submitted.on"/></label>
|
||||
<input id="submittedOnDate" name="submittedOnDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(submittedOnDate)}}" />
|
||||
|
||||
<label for="submittedOnNote"><spring:message code="form.label.loan.submitted.on.note"/></label>
|
||||
<textarea id="submittedOnNote" name="submittedOnNote" rows="2" cols="50" draggable="false">{{=submittedOnNote}}</textarea>
|
||||
@@ -103,7 +103,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.loan.amount"/></td>
|
||||
<td>
|
||||
<input id="principalFormatted" name="principalFormatted" title="" type="text" value="{{=$ctx.money(selectedProduct.principalMoney)}}" style="width: 125px;" />
|
||||
<input id="principal" name="principal" title="" type="text" value="{{=$ctx.money(selectedProduct.principalMoney)}}" style="width: 125px;" />
|
||||
<input id="principalCurrencyCode" name="principalCurrencyCode" title="" type="text" value="{{=selectedProduct.principalMoney.displaySymbol}}" style="width: 40px;" disabled="disabled" />
|
||||
</td>
|
||||
</tr>
|
||||
@@ -112,7 +112,7 @@
|
||||
<td>
|
||||
<input id="repaymentEvery" name="repaymentEvery" title="" type="text" value="{{=$ctx.number(selectedProduct.repaidEvery)}}" style="width: 50px;" />
|
||||
|
||||
<select name="repaymentFrequency" id="repaymentFrequency" title="" style="width: 121px;">
|
||||
<select name="repaymentFrequencyType" id="repaymentFrequencyType" title="" style="width: 121px;">
|
||||
{{#each selectedProduct.repaymentFrequencyOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.selectedProduct.repaymentPeriodFrequency)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -132,13 +132,13 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.expected.disbursement.date.on"/></td>
|
||||
<td>
|
||||
<input id="expectedDisbursementDateFormatted" name="expectedDisbursementDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(expectedDisbursementDate)}}" style="width:172px;"/>
|
||||
<input id="expectedDisbursementDate" name="expectedDisbursementDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(expectedDisbursementDate)}}" style="width:172px;"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.first.repayment.on"/></td>
|
||||
<td>
|
||||
<input id="repaymentsStartingFromDateFormatted" name="repaymentsStartingFromDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(repaymentsStartingFromDate)}}" style="width:172px;"/>
|
||||
<input id="repaymentsStartingFromDate" name="repaymentsStartingFromDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(repaymentsStartingFromDate)}}" style="width:172px;"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -149,9 +149,9 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.nominal.interestrate"/></td>
|
||||
<td>
|
||||
<input id="interestRatePerPeriodFormatted" name="interestRatePerPeriodFormatted" title="" type="text" value="{{=$ctx.decimal(selectedProduct.interestRatePerPeriod, 4)}}" style="width: 60px;" />
|
||||
<input id="interestRatePerPeriod" name="interestRatePerPeriod" title="" type="text" value="{{=$ctx.decimal(selectedProduct.interestRatePerPeriod, 4)}}" style="width: 60px;" />
|
||||
|
||||
<select name="interestRateFrequencyMethod" id="interestRateFrequencyMethod" title="" style="width: 115px;">
|
||||
<select name="interestRateFrequencyType" id="interestRateFrequencyType" title="" style="width: 115px;">
|
||||
{{#each selectedProduct.interestFrequencyOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.selectedProduct.interestRatePeriod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -171,7 +171,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.amortization"/></td>
|
||||
<td>
|
||||
<select name="amortizationMethod" id="amortizationMethod" title="" style="width: 178px;">
|
||||
<select name="amortizationType" id="amortizationType" title="" style="width: 178px;">
|
||||
{{#each selectedProduct.possibleAmortizationOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.selectedProduct.amortizationMethod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -185,7 +185,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.interest.method"/></td>
|
||||
<td>
|
||||
<select name="interestMethod" id="interestMethod" title="" style="width: 180px;">
|
||||
<select name="interestType" id="interestType" title="" style="width: 180px;">
|
||||
{{#each selectedProduct.possibleInterestOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.selectedProduct.interestMethod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -199,7 +199,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.interest.rate.calcutated.in.period"/></td>
|
||||
<td>
|
||||
<select id="interestCalculationPeriodMethod" name="interestCalculationPeriodMethod" title="" style="width: 220px;">
|
||||
<select id="interestCalculationPeriodType" name="interestCalculationPeriodType" title="" style="width: 220px;">
|
||||
{{#each selectedProduct.possibleInterestRateCalculatedInPeriodOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.selectedProduct.interestRateCalculatedInPeriod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -213,13 +213,13 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.interest.charged.from"/></td>
|
||||
<td>
|
||||
<input id="interestCalculatedFromDateFormatted" name="interestCalculatedFromDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(interestCalculatedFromDate)}}" style="width:172px;"/>
|
||||
<input id="interestChargedFromDate" name="interestChargedFromDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(interestCalculatedFromDate)}}" style="width:172px;"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.arrears.tolerance"/></td>
|
||||
<td>
|
||||
<input id="inArrearsToleranceAmountFormatted" name="inArrearsToleranceAmountFormatted" title="" type="text" value="{{=$ctx.money(selectedProduct.inArrearsTolerance)}}" style="width: 125px;" />
|
||||
<input id="inArrearsTolerance" name="inArrearsTolerance" title="" type="text" value="{{=$ctx.money(selectedProduct.inArrearsTolerance)}}" style="width: 125px;" />
|
||||
<input id="inArrearsCurrencyCode" name="inArrearsCurrencyCode" title="" type="text" value="{{=selectedProduct.inArrearsTolerance.displaySymbol}}" style="width: 40px;" disabled="disabled" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user