/** * Copyright since 2025 Mifos Initiative * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Component, inject } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialogContent, MatDialogActions, MatDialogClose } from '@angular/material/dialog'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; export interface TransactionConfirmData { /** 'deposit' | 'withdrawal' — drives the colour palette + sign. */ kind: 'deposit' | 'withdrawal'; clientName: string | null; accountNo: string | null; currentBalance: number; transactionAmount: number; paymentTypeLabel: string | null; } /** * Pre-commit confirmation pop-up showing the cashier exactly how the * deposit / withdrawal will affect the account: current balance, the * transaction amount, and the post-transaction balance. */ @Component({ selector: 'mifosx-transaction-confirm-dialog', standalone: true, templateUrl: './transaction-confirm-dialog.component.html', styleUrls: ['./transaction-confirm-dialog.component.scss'], imports: [ ...STANDALONE_SHARED_IMPORTS, MatDialogContent, MatDialogActions, MatDialogClose, FaIconComponent ] }) export class TransactionConfirmDialogComponent { dialogRef = inject>(MatDialogRef); data = inject(MAT_DIALOG_DATA); get isDeposit(): boolean { return this.data.kind === 'deposit'; } get signedAmount(): number { return this.isDeposit ? this.data.transactionAmount : -this.data.transactionAmount; } get newBalance(): number { return this.data.currentBalance + this.signedAmount; } get overdraft(): boolean { return !this.isDeposit && this.newBalance < 0; } confirm(): void { this.dialogRef.close({ confirm: true }); } cancel(): void { this.dialogRef.close({ confirm: false }); } }