reset outstandings
This commit is contained in:
@@ -36,9 +36,13 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
$scope.accountUsers[i].outstandingSum = 0.0;
|
$scope.accountUsers[i].outstandingSum = 0.0;
|
||||||
|
|
||||||
for (j = 0; j < data[i]._embedded.transactions.length; j++) {
|
for (j = 0; j < data[i]._embedded.transactions.length; j++) {
|
||||||
|
|
||||||
$scope.accountUsers[i].outstandings[j] = new Object();
|
$scope.accountUsers[i].outstandings[j] = new Object();
|
||||||
|
|
||||||
$scope.accountUsers[i].outstandings[j].date = data[i]._embedded.transactions[j].date;
|
$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].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;
|
$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
|
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({
|
var modalInstance = $uibModal.open({
|
||||||
templateUrl: 'outstandingsTemplate.html',
|
templateUrl: 'outstandingsTemplate.html',
|
||||||
controller: 'OutstandingsModalCtrl',
|
controller: 'OutstandingsModalCtrl',
|
||||||
@@ -246,7 +250,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
});
|
});
|
||||||
|
|
||||||
modalInstance.result.then(function() {
|
modalInstance.result.then(function() {
|
||||||
refreshExpenses();
|
$scope.refreshList();
|
||||||
}, function () {
|
}, function () {
|
||||||
$log.info('OutstandingsModal dismissed ' + new Date());
|
$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;
|
$scope.accountUser = accountUser;
|
||||||
|
|
||||||
@@ -322,6 +326,21 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.clearOutstandings = function() {
|
$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');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} ]);
|
} ]);
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ transactionServices.factory('Transaction', [ '$resource', function($resource) {
|
|||||||
return $resource('/transactions/:id', { id: '@id' }, {
|
return $resource('/transactions/:id', { id: '@id' }, {
|
||||||
update : {
|
update : {
|
||||||
method : 'PUT'
|
method : 'PUT'
|
||||||
|
},
|
||||||
|
patch : {
|
||||||
|
method : 'PATCH'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} ]);
|
} ]);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="margin-top: 2em; text-align: center;">
|
<div style="margin-top: 2em; text-align: center;">
|
||||||
<span ng-repeat="user in accountUsers" ng-click="openExpenses(user)" class="clickable">{{user.name}} {{user.outstandingAmount}} €<br/></span>
|
<span ng-repeat="user in accountUsers" ng-click="openOutstandings(user)" class="clickable">{{user.name}} {{user.outstandingAmount}} €<br/></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user