Pattern processing, pt. 3
http://stackoverflow.com/a/23287265/3761783 http://docs.spring.io/spring-data/rest/docs/current/reference/html/#projections-excerpts.projections
This commit is contained in:
@@ -367,20 +367,13 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa
|
||||
transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$location', 'ImportService', function($scope, $resource, $location, ImportService) {
|
||||
|
||||
$scope.importCSV = function () {
|
||||
ImportService.saveData($scope.csvInput);
|
||||
ImportService.setAccount($scope.account);
|
||||
ImportService.setCategories($scope.categories);
|
||||
ImportService.setCSV($scope.csvInput);
|
||||
$location.path('importList');
|
||||
}
|
||||
|
||||
$scope.processCSV = function () {
|
||||
$scope.csv = Papa.parse("\"08.07.2016\";\"08.07.2016\";\"Übertrag/Überweisung\";\"Empfänger: Tilman Liero Kto/IBAN: DE44200411330649163305 BLZ/BIC: COBADEHD001 Buchungstext: none End-to-End-Ref.: nicht angegeben Ref. JK21619010302362/2\";\"-40,00\";\n\"07.07.2016\";\"07.07.2016\";\"Übertrag/Überweisung\";\"Empfänger: Tilman Liero Kto/IBAN: DE44200411330649163305 BLZ/BIC: COBADEHD001 Buchungstext: Uebertrag auf Tagesgeld PLUS-Konto End-to-End-Ref.: nicht angegeben Ref. J521618965322854/2\";\"-185,76\";\n\"06.07.2016\";\"06.07.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Bayer AG Buchungstext: /EDAM WORSHOP MIT/ Delaware (15.-16 End-to-End-Ref.: 8000012618 Ref. J321618880156700/705\";\"226,90\";\n\"01.07.2016\";\"01.07.2016\";\"Lastschrift/Belast.\";\"Auftraggeber: comdirect Visa-Monatsabrechnung Buchungstext: VISA-KARTE NR. 42635401XXXX5230 SUMME MONATSABRECHNUNG VISA TILMAN LIERO Ref. I421618341001491/75009\";\"-346,67\";\n");
|
||||
// $scope.csv = Papa.parse(ImportService.getData());
|
||||
console.log($scope.csv.meta.delimiter);
|
||||
console.log($scope.csv);
|
||||
}
|
||||
|
||||
// COPIED CODE from TransactionListCtrl.initList, needs to be moved into a Service
|
||||
$scope.initPage = function () {
|
||||
console.log('aloha');
|
||||
var userinfo = $resource('/user').get();
|
||||
userinfo.$promise.then(function(data) {
|
||||
$scope.userid = userinfo.name;
|
||||
@@ -392,17 +385,8 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
|
||||
|
||||
var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get();
|
||||
accountInfo.$promise.then(function(data) {
|
||||
console.log(accountInfo._embedded.accounts);
|
||||
$scope.accounts = accountInfo._embedded.accounts;
|
||||
if ($scope.account == undefined) {
|
||||
$scope.account = $scope.accounts[0];
|
||||
if ($routeParams.account != undefined) {
|
||||
for (i = 0; i < $scope.accounts.length; i++) {
|
||||
if ($scope.accounts[i].name == $routeParams.account)
|
||||
$scope.account = $scope.accounts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.account = $scope.accounts[0];
|
||||
|
||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||
categories.$promise.then(function(data) {
|
||||
@@ -415,8 +399,75 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// XXX
|
||||
$scope.csvInput = "\"08.07.2016\";\"08.07.2016\";\"Übertrag/Überweisung\";\"Empfänger: Tilman Liero Kto/IBAN: DE44200411330649163305 BLZ/BIC: COBADEHD001 Buchungstext: none End-to-End-Ref.: nicht angegeben Ref. JK21619010302362/2\";\"-40,00\";\n\"27.06.2016\";\"27.06.2016\";\"Lastschrift/Belast.\";\"Auftraggeber: DANKE, IHR LIDL Kto/IBAN: DE61300500000008000119 Buchungstext: Kartenzahlung DANKE, IHR LIDL//Berlin/DE 2016-06-25T09:47:08 KFN 2 VJ 1912 Ref. 6GL16179A2640086/6763\";\"-70,17\";\n\"24.06.2016\";\"24.06.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Tilman Liero Buchungstext: Uebertrag comdirect bank End-to-End-Ref.: nicht angegeben Ref. IX216176F0205292/1\";\"200,00\";\n\"24.06.2016\";\"24.06.2016\";\"Übertrag/Überweisung\";\"Auftraggeber: Wohnungsbau-Verein Neukölln eG Buchungstext: Mg.-Nr. 35823, Walther, Tilman - 4, Dividende 2015 End-to-End-Ref.: nicht angegeben Ref. H221617674648332/35629\";\"4,42\";";
|
||||
}
|
||||
|
||||
$scope.initPage();
|
||||
|
||||
} ]);
|
||||
|
||||
transactionControllers.controller('ImportListCtrl', [ '$scope', '$resource', '$location', 'ImportService', function($scope, $resource, $location, ImportService) {
|
||||
|
||||
$scope.processCSV = function () {
|
||||
$scope.account = ImportService.getAccount();
|
||||
$scope.categories = ImportService.getCategories();
|
||||
$scope.csv = Papa.parse(ImportService.getCSV()).data;
|
||||
|
||||
var matcherData = $resource('/matchers/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||
matcherData.$promise.then(function(data) {
|
||||
|
||||
// XXX
|
||||
console.log(matcherData);
|
||||
|
||||
|
||||
matcherData = matcherData._embedded.matchers;
|
||||
var matchers = new Array(matcherData.length);
|
||||
|
||||
for (i = 0; i < matchers.length; i++) {
|
||||
matchers[i] = {};
|
||||
|
||||
if (matcherData[i].dateMatcherCode != null)
|
||||
matchers[i].dateMatcher = new Function('x', matcherData[i].dateMatcherCode);
|
||||
if (matcherData[i].typeMatcherCode != null)
|
||||
matchers[i].typeMatcher = new Function('x', matcherData[i].typeMatcherCode);
|
||||
if (matcherData[i].textMatcherCode != null)
|
||||
matchers[i].textMatcher = new Function('x', matcherData[i].textMatcherCode);
|
||||
if (matcherData[i].amountMatcherCode != null)
|
||||
matchers[i].amountMatcher = new Function('x', matcherData[i].amountMatcherCode);
|
||||
|
||||
matchers[i].targetDescription = matcherData[i].targetDescription;
|
||||
}
|
||||
|
||||
// XXX
|
||||
console.log(matchers);
|
||||
|
||||
for (i = 0; i < $scope.csv.length; i++) {
|
||||
var matched = false;
|
||||
var j = 0;
|
||||
|
||||
while (!matched && j < matchers.length) {
|
||||
var match = true;
|
||||
|
||||
if (match && matchers[j].dateMatcher)
|
||||
match = matchers[j].dateMatcher($scope.csv[i][1]);
|
||||
if (match && matchers[j].typeMatcher)
|
||||
match = matchers[j].typeMatcher($scope.csv[i][2]);
|
||||
if (match && matchers[j].textMatcher)
|
||||
match = matchers[j].textMatcher($scope.csv[i][3]);
|
||||
if (match && matchers[j].amountMatcher)
|
||||
match = matchers[j].amountMatcher(amountToNumber($scope.csv[i][4]));
|
||||
|
||||
if (match) {
|
||||
$scope.csv[i].targetDescription = matchers[j].targetDescription;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} ]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user