reset outstandings
This commit is contained in:
@@ -36,9 +36,13 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
$scope.accountUsers[i].outstandingSum = 0.0;
|
||||
|
||||
for (j = 0; j < data[i]._embedded.transactions.length; j++) {
|
||||
|
||||
$scope.accountUsers[i].outstandings[j] = new Object();
|
||||
|
||||
$scope.accountUsers[i].outstandings[j].date = data[i]._embedded.transactions[j].date;
|
||||
$scope.accountUsers[i].outstandings[j].description = data[i]._embedded.transactions[j].description;
|
||||
|
||||
$scope.accountUsers[i].outstandings[j].href = data[i]._embedded.transactions[j]._links.self.href;
|
||||
$scope.accountUsers[i].outstandings[j].category = data[i]._embedded.transactions[j].category.name;
|
||||
|
||||
if ($scope.accountUsers[i].outstandings[j].category === 'Private Entnahme') { // magic strings ftw
|
||||
@@ -236,7 +240,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openExpenses = function(user) {
|
||||
$scope.openOutstandings = function(user) {
|
||||
var modalInstance = $uibModal.open({
|
||||
templateUrl: 'outstandingsTemplate.html',
|
||||
controller: 'OutstandingsModalCtrl',
|
||||
@@ -246,7 +250,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
});
|
||||
|
||||
modalInstance.result.then(function() {
|
||||
refreshExpenses();
|
||||
$scope.refreshList();
|
||||
}, function () {
|
||||
$log.info('OutstandingsModal dismissed ' + new Date());
|
||||
});
|
||||
@@ -309,7 +313,7 @@ transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$resource', '
|
||||
}
|
||||
} ]);
|
||||
|
||||
transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModalInstance', 'accountUser', function($scope, $uibModalInstance, accountUser) {
|
||||
transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModalInstance', '$http', '$resource', '$q', 'accountUser', function($scope, $uibModalInstance, $http, $resource, $q, accountUser) {
|
||||
|
||||
$scope.accountUser = accountUser;
|
||||
|
||||
@@ -322,6 +326,21 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa
|
||||
};
|
||||
|
||||
$scope.clearOutstandings = function() {
|
||||
// TODO
|
||||
var promises = new Array($scope.accountUser.outstandings.length);
|
||||
for (i = 0; i < $scope.accountUser.outstandings.length; i++) {
|
||||
if ($scope.accountUser.outstandings[i].category === 'Private Entnahme') {
|
||||
// delete withdrawals
|
||||
var resource = $resource($scope.accountUser.outstandings[i].href).remove();
|
||||
promises[i] = resource.$promise;
|
||||
}
|
||||
else {
|
||||
// remove creditor from expenses
|
||||
promises[i] = $http.patch($scope.accountUser.outstandings[i].href, '{ "creditor" : "" }');
|
||||
}
|
||||
}
|
||||
|
||||
$q.all(promises).then(function(data) {
|
||||
$uibModalInstance.close('cleared outstandings');
|
||||
});
|
||||
}
|
||||
} ]);
|
||||
|
||||
Reference in New Issue
Block a user