-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathElectricity Bill Calculation.htm
540 lines (486 loc) · 26.7 KB
/
Electricity Bill Calculation.htm
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<title>Electricity Bill Calculator</title>
<style>
</style>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="angular.min.js" type="text/javascript"></script>
</head>
<body ng-app="calculator" ng-controller="BillController" lang=EN-US>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
<form ng-submit="addNew()" class="">
<div class="row">
<div class="col-lg-4">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label class="control-label">Heading</label>
<input type="text" value="" ng-model="billDetails.heading" class="form-control">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="control-label">Bill Payable Amount</label>
<input type="number" value="" ng-model="billDetails.payable" class="form-control" style="max-width: 120px;">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="control-label">Bill Units</label>
<input type="number" value="" ng-model="billDetails.units" class="form-control" style="max-width: 120px;">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="control-label">Fixed Amount</label>
<input type="number" value="" ng-model="billDetails.rent" class="form-control" style="max-width: 120px;">
<small class="help-block">Example: Rental</small>
</div>
</div>
<div class="col-md-12">
<input type="button" class="btn btn-success" value="Calculate" ng-click="calculate()">
<button type="button" class="btn btn-primary " value="Print" onclick="window.print()">Print </button>
</div>
</div>
</div>
<div class="col-lg-6">
<h4 class="">Floor Units Consumptions & Cost</h4>
<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" /></th>
<th>Floor name</th>
<th>Units Recorded</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="floorDetail in floorsDetails">
<td>
<input type="checkbox" ng-model="floorDetail.selected"/></td>
<td>
<input type="text" class="form-control input-sm" ng-model="floorDetail.fname" required/></td>
<td>
<input type="number" class="form-control input-sm" style="max-width: 120px" ng-model="floorDetail.units" required/></td>
</tr>
</tbody>
</table>
<input type="submit" class="btn btn-primary btn-xs addnew " value="Add New">
<input ng-hide="!floorsDetails.length" type="button" class="btn btn-danger btn-xs " ng-click="remove()" value="Remove">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class=WordSection1>
<h1 align=center style='text-align:center' id="txt_heading" ><b ng-bind="billDetails.heading"></b></h1>
<p class=MsoNormal><span style='font-size:6.0pt;line-height:107%'> </span></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=630
style='width:472.55pt;border-collapse:collapse;border:none'>
<tr style='height:20.65pt'>
<td width=420 colspan=2 style='width:315.0pt;border:solid windowtext 1.0pt;
background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:20.65pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total Bill Payable Amount</b></p>
</td>
<td width=210 style='width:157.55pt;border:solid windowtext 1.0pt;border-left:
none;padding:0in 5.4pt 0in 5.4pt;height:20.65pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Rs. {{billDetails.payable | number}}</b></p>
</td>
</tr>
<tr style='height:19.55pt'>
<td width=420 colspan=2 style='width:315.0pt;border:solid windowtext 1.0pt;
border-top:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:19.55pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total Unit Consumption</b></p>
</td>
<td width=210 style='width:157.55pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:19.55pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b><span id="txt_bill_units" >{{billDetails.units | number}}</span></b></p>
</td>
</tr>
<tr style='height:19.55pt'>
<td width=312 style='width:233.75pt;border:solid windowtext 1.0pt;border-top:
none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:19.55pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Per Unit Cost</b></p>
</td>
<td width=108 style='width:81.25pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:19.55pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b><span id="txt_frml_unit_cost">{{billDetails.payable | number}} / {{billDetails.units | number}}</span></b></p>
</td>
<td width=210 style='width:157.55pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:19.55pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Rs. <span id="txt_unit_cost">{{ unitCost | number:2 }}</span> /unit </b>
</td>
</tr>
<tr height=0>
<td width=312 style='border:none'></td>
<td width=108 style='border:none'></td>
<td width=210 style='border:none'></td>
</tr>
</table>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'> </p>
<h2><b>Floor Unit Consumptions & Cost</b></h2>
<p class=MsoNormal>Recorded are the details provided by the owner of the floor.
</p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="100%"
style='width:100.0%;border-collapse:collapse;border:none'>
<tr style='height:17.1pt'>
<td width="22%" style='width:22.6%;border:solid windowtext 1.0pt;background:
#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:17.1pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Floor</b></p>
</td>
<td width="17%" style='width:17.78%;border:solid windowtext 1.0pt;border-left:
none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:17.1pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Units Recorded</b></p>
</td>
<td width="17%" style='width:17.24%;border:solid windowtext 1.0pt;border-left:
none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:17.1pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Unit Cost </b>(Rs.)</p>
</td>
<td width="15%" style='width:15.18%;border:solid windowtext 1.0pt;border-left:
none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:17.1pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b> </b></p>
</td>
<td width="27%" valign=top style='width:27.2%;border:solid windowtext 1.0pt;
border-left:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:17.1pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total </b>(Rs.)</p>
</td>
</tr>
<tr style='height:16.15pt' ng-repeat="floorDetail in floorsDetails">
<td width="22%" style='width:22.6%;border:solid windowtext 1.0pt;border-top:
none;padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal' >{{ floorDetail.fname }}</p>
</td>
<td width="17%" style='width:17.78%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal' >{{floorDetail.units | number}}</p>
</td>
<td width="17%" style='width:17.24%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal' id="txt_ground_unit_cost">{{ unitCost | number:2 }}</p>
</td>
<td width="15%" style='width:15.18%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal' id="txt_frml_ground_cost_1">{{floorDetail.units | number}} x {{ unitCost | number:2 }}</p>
</td>
<td width="27%" valign=top style='width:27.2%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>{{floorDetail.pretotal | number:2}}</b></p>
</td>
</tr>
<tr style='height:18.4pt'>
<td width="22%" style='width:22.6%;border:solid windowtext 1.0pt;border-top:
none;padding:0in 5.4pt 0in 5.4pt;height:18.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total Recorded</b></p>
</td>
<td width="17%" style='width:17.78%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:18.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>{{ floorsTotal.units | number}}</b></p>
</td>
<td width="17%" style='width:17.24%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:18.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'> </p>
</td>
<td width="15%" style='width:15.18%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:18.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'> </p>
</td>
<td width="27%" valign=top style='width:27.2%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:18.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>{{ floorsTotal.pretotal | number:2}}</b></p>
</td>
</tr>
</table>
<p class=MsoNormal> </p>
<h2><b>Difference Outcome</b></h2>
<p class=MsoNormal><span style='font-size:1.0pt;line-height:107%'> </span></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0
style='border-collapse:collapse;border:none'>
<tr>
<td width=312 valign=top style='width:233.75pt;border:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'> </p>
</td>
<td width=90 valign=top style='width:67.5pt;border:solid windowtext 1.0pt;
border-left:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Units</b></p>
</td>
<td width=222 valign=top style='width:166.25pt;border:solid windowtext 1.0pt;
border-left:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Cost</b></p>
</td>
</tr>
<tr>
<td width=312 valign=top style='width:233.75pt;border:solid windowtext 1.0pt;
border-top:none;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total Billed Actual</b></p>
</td>
<td width=90 valign=top style='width:67.5pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ billDetails.units | number}}</p>
</td>
<td width=222 valign=top style='width:166.25pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ billDetails.payable | number:2 }}</p>
</td>
</tr>
<tr>
<td width=312 valign=top style='width:233.75pt;border:solid windowtext 1.0pt;
border-top:none;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Total Recorded</b></p>
</td>
<td width=90 valign=top style='width:67.5pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ floorsTotal.units | number}}</p>
</td>
<td width=222 valign=top style='width:166.25pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ floorsTotal.pretotal | number:2 }}</p>
</td>
</tr>
<tr>
<td width=312 valign=top style='width:233.75pt;border:solid windowtext 1.0pt;
border-top:none;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Difference </b></p>
</td>
<td width=90 valign=top style='width:67.5pt;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>{{ floorsTotal.diff_units | number}}</b></p>
</td>
<td width=222 valign=top style='width:166.25pt;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>{{ floorsTotal.diff_pretotal | number:2}}</b></p>
</td>
</tr>
</table>
<p class=MsoNormal> </p>
<h2 style='margin-bottom:12.0pt'><b>Final Calculations</b></h2>
<p class=MsoNormal><b>Proportionate Formula</b>: (Floor Recorded Units / Total
Recorded Units) x Difference Total Cost</p>
<p class=MsoNormal>Actual Difference Cost = {{ floorsTotal.diff_pretotal | number:2 }} {{ billDetails.rent | number}} (Fixed*) = <b>Rs.</b>
<b>{{ floorsTotal.diff_actual | number:2 }}</b></p>
<p class=MsoNormal>*<span style='color:red'>Avg. fixed amount will be equally
divided to all</span>. {{ billDetails.rent | number}} / {{ floorsDetails.length }}<b> = Rs. {{ floorsTotal.rent | number:2}}</b></p>
<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="100%"
style='width:100.0%;border-collapse:collapse;border:none'>
<tr style='height:22.0pt'>
<td width="15%" style='width:15.34%;border:solid windowtext 1.0pt;background:
#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:22.0pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Floor</b></p>
</td>
<td width="17%" style='width:17.34%;border:solid windowtext 1.0pt;border-left:
none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:22.0pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'><b>Units Recorded</b></p>
</td>
<td width="33%" style='width:33.68%;border:solid windowtext 1.0pt;
border-left:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:22.0pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-align:right;'><b>Proportionate Difference</b></p>
</td>
<td width="33%" style='width:33.64%;border:solid windowtext 1.0pt;
border-left:none;background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt;height:22.0pt'>
<p class=MsoNormal align=right style='margin-bottom:0in;margin-bottom:.0001pt;
text-align:right;line-height:normal'><b>Total </b>(Rs.)</p>
</td>
</tr>
<tr style='height:16.15pt' ng-repeat="floorDetail in floorsDetails">
<td width="15%" style='width:15.34%;border:solid windowtext 1.0pt;border-top:
none;padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ floorDetail.fname }}</p>
</td>
<td width="17%" style='width:17.34%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal'>{{ floorDetail.units | number }}</p>
</td>
<td width="24%" style='width:24.06%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-align:right;'>( {{ floorDetail.units | number }} / {{ floorsTotal.units | number }} x {{ floorsTotal.diff_actual | number:2 }} ) + {{ floorDetail.pretotal | number:2 }} + {{ floorsTotal.rent | number:2 }}</p>
</td>
<td width="45%" valign=top style='width:12.44%;border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:16.15pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-align:right;'><b>{{ floorDetail.total | number:2 }}</b></p>
</td>
</tr>
<tr style='height:13.0pt'>
<td width="" colspan=3 style='width:65.4%;border:solid windowtext 1.0pt;
border-top:none;padding:0in 5.4pt 0in 5.4pt;height:13.0pt'>
<p class=MsoNormal align=right style='margin-bottom:0in;margin-bottom:.0001pt;
text-align:right;line-height:normal'><b>Total</b></p>
</td>
<td width="" style='width:34.6%;border-top:none;border-left:none;
border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
padding:0in 5.4pt 0in 5.4pt;height:13.0pt'>
<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-align:right;'><b>{{ floorsTotal.total | number }}</b></p>
</td>
</tr>
</table>
<p class=MsoNormal> </p>
<p class=MsoNormal> </p>
</div>
<script>
var app = angular.module("calculator", []);
app.controller("BillController", ['$scope', '$http', '$filter', function($scope, $http,$filter) {
$scope.billDetails = {
'heading' : 'Electricity Bill Calculation',
'payable' : 35265,
'units' : 3689,
'rent' : 119
};
$scope.floorsDetails = [
{
'fname':'Ground Floor',
'units': 662,
'pretotal' : 0,
'total' : 0
},{
'fname':'1st Floor',
'units': 458,
'pretotal' : 0,
'total' : 0
},{
'fname':'2nd Floor',
'units': 367,
'pretotal' : 0,
'total' : 0
},{
'fname':'3rd Floor',
'units': 707,
'pretotal' : 0,
'total' : 0
}
];
$scope.unitCost = ($scope.billDetails.payable / $scope.billDetails.units);
$scope.calculate = function() {
$scope.floorsTotal = {
'units' : 0,
'diff_units' : 0,
'pretotal' : 0,
'diff_pretotal' : 0,
'diff_actual' : 0,
'subtotal' : 0,
'rent' : $scope.billDetails.rent / $scope.floorsDetails.length,
'total' : 0
};
//Calculate unit cost
$scope.unitCost = $filter('number')(($scope.billDetails.payable / $scope.billDetails.units), 2);
angular.forEach($scope.floorsDetails, function(floor, key){
//Update floor pretotal
floor.pretotal = floor.units * $scope.unitCost;
//Increment floorsTotal
$scope.floorsTotal.pretotal += floor.pretotal;
$scope.floorsTotal.units += floor.units;
});
//Difference
$scope.floorsTotal.diff_units = $scope.billDetails.units - $scope.floorsTotal.units;
$scope.floorsTotal.diff_pretotal = $scope.billDetails.payable - $scope.floorsTotal.pretotal;
//Minimize
$scope.floorsTotal.diff_actual = $scope.floorsTotal.diff_pretotal - $scope.billDetails.rent;
angular.forEach($scope.floorsDetails, function(floor, key){
//Total total
$scope.floorsTotal.total += floor.total = ( floor.units / $scope.floorsTotal.units * $scope.floorsTotal.diff_actual ) + floor.pretotal + $scope.floorsTotal.rent;
console.log(floor.total);
});
//$scope.floorsTotal.total += $scope.floorsTotal.diff_pretotal - $scope.billDetails.rent;
};
$scope.addNew = function(personalDetail){
$scope.floorsDetails.push({
'fname': "",
'units': 0,
'pretotal' : 0,
'subtotal' : 0,
'total' : 0
});
};
$scope.remove = function(){
var newDataList=[];
$scope.selectedAll = false;
angular.forEach($scope.floorsDetails, function(selected){
if(!selected.selected){
newDataList.push(selected);
}
});
$scope.floorsDetails = newDataList;
};
$scope.checkAll = function () {
if (!$scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.floorsDetails, function(personalDetail) {
personalDetail.selected = $scope.selectedAll;
});
};
}]);
</script>
</body>
</html>