/** * 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/. */ /** Angular Imports */ import { Component, Input, Output, EventEmitter, OnChanges } from '@angular/core'; import { MatTableDataSource, MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow } from '@angular/material/table'; import { MatDivider } from '@angular/material/divider'; import { ExternalIdentifierComponent } from '../../../shared/external-identifier/external-identifier.component'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { FindPipe } from '../../../pipes/find.pipe'; import { DateFormatPipe } from '../../../pipes/date-format.pipe'; import { FormatNumberPipe } from '../../../pipes/format-number.pipe'; import { YesnoPipe } from '../../../pipes/yesno.pipe'; import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; /** * Savings account preview step */ @Component({ selector: 'mifosx-savings-account-preview-step', templateUrl: './savings-account-preview-step.component.html', styleUrls: ['./savings-account-preview-step.component.scss'], imports: [ ...STANDALONE_SHARED_IMPORTS, MatDivider, ExternalIdentifierComponent, MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow, FaIconComponent, FindPipe, DateFormatPipe, FormatNumberPipe, YesnoPipe ] }) export class SavingsAccountPreviewStepComponent implements OnChanges { readonly digitalFacilityLabels = [ { key: 'atmFacility', label: 'ATM Facility' }, { key: 'atmWithdrawalFacility', label: 'ATM Withdrawal' }, { key: 'upiFacility', label: 'UPI Facility' }, { key: 'posTransactionsFacility', label: 'POS Transactions' }, { key: 'chequeBook', label: 'Cheque Book' }, { key: 'impsFacility', label: 'IMPS Facility' }, { key: 'smsAlerts', label: 'SMS Alerts' }, { key: 'bbpsFacility', label: 'BBPS Facility' }, { key: 'insuranceCover', label: 'Insurance Cover' }, { key: 'bepgFacility', label: 'BEPG Facility' }, { key: 'neftFacility', label: 'NEFT Facility' }, { key: 'rtgsFacility', label: 'RTGS Facility' }, { key: 'interBankTotalCapFacility', label: 'Inter-Bank Total Cap' }, { key: 'depositFacilityKyc', label: 'Deposit Facility (KYC)' }, { key: 'virtualDebitCard', label: 'Virtual Debit Card' } ]; /** Savings Account Product Template */ @Input() savingsAccountProductTemplate: any; /** Savings Account Template */ @Input() savingsAccountTemplate: any; /** Savings Account Terms Form */ @Input() savingsAccountTermsForm: any; /** Savings Account */ @Input() savingsAccount: any; /** Digital facilities — user-modified values from digital step */ @Input() savingsAccountDigital: any; /** Nominees list from currency step */ @Input() savingsAccountNominees: any[] = []; /** active Client Members in case of GSIM Account */ @Input() activeClientMembers?: any; /** Hide internal Cancel/Submit buttons when parent provides its own action bar */ @Input() hideButtons = false; /** Disables the Submit button while a submission is in flight, preventing duplicate double-click requests */ @Input() submitting = false; /** Table Data Source */ dataSource: any; /** Display columns for charges table */ chargesDisplayedColumns: string[] = [ 'name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'date', 'repaymentsEvery' ]; /** Columns to be displayed in active members table. */ membersDisplayedColumns: string[] = [ 'id', 'name' ]; /** Form submission event */ @Output() submitEvent = new EventEmitter(); /** Goes back a tab in the parent wizard — kept here so Previous renders in the same row as * Cancel/Submit instead of a separate action bar underneath. */ @Output() previousEvent = new EventEmitter(); ngOnChanges(): void { if (this.activeClientMembers?.length > 0) { this.dataSource = new MatTableDataSource(this.activeClientMembers.filter((member: any) => member.selected)); } } /** Digital facility config as actually captured by a digital step in this wizard -- no fallback * to the product's own defaults, since account creation no longer has a digital step at all and * must not preview facilities the officer never actually chose. */ get digitalFacilityConfig(): any { return this.savingsAccountDigital?.accountFacilityConfig ?? null; } get hasDigitalSection(): boolean { return !!this.digitalFacilityConfig; } /** Currency info from product template */ get currencyName(): string { return ( this.savingsAccountProductTemplate?.currency?.name || this.savingsAccountTermsForm?.get?.('currencyCode')?.value || '—' ); } get decimalPlaces(): string | number { return this.savingsAccountProductTemplate?.currency?.decimalPlaces ?? '—'; } get inMultiplesOf(): string | number { return this.savingsAccountProductTemplate?.currency?.inMultiplesOf ?? '—'; } }