diff --git a/src/app/clients/clients-routing.module.ts b/src/app/clients/clients-routing.module.ts index fa363a5f0..df5ce2132 100644 --- a/src/app/clients/clients-routing.module.ts +++ b/src/app/clients/clients-routing.module.ts @@ -43,6 +43,8 @@ import { ChargesOverviewComponent } from './clients-view/charges-overview/charge import { ClientChargeOverviewResolver } from './clients-view/charges-overview/charge-overview.resolver'; import { ClientActionsResolver } from './common-resolvers/client-actions.resolver'; import { TakeSurveyResolver } from './common-resolvers/take-survey.resolver'; +import { ViewChargeComponent } from './clients-view/view-charge/view-charge.component'; +import { ClientChargeViewResolver } from './common-resolvers/client-charge-view.resolver'; const routes: Routes = [ Route.withShell([{ @@ -243,7 +245,8 @@ const routes: Routes = [ ClientAddressTemplateResolver, ClientChargeOverviewResolver, ClientActionsResolver, - TakeSurveyResolver + TakeSurveyResolver, + ClientChargeViewResolver ] }) export class ClientsRoutingModule { } diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.html b/src/app/clients/clients-view/general-tab/general-tab.component.html index eb3d33141..b80a988c7 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.html +++ b/src/app/clients/clients-view/general-tab/general-tab.component.html @@ -78,7 +78,7 @@ - + diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.scss b/src/app/clients/clients-view/general-tab/general-tab.component.scss index 65f6665da..482461bff 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.scss +++ b/src/app/clients/clients-view/general-tab/general-tab.component.scss @@ -12,6 +12,9 @@ table { width: 100%; + td:hover { + cursor: pointer; + } .account-action-button{ min-width: 26px; padding: 0 6px; diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.ts b/src/app/clients/clients-view/general-tab/general-tab.component.ts index 9da4a4408..9068b12ba 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.ts +++ b/src/app/clients/clients-view/general-tab/general-tab.component.ts @@ -35,6 +35,8 @@ export class GeneralTabComponent { showClosedFixedAccounts = false; clientid: any; + /** Route to Charges */ + routeToCharges: any; constructor( private route: ActivatedRoute, @@ -48,6 +50,11 @@ export class GeneralTabComponent { this.upcomingCharges = data.clientChargesData.pageItems; this.clientSummary = data.clientSummary[0]; this.clientid = this.route.parent.snapshot.params['clientId']; + }); + + /** Get Client Id and generate the route link. */ + this.route.parent.params.subscribe((params: any) => { + this.routeToCharges = '../../' + params.clientId + '/charges'; }); } diff --git a/src/app/clients/clients-view/view-charge/view-charge.component.html b/src/app/clients/clients-view/view-charge/view-charge.component.html new file mode 100644 index 000000000..a40b11fd6 --- /dev/null +++ b/src/app/clients/clients-view/view-charge/view-charge.component.html @@ -0,0 +1,132 @@ +
+ + + +
+ +
+ + + + + {{ chargeData.name }} + + + + + + + + + + +
+

Transactions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID {{element.id}} Office Name {{element.officeName }} Type {{element.type.value}} Transaction Date {{element.date | date}} Amount {{element.amount}} Actions + +
+ +
+ + + + + + +
+ +
\ No newline at end of file diff --git a/src/app/clients/clients-view/view-charge/view-charge.component.scss b/src/app/clients/clients-view/view-charge/view-charge.component.scss new file mode 100644 index 000000000..6a8f07526 --- /dev/null +++ b/src/app/clients/clients-view/view-charge/view-charge.component.scss @@ -0,0 +1,19 @@ +.delBtn{ + width: 20px !important; + height: 25px; + min-width: 20px!important; + line-height: 0px; + padding-left: 10px; + padding-right: 25px; +} + +.strikeoff { + color: red !important; + text-decoration: line-through; + text-decoration-style: double; +} + +.share-account-tables { + display: flex; + justify-content: space-between; +} diff --git a/src/app/clients/clients-view/view-charge/view-charge.component.spec.ts b/src/app/clients/clients-view/view-charge/view-charge.component.spec.ts new file mode 100644 index 000000000..6c6e3739c --- /dev/null +++ b/src/app/clients/clients-view/view-charge/view-charge.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewChargeComponent } from './view-charge.component'; + +describe('ViewChargeComponent', () => { + let component: ViewChargeComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewChargeComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewChargeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/clients/clients-view/view-charge/view-charge.component.ts b/src/app/clients/clients-view/view-charge/view-charge.component.ts new file mode 100644 index 000000000..1dbe36d55 --- /dev/null +++ b/src/app/clients/clients-view/view-charge/view-charge.component.ts @@ -0,0 +1,78 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DatePipe } from '@angular/common'; +import { ClientsService } from 'app/clients/clients.service'; + +/** + * View Charge component. + */ +@Component({ + selector: 'mifosx-view-charge', + templateUrl: './view-charge.component.html', + styleUrls: ['./view-charge.component.scss'] +}) +export class ViewChargeComponent implements OnInit { + + /** Charge Data. */ + chargeData: any; + /** Mat Table Column defs. */ + viewChargeTableColumns: string[] = ['id', 'officeName', 'type', 'transactionDate', 'amount', 'actions']; + + /** + * Retrieves the selected job data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private route: ActivatedRoute, + private router: Router, + private date: DatePipe, + private clientService: ClientsService) { + this.route.data.subscribe((data: { clientChargeData: any }) => { + this.chargeData = data.clientChargeData; + }); + } + + ngOnInit() { + + } + + /** + * Waive Charge. + */ + waiveCharge() { + const waiveChargeObj = { clientId: this.chargeData.clientId, resourceType: this.chargeData.id}; + this.clientService.waiveClientCharge(waiveChargeObj).subscribe(() => { + this.getChargeData(); + }); + } + + /** + * Undo Transaction. + */ + undoTransaction(transactionId: any) { + const transactionData = { clientId: this.chargeData.clientId.toString(), transactionId: transactionId}; + this.clientService.undoTransaction(transactionData).subscribe(() => { + this.getChargeData(); + }); + } + + /** + * Get Charge Data. + */ + getChargeData() { + this.clientService.getSelectedChargeData(this.chargeData.clientId, this.chargeData.id).subscribe((data: any) => { + this.chargeData = data; + }); + } + + /** + * Delete Charge. + */ + deleteCharge() { + this.clientService.deleteCharge(this.chargeData.clientId, this.chargeData.id).subscribe(() => { + this.router.navigate(['../../clients', this.chargeData.clientId, 'general']); + }); + } + +} diff --git a/src/app/clients/clients.module.ts b/src/app/clients/clients.module.ts index f0f9580e1..ca087d347 100644 --- a/src/app/clients/clients.module.ts +++ b/src/app/clients/clients.module.ts @@ -42,6 +42,7 @@ import { AcceptClientTransferComponent } from './clients-view/client-actions/acc import { ReactivateClientComponent } from './clients-view/client-actions/reactivate-client/reactivate-client.component'; import { UndoClientRejectionComponent } from './clients-view/client-actions/undo-client-rejection/undo-client-rejection.component'; import { AddClientChargeComponent } from './clients-view/client-actions/add-client-charge/add-client-charge.component'; +import { ViewChargeComponent } from './clients-view/view-charge/view-charge.component'; /** @@ -89,7 +90,8 @@ import { AddClientChargeComponent } from './clients-view/client-actions/add-clie AcceptClientTransferComponent, ReactivateClientComponent, UndoClientRejectionComponent, - AddClientChargeComponent + AddClientChargeComponent, + ViewChargeComponent ], entryComponents: [ UploadDocumentDialogComponent, diff --git a/src/app/clients/clients.service.ts b/src/app/clients/clients.service.ts index 405b06f00..30d146bdf 100644 --- a/src/app/clients/clients.service.ts +++ b/src/app/clients/clients.service.ts @@ -90,6 +90,14 @@ export class ClientsService { return this.http.get(`/clients/${clientId}/charges`, { params: httpParams }); } + getSelectedChargeData(clientId: string, chargeId: string) { + const httpParams = new HttpParams().set('associations', 'all'); + return this.http.get(`/clients/${clientId}/charges/${chargeId}`, { params: httpParams }); + } + + /** + * @param chargeData Charge Data to be waived. + */ waiveClientCharge(chargeData: any) { const httpParams = new HttpParams().set('command', 'waive'); return this.http.post(`/clients/${chargeData.clientId}/charges/${chargeData.resourceType}`, chargeData, { params: httpParams }); @@ -99,6 +107,21 @@ export class ClientsService { return this.http.get(`/clients/${clientId}/charges`); } + /** + * @param transactionData Transaction Data to be undone. + */ + undoTransaction(transactionData: any) { + return this.http.post(`/clients/${transactionData.clientId}/transactions/${transactionData.transactionId}?command=undo`, transactionData); + } + + /** + * @param clientId Client Id of the relevant charge. + * @param chargeId Charge Id to be deleted. + */ + deleteCharge(clientId: string, chargeId: string) { + return this.http.delete(`/clients/${clientId}/charges/${chargeId}?associations=all`); + } + getClientSummary(clientId: string) { const httpParams = new HttpParams().set('R_clientId', clientId) .set('genericResultSet', 'false'); diff --git a/src/app/clients/common-resolvers/client-charge-view.resolver.ts b/src/app/clients/common-resolvers/client-charge-view.resolver.ts new file mode 100644 index 000000000..f96d2a21d --- /dev/null +++ b/src/app/clients/common-resolvers/client-charge-view.resolver.ts @@ -0,0 +1,32 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { ClientsService } from '../clients.service'; + +/** + * Client Charge data resolver. + */ +@Injectable() +export class ClientChargeViewResolver implements Resolve { + + /** + * @param {ClientsService} ClientsService Clients service. + */ + constructor(private clientsService: ClientsService) { } + + /** + * Returns the Client Charge data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const clientId = route.paramMap.get('clientId'); + const chargeId = route.paramMap.get('chargeId'); + return this.clientsService.getSelectedChargeData(clientId, chargeId); + } + +}