From c1fc95d9b7b6318ab5b63c44830a8f5f1e34566d Mon Sep 17 00:00:00 2001 From: Nitesh Yadav Date: Tue, 28 Jul 2026 12:56:30 +0530 Subject: [PATCH] fix(clients): minor-specific KYC document types (Birth Certificate/School ID) never appeared filterDocTypesForMinor() only ever removes entries. The initial (pre-DOB, isMinor=false) seed already stripped Birth Certificate/School ID Card out of kycDocumentTypes, so the isMinor ngOnChanges handler re-filtering that same shortened list could never bring them back once the client turned out to be a minor. Rebuild from the full defaultDocumentTypes source instead (matching how the initial seed itself is built) whenever isMinor changes and the backend KYC template hasn't already taken over. Also gives School ID Card the "Government-issued ID" category it was missing, so it groups with Aadhaar/Passport/Birth Certificate instead of "Other". Co-Authored-By: Claude Sonnet 5 --- .../client-kyc-step/client-kyc-step.component.ts | 16 ++++++++++++---- src/app/clients/shared/kyc-proof-types.ts | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/clients/client-stepper/client-kyc-step/client-kyc-step.component.ts b/src/app/clients/client-stepper/client-kyc-step/client-kyc-step.component.ts index 78ad94746..3a6f0b97a 100644 --- a/src/app/clients/client-stepper/client-kyc-step/client-kyc-step.component.ts +++ b/src/app/clients/client-stepper/client-kyc-step/client-kyc-step.component.ts @@ -607,11 +607,19 @@ export class ClientKycStepComponent implements OnInit, OnChanges, OnDestroy { this.kycForm.get('hasPan')?.setValue(false); this.kycForm.get('panNumber')?.setValue(''); } - const filtered = this.filterDocTypesForMinor(this.kycDocumentTypes); - if (filtered.length !== this.kycDocumentTypes.length) { - this.kycDocumentTypes = filtered; + // Re-derive from the full default list, not by re-filtering the already-narrowed + // `kycDocumentTypes` — filterDocTypesForMinor() only ever REMOVES entries, so once the + // initial (pre-DOB, isMinor=false) seed has already stripped out Birth Certificate / + // School ID Card, re-filtering that same shortened list can never bring them back once + // the client turns out to be a minor. Once the backend KYC template has loaded + // (kycTemplateLoaded), that list is already minor-aware and authoritative — leave it alone. + if (!this.kycTemplateLoaded) { + const rebuilt = this.filterDocTypesForMinor( + this.defaultDocumentTypes.map((d) => ({ name: d.name, code: d.code, mandatory: false })) + ); + this.kycDocumentTypes = rebuilt; const currentName = this.kycForm.get('kycDocumentName')?.value; - if (currentName && !filtered.some((d) => d.name === currentName)) { + if (currentName && !rebuilt.some((d) => d.name === currentName)) { this.kycForm.get('kycDocumentName')?.setValue(''); } this.rebuildKycDocPicker(); diff --git a/src/app/clients/shared/kyc-proof-types.ts b/src/app/clients/shared/kyc-proof-types.ts index c0d678aec..239e47713 100644 --- a/src/app/clients/shared/kyc-proof-types.ts +++ b/src/app/clients/shared/kyc-proof-types.ts @@ -81,6 +81,7 @@ export const PROOF_META: Record> = { sides: 1, documentKeyLabel: 'School ID / admission number', documentKeyPlaceholder: 'Student ID number', + category: 'Government-issued ID', info: 'School identity card bearing photograph — accepted proof of identity for minor clients as per RBI KYC norms.' }, UTILITY_BILL: {