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 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 12:56:30 +05:30
co-authored by Claude Sonnet 5
parent b422ae6600
commit c1fc95d9b7
2 changed files with 13 additions and 4 deletions
@@ -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();
@@ -81,6 +81,7 @@ export const PROOF_META: Record<string, Partial<ProofType>> = {
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: {