-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc.html
119 lines (103 loc) · 2.8 KB
/
calc.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
function getDaysInMonth(month, year) {
return new Date(year, month+1, 0).getDate();
}
$(document).ready(function(){
date = new Date();
function calcProrateFromToday() {
daysInMonth = getDaysInMonth(date.getFullYear(), date.getMonth());
proratedDays = daysInMonth - date.getDate();
$('input#days').val(proratedDays);
}
function calc() {
period = parseInt($('select#period').val());
proRate = $('select#prorate').val()=='1'?true:false;
prorated = parseInt($('input#days').val()) * 1.61;
membership = parseInt($('select#level').val()) * period;
if (period==3) {
membership = membership * 0.9;
} else if (period==12) {
membership = membership * 0.8;
}
membership = parseFloat($('select#discount').val()) * membership;
if (proRate) {
amount = membership + prorated;
period = period + 1;
} else {
amount = membership;
}
nextPayment = new Date(date.getFullYear(), date.getMonth()+period, 1 );
$('span#total').text(Math.round(amount*100)/100);
$('span#due').text(nextPayment.toDateString());
}
calcProrateFromToday();
calc();
$('select, input').change(calc);
$('form').submit(function(e) {
e.preventDefault();
return false;
});
$('a#from-today').click(function(e) {
calcProrateFromToday();
calc();
e.preventDefault();
return false;
})
});
</script>
<title>LMN Prorating Calculator</title>
</head>
<body>
<h1>LMN Prorating Calculator</h1>
<form id="calc">
<div>
<label for="prorate">Pro-rate</label>
<select id="prorate">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
<div>
<label for="level">Membership Level</label>
<select id="level">
<option value="50">Coder/Crafter</option>
<option value="80">Full</option>
</select>
</div>
<div>
<label for="days">Prorated Days</label>
<input width="4" id="days"/>
<a id="from-today" href="#">Calc from Today</a>
</div>
<div>
<label for="period">Renewal Period</label>
<select id="period">
<option value="1">One Month</option>
<option value="3">Three Month</option>
<option value="12">One Year</option>
</select>
</div>
<div>
<label for="discount">Discount</label>
<select id="discount">
<option value="1">None</option>
<option value="0.5">Family</option>
<option value="0.5">Senior</option>
</select>
</div>
<div>
<label>Total Due:</label>
$<span id="total"></span>
</div>
<div>
<label>Next Due On:</label>
<span id="due"></span>
</div>
</form>
</body>
</html>