Show CSV data

This commit is contained in:
2016-07-29 17:40:52 +02:00
parent 4d3da2ac09
commit 889e7ab7e0
4 changed files with 30 additions and 8 deletions
+10 -3
View File
@@ -392,6 +392,7 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
$scope.processCSV = function () {
$scope.account = ImportService.getAccount();
$scope.categories = ImportService.getCategories();
$scope.csvInput = ImportService.getCSV();
$scope.csv = Papa.parse(ImportService.getCSV()).data;
var matcherData = $resource('/api/matchers/search/listForAccount', { projection: 'full', accountId: $scope.account.id }).get();
@@ -464,9 +465,6 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
$scope.importTransaction = function(line) {
if (line.targetCategory) {
console.log(line[1]);
console.log(line[1].substr(6,4) + "-" + line[1].substr(3,2) + "-" + line[1].substr(0,2));
var newTransaction = new Transaction({
"account" : $scope.account._links.self.href,
"amount" : line[4].replace(',', '.'),
@@ -481,6 +479,15 @@ transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$l
console.log(transaction);
line.submittedTransactionLink = transaction._links.self.href;
line.submittedTransactionId = transaction.id;
// delete from CSV
var descriptionPos = $scope.csvInput.search(line[3]);
var lineStart = $scope.csvInput.lastIndexOf('\n', descriptionPos);
var lineEnd = $scope.csvInput.indexOf('\n', descriptionPos);
if (lineEnd < 0)
lineEnd = $scope.csvInput.length;
$scope.csvInput = $scope.csvInput.substring(0, lineStart) + $scope.csvInput.substring(lineEnd, $scope.csvInput.length);
});
}
}