mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2024-12-26 09:59:18 +01:00
merge
This commit is contained in:
commit
f191e1283d
3 changed files with 94 additions and 180 deletions
|
@ -3,6 +3,6 @@
|
|||
md-content table { max-width: 99%;
|
||||
width: 99%;
|
||||
margin: 0 0.5%; }
|
||||
|
||||
md-card select { height: 100%; }
|
||||
.even{background-color:#ddd}
|
||||
.odd{background-color:#eee}
|
||||
|
|
|
@ -22,10 +22,8 @@ app.controller( 'DashboardCtrl',
|
|||
|
||||
// compute an account's score: from 1 (good) to 10 (bad), 0 is neutral/undecided
|
||||
var score_account = function ( account ) {
|
||||
if ( account.match( /^Income:(salaire|Sécu|Mutuelle)$/ ) ) {
|
||||
return 11;
|
||||
} else if ( account.match( /^Income:(Gift|Remboursement)$/ ) ) {
|
||||
return 12;
|
||||
if ( account.match( /^Income/ ) ) {
|
||||
return -10;
|
||||
} else if ( account.match( /^Expenses:(courses|Hang)$/ ) ) {
|
||||
return 1;
|
||||
} else if ( account.match( /^Expenses:Home/ ) ) {
|
||||
|
@ -41,9 +39,9 @@ app.controller( 'DashboardCtrl',
|
|||
} else if ( account.match( /^Expenses:Gadgets/ ) ) {
|
||||
return 10;
|
||||
} else if ( account.match( /^Liabilities/ ) ) {
|
||||
return 1000;
|
||||
return 0;
|
||||
} else if ( account.match( /^Assets/ ) ) {
|
||||
return 100;
|
||||
return -100;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -53,18 +51,14 @@ app.controller( 'DashboardCtrl',
|
|||
var adjusted_score = score;
|
||||
var color_scale = [ '#99f', '#0f0', '#3f0', '#6f0', '#9f0', '#cf0', '#fc0', '#f90', '#f60', '#f30', '#f00' ];
|
||||
|
||||
if ( score >= 1000 ) {
|
||||
// Liabilities
|
||||
adjusted_score = score - 1000;
|
||||
color_scale = [ '#0ff' ];
|
||||
} else if ( score >= 100 ) {
|
||||
if ( score <= -100 ) {
|
||||
// Assets
|
||||
adjusted_score = score - 100;
|
||||
adjusted_score = ( score * -1 ) - 100;
|
||||
color_scale = [ '#f0f' ];
|
||||
} else if ( score >= 11 ) {
|
||||
} else if ( score <= -10 ) {
|
||||
// Income
|
||||
adjusted_score = score - 11;
|
||||
color_scale = [ '#360', '#369' ];
|
||||
adjusted_score = ( score * -1 ) - 10;
|
||||
color_scale = [ '#360' ];
|
||||
}
|
||||
|
||||
return color_scale[ adjusted_score ];
|
||||
|
@ -97,7 +91,7 @@ app.controller( 'DashboardCtrl',
|
|||
return memo + account.amount;
|
||||
}, 0 );
|
||||
} )
|
||||
.value();
|
||||
.value();
|
||||
bucket.total_detailed = _.chain(bucket.total_detailed)
|
||||
.keys()
|
||||
.map( function( key ) {
|
||||
|
@ -109,12 +103,6 @@ app.controller( 'DashboardCtrl',
|
|||
} );
|
||||
};
|
||||
|
||||
$scope.select = { score_higher_than: function( bucket, score ) {
|
||||
bucket.accounts_selected = _(bucket.raw_data).filter( function( account ) {
|
||||
return account.score >= score;
|
||||
} );
|
||||
}};
|
||||
|
||||
var Bucket = function( categories, period ) {
|
||||
var _this = this;
|
||||
this.categories = categories;
|
||||
|
@ -164,29 +152,11 @@ app.controller( 'DashboardCtrl',
|
|||
}, 0 );
|
||||
bucket.accounts_selected = bucket.raw_data;
|
||||
|
||||
$scope.select.score_higher_than( bucket, bucket.score_threshold );
|
||||
$scope.filter_data();
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
// $scope.dates_salaries = [];
|
||||
|
||||
// var retrieve_dates_salaries = function() {
|
||||
// API.dates_salaries()
|
||||
// .then( function ( response ) {
|
||||
// $scope.dates_salaries = response.data;
|
||||
// $scope.periods= [];
|
||||
// for ( var i = 0 ; i < ( $scope.dates_salaries.length - 1 ) ; i++ ) {
|
||||
// $scope.periods.push( 'from ' + $scope.dates_salaries[i] + ' to ' + $scope.dates_salaries[i+1] );
|
||||
// }
|
||||
// $scope.periods.push( 'from ' + _($scope.dates_salaries).last() );
|
||||
// $scope.periods = _($scope.periods).reverse();
|
||||
// $scope.period = _($scope.periods).first();
|
||||
// } );
|
||||
// };
|
||||
//retrieve_dates_salaries();
|
||||
|
||||
var retrieve_accounts = function() {
|
||||
API.accounts()
|
||||
.then( function ( response ) {
|
||||
|
|
|
@ -1,141 +1,85 @@
|
|||
<md-content flex="100" layout="column" layout-gt-md="row">
|
||||
<md-card flex="20">
|
||||
<select multiple="true" data-ng-model="graphed_accounts" style="height: 100%">
|
||||
<option data-ng-repeat="account in accounts">{{account}}</option>
|
||||
</select>
|
||||
</md-card>
|
||||
<md-card flex="75">
|
||||
<nvd3-multi-bar-chart
|
||||
data="monthly_values"
|
||||
id="monthlyValues"
|
||||
height="350"
|
||||
showXAxis="true"
|
||||
showYAxis="true"
|
||||
showLegend="true"
|
||||
interactive="true"
|
||||
tooltips="true"
|
||||
tooltipContent="barGraphToolTipContentFunction()"
|
||||
rotateLabels="67"
|
||||
margin="{left:70,top:70,bottom:70,right:125}" >
|
||||
<svg></svg>
|
||||
</nvd3-multi-bar-chart>
|
||||
</md-card>
|
||||
</md-content>
|
||||
<md-content flex="100" layout="column">
|
||||
<md-card flex="100" layout="row">
|
||||
<md-card flex="20">
|
||||
<select multiple="true" data-ng-model="graphed_accounts">
|
||||
<option data-ng-repeat="account in accounts">{{account}}</option>
|
||||
</select>
|
||||
</md-card>
|
||||
<md-card flex="81">
|
||||
<nvd3-multi-bar-chart
|
||||
data="monthly_values"
|
||||
id="monthlyValues"
|
||||
height="300"
|
||||
showXAxis="true"
|
||||
showYAxis="true"
|
||||
showLegend="true"
|
||||
interactive="true"
|
||||
tooltips="true"
|
||||
tooltipContent="barGraphToolTipContentFunction()"
|
||||
rotateLabels="67"
|
||||
margin="{left:70,top:70,bottom:70,right:125}" >
|
||||
<svg></svg>
|
||||
</nvd3-multi-bar-chart>
|
||||
</md-card>
|
||||
</md-card>
|
||||
|
||||
<md-toolbar flex="100" layout="column" layout-gt-md="row" layout-align="center center">
|
||||
<h2>
|
||||
<md-input-container>
|
||||
<md-select data-ng-model="period" aria-label="what">
|
||||
<md-option data-ng-repeat="period in periods">{{period}}</md-option>
|
||||
</md-select>
|
||||
</md-input-container>
|
||||
</h2>
|
||||
</md-toolbar>
|
||||
|
||||
<md-content flex="100" layout="column" layout-gt-md="row">
|
||||
<md-card flex="48" layout="column"
|
||||
data-ng-repeat="bucket in balance.buckets">
|
||||
<md-toolbar>
|
||||
<h4 data-ng-repeat="account in bucket.total_detailed">{{account.account}} = {{account.amount | number:2}} €</h4>
|
||||
<!-- <md-slider discrete
|
||||
aria-label="score threshold"
|
||||
min="0" max="10" step="1"
|
||||
data-ng-model="bucket.score_threshold"
|
||||
data-ng-change="select.score_higher_than( bucket, bucket.score_threshold ); filter_data()">
|
||||
</md-slider> -->
|
||||
<select multiple
|
||||
data-ng-model="bucket.accounts_selected"
|
||||
data-ng-options="account.account for account in bucket.raw_data | orderBy:'account'"
|
||||
data-ng-change="filter_data()">
|
||||
<option value=''>...</option>
|
||||
</select>
|
||||
</md-toolbar>
|
||||
<md-content>
|
||||
<md-card>
|
||||
<nvd3-pie-chart
|
||||
data="bucket.data"
|
||||
x="xFunction()"
|
||||
y="yFunction()"
|
||||
height="300"
|
||||
margin="{left:0,top:0,bottom:0,right:0}"
|
||||
color="color()"
|
||||
tooltips="true"
|
||||
tooltipcontent="toolTipContentFunction()"
|
||||
showLabels="true"
|
||||
labelType="value"
|
||||
donut="true"
|
||||
donutRatio="0.25">
|
||||
<svg></svg>
|
||||
</nvd3-pie-chart>
|
||||
</md-card>
|
||||
<md-card>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'account' )">account</md-buton></th>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'amount' )">amount</md-buton></th>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'score' )">score</md-buton></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr data-ng-repeat="account in bucket.data | orderBy:bucket.orderBy:bucket.orderDesc"
|
||||
data-ng-class="{'even': $even, 'odd': $odd}"
|
||||
style="border-left:10px solid {{coloring_score( account.score )}};border-right:10px solid {{coloring_score( account.score )}}">
|
||||
<td style="border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.account}}
|
||||
</td>
|
||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.amount | number:2}} €
|
||||
</td>
|
||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.score}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</md-card>
|
||||
</md-content>
|
||||
</md-card>
|
||||
<!-- <md-card flex="48" layout="column">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 11%">Account</th>
|
||||
<th style="width: 3%">Spent</th>
|
||||
<th style="width: 3%">Budgeted</th>
|
||||
<th style="width: 3%">Percentage</th>
|
||||
<th>Progress</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr data-ng-repeat="account in budget"
|
||||
data-ng-class="{'even': $even, 'odd': $odd}">
|
||||
<td>
|
||||
{{account.account}}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{account.amount | number:2}}{{account.currency}}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<span data-ng-if="account.percentage >= 0">{{account.budget | number:2}}{{account.currency}}</span>
|
||||
<span data-ng-if="account.percentage < 0">
|
||||
{{balance.buckets[1].raw_total - total_budget | number:2}}{{account.currency}}
|
||||
</span>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<span data-ng-if="account.percentage >= 0">{{account.percentage | number:2}}%</span>
|
||||
<span data-ng-if="account.percentage < 0">
|
||||
{{( account.amount / ( balance.buckets[1].raw_total - total_budget ) ) * 100 | number:2}}%
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<md-progress-linear
|
||||
ng-class="{'md-warn': account.percentage > 100, 'md-warn md-hue-3': account.account == '(unbudgeted)' }"
|
||||
md-mode="determinate"
|
||||
value="{{account.percentage}}"></md-progress-linear>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</md-card> -->
|
||||
<md-card flex="100" layout="column"
|
||||
data-ng-repeat="bucket in balance.buckets">
|
||||
<md-toolbar>
|
||||
<span data-ng-repeat="account in bucket.total_detailed">{{account.account}} = {{account.amount | number:2}} €</span>
|
||||
</md-toolbar>
|
||||
<md-content layout="row">
|
||||
<md-card flex="20">
|
||||
<select multiple
|
||||
data-ng-model="bucket.accounts_selected"
|
||||
data-ng-options="account.account for account in bucket.raw_data | orderBy:'account'"
|
||||
data-ng-change="filter_data()">
|
||||
<option value=''>...</option>
|
||||
</select>
|
||||
</md-card>
|
||||
<md-card flex="20">
|
||||
<nvd3-pie-chart
|
||||
data="bucket.data"
|
||||
x="xFunction()"
|
||||
y="yFunction()"
|
||||
height="300"
|
||||
margin="{left:0,top:0,bottom:0,right:0}"
|
||||
color="color()"
|
||||
tooltips="true"
|
||||
tooltipcontent="toolTipContentFunction()"
|
||||
showLabels="true"
|
||||
labelType="value"
|
||||
donut="true"
|
||||
donutRatio="0.25">
|
||||
<svg></svg>
|
||||
</nvd3-pie-chart>
|
||||
</md-card>
|
||||
<md-card flex="56">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'account' )">account</md-buton></th>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'amount' )">amount</md-buton></th>
|
||||
<th><md-buton data-ng-click="bucket.order_by( 'score' )">score</md-buton></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr data-ng-repeat="account in bucket.data | orderBy:bucket.orderBy:bucket.orderDesc"
|
||||
data-ng-class="{'even': $even, 'odd': $odd}"
|
||||
style="border-left:10px solid {{coloring_score( account.score )}};border-right:10px solid {{coloring_score( account.score )}}">
|
||||
<td style="border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.account}}
|
||||
</td>
|
||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.amount | number:2}} €
|
||||
</td>
|
||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||
{{account.score}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</md-card>
|
||||
</md-content>
|
||||
</md-card>
|
||||
</md-content>
|
||||
|
|
Loading…
Reference in a new issue