Skip to content

Commit 6c7222d

Browse files
author
Prashanth Batchu
committed
added ability to sum up calculated total.
1 parent da9979d commit 6c7222d

File tree

3 files changed

+16
-64
lines changed

3 files changed

+16
-64
lines changed
Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
billRive.controller('billController', function($scope, billService) {
2-
3-
//$scope.bills= billService.getBills();
4-
52
$scope.friends = billService.getFriends();
63
$scope.groups = billService.getGroups();
74
$scope.payers = billService.getPayers();
@@ -12,10 +9,7 @@ billRive.controller('billController', function($scope, billService) {
129
$scope.addBill = function() {
1310

1411
};
15-
//console.log( $scope.friends);
16-
1712
$scope.setBillGroup = function() {
18-
// console.log(id);
1913
var $groupId = $scope.bill.groupId;
2014

2115
var $groupMembers;
@@ -27,68 +21,29 @@ billRive.controller('billController', function($scope, billService) {
2721
}
2822
}
2923
var $groupUserAndLiableCost = [];
30-
console.log($scope.friends[0].id);
3124
var $friendNamefromId = null;
3225
for (i = 0; i < $groupMembers.length; i++) {
3326

3427
for (var j = 0; j < $scope.friends.length; j++) {
35-
36-
//
3728
if ($scope.friends[j].id == $groupMembers[i])
38-
{
3929
$friendNamefromId = $scope.friends[j].name;
40-
}
41-
//
4230
}
4331
$groupUserAndLiableCost.push({userId: $groupMembers[i], liableCost: null, name: $friendNamefromId});
4432
}
45-
46-
//console.log($groupUserAndLiableCost);
47-
// for(var i=0;i<)
48-
// var $userAndLiableCost=
49-
$scope.bill.billFinances.billItemEntry = $groupUserAndLiableCost;
33+
$scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost = $groupUserAndLiableCost;
5034
$groupUserAndLiableCost = [];
51-
//$scope.bill.billFinances.billItemEntry.push($groupUserAndLiableCost);
52-
//console.log($userAndLiableCost);
35+
5336
};
5437

38+
$scope.calculateSimpleSum=function(){
39+
40+
$scope.simpleCalculatedTotal=0;
41+
for (i = 0; i < $scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost.length; i++) {
42+
$scope.simpleCalculatedTotal+= parseInt($scope.bill.billFinances.billSimpleTotals.userIdAndLiableCost[i].liableCost);
43+
}
44+
45+
46+
};
5547

56-
// billService.getBills(function(data) {
57-
// $scope.bills = data;
58-
// $scope.username ="Prashanth";
59-
//
60-
//
61-
//$scope.friends= [
62-
//{name:'John Doe'},
63-
//{name:'Kristen Stewart'},
64-
//{name:'Trevor Pott'},
65-
//{name:'Hilda Hess'},
66-
//{name:'Gavin Mays'}
67-
//];
68-
//
69-
//
70-
//$scope.groups= [
71-
//{name:'SLC Roommates'},
72-
//{name:'Denver Old Buddies'},
73-
//{name:'Ski Club'},
74-
//{name:'Family'},
75-
//{name:'India'}
76-
//];
77-
//
78-
// function addBill(){
79-
//
80-
//// $scope.bills.put();
81-
// };
82-
//
83-
// function deleteBill(){
84-
//
85-
//
86-
// };
87-
//
88-
// function editBill(){
89-
//
90-
//
91-
// };
92-
// });
9348
});
9449

billrive-client/app/js/services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var bill={
185185
"notes": "",
186186
"billFinances": {
187187
"billPayerId": null,
188-
"billTotals":
188+
"billSimpleTotals":
189189
{
190190
"itemDescriptionId": 1,
191191
"itemDescription": "Simple",

billrive-client/app/partials/addBill/simple.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<br />
22
<div> <ul class="unstyled">
33

4-
<li ng-repeat="user in bill.billFinances.billItemEntry" >
5-
6-
7-
4+
<li ng-repeat="user in bill.billFinances.billSimpleTotals.userIdAndLiableCost " >
85
<div class="row-fluid">
96

107
<div class="span3">
118
<input type="checkbox" ng-model="todo.done"/>
129
{{user.name}}
1310
</div>
1411
<div class="span3">
15-
<input type="text" ng-model='user.liableCost' class="span6" placeholder="5.00" />
12+
<input ng-change='calculateSimpleSum()' type="text" ng-model='user.liableCost' class="span6" placeholder="0.00" />
1613
</div>
1714
</div>
1815
</li>
@@ -26,10 +23,10 @@
2623

2724
<div class="span3">
2825

29-
Total
26+
Calculated Total
3027
</div>
3128
<div class="span3">
32-
<input type="text" class="span6" placeholder="5.00" />
29+
<input type="text" disabled ng-model='simpleCalculatedTotal' class="span6" placeholder="0.00" />
3330
</div>
3431
</div>
3532
</li></ul>

0 commit comments

Comments
 (0)