diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f3c39a..44f290b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,19 @@ # Next Release +# v0.1.6 + +* Changed layout of category choosing on upload +* Added ability to edit and remove recurring transactions +* Fixed HttpClient error log viewing +* Made transaction validation more lenient + # v0.1.5 * Fixed category viewing on purchase +* Changed category view from radio buttons to full label buttons +* Amended local validation of submit +* Changed recurring purchase selection view # v0.1.4 diff --git a/package-lock.json b/package-lock.json index ecdbe1a..7334a98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6752,9 +6752,9 @@ "integrity": "sha1-zJJ7GR2Yb+D7atKVeQdQxV3L6FE=" }, "ngx-bootstrap": { - "version": "2.0.0-beta.8", - "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-2.0.0-beta.8.tgz", - "integrity": "sha512-e+3euXDb4nhzxn9kBO4RPWwRaI2ef7Lg+us8Yo2DBfD/Kuk/vl7ksWjoolMFLKEGpcTcKhMT/4BH5dUx+S4AtA==" + "version": "2.0.0-rc.1", + "resolved": "https://registry.npmjs.org/ngx-bootstrap/-/ngx-bootstrap-2.0.0-rc.1.tgz", + "integrity": "sha512-/ARJ2LLrT4bDghOVS16btJovJ7lsDcILmBUvGt0EXzNlU1HbTQZKfl/OKhrufmRgHQIzc6kXckVUhz5d5QIsUA==" }, "ngx-pagination": { "version": "3.0.3", diff --git a/package.json b/package.json index 11dcb5e..5d7e254 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "moment": "^2.21.0", "ng2-charts": "1.6.0", "ng2-validation-manager": "0.5.3", - "ngx-bootstrap": "2.0.0-beta.8", + "ngx-bootstrap": "2.0.0-rc.1", "ngx-pagination": "3.0.3", "rxjs": "5.5.6", "ts-helpers": "1.1.2", diff --git a/src/app/auth/register.component.ts b/src/app/auth/register.component.ts index 419eeef..95c86db 100644 --- a/src/app/auth/register.component.ts +++ b/src/app/auth/register.component.ts @@ -78,24 +78,18 @@ export class RegisterComponent { .register(data) .subscribe( result => { - console.log('registered!'); this.registerStatus = 'success'; - console.log(this.registerStatus); this.router.navigate(['/dashboard']); }, error => { console.log('Register Error'); console.log(error); try { - console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + this.registerStatusError = '"' + error.error.error + '" Error, ' + error.error.message; } catch (e) { this.registerStatusError = 'There was a server error, please try again later.'; } this.registerStatus = 'send_failed'; - console.log(this.registerStatus); } ); } @@ -127,19 +121,13 @@ export class RegisterComponent { .register(data) .subscribe( result => { - console.log('registered!'); this.registerStatus = 'success'; - console.log(this.registerStatus); this.router.navigate(['/dashboard']); }, error => { - console.log('Register Error'); console.log(error); try { - console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + this.registerStatusError = '"' + error.error.error + '" Error, ' + error.error.message; } catch (e) { this.registerStatusError = 'There was a server error, please try again later.'; } diff --git a/src/app/dashboard/account-edit.component.ts b/src/app/dashboard/account-edit.component.ts index 7590154..ea839fd 100644 --- a/src/app/dashboard/account-edit.component.ts +++ b/src/app/dashboard/account-edit.component.ts @@ -105,23 +105,17 @@ export class AccountEditComponent implements OnInit { .accountEditUpdate(submitData) .subscribe( result => { - console.log('data submitted!'); this.submitStatus = 'success'; - console.log(this.submitStatus); }, error => { console.log('Edit Error'); console.log(error); try { - console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + this.submitStatusError = '"' + error.error.error + '" Error, ' + error.error.message; } catch (e) { this.submitStatusError = 'There was a server error, please try again later.'; } this.submitStatus = 'send_failed'; - console.log(this.submitStatus); } ); } @@ -131,7 +125,6 @@ export class AccountEditComponent implements OnInit { if (!this.settingForm.valid && !this.settingCustomerForm.valid) { console.log('Not Valid!'); this.submitStatus = 'validation_failed'; - console.log(this.submitStatus); return; } diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 329c7d9..f1630c4 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -46,29 +46,22 @@
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
+
+ + + + +
Please give the period of time the purchase will recur from "Time of Transaction". @@ -78,21 +71,18 @@
-
-
- - -
-
- - -
+
+ +
-
-
- - -
+
+
Optional: Choose the Budget Type for the majority of the purchase. @@ -108,21 +98,21 @@
- +
Enter the street name where the organisation is located at.
- +
Enter the name of the town where the organisation is located at.
- +
Enter the postcode where the organisation is located at. diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 99a1df4..34b0ca3 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -30,8 +30,6 @@ export class AddDataComponent implements OnInit { organisationTown: string; organisationPostcode: string; amount: number; - // Assumes Groceries is 1st category - categoryId: number = 1; essentialPurchase = false; recurringPurchase = false; recurringType: string; @@ -42,10 +40,11 @@ export class AddDataComponent implements OnInit { transactionFormInvalid = true; myDate: any; minDate: any; - leftCategoryIdList: number[] = []; - rightCategoryIdList: number[] = []; - leftCategoryNameList: number[] = []; - rightCategoryNameList: number[] = []; + categoryList: any; + categoryIdList: any; + leftCategoryList: number[] = []; + rightCategoryList: string[] = []; + categoryId: number; constructor( private formBuilder: FormBuilder, @@ -75,7 +74,9 @@ export class AddDataComponent implements OnInit { // this.myDate = new Date().toISOString().slice(0, 16); this.api.categoryList().subscribe( result => { - this.setCategoryList(result.categories); + this.categoryList = result.categories; + this.categoryIdList = Object.keys(this.categoryList); + this.setCategoryList(this.categoryIdList); }, error => { console.log('Retrieval Error'); @@ -90,13 +91,9 @@ export class AddDataComponent implements OnInit { } private setCategoryList(data: any) { - let categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); - let categoryNameList = Object.keys(data.names).map(key => data.names[key]); - let halfLength = Math.floor(categoryIdList.length / 2); - this.leftCategoryIdList = categoryIdList.splice(0, halfLength); - this.leftCategoryNameList = categoryNameList.splice(0, halfLength); - this.rightCategoryIdList = categoryIdList; - this.rightCategoryNameList = categoryNameList; + let halfLength = Math.floor(data.length / 2); + this.leftCategoryList = data.splice(0, halfLength); + this.rightCategoryList = data; } getMinDate() { @@ -177,14 +174,15 @@ export class AddDataComponent implements OnInit { } transactionFormValidate() { - if (this.submitOrg.name.length === 0 || - this.submitOrg.town.length === 0 || - this.amount === 0 || - this.recurringPurchase && - !this.recurringType) { - this.transactionFormInvalid = true; - } else { + if (this.submitOrg.name.length && + this.amount && + (this.recurringPurchase && + this.recurringType || + !this.recurringPurchase && + !this.recurringType)) { this.transactionFormInvalid = false; + } else { + this.transactionFormInvalid = true; } } @@ -238,31 +236,22 @@ export class AddDataComponent implements OnInit { .subscribe( result => { if ( result.success === true ) { - console.log('Successful Upload'); - console.log(result); this.transactionFormStatus = 'success'; - console.log(this.transactionFormStatus); this.resetForm(); } else { - console.log('Upload Error'); this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } }, error => { - console.log('Upload Error'); console.log(error); try { console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + this.transactionFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message; } catch (e) { this.transactionFormStatusError = 'There was a server error, please try again later.'; } this.transactionFormStatus = 'send_failed'; - console.log(this.transactionFormStatus); } ); } @@ -290,14 +279,11 @@ export class AddDataComponent implements OnInit { .orgPayroll(this.payrollForm.value) .subscribe( result => { - console.log('data submitted!'); this.payrollFormStatus = 'success'; - console.log(this.payrollFormStatus); }, error => { console.log( error._body ); this.payrollFormStatus = 'send_failed'; - console.log(this.payrollFormStatus); } ); } @@ -309,14 +295,10 @@ export class AddDataComponent implements OnInit { .orgSupplier(this.singleSupplierForm.value) .subscribe( result => { - console.log('data submitted!'); this.singleSupplierFormStatus = 'success'; - console.log(this.singleSupplierFormStatus); }, error => { - console.log( error._body ); this.singleSupplierFormStatus = 'send_failed'; - console.log(this.singleSupplierFormStatus); } ); } @@ -328,14 +310,10 @@ export class AddDataComponent implements OnInit { .orgEmployee(this.employeeForm.value) .subscribe( result => { - console.log('data submitted!'); this.employeeFormStatus = 'success'; - console.log(this.employeeFormStatus); }, error => { - console.log( error._body ); this.employeeFormStatus = 'send_failed'; - console.log(this.employeeFormStatus); } ); } diff --git a/src/app/dashboard/category-month.component.html b/src/app/dashboard/category-month.component.html index 7bb83db..db24b1f 100644 --- a/src/app/dashboard/category-month.component.html +++ b/src/app/dashboard/category-month.component.html @@ -12,8 +12,8 @@
  • Essential Purchases - {{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential1.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }}) + {{ ( weekEssential1 ? weekEssential1.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential1 ? weekEssential1.value : 0 ) / weekListValueSum1 | percent:'1.0-0' }})
  • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})
    @@ -54,8 +54,8 @@
    • Essential Purchases - {{ ( weekEssential2.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential2.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }}) + {{ ( weekEssential2 ? weekEssential2.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential2 ? weekEssential2.value : 0 ) / weekListValueSum2 | percent:'1.0-0' }})
    • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})
      @@ -96,8 +96,8 @@
      • Essential Purchases - {{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential3.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }}) + {{ ( weekEssential3 ? weekEssential3.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential3 ? weekEssential3.value : 0 ) / weekListValueSum3 | percent:'1.0-0' }})
      • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})
        @@ -138,8 +138,8 @@
        • Essential Purchases - {{ ( weekEssential4.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} - ({{ (weekEssential4.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }}) + {{ ( weekEssential4 ? weekEssential4.value : 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ ( weekEssential4 ? weekEssential4.value : 0 ) / weekListValueSum4 | percent:'1.0-0' }})
        • - {{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }} + {{ categoryList[categoryEntry.category] || 'Uncategorised' }} {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} ({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})
          diff --git a/src/app/dashboard/category-month.component.ts b/src/app/dashboard/category-month.component.ts index 809e71f..140e8e3 100644 --- a/src/app/dashboard/category-month.component.ts +++ b/src/app/dashboard/category-month.component.ts @@ -31,15 +31,13 @@ export class CategoryMonthComponent implements OnInit { weekEssential3: number = 0; weekEssential4: number = 0; - categoryList: number[] = []; + categoryList: any; dayList: any[] = []; valueList: number[] = []; myWeek1: any; myWeek2: any; myWeek3: any; myWeek4: any; - categoryIdList: number[] = []; - categoryNameList: string[] = []; categoryLimit1: number = 6; categoryLimit2: number = 6; categoryLimit3: number = 6; @@ -51,7 +49,8 @@ export class CategoryMonthComponent implements OnInit { this.setDate(); this.api.categoryList().subscribe( result => { - this.setCategoryList(result.categories); + this.categoryList = result.categories; + console.log('Category List received'); }, error => { console.log('Retrieval Error'); @@ -72,11 +71,6 @@ export class CategoryMonthComponent implements OnInit { ngOnInit(): void { } - private setCategoryList(data: any) { - this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]); - this.categoryNameList = Object.keys(data.names).map(key => data.names[key]); - } - private setDate () { this.myWeek1 = moment().startOf('isoWeek').format('YYYY-MM-DD'); this.myWeek2 = moment(this.myWeek1).subtract(1, 'weeks').format('YYYY-MM-DD'); diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 2e47f80..21573f4 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -31,6 +31,8 @@ import { PiePanel } from '../panels/pie-panel.component'; import { DashboardRoutingModule } from './dashboard.routing'; import { OrgResultComponent } from '../shared/org-result.component'; import { OrgTableComponent } from '../shared/org-table.component'; +import { RecurResultComponent } from '../shared/recur-result.component'; +import { RecurTableComponent } from '../shared/recur-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; import { LeaderboardResultComponent } from '../shared/leaderboard-result.component'; @@ -61,6 +63,8 @@ import { environment } from '../../environments/environment'; AddDataComponent, OrgResultComponent, OrgTableComponent, + RecurResultComponent, + RecurTableComponent, TransactionLogComponent, CategoryMonthComponent, TransactionResultComponent, diff --git a/src/app/dashboard/feedback.component.ts b/src/app/dashboard/feedback.component.ts index 5228a3c..0603fbc 100644 --- a/src/app/dashboard/feedback.component.ts +++ b/src/app/dashboard/feedback.component.ts @@ -55,9 +55,7 @@ export class FeedbackComponent implements OnInit { result => { if ( result.success === true ) { console.log('Successful Upload'); - console.log(result); this.feedbackFormStatus = 'success'; - console.log(this.feedbackFormStatus); this.feedbackForm.patchValue({ feedbacktext: '', }); @@ -65,22 +63,16 @@ export class FeedbackComponent implements OnInit { console.log('Upload Error'); this.feedbackFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); this.feedbackFormStatus = 'send_failed'; - console.log(this.feedbackFormStatus); } }, error => { console.log('Upload Error'); - console.log(error); try { - console.log(error.error); - const jsonError = error.json(); - console.log('boop'); - this.feedbackFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + this.feedbackFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message; } catch (e) { this.feedbackFormStatusError = 'There was a server error, please try again later.'; } this.feedbackFormStatus = 'send_failed'; - console.log(this.feedbackFormStatus); } ); } diff --git a/src/app/dashboard/trail-map.component.ts b/src/app/dashboard/trail-map.component.ts index 3f15c06..6390d27 100644 --- a/src/app/dashboard/trail-map.component.ts +++ b/src/app/dashboard/trail-map.component.ts @@ -51,7 +51,6 @@ export class TrailMapComponent implements OnInit, AfterViewInit { } public onMarkerClick(clickedMarker, template: TemplateRef) { - console.log(clickedMarker); this.clickedMarker = clickedMarker; this.assocLogo = 'assets/img/association/' + this.assocMap + '-logo.png'; this.openModal(template); diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index b4f1e30..424897e 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -44,6 +44,102 @@ No Transactions available.
        +
        +
        + Recurring Transactions + Select a Recurring Transaction below to edit it. +
        +
        + + + + + + +
        +
        + No Recurring Transactions. +
        +
diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index 34408cd..019192c 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -1,10 +1,8 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Component, OnInit, EventEmitter, TemplateRef } from '@angular/core'; import { ApiService } from '../providers/api-service'; -// import { PaginatePipe } from 'ngx-pagination'; -import {PaginationInstance} from 'ngx-pagination'; -// import { PaginationControlsComponent } from 'ngx-pagination'; -// import { PaginationControlsDirective } from 'ngx-pagination'; -// import { TransactionResultComponent } from '../shared/transaction-result.component'; +import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; +import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; +import { PaginationInstance } from 'ngx-pagination'; import * as moment from 'moment'; import 'rxjs/add/operator/map'; @@ -13,11 +11,24 @@ import 'rxjs/add/operator/map'; }) export class TransactionLogComponent implements OnInit { - transactionList; + transactionList: any; + recurringTransactionList: any; noTransactionList = true; + noRecurringList = true; myDate: any; minDate: any; public p: any; + public modalRef: BsModalRef; + clickedRecur: any; + public updatedDate: string; + public startTime: string; + categoryIdList: any; + categoryList: any; + categoryNameList: string[] = []; + transactionFormStatus: string; + transactionFormStatusSuccess: string; + transactionFormStatusError = 'Error received, please try again.'; + updatedTime: string; public paginateConfig: PaginationInstance = { id: 'transpaginate', @@ -28,31 +39,27 @@ export class TransactionLogComponent implements OnInit { constructor( private api: ApiService, + private modalService: BsModalService, ) { this.myDate = moment().format('YYYY-MM-DD[T]HH:mm'); + this.api.categoryList().subscribe( + result => { + this.categoryList = result.categories; + this.categoryIdList = Object.keys(this.categoryList); + }, + error => { + console.log('Retrieval Error'); + console.log( error._body ); + } + ); // this.myDate = new Date().toISOString().slice(0, 16); } ngOnInit(): void { - this.getMinDate(); this.loadTransactions(1); } - getMinDate() { - // gets the April 1st date of the current year - const aprilDate = moment().month(3).date(1); - const now = moment(); - // Checks if current time is before April 1st, if so returns true - const beforeApril = now.isBefore(aprilDate); - if ( beforeApril === true ) { - this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); - } else { - this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); - } - } - loadTransactions(logPage: number) { - console.log(logPage); this.api.transList(logPage).subscribe( result => { if (result.transactions.length > 0) { @@ -66,6 +73,13 @@ export class TransactionLogComponent implements OnInit { this.transactionList = null; this.noTransactionList = true; } + if (result.recurring_transactions) { + this.recurringTransactionList = result.recurring_transactions; + this.noRecurringList = false; + } else { + this.recurringTransactionList = null; + this.noRecurringList = true; + } }, error => { console.log(error); @@ -73,4 +87,78 @@ export class TransactionLogComponent implements OnInit { ); } + recurringTransactionDetails(clicked, template: TemplateRef) { + this.clickedRecur = clicked; + this.updatedTime = moment(this.clickedRecur.display_time, 'llll').format('YYYY-MM-DD[T]HH:mm'); + this.openModal(template); + } + + openModal(template: TemplateRef) { + this.modalRef = this.modalService.show(template); + } + + editRecurringTransaction() { + let updatedTimeSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); + this.clickedRecur.display_time = moment(this.updatedTime).format('llll'); + let myParams = { + category: (this.clickedRecur.category == 0 ? undefined : this.clickedRecur.category), + essential: this.clickedRecur.essential, + id: this.clickedRecur.id, + apply_time: updatedTimeSubmit, + recurring_period: this.clickedRecur.recurring_period, + seller: this.clickedRecur.seller, + value: this.clickedRecur.value, + }; + this.api + .recurUpdate(myParams) + .subscribe( + result => { + if ( result.success === true ) { + this.transactionFormStatus = 'success'; + this.transactionFormStatusSuccess = 'Edit Succeeded.'; + } else { + this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); + this.transactionFormStatus = 'send_failed'; + } + }, + error => { + console.log(error); + try { + this.transactionFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message; + } catch (e) { + this.transactionFormStatusError = 'There was a server error, please try again later.'; + } + this.transactionFormStatus = 'send_failed'; + } + ); + } + + deleteRecurringTransaction() { + let myParams = { + id: this.clickedRecur.id, + }; + this.api + .recurDelete(myParams) + .subscribe( + result => { + if ( result.success === true ) { + this.transactionFormStatus = 'success'; + this.transactionFormStatusSuccess = 'Delete Succeeded.'; + } else { + this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); + this.transactionFormStatus = 'send_failed'; + } + }, + error => { + console.log(error); + try { + this.transactionFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message; + } catch (e) { + this.transactionFormStatusError = 'There was a server error, please try again later.'; + } + this.transactionFormStatus = 'send_failed'; + } + ); + } + } diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index bbf3464..a77a68c 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -158,6 +158,26 @@ export class ApiService { ); } + // Edits a recurring transaction + + public recurUpdate(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/recurring-transactions', + data + ); + } + + // Edits a recurring transaction + + public recurDelete(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/recurring-transactions/delete', + data + ); + } + // gets payroll list for log public payrollList(data) { diff --git a/src/app/shared/recur-result.component.html b/src/app/shared/recur-result.component.html new file mode 100644 index 0000000..c494b71 --- /dev/null +++ b/src/app/shared/recur-result.component.html @@ -0,0 +1,6 @@ +{{recur.seller}} +{{categories[recur.category] || 'Uncategorised'}} +{{recur.essential == 1 ? 'true' : 'false'}} +{{recur.display_time}} +{{recur.recurring_period}} +{{recur.value}} diff --git a/src/app/shared/recur-result.component.ts b/src/app/shared/recur-result.component.ts new file mode 100644 index 0000000..3532464 --- /dev/null +++ b/src/app/shared/recur-result.component.ts @@ -0,0 +1,40 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import * as moment from 'moment'; + +interface RecurData { + category: number; + essential: number; + id: number; + last_updated: string; + recurring_period: string; + seller: string; + start_time: string; + value: number; + display_time: any; +} + +@Component({ + // tslint:disable-next-line + selector: '[recur-result]', + templateUrl: 'recur-result.component.html', +}) +export class RecurResultComponent { + @Input() public recur: RecurData; + @Output() public onClick = new EventEmitter(); + @Input() public categories: any; + public updatedDate: string; + + ngOnInit(): void { + if (this.recur.last_updated) { + this.recur.display_time = moment(this.recur.last_updated).format('llll'); + } else { + this.recur.display_time = moment(this.recur.start_time).format('llll'); + } + } + + public recurClick(): void { + this.onClick.emit( + this.recur + ); + } +} diff --git a/src/app/shared/recur-table.component.html b/src/app/shared/recur-table.component.html new file mode 100644 index 0000000..a6ec55d --- /dev/null +++ b/src/app/shared/recur-table.component.html @@ -0,0 +1,17 @@ +
+ + + + + + + + + + + + + + +
SellerCategoryEssentialLast AppliedRecurring PeriodValue
+
diff --git a/src/app/shared/recur-table.component.ts b/src/app/shared/recur-table.component.ts new file mode 100644 index 0000000..c2f6ef0 --- /dev/null +++ b/src/app/shared/recur-table.component.ts @@ -0,0 +1,30 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { RecurResultComponent } from '../shared/recur-result.component'; + +interface RecurData { + category: string; + essential: number; + id: number; + last_updated: string; + recurring_period: string; + seller: string; + start_time: string; + value: number; + display_time: any; +} + +@Component({ + // tslint:disable-next-line + selector: 'recur-table', + templateUrl: 'recur-table.component.html', +}) +export class RecurTableComponent { + @Input() public recurList: Array; + @Output() public onClick = new EventEmitter(); + @Input() public categories: any; + + + public recurClick(event: any): void { + this.onClick.emit( event ); + } +}