-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
374 lines (331 loc) · 23.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="favicon.ico" type="image/x-icon">
<title>Finance Planner</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/foundation.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="index.css">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
</head>
<body>
<div class="grid-container" x-data="getData()" x-init="loadData()">
<div class="grid-x grid-padding-x align-right">
<div class="medium-8 cell text-center">
<h1>Finance Planner!</h1>
</div>
<div class="medium-2 cell align-self-middle text-right">
<a class="button secondary" name="compare" @click="enterCompare()" x-show="!compareMode">Compare Mode</a>
<a class="button alert" name="compare" @click="exitCompare()" x-show="compareMode">Exit Compare</a>
</div>
<div class="medium-1 cell align-self-middle text-right">
<a class="button alert" name="reset" @click="reset()">Reset</a>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="medium-6 cell">
<h3>Basic Details</h3>
<form>
<section class="grid-x grid-padding-x">
<label class="small-6 large-4 cell">Base Salary (£)
<sup><span data-tooltip tabindex="1" title="Without bonuses, overtime or things like car allowances." data-trigger-class="">?</span></sup>
<input type="number" placeholder="Enter your salary" name="baseSalary" value="30000"
x-model.number="data.baseSalary" required>
</label>
<label class="small-6 large-4 cell">Additional (£)
<sup><span data-tooltip tabindex="1" title="Total bonuses, overtime or things like car allowances.." data-trigger-class="">?</span></sup>
<input type="number" placeholder="Enter your totalbonuses, overtime, etc. " name="bonuses" value="30000"
x-model.number="data.bonuses" required>
</label>
<label class="small-6 large-4 cell">Increase (%)
<input type="number" placeholder="Enter the salary increase percentage"
name="salaryPercent" value="6" x-model.number="data.salaryPercent" required>
</label>
</section>
<section class="grid-x grid-padding-x">
<h5 class="small-6 cell">
Pension
<sup>
<span data-tooltip tabindex="1" data-trigger-class=""
title="It looks like you're a higher rate tax payer. Make sure you claim tax relief from HMRC if your employer doesn't do it for you."
x-show="data.pensionPercent > 0 && totalSalary() > 50270">
!
</span>
</sup>
</h5>
</section>
<section class="grid-x grid-padding-x">
<label class="small-6 large-4 cell">Contributions (%)
<input type="number" placeholder="Enter your pension contribution percentage" name="pensionPercent"
x-model.number="data.pensionPercent" required>
</label>
<label class="small-6 large-4 cell" x-show="data.pensionPercent > 0" x-transition>Amount (£)
<input type="number" placeholder="Enter your how much you have in your pension" name="pensionValue"
x-model.number="data.pensionValue" required>
</label>
<label class="small-6 large-4 cell" x-show="data.pensionPercent > 0" x-transition>Employer match (%)
<input type="number" placeholder="Enter your how much your emplyer matches up to" name="pensionEmployer"
x-model.number="data.pensionEmployer" required>
</label>
<fieldset class="medium-12 large-4 cell" x-show="data.pensionPercent > 0 && data.bonuses > 0" x-transition>
<input id="pensionBaseCheckbox" type="checkbox" x-model="data.pensionFromBase"><label for="pensionBaseCheckbox">From base salary?</label>
</fieldset>
</section>
<section class="grid-x grid-padding-x">
<label class="small-6 large-4 cell">Student Loan
<select x-model="data.studentLoanType">
<option value="None">None</option>
<option value="Plan1">Plan 1</option>
<option value="Plan2">Plan 2</option>
<option value="Plan4">Plan 4</option>
<option value="Plan5">Plan 5</option>
<option value="PostGrad">Post Graduate</option>
</select>
</label>
<label class="small-6 large-4 cell" x-show="data.studentLoanType!='None'" x-transition>Debt (£)
<input type="number" placeholder="Enter your total student loan debt" name="studentLoanValue"
x-model.number="data.studentLoanValue" required>
</label>
<!-- TODO: Graduation date to do expiry. Maybe an opportunity to do events (i.e. moving money at specific years/conditions) -->
</section>
<section class="grid-x grid-padding-x">
<label class="small-6 large-4 cell" x-transition>Years
<input type="number" placeholder="Enter the number of years to show" name="year"
value="10" x-model.number="data.years" :readonly="compareMode" required>
</label>
<label class="small-6 large-4 cell">Age
<input type="number" placeholder="Enter your age" name="age"
x-model.number="data.age" required>
</label>
</section>
</form>
</div>
<div class="medium-6 cell">
<h3>Pots</h3>
<ul class="accordion" data-accordion data-allow-all-closed="true" name="pots">
<template x-for="(pot, index) in getAllPots()" :key="index">
<li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">
<span x-text="pot.name"></span>
<span class="label secondary" x-show="pot.hide">Hidden</span>
</a>
<div class="accordion-content" data-tab-content>
<div class="grid-x grid-padding-x">
<label class="small-7 cell">Name
<input type="text" placeholder="Enter a name for the pot" name="name"
x-model="pot.name" :readonly="pot.readonly" required>
</label>
<fieldset class="small-5 cell">
<legend>Hide table column?</legend>
<div class="grid-x grid-padding-x">
<div class="medium-12 cell">
<input id="hide" type="checkbox"
x-model="pot.hide" :readonly="pot.readonly" :disabled="pot.readonly">
<label for="tax">Yes</label>
</div>
</div>
</fieldset>
</div>
<div class="grid-x grid-padding-x">
<fieldset class="medium-6 cell">
<legend>Is it a tax?</legend>
<div class="grid-x grid-padding-x">
<div class="medium-12 cell">
<input id="taxCheckbox" type="checkbox" x-model="pot.isTax" :readonly="pot.readonly" :disabled="pot.readonly" >
<label for="tax">Yes</label>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="medium-12 cell">
<input id="taxCheckbox" type="checkbox" x-model="pot.postPension" :readonly="pot.readonly" :disabled="pot.readonly" x-show="pot.isTax">
<label x-show="pot.isTax" for="tax">After Pension?</label>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="medium-12 cell">
<input id="taxCheckbox" type="checkbox" x-model="pot.fromBase" :readonly="pot.readonly" :disabled="pot.readonly" x-show="pot.isTax">
<label x-show="pot.isTax" for="tax">From base salary?</label>
</div>
</div>
</fieldset>
<fieldset class="medium-6 cell">
<legend>
What type of pot is it?
<!-- <sup><span data-tooltip tabindex="1" title="E.g. savings accounts or investments" data-trigger-class="">?</span></sup> -->
</legend>
<input type="radio" :name="'type'+index" x-model="pot.type" value="Cost" :readonly="pot.readonly" :disabled="pot.readonly">
<label for="typeCost">
Cost
</label>
<input type="radio" :name="'type'+index" x-model="pot.type" value="Debt" :readonly="pot.readonly" :disabled="pot.readonly">
<label for="typeDebt">
Debt
</label>
<input type="radio" :name="'type'+index" x-model="pot.type" value="Asset" :readonly="pot.readonly" :disabled="pot.readonly">
<label for="typeAsset">
Asset
<!-- <sup><span data-tooltip tabindex="1" title="E.g. savings accounts or investments" data-trigger-class="">?</span></sup> -->
</label>
</fieldset>
</div>
<div class="grid-x grid-padding-x">
<label class="small-7 cell" x-show="pot.type != 'Cost'" x-transition>Initial Value
<input type="number" placeholder="Enter the initial value of the pot" name="value"
x-model.number="pot.value" :readonly="pot.readonly" required>
</label>
<label class="small-5 cell" x-show="pot.type != 'Cost'" x-transition>Interest
<input type="number" placeholder="Enter the yearly interest" name="value"
x-model.number="pot.interest" :readonly="pot.readonly" required>
</label>
</div>
<hr></hr>
<template x-for="(contribution, index) in [{ 'data': pot.personalContribution}, { 'data': pot.externalContribution, 'external': true} ]" :key="index">
<div x-show="!contribution.external || !(pot.type == 'Cost' || (pot.isTax && pot.readonly && contribution.data.brackets.length == 0) )">
<section class="grid-x grid-padding-x">
<h6 class="small-12 cell" x-text="(contribution.external ? 'External' : 'Personal') + ' Contributions'"></h6>
</section>
<div class="grid-x grid-padding-x" x-show="!pot.isTax">
<div class="small-7 cell">
<input type="number" placeholder="Enter the contribution amount" name="value"
x-model.number="contribution.data.value" :readonly="pot.readonly" required>
</div>
<div class="small-5 cell">
<select x-model="contribution.data.interval" :readonly="pot.readonly">
<option value="Monthly">Monthly</option>
<option value="Yearly">Yearly</option>
</select>
</div>
</div>
<div x-show="pot.isTax">
<template x-for="(bracket, index) in contribution.data.brackets" :key="index">
<div class="grid-x grid-padding-x">
<div class="small-3 cell">
<legend>Threshold (£)</legend>
<input type="number" placeholder="Enter tax interval threshold" name="value"
x-model.number="bracket.threshold" :readonly="pot.readonly" required>
</div>
<div class="small-3 cell">
<legend>Percentage (%)</legend>
<input type="number" placeholder="Enter percentage in this threshold" name="value"
x-model.number="bracket.percentage" :readonly="pot.readonly" required>
</div>
<div class="small-3 cell">
<legend>Add PA</legend>
<input id="taxCheckbox" type="checkbox" x-model="bracket.addPA" :readonly="pot.readonly" :disabled="pot.readonly" >
<!-- <label for="tax">Yes</label> -->
</div>
<div class="small-3 cell align-self-bottom">
<a class="button alert" name="delete_interval"
@click="contribution.external ? deleteInterval(pot.externalContribution.brackets, index) : deleteInterval(pot.personalContribution.brackets, index)"
x-show="!pot.readonly">
Delete
</a>
</div>
</div>
</template>
<div class="grid-x grid-padding-x">
<div class="small-4 cell">
<a class="button success " name="add_interval"
@click="contribution.external ? addInterval(pot.externalContribution.brackets) : addInterval(pot.personalContribution.brackets)"
x-show="!pot.readonly">Add Bracket</a>
</div>
</div>
</div>
</div>
</template>
<div x-show="!pot.readonly">
<hr></hr>
<a class="button alert" name="delete_pot" x-show="!compareMode" @click="deletePot(pot)">Delete Pot</a>
</div>
</div>
</li>
</template>
</ul>
<a class="button success " name="add_pot" @click="addCustomPot()" x-show="!compareMode">Add Custom Pot</a>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="medium-12 cell table-scroll" id="results">
<table>
<thead>
<tr>
<th x-text="data.age > 0 ? 'Age' : 'Year'"></th>
<th>Salary</th>
<th>
Take Home Pay
<sup><span data-tooltip tabindex="1" title="This is your salary after taxes." data-trigger-class="">?</span></sup>
</th>
<th x-show="data.pots.length > 0" x-transition>
Disposable Income
<sup><span data-tooltip tabindex="1" title="This is your salary after all outgoings." data-trigger-class="">?</span></sup>
</th>
<template x-for="(pot, index) in getAllPots()" :key="index">
<th x-show="!pot.hide" x-text="pot.type === 'Cost' ? '(' + pot.name + ')' : pot.name"></th>
</template>
</tr>
</thead>
<tbody>
<template x-for="row in project()" :key="row.year">
<tr>
<td x-text="row.year"></td>
<td>
<span x-text="printMoney(row.salary)"></span>
<span x-show="compareMode && row.change.salary != 0" x-transition
x-text="printChange(row.change.salary)"
:class="row.change.salary > 0 ? 'text-success' : 'text-alert'"></span>
</td>
<td>
<span x-text="printMoney(row.takeHome)"></span>
<span x-show="compareMode && row.change.takeHome != 0" x-transition
x-text="printChange(row.change.takeHome)"
:class="row.change.takeHome > 0 ? 'text-success' : 'text-alert'"></span>
</td>
<td x-show="data.pots.length > 0" x-transition>
<span x-text="printMoney(row.disposable)"></span>
<span x-show="compareMode && row.change.disposable != 0" x-transition
x-text="printChange(row.change.disposable)"
:class="row.change.disposable > 0 ? 'text-success' : 'text-alert'"></span>
</td>
<template x-for="(pot, index) in row.pots" :key="index">
<td x-show="!pot.hide">
<span x-text="pot.type == 'Cost' ? printMoney(pot.contribution) : printMoney(pot.value)"></span>
<span x-show="compareMode && pot.change != 0" x-transition
x-text="printChange(pot.change)"
:class="pot.change > 0 ^ pot.type == 'Debt' ? 'text-success' : 'text-alert'"></span>
</td>
</template>
</tr>
</template>
</tbody>
</table>
</div>
</div>
</div>
<hr></hr>
<footer class="footer grid-container">
<div class="grid-x grid-padding-x align-middle align-center">
<div class="cell small-12 medium-6 text-center medium-text-left">
<a href="https://github.com/jccroft1/ukfinanceplanner/" target="_blank">
<i class="fi-social-github"></i> View on GitHub
</a>
</div>
<div class="cell small-12 medium-6 text-center medium-text-right align-self-bottom">
<p><button class="button secondary" data-open="disclaimerModal">Disclaimer</button></p>
</div>
</div>
</footer>
<div class="reveal" id="disclaimerModal" data-reveal>
<h4>Disclaimer</h4>
<p>This is not financial advice. </p>
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/foundation.min.js" crossorigin="anonymous"></script>
<script src="index.js"></script>
<script>$(document).foundation();</script>
</body>
</html>