mirror of
https://github.com/Febbweiss/CloudBudget-AngularJS.git
synced 2026-03-04 22:35:38 +00:00
Feature: display account balance
This commit is contained in:
@@ -65,6 +65,7 @@
|
|||||||
|
|
||||||
vm.dataLoading = false;
|
vm.dataLoading = false;
|
||||||
vm.entries = [];
|
vm.entries = [];
|
||||||
|
vm.balance = undefined;
|
||||||
vm.categories = [];
|
vm.categories = [];
|
||||||
vm.sub_categories = [];
|
vm.sub_categories = [];
|
||||||
vm.account = undefined;
|
vm.account = undefined;
|
||||||
@@ -92,6 +93,7 @@
|
|||||||
AccountService.list($routeParams.account_id)
|
AccountService.list($routeParams.account_id)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if( response.success ) {
|
if( response.success ) {
|
||||||
|
vm.balance = response.data.balance;
|
||||||
vm.entries = response.data.entries;
|
vm.entries = response.data.entries;
|
||||||
} else {
|
} else {
|
||||||
FlashService.error(response.message);
|
FlashService.error(response.message);
|
||||||
@@ -104,6 +106,7 @@
|
|||||||
AccountService.create(vm.account, vm.entry)
|
AccountService.create(vm.account, vm.entry)
|
||||||
.then( function(response) {
|
.then( function(response) {
|
||||||
if( response.success) {
|
if( response.success) {
|
||||||
|
vm.balance = response.data.balance;
|
||||||
vm.entries = response.data.entries;
|
vm.entries = response.data.entries;
|
||||||
} else {
|
} else {
|
||||||
FlashService.error(response.message);
|
FlashService.error(response.message);
|
||||||
@@ -120,6 +123,7 @@
|
|||||||
AccountService.drop(vm.account, entry)
|
AccountService.drop(vm.account, entry)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if( response.success ) {
|
if( response.success ) {
|
||||||
|
vm.balance = response.data.balance;
|
||||||
vm.entries = response.data.entries;
|
vm.entries = response.data.entries;
|
||||||
} else {
|
} else {
|
||||||
FlashService.error( response.message );
|
FlashService.error( response.message );
|
||||||
@@ -134,6 +138,7 @@
|
|||||||
.then( function(response) {
|
.then( function(response) {
|
||||||
vm.dataLoading = false;
|
vm.dataLoading = false;
|
||||||
if( response.success ) {
|
if( response.success ) {
|
||||||
|
vm.balance = response.data.balance;
|
||||||
var index = vm.entries.map(function (item) {
|
var index = vm.entries.map(function (item) {
|
||||||
return item._id;
|
return item._id;
|
||||||
}).indexOf(origin._id);
|
}).indexOf(origin._id);
|
||||||
|
|||||||
@@ -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="container-fluid div-striped">
|
||||||
<div class="row vcenter">
|
<div class="row vcenter">
|
||||||
<form name="form" ng-submit="vm.create()" role="form">
|
<form name="form" ng-submit="vm.create()" role="form">
|
||||||
@@ -17,7 +32,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2 hidden-sm">
|
||||||
<div class="form-group">
|
<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">
|
<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>
|
<option value=""></option>
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><a href="/login">Login</a></li>
|
<li><a href="/login" ng-hide="{{globals.user}}">Login</a></li>
|
||||||
|
<li><a href="/logout" ng-show="{{globals.user}}">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ describe('AccountController', function() {
|
|||||||
should.exist(accountController.account);
|
should.exist(accountController.account);
|
||||||
accountController.account._id.should.be.equal(DEFAULT_ACCOUNT._id);
|
accountController.account._id.should.be.equal(DEFAULT_ACCOUNT._id);
|
||||||
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(1);
|
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(1);
|
||||||
|
accountController.balance.should.be.equal(100);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should fail to init', inject(function($httpBackend) {
|
it('should fail to init', inject(function($httpBackend) {
|
||||||
@@ -109,6 +110,7 @@ describe('AccountController', function() {
|
|||||||
|
|
||||||
should.not.exist(accountController.account);
|
should.not.exist(accountController.account);
|
||||||
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
||||||
|
should.not.exist(accountController.balance);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -139,6 +141,7 @@ describe('AccountController', function() {
|
|||||||
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
||||||
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
||||||
should.exist(entry._id);
|
should.exist(entry._id);
|
||||||
|
accountController.balance.should.be.equal(100);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should fail to create entry', inject(function($httpBackend) {
|
it('should fail to create entry', inject(function($httpBackend) {
|
||||||
@@ -165,6 +168,7 @@ describe('AccountController', function() {
|
|||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
||||||
|
accountController.balance.should.be.equal(0);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -189,6 +193,7 @@ describe('AccountController', function() {
|
|||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(0);
|
||||||
|
accountController.balance.should.be.equal(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should fail to delete unknown entry', inject(function($httpBackend) {
|
it('should fail to delete unknown entry', inject(function($httpBackend) {
|
||||||
@@ -211,6 +216,7 @@ describe('AccountController', function() {
|
|||||||
|
|
||||||
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(1);
|
accountController.entries.should.be.instanceof(Array).and.have.lengthOf(1);
|
||||||
accountController.entries[0]._id.should.be.equal(DEFAULT_ENTRY._id);
|
accountController.entries[0]._id.should.be.equal(DEFAULT_ENTRY._id);
|
||||||
|
accountController.balance.should.be.equal(100);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -248,6 +254,7 @@ describe('AccountController', function() {
|
|||||||
entry.category.should.be.equal(DEFAULT_ENTRY.category);
|
entry.category.should.be.equal(DEFAULT_ENTRY.category);
|
||||||
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
||||||
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
||||||
|
accountController.balance.should.be.equal(120);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should fail to edit unknown entry', inject(function($httpBackend) {
|
it('should fail to edit unknown entry', inject(function($httpBackend) {
|
||||||
@@ -283,6 +290,7 @@ describe('AccountController', function() {
|
|||||||
entry.category.should.be.equal(DEFAULT_ENTRY.category);
|
entry.category.should.be.equal(DEFAULT_ENTRY.category);
|
||||||
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
entry.sub_category.should.be.equal(DEFAULT_ENTRY.sub_category);
|
||||||
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
entry.type.should.be.equal(DEFAULT_ENTRY.type);
|
||||||
|
accountController.balance.should.be.equal(100);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user