Feature: display account balance

This commit is contained in:
2015-10-08 11:59:53 +00:00
parent 784fb188d2
commit 13b0a57600
4 changed files with 32 additions and 3 deletions

View File

@@ -65,6 +65,7 @@
vm.dataLoading = false;
vm.entries = [];
vm.balance = undefined;
vm.categories = [];
vm.sub_categories = [];
vm.account = undefined;
@@ -92,6 +93,7 @@
AccountService.list($routeParams.account_id)
.then(function(response) {
if( response.success ) {
vm.balance = response.data.balance;
vm.entries = response.data.entries;
} else {
FlashService.error(response.message);
@@ -104,6 +106,7 @@
AccountService.create(vm.account, vm.entry)
.then( function(response) {
if( response.success) {
vm.balance = response.data.balance;
vm.entries = response.data.entries;
} else {
FlashService.error(response.message);
@@ -120,7 +123,8 @@
AccountService.drop(vm.account, entry)
.then(function(response) {
if( response.success ) {
vm.entries = response.data.entries;
vm.balance = response.data.balance;
vm.entries = response.data.entries;
} else {
FlashService.error( response.message );
}
@@ -134,6 +138,7 @@
.then( function(response) {
vm.dataLoading = false;
if( response.success ) {
vm.balance = response.data.balance;
var index = vm.entries.map(function (item) {
return item._id;
}).indexOf(origin._id);

View File

@@ -1,3 +1,18 @@
<div class="page-header">
<div class="pull-left">
<h1>
{{vm.account.name}}
<small ng-show="vm.reference"> - {{vm.account.reference}}</small>
</h1>
</div>
<div class="pull-right">
<h3 ng-class="{'text-danger': vm.balance <= 0}">
{{vm.balance | currency }}
<i class="fa fa-fw fa-balance-scale"></i>
</h3>
</div>
<div class="clearfix"></div>
</div>
<div class="container-fluid div-striped">
<div class="row vcenter">
<form name="form" ng-submit="vm.create()" role="form">
@@ -17,7 +32,7 @@
</select>
</div>
</div>
<div class="col-sm-2">
<div class="col-sm-2 hidden-sm">
<div class="form-group">
<select name="sub_category" class="form-control input-sm" ng-hide="!vm.entry.category || vm.sub_categories.length === 0" ng-model="vm.entry.sub_category">
<option value=""></option>