Pattern processing, pt. 1

This commit is contained in:
2016-07-19 15:33:51 +02:00
parent 610e77f7b9
commit 9a55fc9d0d
15 changed files with 268 additions and 25 deletions
+22 -17
View File
@@ -11,24 +11,29 @@ INSERT INTO Category (id, name, account_id, position) VALUES
INSERT INTO Account_User (account_id, user_id) VALUES (1, 1), (1, 2), (1, 3), (2, 1);
INSERT INTO Pattern (id, account_id, position, type_pattern, date_pattern, text_pattern, amount_pattern, target_category_id, target_description) VALUES
(NULL, 1, 1, '', '', '*.LIDL*.', '', 1, 'Lidl'),
(NULL, 1, 1, null, null, '*.Buchungstext: none*.', -40.0, 4, '(in Rücklage)'),
(NULL, 1, 1, 'Kontoübertrag', null, 'Auftraggeber: Tilman Liero Kto/IBAN: DE44200411330649163305*.', null, 4, '(Entnahme aus Rücklagen)');
INSERT INTO Transaction (id, amount, account_id, category_id, date, description, creditor_id) VALUES
(NULL, 1280.81, 1, 2, '2016-04-01 14:14:14', 'Gehalt', null),
(NULL, -2.21, 1, 1, '2016-04-10', 'Brot', null),
(NULL, -3.41, 1, 1, '2016-04-12', 'Gemüse', null),
(NULL, -7.81, 1, 3, '2016-04-19', 'Kantine', null),
(NULL, -4.81, 1, 3, '2016-04-18', 'Currywurst (Auslage Adam)', 1),
(NULL, -4.50, 1, 3, '2016-04-19', 'Currywurst', null),
(NULL, -4.50, 1, 3, '2016-04-20', 'Currywurst', null),
(NULL, -4.09, 1, 3, '2016-04-18', 'Currywurst-Frühstück', null),
(NULL, -4.90, 1, 3, '2016-04-18', 'Currywurst (Auslage Betty)', 2),
(NULL, -8.90, 1, 3, '2016-04-18', 'Curry beim Inder (Auslage Adam)', 1),
(NULL, -20, 1, 4, '2016-04-12 18:20:15', 'Entnahme Betty', 2),
(NULL, -10, 1, 4, '2016-04-14 10:03:00', 'Entnahme Adam', 1),
(NULL, 1340.22, 2, 5, '2016-04-02', 'Gehalt Adam', null),
(NULL, -4.50, 2, 6, '2016-04-20', 'WebPack', null),
(NULL, -12.90, 2, 6, '2016-04-16', 'Host Europe', null);
(NULL, 1280.81, 1, 2, '2016-04-01 14:14:14', 'Gehalt', null),
(NULL, -2.21, 1, 1, '2016-04-10', 'Brot', null),
(NULL, -3.41, 1, 1, '2016-04-12', 'Gemüse', null),
(NULL, -7.81, 1, 3, '2016-04-19', 'Kantine', null),
(NULL, -4.81, 1, 3, '2016-04-18', 'Currywurst (Auslage Adam)', 1),
(NULL, -4.50, 1, 3, '2016-04-19', 'Currywurst', null),
(NULL, -4.50, 1, 3, '2016-04-20', 'Currywurst', null),
(NULL, -4.09, 1, 3, '2016-04-18', 'Currywurst-Frühstück', null),
(NULL, -4.90, 1, 3, '2016-04-18', 'Currywurst (Auslage Betty)', 2),
(NULL, -8.90, 1, 3, '2016-04-18', 'Curry beim Inder (Auslage Adam)', 1),
(NULL, -20, 1, 4, '2016-04-12 18:20:15', 'Entnahme Betty', 2),
(NULL, -10, 1, 4, '2016-04-14 10:03:00', 'Entnahme Adam', 1),
(NULL, 1340.22, 2, 5, '2016-04-02', 'Gehalt Adam', null),
(NULL, -4.50, 2, 6, '2016-04-20', 'WebPack', null),
(NULL, -12.90, 2, 6, '2016-04-16', 'Host Europe', null);
-- add as many transactions as needed
+13
View File
@@ -73,6 +73,19 @@ label {
color: green;
}
.importTable th, td {
font-size: 80%;
border: none;
border-bottom: 1px solid #ddd;
background-color: #fff;
padding: 1ex;
}
.importTable .spacer {
background-color: transparent;
border: none;
}
/* for angular-ui, see https://angular-ui.github.io/bootstrap/#/getting_started */
.nav, .pagination, .carousel, .panel-title a { cursor: pointer; }
+2 -1
View File
@@ -16,12 +16,13 @@
<script src="js/angular-animate.min.js"></script>
<script src="js/angular-touch.min.js"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="js/ui-bootstrap-custom-tpls-1.3.3.min.js"></script>
<script src="js/papaparse.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
+6
View File
@@ -4,6 +4,12 @@ transactionsApp.config([ '$routeProvider', function($routeProvider) {
$routeProvider.when('/list', {
templateUrl : 'partials/transaction-list.html',
controller : 'TransactionListCtrl'
}).when('/import', {
templateUrl : 'partials/import.html',
controller : 'ImportCtrl'
}).when('/importList', {
templateUrl : 'partials/import-list.html',
controller : 'ImportCtrl'
}).otherwise({
redirectTo : '/list'
});
@@ -358,3 +358,19 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa
});
}
} ]);
transactionControllers.controller('ImportCtrl', [ '$scope', '$location', 'ImportService', function($scope, $location, ImportService) {
$scope.importCSV = function () {
ImportService.saveData($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);
}
} ]);
File diff suppressed because one or more lines are too long
+13
View File
@@ -10,3 +10,16 @@ transactionServices.factory('Transaction', [ '$resource', function($resource) {
}
});
} ]);
transactionServices.factory('ImportService', function() {
var dataResponse = {};
return {
saveData: function(data) {
dataResponse = data;
console.log(data);
},
getData : function() {
return dataResponse;
}
};
});
@@ -0,0 +1,28 @@
<div class="container" ng-init="processCSV()">
<div class="row">
<table class="importTable">
<tr>
<th>Wertstellung</th>
<th>Typ</th>
<th>Text</th>
<th>Betrag</th>
<th class="spacer"></th>
<th>Kategorie</th>
<th>Notiz</th>
<th class="spacer"></th>
<th>Pattern</th>
</tr>
<tr ng-repeat="line in csv.data">
<td>{{line[1]}}</td>
<td>{{line[2]}}</td>
<td>{{line[3]}}</td>
<td align="right">{{line[4]}}</td>
<td class="spacer"></td>
<td></td>
<td></td>
<td class="spacer"></td>
<td></td>
</tr>
</table>
</div>
</div>
@@ -0,0 +1,14 @@
<div class="container">
<div class="row">
<form name="importForm" ng-submit="importCSV()" style="text-align: center;">
<textarea ng-model='csvInput' name="csvText" cols="140" rows="20"></textarea>
<div>
<button id="transactionSubmit" type="submit" class="btn btn-primary">
<span ng-show="waitingForImport"><i class="glyphicon glyphicon-refresh spinning"></i>&nbsp;</span>
Analyze
</button>
</div>
</form>
</div>
</div>
@@ -101,7 +101,9 @@
<div style="text-align: center; font-size: 80%" ng-show="nextPageAvailable">
<a href="" ng-click="moreTransactions()">more</a>
</div>
</div>
<div class="row">
<div ng-show="accountUsers.length > 1" style="margin-top: 2em; text-align: center;">
<span ng-repeat="user in accountUsers" ng-click="openOutstandings(user)" class="clickable">{{user.name}} {{user.outstandingAmount}}&nbsp;<br/></span>
</div>