mirror of
https://github.com/openMF/web-app.git
synced 2026-02-06 14:11:48 +00:00
Merge dc1a29f7d2 into ad99027843
This commit is contained in:
commit
aa8bd22cac
@ -106,7 +106,7 @@
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<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">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
@ -115,6 +115,12 @@
|
||||
<mat-icon><fa-icon icon="eye" size="sm"></fa-icon></mat-icon>
|
||||
<span>{{ 'labels.text.View Transaction' | translate }}</span>
|
||||
</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
|
||||
mat-menu-item
|
||||
(click)="routeEdit($event)"
|
||||
|
||||
@ -36,6 +36,11 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { DateFormatPipe } from '../../../../pipes/date-format.pipe';
|
||||
import { FormatNumberPipe } from '../../../../pipes/format-number.pipe';
|
||||
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.
|
||||
@ -71,12 +76,17 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
export class TransactionsTabComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private translateService = inject(TranslateService);
|
||||
private settingsService = inject(SettingsService);
|
||||
private dateUtils = inject(Dates);
|
||||
private fixedDepositsService = inject(FixedDepositsService);
|
||||
dialog = inject(MatDialog);
|
||||
|
||||
clientId: string;
|
||||
accountId: string;
|
||||
status: any;
|
||||
/** Transactions Data */
|
||||
transactionsData: any;
|
||||
transactionsData: any[] = [];
|
||||
/** Form control to handle accural parameter */
|
||||
hideAccrualsParam: UntypedFormControl;
|
||||
hideReversedParam: UntypedFormControl;
|
||||
@ -104,6 +114,7 @@ export class TransactionsTabComponent implements OnInit {
|
||||
constructor() {
|
||||
this.route.parent.data.subscribe((data: { fixedDepositsAccountData: any }) => {
|
||||
this.transactionsData = data.fixedDepositsAccountData.transactions;
|
||||
this.clientId = this.route.parent.snapshot.params['clientId'];
|
||||
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
||||
this.status = data.fixedDepositsAccountData.status.value;
|
||||
});
|
||||
@ -200,5 +211,42 @@ export class TransactionsTabComponent implements OnInit {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user