improved withdrawal handling

This commit is contained in:
2016-07-30 23:14:25 +02:00
parent 23e4891a64
commit df8edf4607
4 changed files with 23 additions and 6 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ INSERT INTO Category (id, name, account_id, position) VALUES
(null, 'Essen - Lebensmittel', 1, 2),
(null, 'Einnahmen - Gehalt', 1, 1),
(null, 'Essen - Arbeit', 1, 3),
(null, 'Private Entnahme', 1, 4),
(null, 'Wohnen - Haushalt', 1, 4),
(null, 'Private Entnahme', 1, 5),
(null, 'Einnahmen - Gehalt', 2, 1),
(null, 'Technik - Server und Hosting', 2, 2);
+19 -3
View File
@@ -84,6 +84,8 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
}
}
$scope.checkCategory();
// get recent transactions
var transactions = $resource('/api/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get();
transactions.$promise.then(function(data) {
@@ -101,9 +103,23 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
}
$scope.checkCategory = function() {
var radioButtons = document.getElementsByName('expenseBy');
var userLabels = document.getElementsByClassName('userLabel');
}
// if this is selected to be a withdrawal, preselect the current user and disable "no creditor" radio button
if ($scope.transaction.category.name === 'Private Entnahme') {
var userLabels = document.getElementsByClassName('userLabel');
for (i = 0; i < userLabels.length; i++) {
if (userLabels[i].innerHTML.indexOf($scope.userinfo.name) >= 0) {
userLabels[i].getElementsByTagName('INPUT')[0].checked = true;
}
}
document.getElementById('noCreditorRadioButton').disabled = true;
}
else {
document.getElementById('noCreditorRadioButton').disabled = false;
document.getElementById('noCreditorRadioButton').checked = true;
}
}
$scope.initList = function() {
$scope.pageSize = 20;
@@ -10,7 +10,7 @@
<div class="col-md-offset-4 col-md-4 col-xs-12">
<div ng-show="lastSubmission" class="lastSubmission col-xs-offset-1 alert alert-info" role="alert">
<div ng-show="lastSubmission" class="lastSubmission alert alert-info" role="alert">
{{lastSubmission.date | date:'dd.MM.yyyy'}}
<span ng-class="{ 'color-green': lastSubmission.amount.charAt(0) == '+', 'color-red': lastSubmission.amount.charAt(0) == '-' }">{{lastSubmission.amount}}&nbsp;</span>
&nbsp;&nbsp;&nbsp;