diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f5d783..74408eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ # Next Release +* Amended category list on transaction submission +* Added budget view for weekly breakdown of spend by category + # v0.1.3 * Made fix to Travis config diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index c778998..c413237 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -25,17 +25,33 @@
- +
-
- +
+
+
+ +
+
+ +
+
+
+
+ +
+
- Optional: Choose the relevant Category for the purchase. + Optional: Choose the Budget Type for the majority of the purchase.
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 6d64ca8..48622bf 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -39,7 +39,8 @@ export class AddDataComponent implements OnInit { transactionFormInvalid = true; myDate: any; minDate: any; - categoryIdList: number[] = []; + leftCategoryIdList: number[] = []; + rightCategoryIdList: number[] = []; categoryNameList: string[] = []; constructor( @@ -85,8 +86,14 @@ export class AddDataComponent implements OnInit { } 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]); + 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() { diff --git a/src/app/dashboard/category-month.component.html b/src/app/dashboard/category-month.component.html index 5b5434d..0a7c91f 100644 --- a/src/app/dashboard/category-month.component.html +++ b/src/app/dashboard/category-month.component.html @@ -5,7 +5,7 @@
-

Purchases this week

+

Purchases Last Week

@@ -13,11 +13,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax1 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -36,7 +36,7 @@
    -

    Purchases last week

    +

    Purchases 1 Week Ago

    @@ -44,11 +44,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax2 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -67,7 +67,7 @@
    -

    Purchases 2 weeks ago

    +

    Purchases 2 Weeks Ago

    @@ -75,11 +75,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax3 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • @@ -98,7 +98,7 @@
    -

    Purchases 3 weeks ago

    +

    Purchases 3 Weeks Ago

    @@ -106,11 +106,11 @@
  • {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (categoryEntry.value || 0 ) / weekListValueMax4 | percent:'1.0-0' }}) + ({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})
    + [style.width]="(categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100">
  • diff --git a/src/app/dashboard/category-month.component.ts b/src/app/dashboard/category-month.component.ts index 6569a26..1356a3f 100644 --- a/src/app/dashboard/category-month.component.ts +++ b/src/app/dashboard/category-month.component.ts @@ -22,10 +22,10 @@ export class CategoryMonthComponent implements OnInit { weekList2 = []; weekList3 = []; weekList4 = []; - weekListValueMax1: number = 0; - weekListValueMax2: number = 0; - weekListValueMax3: number = 0; - weekListValueMax4: number = 0; + weekListValueSum1: number = 0; + weekListValueSum2: number = 0; + weekListValueSum3: number = 0; + weekListValueSum4: number = 0; categoryList: number[] = []; dayList: any[] = []; @@ -56,7 +56,6 @@ export class CategoryMonthComponent implements OnInit { ); this.api.categoryTransactionList().subscribe( result => { - console.log(result); this.setData(result); }, error => { @@ -97,16 +96,16 @@ export class CategoryMonthComponent implements OnInit { data3: any, data4: any) { 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) { - 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) { - 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) { - 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); } }