Skip to content

Commit

Permalink
Merge pull request #23 from nvisionative/release/1.0.1
Browse files Browse the repository at this point in the history
Merged `release/1.0.1` into `main` for `1.0.1` release
  • Loading branch information
david-poindexter authored Jul 16, 2024
2 parents 805239f + 8da8520 commit b8ad594
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/components/nvq-loan-calculator/nvq-loan-calculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class NvqLoanCalculator {
}

private getValidatedNumber(target: HTMLInputElement, digits: number, defaultValue: number = 0): number {
if (target.value === '') {
target.dataset.lastValidValue = defaultValue.toString();
return undefined;
}

if (target.validity.valid) {
const value = parseFloat(target.value);
const roundedValue = this.roundTo(value, digits);
Expand Down Expand Up @@ -115,6 +120,10 @@ export class NvqLoanCalculator {
}

private calculatePayment() {
if (isNaN(this.downPayment)) {
this.downPayment = 0;
}

// Assuming monthly compounding.
const monthlyInterestRate = this.interestRate / 100 / 12;
if (this.amortizationYears === undefined){
Expand Down Expand Up @@ -176,8 +185,7 @@ export class NvqLoanCalculator {
min={0}
max={this.totalAmount}
step={0.01}
required
value={this.downPayment}
value={this.downPayment > 0 ? this.downPayment : ''}
onKeyDown={e => this.onlyAllowNumbers(e)}
onInput={e => this.downPayment = this.getValidatedNumber(e.target as HTMLInputElement, 2)}
onBlur={e => this.displayErrorIfAny(e.target as HTMLInputElement)}
Expand Down

0 comments on commit b8ad594

Please sign in to comment.