WEB-656: Allow Undo Fixed Deposit transaction (#3077)
Co-authored-by: Jose Alberto Hernandez <alberto@black-box.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
e198f92ba4
commit
173c03023d
+7
-1
@@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
|
<th mat-header-cell *matHeaderCellDef>{{ 'labels.inputs.Actions' | translate }}</th>
|
||||||
<td mat-cell class="center" *matCellDef="let transaction">
|
<td mat-cell class="center" *matCellDef="let transaction; let idx = index">
|
||||||
<button mat-icon-button [matMenuTriggerFor]="transactionMenu" aria-label="" class="action-button">
|
<button mat-icon-button [matMenuTriggerFor]="transactionMenu" aria-label="" class="action-button">
|
||||||
<mat-icon>more_vert</mat-icon>
|
<mat-icon>more_vert</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
@@ -115,6 +115,12 @@
|
|||||||
<mat-icon><fa-icon icon="eye" size="sm"></fa-icon></mat-icon>
|
<mat-icon><fa-icon icon="eye" size="sm"></fa-icon></mat-icon>
|
||||||
<span>{{ 'labels.text.View Transaction' | translate }}</span>
|
<span>{{ 'labels.text.View Transaction' | translate }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@if (!isFirstTransaction(idx)) {
|
||||||
|
<button mat-menu-item (click)="undoTransaction(transaction)">
|
||||||
|
<mat-icon><fa-icon icon="undo" size="sm"></fa-icon></mat-icon>
|
||||||
|
<span>{{ 'tooltips.Undo Transaction' | translate }}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
<button
|
<button
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
(click)="routeEdit($event)"
|
(click)="routeEdit($event)"
|
||||||
|
|||||||
+50
-2
@@ -36,6 +36,11 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
|||||||
import { DateFormatPipe } from '../../../../pipes/date-format.pipe';
|
import { DateFormatPipe } from '../../../../pipes/date-format.pipe';
|
||||||
import { FormatNumberPipe } from '../../../../pipes/format-number.pipe';
|
import { FormatNumberPipe } from '../../../../pipes/format-number.pipe';
|
||||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { SettingsService } from 'app/settings/settings.service';
|
||||||
|
import { Dates } from 'app/core/utils/dates';
|
||||||
|
import { FixedDepositsService } from '../../fixed-deposits.service';
|
||||||
|
import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/confirmation-dialog.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transactions Tab Component.
|
* Transactions Tab Component.
|
||||||
@@ -71,12 +76,17 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
|||||||
export class TransactionsTabComponent implements OnInit {
|
export class TransactionsTabComponent implements OnInit {
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
|
private translateService = inject(TranslateService);
|
||||||
|
private settingsService = inject(SettingsService);
|
||||||
|
private dateUtils = inject(Dates);
|
||||||
|
private fixedDepositsService = inject(FixedDepositsService);
|
||||||
dialog = inject(MatDialog);
|
dialog = inject(MatDialog);
|
||||||
|
|
||||||
|
clientId: string;
|
||||||
accountId: string;
|
accountId: string;
|
||||||
status: any;
|
status: any;
|
||||||
/** Transactions Data */
|
/** Transactions Data */
|
||||||
transactionsData: any;
|
transactionsData: any[] = [];
|
||||||
/** Form control to handle accural parameter */
|
/** Form control to handle accural parameter */
|
||||||
hideAccrualsParam: UntypedFormControl;
|
hideAccrualsParam: UntypedFormControl;
|
||||||
hideReversedParam: UntypedFormControl;
|
hideReversedParam: UntypedFormControl;
|
||||||
@@ -104,6 +114,7 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
|
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
|
||||||
this.transactionsData = data.fixedDepositsAccountData.transactions;
|
this.transactionsData = data.fixedDepositsAccountData.transactions;
|
||||||
|
this.clientId = this.route.parent.snapshot.params['clientId'];
|
||||||
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
||||||
this.status = data.fixedDepositsAccountData.status.value;
|
this.status = data.fixedDepositsAccountData.status.value;
|
||||||
});
|
});
|
||||||
@@ -200,5 +211,42 @@ export class TransactionsTabComponent implements OnInit {
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
undoTransaction(transactionData: SavingsAccountTransaction): void {}
|
undoTransaction(transactionData: SavingsAccountTransaction): void {
|
||||||
|
const undoTransactionAccountDialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
data: {
|
||||||
|
heading: this.translateService.instant('labels.heading.Undo Transaction'),
|
||||||
|
dialogContext: this.translateService.instant(
|
||||||
|
'labels.dialogContext.Are you sure you want to undo this transaction ?'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.confirm) {
|
||||||
|
const locale = this.settingsService.language.code;
|
||||||
|
const dateFormat = this.settingsService.dateFormat;
|
||||||
|
const data = {
|
||||||
|
transactionDate: this.dateUtils.formatDate(transactionData.date, dateFormat),
|
||||||
|
transactionAmount: 0,
|
||||||
|
dateFormat,
|
||||||
|
locale
|
||||||
|
};
|
||||||
|
this.fixedDepositsService
|
||||||
|
.executeFixedDepositsAccountTransactionsCommand(this.accountId, 'undo', data, transactionData.id)
|
||||||
|
.subscribe(() => {
|
||||||
|
this.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
const url: string = this.router.url;
|
||||||
|
this.router
|
||||||
|
.navigateByUrl(`/clients/${this.clientId}/fixed-deposits-accounts`, { skipLocationChange: true })
|
||||||
|
.then(() => this.router.navigate([url]));
|
||||||
|
}
|
||||||
|
|
||||||
|
isFirstTransaction(idx: number): boolean {
|
||||||
|
return idx + 1 === this.transactionsData.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user