feat: view fixed deposit account transaction (#989)

Fixes: #988
This commit is contained in:
Karan Takalkar
2020-07-04 16:02:39 +05:30
committed by GitHub
parent 19c6dee1a5
commit 18a6e6f487
14 changed files with 379 additions and 4 deletions
@@ -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<Object> {
/**
* @param {FixedDepositsService} fixedDepositsService Savings service.
*/
constructor(private fixedDepositsService: FixedDepositsService) { }
/**
* Returns the Fixed Deposits Account Transaction data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const fixedDepositAccountId = route.parent.paramMap.get('fixedDepositAccountId');
const transactionId = route.paramMap.get('id');
return this.fixedDepositsService.getFixedDepositsAccountTransaction(fixedDepositAccountId, transactionId);
}
}
@@ -0,0 +1,8 @@
<h1 mat-dialog-title>Undo Transaction</h1>
<div mat-dialog-content>
<p>Are you sure you want to undo this transaction ?</p>
</div>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="warn" [mat-dialog-close]="{ confirm: true }">Confirm</button>
</mat-dialog-actions>
@@ -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<UndoTransactionDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UndoTransactionDialogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UndoTransactionDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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<UndoTransactionDialogComponent>) { }
}
@@ -35,7 +35,7 @@
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row" [routerLink]="[row.id]"></tr>
</table>
@@ -6,5 +6,8 @@
}
table {
width: 100%;
.select-row:hover {
cursor: pointer;
}
}
}
@@ -0,0 +1,131 @@
<div fxLayoutAlign="end" class="container m-b-20" fxLayoutGap="2%"
*ngIf="!(transactionData.reversed)">
<span *mifosxHasPermission="'ADJUSTTRANSACTION_SAVINGSACCOUNT'">
<button mat-raised-button color="primary"
*ngIf="transactionData.transactionType.value == 'Transfer' || transactionData.reversed == 'true'"
[routerLink]="'edit'">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;Edit
</button>
</span>
<button mat-raised-button color="warn"
*mifosxHasPermission="'UNDOTRANSACTION_SAVINGSACCOUNT'"
(click)="undoTransaction()">
<fa-icon icon="undo"></fa-icon>&nbsp;&nbsp;Undo
</button>
</div>
<div class="container">
<mat-card>
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="50%" class="mat-body-strong">
Transaction Id
</div>
<div fxFlex="50%">
{{ transactionData.id }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Type
</div>
<div fxFlex="50%">
{{ transactionData.transactionType.value }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Transaction Date
</div>
<div fxFlex="50%">
{{ transactionData.date | date }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Currency
</div>
<div fxFlex="50%">
{{ transactionData.currency.displayLabel }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Amount
</div>
<div fxFlex="50%">
{{ transactionData.amount }}
</div>
<div fxFlex="50%" *ngIf="transactionData.note" class="mat-body-strong">
Note
</div>
<div fxFlex="50%" *ngIf="transactionData.note">
{{ transactionData.note }}
</div>
<ng-container *ngIf="transactionData.paymentDetailData">
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%" class="mat-body-strong">
Payment Type
</div>
<div *ngIf="transactionData.paymentDetailData.paymentType" fxFlex="50%">
{{ transactionData.paymentDetailData.paymentType.name }}
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%" class="mat-body-strong">
Account No.
</div>
<div *ngIf="transactionData.paymentDetailData.accountNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.accountNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%" class="mat-body-strong">
Cheque Number
</div>
<div *ngIf="transactionData.paymentDetailData.checkNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.checkNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%" class="mat-body-strong">
Routing Code
</div>
<div *ngIf="transactionData.paymentDetailData.routingCode" fxFlex="50%">
{{ transactionData.paymentDetailData.routingCode }}
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%" class="mat-body-strong">
Receipt No.
</div>
<div *ngIf="transactionData.paymentDetailData.receiptNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.receiptNumber }}
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%" class="mat-body-strong">
Bank No.
</div>
<div *ngIf="transactionData.paymentDetailData.bankNumber" fxFlex="50%">
{{ transactionData.paymentDetailData.bankNumber }}
</div>
</ng-container>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -0,0 +1,10 @@
.container {
max-width: 37rem;
.content {
div {
margin: 1rem 0;
word-wrap: break-word;
}
}
}
@@ -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<ViewTransactionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewTransactionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewTransactionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -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 });
});
}
});
}
}
@@ -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 { }
@@ -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]
})
@@ -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<any>}
*/
getFixedDepositsAccountTransaction(accountId: string, transactionId: string): Observable<any> {
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<any>}
*/
executeFixedDepositsAccountTransactionsCommand(accountId: string, command: string, data: any, transactionId?: any): Observable<any> {
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