amount validation

This commit is contained in:
2016-04-11 17:28:56 +02:00
parent 46e718bb85
commit f628531c09
2 changed files with 11 additions and 6 deletions
+7 -3
View File
@@ -18,8 +18,6 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
};
if (typeof $scope.categories !== 'undefined') {
// TODO default-Kategorie sollte per Account einstellbar sein
console.log('DID IT!');
$scope.transaction.category = $scope.categories[0];
}
@@ -60,12 +58,18 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
$scope.postTransaction = function() {
var amount = $scope.transaction.amount.replace(',', '.');
if (amount.charAt(0) !== '+' && amount.charAt(0) !== '-') {
amount = '-' + amount;
}
// via Resource (might be moved into a service)
var Transaction = $resource('/transactions');
var newTransaction = new Transaction({
"account" : $scope.account._links.self.href,
"amount" : $scope.transaction.amount,
"amount" : amount,
"date" : $scope.transaction.date,
"description" : $scope.transaction.description,
"category" : $scope.transaction.category._links.self.href,