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
227f87af8f
4 changed files with 105 additions and 80 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,3 +34,4 @@
|
||||||
.rvmrc
|
.rvmrc
|
||||||
/thin.*
|
/thin.*
|
||||||
/bundle/
|
/bundle/
|
||||||
|
vendor/
|
||||||
|
|
|
@ -63,6 +63,7 @@ module Ledger
|
||||||
period = period.nil? ? '' : "-p '#{period}'"
|
period = period.nil? ? '' : "-p '#{period}'"
|
||||||
depth = depth.nil? ? '' : "--depth #{depth}"
|
depth = depth.nil? ? '' : "--depth #{depth}"
|
||||||
operation = cleared ? 'cleared' : 'balance'
|
operation = cleared ? 'cleared' : 'balance'
|
||||||
|
|
||||||
run( "--flat --no-total --exchange '#{CURRENCY}' #{period} #{depth}", operation, categories )
|
run( "--flat --no-total --exchange '#{CURRENCY}' #{period} #{depth}", operation, categories )
|
||||||
.split( "\n" )
|
.split( "\n" )
|
||||||
.map do |line|
|
.map do |line|
|
||||||
|
@ -72,7 +73,20 @@ module Ledger
|
||||||
amount: line_array[ 0 ].tr( SEPARATOR, '.' ).to_f }
|
amount: line_array[ 0 ].tr( SEPARATOR, '.' ).to_f }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def int_treefied_balance( node )
|
||||||
|
# return { name: node[:account], size: node[:amount] } unless node[:account].include( ':' )
|
||||||
|
|
||||||
|
# { name: node[:account].split(':').first,
|
||||||
|
# children: int_treefied_balance( ... ) }
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def treefeid_balance( cleared = false, depth = nil, period = nil, categories = '' )
|
||||||
|
# bal = balance( cleared, depth, period, categories )
|
||||||
|
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
def cleared
|
def cleared
|
||||||
run( "--flat --no-total --exchange '#{CURRENCY}'", 'cleared', 'Assets Equity' )
|
run( "--flat --no-total --exchange '#{CURRENCY}'", 'cleared', 'Assets Equity' )
|
||||||
.split( "\n" )
|
.split( "\n" )
|
||||||
|
|
|
@ -119,14 +119,19 @@ app.controller( 'DashboardCtrl',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pie_graph_options = { chart: { type: 'pieChart',
|
this.pie_graph_options = { chart: { type: 'pieChart',
|
||||||
|
donut: true,
|
||||||
|
donutRatio: 0.25,
|
||||||
height: 300,
|
height: 300,
|
||||||
x: function( d ) { return d.account; },
|
x: function( d ) { return d.account; },
|
||||||
y: function( d ) { return d.amount; },
|
y: function( d ) { return d.amount; },
|
||||||
showLabels: false,
|
showLabels: false,
|
||||||
showLegend: false,
|
showLegend: true,
|
||||||
|
legendPosition: 'right',
|
||||||
|
showTooltipPercent: true,
|
||||||
duration: 500,
|
duration: 500,
|
||||||
labelThreshold: 0.01,
|
labelThreshold: 0.01,
|
||||||
labelSunbeamLayout: true
|
labelSunbeamLayout: true,
|
||||||
|
donutLabelsOutside: true
|
||||||
} };
|
} };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,48 +207,53 @@ app.controller( 'DashboardCtrl',
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$scope.graphiques = { monthly_values: { options: { chart: { type: 'multiBarChart',
|
$scope.graphiques = {
|
||||||
height: 300,
|
monthly_values: {
|
||||||
showControls: false,
|
options: {
|
||||||
showLegend: true,
|
chart: {
|
||||||
showLabels: true,
|
type: 'multiBarChart',
|
||||||
stacked: false,
|
height: 300,
|
||||||
duration: 500,
|
showControls: false,
|
||||||
reduceXTicks: false,
|
showLegend: true,
|
||||||
rotateLabels: 67,
|
showLabels: true,
|
||||||
labelSunbeamLayout: true,
|
stacked: false,
|
||||||
useInteractiveGuideline: false,
|
duration: 500,
|
||||||
multibar: {
|
reduceXTicks: false,
|
||||||
dispatch: {
|
rotateLabels: 67,
|
||||||
elementClick: function( event ) {
|
labelSunbeamLayout: true,
|
||||||
$scope.period = event.data.x;
|
useInteractiveGuideline: false,
|
||||||
retrieve_period_detailed_data();
|
multibar: {
|
||||||
}
|
dispatch: {
|
||||||
}
|
elementClick: function( event ) {
|
||||||
}}
|
$scope.period = event.data.x;
|
||||||
},
|
retrieve_period_detailed_data();
|
||||||
data: _.chain( response.data )
|
}
|
||||||
.keys()
|
}
|
||||||
.reverse()
|
}
|
||||||
.map( function( key ) {
|
}
|
||||||
var multiplicator = ( key == "Income" ) ? -1 : 1;
|
},
|
||||||
return { key: key,
|
data: _.chain( response.data )
|
||||||
values: _.chain(response.data[ key ]).map( function( value ) {
|
.keys()
|
||||||
var date = new Date( value.date );
|
.reverse()
|
||||||
var period = date.getFullYear() + '-' + ( date.getMonth() < 9 ? '0' : '' ) + ( date.getMonth() + 1 );
|
.map( function( key ) {
|
||||||
$scope.periods.push( period );
|
var multiplicator = ( key == "Income" ) ? -1 : 1;
|
||||||
|
return { key: key,
|
||||||
|
values: _.chain(response.data[ key ]).map( function( value ) {
|
||||||
|
var date = new Date( value.date );
|
||||||
|
var period = date.getFullYear() + '-' + ( date.getMonth() < 9 ? '0' : '' ) + ( date.getMonth() + 1 );
|
||||||
|
$scope.periods.push( period );
|
||||||
|
|
||||||
return { key: key,
|
return { key: key,
|
||||||
x: period,
|
x: period,
|
||||||
y: parseInt( value.amount ) * multiplicator };
|
y: parseInt( value.amount ) * multiplicator };
|
||||||
} )
|
} )
|
||||||
.sortBy( function( item ) { return item.x; } )
|
.sortBy( function( item ) { return item.x; } )
|
||||||
.value()
|
.value()
|
||||||
};
|
};
|
||||||
} )
|
} )
|
||||||
.value()
|
.value()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.periods = _.chain($scope.periods).uniq().sort().reverse().value();
|
$scope.periods = _.chain($scope.periods).uniq().sort().reverse().value();
|
||||||
$scope.period = _($scope.periods).first();
|
$scope.period = _($scope.periods).first();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<md-content flex="100" layout="column">
|
<md-content flex="100" layout="column">
|
||||||
<md-card flex="100" layout="row">
|
<md-card flex="100" layout="row">
|
||||||
<md-card flex="20">
|
<md-card flex="20">
|
||||||
<select multiple="true" data-ng-model="graphed_accounts">
|
<select style="height: 100%;" multiple ng:model="graphed_accounts">
|
||||||
<option data-ng-repeat="account in accounts">{{account}}</option>
|
<option ng:repeat="account in accounts">{{account}}</option>
|
||||||
</select>
|
</select>
|
||||||
</md-card>
|
</md-card>
|
||||||
<md-card flex="81">
|
<md-card flex="81">
|
||||||
<nvd3 data="graphiques.monthly_values.data"
|
<nvd3 data="graphiques.monthly_values.data"
|
||||||
|
@ -12,50 +12,50 @@
|
||||||
</md-card>
|
</md-card>
|
||||||
<h1>{{period | amDateFormat:'MMMM YYYY'}}</h1>
|
<h1>{{period | amDateFormat:'MMMM YYYY'}}</h1>
|
||||||
<md-card flex="100" layout="column"
|
<md-card flex="100" layout="column"
|
||||||
data-ng-repeat="bucket in balance.buckets">
|
ng:repeat="bucket in balance.buckets">
|
||||||
<md-toolbar>
|
<md-toolbar>
|
||||||
<span data-ng-repeat="account in bucket.total_detailed">{{account.account}} = {{account.amount | number:2}} €</span>
|
<span ng:repeat="account in bucket.total_detailed">{{account.account}} = {{account.amount | number:2}} €</span>
|
||||||
</md-toolbar>
|
</md-toolbar>
|
||||||
<md-content layout="row">
|
<md-content layout="row">
|
||||||
<md-card flex="20">
|
<md-card flex="20">
|
||||||
<select multiple
|
<select style="height: 100%;" multiple
|
||||||
data-ng-model="bucket.accounts_selected"
|
ng:model="bucket.accounts_selected"
|
||||||
data-ng-options="account.account for account in bucket.raw_data | orderBy:'account'"
|
ng:options="account.account for account in bucket.raw_data | orderBy:'account'"
|
||||||
data-ng-change="filter_data()">
|
ng:change="filter_data()">
|
||||||
<option value=''>...</option>
|
<option value=''>...</option>
|
||||||
</select>
|
</select>
|
||||||
</md-card>
|
</md-card>
|
||||||
<md-card flex="20">
|
<md-card flex="78">
|
||||||
<nvd3 data="bucket.data"
|
<nvd3 data="bucket.data"
|
||||||
options="bucket.pie_graph_options" >
|
options="bucket.pie_graph_options" >
|
||||||
</nvd3>
|
</nvd3>
|
||||||
</md-card>
|
</md-card>
|
||||||
<md-card flex="56">
|
<!-- <md-card flex="56">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><md-buton data-ng-click="bucket.order_by( 'account' )">account</md-buton></th>
|
<th><md-buton 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 ng:click="bucket.order_by( 'amount' )">amount</md-buton></th>
|
||||||
<th><md-buton data-ng-click="bucket.order_by( 'score' )">score</md-buton></th>
|
<th><md-buton ng:click="bucket.order_by( 'score' )">score</md-buton></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr data-ng-repeat="account in bucket.data | orderBy:bucket.orderBy:bucket.orderDesc"
|
<tr ng:repeat="account in bucket.data | orderBy:bucket.orderBy:bucket.orderDesc"
|
||||||
data-ng-class="{'even': $even, 'odd': $odd}"
|
ng:class="{'even': $even, 'odd': $odd}"
|
||||||
style="border-left:10px solid {{coloring_score( account.score )}};border-right:10px solid {{coloring_score( account.score )}}">
|
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 )}}">
|
<td style="border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||||
{{account.account}}
|
{{account.account}}
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||||
{{account.amount | number:2}} €
|
{{account.amount | number:2}} €
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
<td style="text-align:right;border-bottom:1px solid {{coloring_score( account.score )}}">
|
||||||
{{account.score}}
|
{{account.score}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</md-card>
|
</md-card> -->
|
||||||
</md-content>
|
</md-content>
|
||||||
</md-card>
|
</md-card>
|
||||||
</md-content>
|
</md-content>
|
||||||
|
|
Loading…
Reference in a new issue