Files
cbsnexora/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts
T
Nitesh YadavandClaude Sonnet 4.6 3df7d100df feat: add nominee, auto-debit, charges UI for SB/CA/FD/RD accounts; enforce required fields
- SB/CA/FD/RD Currency Step: add Nomination Facility toggle with multi-nominee form
  (NomineeFormComponent), auto-debit facility toggle, dormancy alert panel
- SB/CA/FD/RD Preview Step: display nominees list, auto-debit status, dormancy info
- FD/RD create component: validate Deposit Tenure, Monthly Installment (RD), and
  Customer Segment are filled before submit; show clear alert messages on missing fields
- FD account details step: remove duplicate Currency section (already shown in
  Currency & Account Status Configuration step)
- CA/SB create component: handle duplicate externalId API error with user-friendly alert
  instead of raw error display

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 08:08:08 +05:30

98 lines
3.1 KiB
TypeScript

/**
* 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, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { NomineeFormComponent } from 'app/shared/nominee-form/nominee-form.component';
import { DormancyAlertPanelComponent } from 'app/shared/dormancy-alert-panel/dormancy-alert-panel.component';
import { MatSlideToggle } from '@angular/material/slide-toggle';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'mifosx-fixed-deposit-account-currency-step',
templateUrl: './fixed-deposit-account-currency-step.component.html',
styleUrls: ['./fixed-deposit-account-currency-step.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
NomineeFormComponent,
DormancyAlertPanelComponent,
MatSlideToggle,
FormsModule
]
})
export class FixedDepositAccountCurrencyStepComponent implements OnChanges {
@Input() fixedDepositsAccountProductTemplate: any;
@Input() primaryClientId: number | null = null;
@ViewChild(NomineeFormComponent) nomineeFormComp: NomineeFormComponent;
nominees: any[] = [];
pendingNominee: any = null;
showNomineeForm = false;
nomineeError = '';
autoDebitFacility = false;
nominationFacility = false;
ngOnChanges(changes: SimpleChanges): void {
if (changes['fixedDepositsAccountProductTemplate']?.currentValue) {
const pt = changes['fixedDepositsAccountProductTemplate'].currentValue;
this.autoDebitFacility = !!pt.autoDebitFacility;
this.nominationFacility = !!pt.nominationFacility;
}
}
get totalShare(): number {
return this.nominees.reduce((sum, n) => sum + (+n.percentageShare || 0), 0);
}
get remainingShare(): number {
return 100 - this.totalShare;
}
get canAddMore(): boolean {
return this.totalShare < 100;
}
onNomineeChange(event: any): void {
this.pendingNominee = event;
this.nomineeError = '';
}
addNominee(): void {
const data = this.nomineeFormComp?.currentNomineeData ?? this.pendingNominee;
if (!data?.nomineeClientId) {
this.nomineeError = 'Please select a nominee before adding.';
return;
}
if (this.nominees.some((n) => n.nomineeClientId === data.nomineeClientId)) {
this.nomineeError = 'This person is already added as a nominee.';
return;
}
const newTotal = this.totalShare + (+data.percentageShare || 0);
if (newTotal > 100) {
this.nomineeError = `Total share cannot exceed 100%. Remaining: ${this.remainingShare}%`;
return;
}
this.nominees.push({ ...data });
this.pendingNominee = null;
this.showNomineeForm = false;
this.nomineeError = '';
}
removeNominee(index: number): void {
this.nominees.splice(index, 1);
}
get currencyStepData() {
return {
autoDebitFacility: this.autoDebitFacility,
nominationFacility: this.nominationFacility
};
}
}