Merge pull request #65 from Pear-Trading/finn/categories
Budget view amended
This commit is contained in:
commit
46e2efeaba
5 changed files with 57 additions and 32 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
# Next Release
|
# Next Release
|
||||||
|
|
||||||
|
* Amended category list on transaction submission
|
||||||
|
* Added budget view for weekly breakdown of spend by category
|
||||||
|
|
||||||
# v0.1.3
|
# v0.1.3
|
||||||
|
|
||||||
* Made fix to Travis config
|
* Made fix to Travis config
|
||||||
|
|
|
@ -25,17 +25,33 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input">Category</label>
|
<label class="col-md-3 form-control-label" for="text-input">Budget Type</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div class="input-group">
|
<div class="row">
|
||||||
<select type="text" class="form-control" [(ngModel)]="categoryId" size="10">
|
<div class="col-md-6">
|
||||||
<option value="">Uncategorised</option>
|
<div>
|
||||||
<option *ngFor="let category of categoryIdList, let i=index" [ngValue]="category" >
|
<label>
|
||||||
{{ categoryNameList[i] }}
|
<input value="" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
</option>
|
Uncategorised
|
||||||
</select>
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="radio" *ngFor="let category of leftCategoryIdList, let i=index">
|
||||||
|
<label>
|
||||||
|
<input [value]="category" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
|
{{ categoryNameList[i] }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="radio" *ngFor="let category2 of rightCategoryIdList, let i=index">
|
||||||
|
<label>
|
||||||
|
<input [value]="category2" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
|
{{ categoryNameList[category2 - 1] }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block"><strong>Optional:</strong> Choose the relevant Category for the purchase.</span>
|
<span class="help-block"><strong>Optional:</strong> Choose the Budget Type for the majority of the purchase.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
|
@ -39,7 +39,8 @@ export class AddDataComponent implements OnInit {
|
||||||
transactionFormInvalid = true;
|
transactionFormInvalid = true;
|
||||||
myDate: any;
|
myDate: any;
|
||||||
minDate: any;
|
minDate: any;
|
||||||
categoryIdList: number[] = [];
|
leftCategoryIdList: number[] = [];
|
||||||
|
rightCategoryIdList: number[] = [];
|
||||||
categoryNameList: string[] = [];
|
categoryNameList: string[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -85,8 +86,14 @@ export class AddDataComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setCategoryList(data: any) {
|
private setCategoryList(data: any) {
|
||||||
this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
let categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
||||||
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
||||||
|
console.log(categoryIdList);
|
||||||
|
let halfLength = Math.floor(categoryIdList.length / 2);
|
||||||
|
this.leftCategoryIdList = categoryIdList.splice(0, halfLength);
|
||||||
|
console.log(this.leftCategoryIdList);
|
||||||
|
this.rightCategoryIdList = categoryIdList;
|
||||||
|
console.log(this.rightCategoryIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMinDate() {
|
getMinDate() {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h4 class="card-title float-left mb-0">Purchases this week</h4>
|
<h4 class="card-title float-left mb-0">Purchases Last Week</h4>
|
||||||
</div><!--/.col-->
|
</div><!--/.col-->
|
||||||
</div><!--/.row-->
|
</div><!--/.row-->
|
||||||
<div class="chart-wrapper">
|
<div class="chart-wrapper">
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<li *ngFor="let categoryEntry of weekList1 | slice:0:categoryLimit1; let i=index;">
|
<li *ngFor="let categoryEntry of weekList1 | slice:0:categoryLimit1; let i=index;">
|
||||||
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
||||||
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
({{ (categoryEntry.value || 0 ) / weekListValueMax1 | percent:'1.0-0' }})</span></span>
|
({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})</span></span>
|
||||||
<div class="bars">
|
<div class="bars">
|
||||||
<div class="progress" style="height: 6px;">
|
<div class="progress" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success" role="progressbar"
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
[style.width]="(categoryEntry.value || 0 ) / weekListValueMax1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h4 class="card-title float-left mb-0">Purchases last week</h4>
|
<h4 class="card-title float-left mb-0">Purchases 1 Week Ago</h4>
|
||||||
</div><!--/.col-->
|
</div><!--/.col-->
|
||||||
</div><!--/.row-->
|
</div><!--/.row-->
|
||||||
<div class="chart-wrapper">
|
<div class="chart-wrapper">
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
<li *ngFor="let categoryEntry of weekList2 | slice:0:categoryLimit2; let i=index;">
|
<li *ngFor="let categoryEntry of weekList2 | slice:0:categoryLimit2; let i=index;">
|
||||||
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
||||||
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
({{ (categoryEntry.value || 0 ) / weekListValueMax2 | percent:'1.0-0' }})</span></span>
|
({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})</span></span>
|
||||||
<div class="bars">
|
<div class="bars">
|
||||||
<div class="progress" style="height: 6px;">
|
<div class="progress" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success" role="progressbar"
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
[style.width]="(categoryEntry.value || 0 ) / weekListValueMax2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h4 class="card-title float-left mb-0">Purchases 2 weeks ago</h4>
|
<h4 class="card-title float-left mb-0">Purchases 2 Weeks Ago</h4>
|
||||||
</div><!--/.col-->
|
</div><!--/.col-->
|
||||||
</div><!--/.row-->
|
</div><!--/.row-->
|
||||||
<div class="chart-wrapper">
|
<div class="chart-wrapper">
|
||||||
|
@ -75,11 +75,11 @@
|
||||||
<li *ngFor="let categoryEntry of weekList3 | slice:0:categoryLimit3; let i=index;">
|
<li *ngFor="let categoryEntry of weekList3 | slice:0:categoryLimit3; let i=index;">
|
||||||
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
||||||
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
({{ (categoryEntry.value || 0 ) / weekListValueMax3 | percent:'1.0-0' }})</span></span>
|
({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})</span></span>
|
||||||
<div class="bars">
|
<div class="bars">
|
||||||
<div class="progress" style="height: 6px;">
|
<div class="progress" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success" role="progressbar"
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
[style.width]="(categoryEntry.value || 0 ) / weekListValueMax3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h4 class="card-title float-left mb-0">Purchases 3 weeks ago</h4>
|
<h4 class="card-title float-left mb-0">Purchases 3 Weeks Ago</h4>
|
||||||
</div><!--/.col-->
|
</div><!--/.col-->
|
||||||
</div><!--/.row-->
|
</div><!--/.row-->
|
||||||
<div class="chart-wrapper">
|
<div class="chart-wrapper">
|
||||||
|
@ -106,11 +106,11 @@
|
||||||
<li *ngFor="let categoryEntry of weekList4 | slice:0:categoryLimit4; let i=index;">
|
<li *ngFor="let categoryEntry of weekList4 | slice:0:categoryLimit4; let i=index;">
|
||||||
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
<span class="title">{{ categoryNameList[categoryEntry.category] || 'Uncategorised' }}</span>
|
||||||
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
({{ (categoryEntry.value || 0 ) / weekListValueMax4 | percent:'1.0-0' }})</span></span>
|
({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})</span></span>
|
||||||
<div class="bars">
|
<div class="bars">
|
||||||
<div class="progress" style="height: 6px;">
|
<div class="progress" style="height: 6px;">
|
||||||
<div class="progress-bar bg-success" role="progressbar"
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
[style.width]="(categoryEntry.value || 0 ) / weekListValueMax4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -22,10 +22,10 @@ export class CategoryMonthComponent implements OnInit {
|
||||||
weekList2 = [];
|
weekList2 = [];
|
||||||
weekList3 = [];
|
weekList3 = [];
|
||||||
weekList4 = [];
|
weekList4 = [];
|
||||||
weekListValueMax1: number = 0;
|
weekListValueSum1: number = 0;
|
||||||
weekListValueMax2: number = 0;
|
weekListValueSum2: number = 0;
|
||||||
weekListValueMax3: number = 0;
|
weekListValueSum3: number = 0;
|
||||||
weekListValueMax4: number = 0;
|
weekListValueSum4: number = 0;
|
||||||
|
|
||||||
categoryList: number[] = [];
|
categoryList: number[] = [];
|
||||||
dayList: any[] = [];
|
dayList: any[] = [];
|
||||||
|
@ -56,7 +56,6 @@ export class CategoryMonthComponent implements OnInit {
|
||||||
);
|
);
|
||||||
this.api.categoryTransactionList().subscribe(
|
this.api.categoryTransactionList().subscribe(
|
||||||
result => {
|
result => {
|
||||||
console.log(result);
|
|
||||||
this.setData(result);
|
this.setData(result);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
@ -97,16 +96,16 @@ export class CategoryMonthComponent implements OnInit {
|
||||||
data3: any,
|
data3: any,
|
||||||
data4: any) {
|
data4: any) {
|
||||||
if (data1) {
|
if (data1) {
|
||||||
this.weekListValueMax1 = Math.max.apply(Math,data1.map(function(o){return o.value;}));
|
this.weekListValueSum1 = data1.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
}
|
}
|
||||||
if (data2) {
|
if (data2) {
|
||||||
this.weekListValueMax2 = Math.max.apply(Math,data2.map(function(o){return o.value;}));
|
this.weekListValueSum2 = data2.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
}
|
}
|
||||||
if (data3) {
|
if (data3) {
|
||||||
this.weekListValueMax3 = Math.max.apply(Math,data3.map(function(o){return o.value;}));
|
this.weekListValueSum3 = data3.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
}
|
}
|
||||||
if (data4) {
|
if (data4) {
|
||||||
this.weekListValueMax4 = Math.max.apply(Math,data4.map(function(o){return o.value;}));
|
this.weekListValueSum4 = data4.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue