Skip to content

Commit

Permalink
added future value of money view and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekVance committed Aug 29, 2018
1 parent e53aabc commit 069ca26
Show file tree
Hide file tree
Showing 9 changed files with 2,189 additions and 2,074 deletions.
4,140 changes: 2,070 additions & 2,070 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CashFlowComponent } from './cash-flow/cash-flow.component';
import { FutureValueComponent } from './future-value/future-value.component';

const routes: Routes = [
{ path: 'cash-flow', component: CashFlowComponent }
{ path: 'cash-flow', component: CashFlowComponent },
{ path: 'future-value', component: FutureValueComponent }
];

@NgModule({
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
Financial Formulas
</a>
<div class="navbar-dropdown">
<a class="navbar-item" routerLink="/future-value-of-money">
<a class="navbar-item" routerLink="/future-value">
Future Value of Money
</a>
<a class="navbar-item" routerLink="/present-value-of-money">
<a class="navbar-item" routerLink="/present-value">
Present Value of Money
</a>
<a class="navbar-item" routerLink="/time-to-double-investment">
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './/app-routing.module';
import { CashFlowComponent } from './cash-flow/cash-flow.component';
import { FutureValueComponent } from './future-value/future-value.component';

@NgModule({
declarations: [
AppComponent,
CashFlowComponent
CashFlowComponent,
FutureValueComponent
],
imports: [
BrowserModule,
Expand Down
7 changes: 7 additions & 0 deletions src/app/future-value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class FutureValue {
present: number;
years: number;
rate: number;
compound: number;
futureValue: string;
}
41 changes: 41 additions & 0 deletions src/app/future-value/future-value.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<h3>Future Value of Money</h3>
<div class="columns">
<div class="column">
<div class="field">
<label class="label">Present Value</label>
<div class="control">
<input (keyup)="calulateFutureValue()" [(ngModel)]="FutureValue.present" class="input" type="text">
</div>
</div>
<div class="field">
<label class="label">Years</label>
<div class="control">
<input (keyup)="calulateFutureValue()" [(ngModel)]="FutureValue.years" class="input" type="text">
</div>
</div>
<div class="field">
<label class="label">Compound Type</label>
<div class="select">
<select (change)="calulateFutureValue()" [(ngModel)]="FutureValue.compound">
<option value="0">Please Select Compound Type</option>
<option value="1">Anually</option>
<option value="2">Semianually</option>
<option value="3">Quarterly</option>
<option value="12">Monthly</option>
</select>
</div>
</div>
</div>
<div class="column">
<h1>Cold Hard Cash</h1>
<h3>{{ FutureValue.futureValue }}</h3>
</div>
<div class="column">
<p>
Cash flow is a movement of money in and out of a businesses, projects, or
investments. It can be used to also calculate the internal rate of return or
the net present value. Cash flow gives insight to a businesses liquidity,
being profitable does not equally compare to a companies liquid assets.
</p>
</div>
</div>
Empty file.
25 changes: 25 additions & 0 deletions src/app/future-value/future-value.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { FutureValueComponent } from './future-value.component';

describe('FutureValueComponent', () => {
let component: FutureValueComponent;
let fixture: ComponentFixture<FutureValueComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FutureValueComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FutureValueComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
38 changes: 38 additions & 0 deletions src/app/future-value/future-value.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component, OnInit } from '@angular/core';
import { FutureValue } from '../future-value'

@Component({
selector: 'app-future-value',
templateUrl: './future-value.component.html',
styleUrls: ['./future-value.component.scss']
})
export class FutureValueComponent implements OnInit {

FutureValue: FutureValue = {
present: 0,
years: 0,
rate: 0,
compound: 0,
futureValue: '$ 0'
}

calulateFutureValue(event: any) {
console.log('here')
const rate = this.FutureValue.years / 100
const numberOfPeriods = this.FutureValue.years * this.FutureValue.compound
const rateOfReturn = rate / this.FutureValue.compound
console.log('rate', rate, 'number of periods', numberOfPeriods, 'rate of return', rateOfReturn);

this.FutureValue.futureValue = '$ ' + (this.FutureValue.present * Math.pow( ( 1 + rateOfReturn ), numberOfPeriods ) ).toFixed(2)
// if (this.FutureValue.futureValue === '$ NaN') {
// this.FutureValue.futureValue = '$ 0'
// }
console.log(this.FutureValue.futureValue)
}

constructor() { }

ngOnInit() {
}

}

0 comments on commit 069ca26

Please sign in to comment.