diff --git a/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver.ts b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver.ts new file mode 100644 index 000000000..7ad489b1c --- /dev/null +++ b/src/app/deposits/fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver.ts @@ -0,0 +1,33 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { FixedDepositsService } from '../fixed-deposits.service'; + +/** + * Fixed Deposits Account Transaction data resolver. + */ +@Injectable() +export class FixedDepositsAccountTransactionResolver implements Resolve { + + /** + * @param {FixedDepositsService} fixedDepositsService Savings service. + */ + constructor(private fixedDepositsService: FixedDepositsService) { } + + /** + * Returns the Fixed Deposits Account Transaction data. + * @param {ActivatedRouteSnapshot} route Route Snapshot + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const fixedDepositAccountId = route.parent.paramMap.get('fixedDepositAccountId'); + const transactionId = route.paramMap.get('id'); + return this.fixedDepositsService.getFixedDepositsAccountTransaction(fixedDepositAccountId, transactionId); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.html new file mode 100644 index 000000000..688f28271 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.html @@ -0,0 +1,8 @@ +

Undo Transaction

+
+

Are you sure you want to undo this transaction ?

+
+ + + + diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.spec.ts new file mode 100644 index 000000000..dbc966965 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UndoTransactionDialogComponent } from './undo-transaction-dialog.component'; + +describe('UndoTransactionDialogComponent', () => { + let component: UndoTransactionDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ UndoTransactionDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(UndoTransactionDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.ts new file mode 100644 index 000000000..07720213b --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component.ts @@ -0,0 +1,20 @@ +/** Angular Imports */ +import { Component } from '@angular/core'; +import { MatDialogRef } from '@angular/material'; + +/** + * Undo transaction dialog component. + */ +@Component({ + selector: 'mifosx-undo-transaction-dialog', + templateUrl: './undo-transaction-dialog.component.html', + styleUrls: ['./undo-transaction-dialog.component.scss'] +}) +export class UndoTransactionDialogComponent { + + /** + * @param {MatDialogRef} dialogRef Component reference to dialog. + */ + constructor(public dialogRef: MatDialogRef) { } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.html index f9307818a..51dc78be9 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.html @@ -35,7 +35,7 @@ - + diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.scss index be9328c80..2cfb92b1f 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.scss +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions-tab/transactions-tab.component.scss @@ -6,5 +6,8 @@ } table { width: 100%; + .select-row:hover { + cursor: pointer; + } } } diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.html new file mode 100644 index 000000000..51f37aa65 --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.html @@ -0,0 +1,131 @@ +
+ + + + +
+ +
+ + + + + +
+ +
+ Transaction Id +
+ +
+ {{ transactionData.id }} +
+ +
+ Type +
+ +
+ {{ transactionData.transactionType.value }} +
+ +
+ Transaction Date +
+ +
+ {{ transactionData.date | date }} +
+ +
+ Currency +
+ +
+ {{ transactionData.currency.displayLabel }} +
+ +
+ Amount +
+ +
+ {{ transactionData.amount }} +
+ +
+ Note +
+ +
+ {{ transactionData.note }} +
+ + + +
+ Payment Type +
+ +
+ {{ transactionData.paymentDetailData.paymentType.name }} +
+ +
+ Account No. +
+ +
+ {{ transactionData.paymentDetailData.accountNumber }} +
+ +
+ Cheque Number +
+ +
+ {{ transactionData.paymentDetailData.checkNumber }} +
+ +
+ Routing Code +
+ +
+ {{ transactionData.paymentDetailData.routingCode }} +
+ +
+ Receipt No. +
+ +
+ {{ transactionData.paymentDetailData.receiptNumber }} +
+ +
+ Bank No. +
+ +
+ {{ transactionData.paymentDetailData.bankNumber }} +
+ +
+ +
+ +
+ +
+ +
diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.scss new file mode 100644 index 000000000..56668f14f --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.scss @@ -0,0 +1,10 @@ +.container { + max-width: 37rem; + + .content { + div { + margin: 1rem 0; + word-wrap: break-word; + } + } +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.spec.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.spec.ts new file mode 100644 index 000000000..bbff0d11b --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewTransactionComponent } from './view-transaction.component'; + +describe('ViewTransactionComponent', () => { + let component: ViewTransactionComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewTransactionComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewTransactionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.ts new file mode 100644 index 000000000..4ee08643b --- /dev/null +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-view/transactions/view-transaction/view-transaction.component.ts @@ -0,0 +1,68 @@ +/** Angular Imports */ +import { Component } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialog } from '@angular/material'; +import { DatePipe } from '@angular/common'; + +/** Custom Services */ +import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service'; + +/** Custom Dialogs */ +import { UndoTransactionDialogComponent } from '../../custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component'; + +/** + * View Transaction Component. + * TODO: Add support for account transfers. + */ +@Component({ + selector: 'mifosx-view-transaction', + templateUrl: './view-transaction.component.html', + styleUrls: ['./view-transaction.component.scss'] +}) +export class ViewTransactionComponent { + + /** Transaction data. */ + transactionData: any; + + /** + * Retrieves the Transaction data from `resolve`. + * @param {FixedDepositsService} fixedDepositsService Savings Service + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + * @param {MatDialog} dialog Dialog reference. + * @param {DatePipe} datePipe DatePipe. + */ + constructor(private fixedDepositsService: FixedDepositsService, + private route: ActivatedRoute, + private datePipe: DatePipe, + private router: Router, + public dialog: MatDialog) { + this.route.data.subscribe((data: { fixedDepositsAccountTransaction: any }) => { + this.transactionData = data.fixedDepositsAccountTransaction; + }); + } + + /** + * Undo the savings transaction + */ + undoTransaction() { + const accountId = this.route.parent.snapshot.params['fixedDepositAccountId']; + const undoTransactionAccountDialogRef = this.dialog.open(UndoTransactionDialogComponent); + undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => { + if (response.confirm) { + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const data = { + transactionDate: this.datePipe.transform(this.transactionData.date && new Date(this.transactionData.date), dateFormat), + transactionAmount: 0, + dateFormat, + locale + }; + this.fixedDepositsService.executeFixedDepositsAccountTransactionsCommand(accountId, 'undo', data, this.transactionData.id).subscribe(() => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + }); + } + +} diff --git a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts index 7efec564a..2e8a5e3bd 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits-routing.module.ts @@ -13,11 +13,13 @@ import { ChargesTabComponent } from './fixed-deposit-account-view/charges-tab/ch import { StandingInstructionsTabComponent } from './fixed-deposit-account-view/standing-instructions-tab/standing-instructions-tab.component'; import { DatatableTabsComponent } from './fixed-deposit-account-view/datatable-tabs/datatable-tabs.component'; import { FixedDepositsAccountActionsComponent } from './fixed-deposits-account-actions/fixed-deposits-account-actions.component'; +import { ViewTransactionComponent } from './fixed-deposit-account-view/transactions/view-transaction/view-transaction.component'; /** Custom Resolvers */ import { FixedDepositsAccountViewResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-view.resolver'; import { SavingsDatatableResolver } from 'app/savings/common-resolvers/savings-datatable.resolver'; import { SavingsDatatablesResolver } from 'app/savings/common-resolvers/savings-datatables.resolver'; +import { FixedDepositsAccountTransactionResolver } from '../fixed-deposits/common-resolvers/fixed-deposit-account-transaction.resolver'; const routes: Routes = [ { @@ -73,6 +75,29 @@ const routes: Routes = [ } ] }, + { + path: 'transactions', + data: { title: extract('Fixed Deposits Account Transactions'), breadcrumb: 'Transactions', routeParamBreadcrumb: false }, + children: [ + { + path: '', + redirectTo: '../transactions', pathMatch: 'prefix' + }, + { + path: ':id', + data: { routeParamBreadcrumb: 'id' }, + children: [ + { + path: '', + component: ViewTransactionComponent, + resolve: { + fixedDepositsAccountTransaction: FixedDepositsAccountTransactionResolver + } + } + ] + } + ] + }, { path: 'actions/:name', data: { title: extract('Fixed Deposits Account Actions'), routeParamBreadcrumb: 'name' }, @@ -90,7 +115,8 @@ const routes: Routes = [ providers: [ FixedDepositsAccountViewResolver, SavingsDatatableResolver, - SavingsDatatablesResolver + SavingsDatatablesResolver, + FixedDepositsAccountTransactionResolver ] }) export class FixedDepositsRoutingModule { } diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts index 1ad92ff54..8263c438a 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.module.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.module.ts @@ -26,6 +26,8 @@ import { ToggleWithholdTaxDialogComponent } from './fixed-deposit-account-view/c import { ActivateFixedDepositsAccountComponent } from './fixed-deposits-account-actions/activate-fixed-deposits-account/activate-fixed-deposits-account.component'; import { UndoApprovalFixedDepositsAccountComponent } from './fixed-deposits-account-actions/undo-approval-fixed-deposits-account/undo-approval-fixed-deposits-account.component'; import { WithdrawByClientFixedDepositsAccountComponent } from './fixed-deposits-account-actions/withdraw-by-client-fixed-deposits-account/withdraw-by-client-fixed-deposits-account.component'; +import { ViewTransactionComponent } from './fixed-deposit-account-view/transactions/view-transaction/view-transaction.component'; +import { UndoTransactionDialogComponent } from './fixed-deposit-account-view/custom-dialogs/undo-transaction-dialog/undo-transaction-dialog.component'; @NgModule({ declarations: [ @@ -45,7 +47,9 @@ import { WithdrawByClientFixedDepositsAccountComponent } from './fixed-deposits- ToggleWithholdTaxDialogComponent, ActivateFixedDepositsAccountComponent, UndoApprovalFixedDepositsAccountComponent, - WithdrawByClientFixedDepositsAccountComponent + WithdrawByClientFixedDepositsAccountComponent, + ViewTransactionComponent, + UndoTransactionDialogComponent ], imports: [ SharedModule, @@ -56,7 +60,8 @@ import { WithdrawByClientFixedDepositsAccountComponent } from './fixed-deposits- entryComponents: [ PostInterestDialogComponent, CalculateInterestDialogComponent, - ToggleWithholdTaxDialogComponent + ToggleWithholdTaxDialogComponent, + UndoTransactionDialogComponent ], providers: [DatePipe] }) diff --git a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts index 469b5b55d..47cb75899 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposits.service.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposits.service.ts @@ -43,6 +43,27 @@ export class FixedDepositsService { return this.http.post(`/fixeddepositaccounts/${accountId}`, data, { params: httpParams }); } + /** + * @param {string} accountId Savings Account Id + * @param {string} transactionId Transaction Id + * @returns {Observable} + */ + getFixedDepositsAccountTransaction(accountId: string, transactionId: string): Observable { + return this.http.get(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`); + } + + /** + * @param {string} accountId Savings Account Id + * @param {string} command Command + * @param {any} data Data + * @param {string} transactionId Transaction Id + * @returns {Observable} + */ + executeFixedDepositsAccountTransactionsCommand(accountId: string, command: string, data: any, transactionId?: any): Observable { + const httpParams = new HttpParams().set('command', command); + return this.http.post(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`, data, { params: httpParams }); + } + /** * @param clientId Client Id * @param clientName Client Name