Merge branch 'feature/account-charges' of https://git.zeptic.in/CBSNexora/Angular-UI-CBS-Main into feature/account-charges

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-05-21 21:19:03 +05:30
co-authored by Claude Sonnet 4.6
98 changed files with 8573 additions and 2572 deletions
@@ -57,13 +57,6 @@
</mat-select>
</mat-form-field>
}
@if (savingsProductSelected) {
<mat-form-field appearance="outline" class="sad-field">
<mat-label>{{ 'labels.inputs.External ID' | translate }}</mat-label>
<input matInput formControlName="externalId" />
</mat-form-field>
}
</div>
</div>
@@ -82,6 +82,10 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
primaryClientCif = '';
primaryClientId: number | null = null;
primaryHolderShare = 0;
/** Best-effort string label of the client's entity type
* (e.g. "Individual", "Corporate", "MSME") — used to auto-fill the
* Customer Segment dropdown when the product template lands. */
private clientEntityType: string | null = null;
// ── Status of Account (RBI) ────────────────────────────────────────────
readonly accountStatusOptions = [
@@ -167,8 +171,7 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
productId: this.savingsAccountTemplate.savingsProductId,
submittedOnDate:
this.savingsAccountTemplate.timeline.submittedOnDate &&
new Date(this.savingsAccountTemplate.timeline.submittedOnDate),
externalId: this.savingsAccountTemplate.externalId
new Date(this.savingsAccountTemplate.timeline.submittedOnDate)
});
} else {
this.savingsAccountDetailsForm.patchValue({
@@ -193,11 +196,49 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
this.autoDetectAccountStatus();
}
}
this.clientEntityType = this.deriveEntityType(client);
// Product template may have already arrived before the client did —
// try the segment-apply both here and when the template lands.
this.applyInferredCustomerSegment();
this.cdr.detectChanges();
});
}
}
/**
* Build a best-effort label for the client's entity / customer type.
* Tries `clientType` first (the explicit master), then falls back to
* `clientClassification` and finally `legalForm`.
*/
private deriveEntityType(client: any): string | null {
if (!client) return null;
const direct =
client.clientType?.value ??
client.clientType?.name ??
client.clientClassification?.value ??
client.clientClassification?.name;
if (direct && typeof direct === 'string') return direct;
const legalForm = client.legalForm?.value ?? client.legalForm?.code ?? client.legalForm?.name;
return typeof legalForm === 'string' ? legalForm : null;
}
/**
* If `clientEntityType` and `customerSegmentOptions` are both ready, try
* to match an option (exact then case-insensitive substring) and set it
* as the selected Customer Segment. Falls through silently otherwise so
* the existing product default stays in place.
*/
private applyInferredCustomerSegment(): void {
if (!this.clientEntityType || !this.customerSegmentOptions?.length) return;
const needle = this.clientEntityType.trim().toLowerCase();
const match =
this.customerSegmentOptions.find((o) => o.toLowerCase() === needle) ||
this.customerSegmentOptions.find((o) => o.toLowerCase().includes(needle) || needle.includes(o.toLowerCase()));
if (match) {
this.selectedCustomerSegment = match;
}
}
/** Parse DOB from backend — handles array [yyyy, mm, dd] or string */
private parseClientDob(dob: any): Date | null {
if (!dob) return null;
@@ -263,8 +304,7 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
'',
Validators.required
],
fieldOfficerId: [''],
externalId: ['']
fieldOfficerId: ['']
});
}
@@ -279,6 +319,9 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
this.customerSegmentOptions = this.extractOptions(response.customerSegmentOptions, response.customerSegment);
this.selectedAccountType = response.accountType ?? null;
this.selectedCustomerSegment = response.customerSegment ?? null;
// Override the product's default segment with the one inferred
// from the client's entity type when an option matches.
this.applyInferredCustomerSegment();
this.savingsAccountProductTemplate.emit(response);
this.fieldOfficerData = response.fieldOfficerOptions;
this.savingsProductSelected = true;