Expense Modal
This commit is contained in:
@@ -25,7 +25,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
|
||||
// initialize attributes for outstanding amounts
|
||||
for (i = 0; i < $scope.accountUsers.length; i++) {
|
||||
$scope.accountUsers[i].outstandings = 0.0;
|
||||
$scope.accountUsers[i].outstandingSum = 0.0;
|
||||
}
|
||||
|
||||
// get expenses for all users of the account
|
||||
@@ -37,12 +37,14 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
|
||||
$q.all(promises).then(function(data) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
$scope.accountUsers[i].expenses = new Array(data[i]._embedded.transactions.length);
|
||||
var expenseSum = 0;
|
||||
for (j = 0; j < data[i]._embedded.transactions.length; j++) {
|
||||
$scope.accountUsers[i].expenses[j] = data[i]._embedded.transactions[j];
|
||||
// XXX $scope.accountUsers[i].expenses[j].amount = numberToAmount(data[i]._embedded.transactions[j].amount);
|
||||
expenseSum = expenseSum + data[i]._embedded.transactions[j].amount;
|
||||
}
|
||||
$scope.accountUsers[i].outstandings -= expenseSum;
|
||||
//console.log('Expenses by ' + $scope.accountUsers[i].name + ': ' + expenseSum);
|
||||
$scope.accountUsers[i].outstandingSum -= expenseSum;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,12 +57,13 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
|
||||
$q.all(promises).then(function(data) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
$scope.accountUsers[i].withdrawals = new Array(data[i]._embedded.withdrawals.length);
|
||||
var withdrawnSum = 0;
|
||||
for (j = 0; j < data[i]._embedded.withdrawals.length; j++) {
|
||||
$scope.accountUsers[i].withdrawals[j] = data[i]._embedded.withdrawals[j];
|
||||
withdrawnSum = withdrawnSum + data[i]._embedded.withdrawals[j].amount;
|
||||
}
|
||||
$scope.accountUsers[i].outstandings -= withdrawnSum;
|
||||
//console.log('Withdrawals by ' + $scope.accountUsers[i].name + ': ' + withdrawnSum);
|
||||
$scope.accountUsers[i].outstandingSum -= withdrawnSum;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -273,7 +276,23 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
refreshExpenses();
|
||||
|
||||
}, function () {
|
||||
$log.info('Modal dismissed at: ' + new Date());
|
||||
$log.info('DetailsModal dismissed ' + new Date());
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openExpenses = function(user) {
|
||||
var modalInstance = $uibModal.open({
|
||||
templateUrl: 'expensesTemplate.html',
|
||||
controller: 'ExpensesModalCtrl',
|
||||
resolve: {
|
||||
accountUser: user
|
||||
}
|
||||
});
|
||||
|
||||
modalInstance.result.then(function() {
|
||||
refreshExpenses();
|
||||
}, function () {
|
||||
$log.info('ExpensesModal dismissed ' + new Date());
|
||||
});
|
||||
};
|
||||
|
||||
@@ -333,3 +352,17 @@ transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$resource', '
|
||||
});
|
||||
}
|
||||
} ]);
|
||||
|
||||
transactionControllers.controller('ExpensesModalCtrl', [ '$scope', '$uibModalInstance', 'accountUser', function($scope, $uibModalInstance, accountUser) {
|
||||
|
||||
$scope.accountUser = accountUser;
|
||||
console.log($scope.accountUser);
|
||||
|
||||
$scope.ok = function () {
|
||||
$uibModalInstance.close();
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('close');
|
||||
};
|
||||
} ]);
|
||||
|
||||
Reference in New Issue
Block a user