update loan product code and rd,fd,saving,current account validation add

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Nitesh Yadav
2026-05-14 07:40:04 +05:30
co-authored by Claude Sonnet 4.6
parent ed45c8637e
commit d0370781e8
30 changed files with 1286 additions and 213 deletions
@@ -19,6 +19,7 @@ import { CurrentAccountDigitalStepComponent } from '../current-account-stepper/c
import { CurrentAccountsService } from '../current-accounts.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
import { AlertService } from 'app/core/alert/alert.service';
import {
MatStepper,
MatStepperIcon,
@@ -60,6 +61,7 @@ export class CreateCurrentAccountComponent {
private dateUtils = inject(Dates);
private currentAccountsService = inject(CurrentAccountsService);
private settingsService = inject(SettingsService);
private alertService = inject(AlertService);
/** Current Account Template */
currentAccountTemplate: any;
@@ -132,6 +134,14 @@ export class CreateCurrentAccountComponent {
* Creates a new current account.
*/
submit() {
const detailsStep = this.currentAccountDetailsStep;
if (detailsStep.selectedAccountStatus === 'JOINT' && detailsStep.totalJointSharePercentage !== 100) {
this.alertService.alert({
type: 'Error',
message: `Total ownership is ${detailsStep.totalJointSharePercentage}%. It must equal 100% before submitting.`
});
return;
}
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const monthDayFormat = 'dd MMMM';
@@ -155,8 +165,19 @@ export class CreateCurrentAccountComponent {
currentAccount.startOperationDate = this.dateUtils.formatDate(details.startOperationDate, dateFormat);
}
// strip UI-only flags not needed by backend
delete currentAccount.isNonIndividualClient;
// Explicitly re-set partners from the details step to ensure all are included
if (this.currentAccountDetailsStep.isNonIndividualClient) {
currentAccount.isNonIndividualClient = true;
currentAccount.partners = this.currentAccountDetailsStep.relatedClients.map((c: any) => ({
clientId: c.clientId,
clientName: c.clientName,
clientCif: c.clientCif,
sharePercentage: c.sharePercentage,
isMandatory: c.isMandatory
}));
} else {
delete currentAccount.isNonIndividualClient;
}
if (this.currentAccountTemplate.clientId) {
currentAccount.clientId = this.currentAccountTemplate.clientId;
@@ -62,18 +62,32 @@
<mat-form-field appearance="outline" class="sad-field" (click)="establishmentDatePicker.open()">
<mat-label>Establishment Date</mat-label>
<input matInput [matDatepicker]="establishmentDatePicker" formControlName="establishmentDate" />
<input matInput [matDatepicker]="establishmentDatePicker" formControlName="establishmentDate" [max]="today" />
<mat-datepicker-toggle matSuffix [for]="establishmentDatePicker"></mat-datepicker-toggle>
<mat-datepicker #establishmentDatePicker></mat-datepicker>
<mat-hint>Date of entity / business establishment</mat-hint>
@if (currentAccountDetailsForm.get('establishmentDate')?.hasError('matDatepickerMax')) {
<mat-error>Establishment Date cannot be a future date.</mat-error>
}
</mat-form-field>
<mat-form-field appearance="outline" class="sad-field" (click)="startOperationDatePicker.open()">
<mat-label>Start of Operation Date</mat-label>
<input matInput [matDatepicker]="startOperationDatePicker" formControlName="startOperationDate" />
<input
matInput
[matDatepicker]="startOperationDatePicker"
formControlName="startOperationDate"
[max]="today"
[min]="minStartOperationDate"
/>
<mat-datepicker-toggle matSuffix [for]="startOperationDatePicker"></mat-datepicker-toggle>
<mat-datepicker #startOperationDatePicker></mat-datepicker>
<mat-hint>Date when operations commenced</mat-hint>
@if (currentAccountDetailsForm.get('startOperationDate')?.hasError('matDatepickerMax')) {
<mat-error>Start of Operation Date cannot be a future date.</mat-error>
} @else if (currentAccountDetailsForm.get('startOperationDate')?.hasError('matDatepickerMin')) {
<mat-error>Start of Operation Date cannot be before Establishment Date.</mat-error>
}
</mat-form-field>
}
</div>
@@ -22,6 +22,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
import { IntroducerSearchComponent } from 'app/shared/introducer-search/introducer-search.component';
import { AddRelatedClientDialogComponent } from './add-related-client-dialog/add-related-client-dialog.component';
import { AlertService } from 'app/core/alert/alert.service';
/**
* Current Account Details Step
@@ -46,6 +47,7 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
private settingsService = inject(SettingsService);
private clientsService = inject(ClientsService);
private dialog = inject(MatDialog);
private alertService = inject(AlertService);
private dateUtils = inject(Dates);
private cdr = inject(ChangeDetectorRef);
@@ -365,9 +367,13 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
});
ref.afterClosed().subscribe((result) => {
if (result) {
const duplicate = this.jointHolders.some((h) => h.clientCif && h.clientCif === result.clientCif);
const isPrimary = this.primaryClientCif && this.primaryClientCif === result.clientCif;
const duplicate = isPrimary || this.jointHolders.some((h) => h.clientCif && h.clientCif === result.clientCif);
if (duplicate) {
alert(`Account holder with CIF ${result.clientCif} is already added.`);
this.alertService.alert({
type: 'Error',
message: `Account holder with CIF ${result.clientCif} is already added.`
});
return;
}
this.jointHolders = [
@@ -407,6 +413,17 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
return this.modeOfOperationOptions.find((o) => o.value === this.modeOfOperation)?.sublabel ?? '';
}
get today(): Date {
const d = new Date();
d.setHours(0, 0, 0, 0);
return d;
}
get minStartOperationDate(): Date | null {
const val = this.currentAccountDetailsForm?.get('establishmentDate')?.value;
return val ? new Date(val) : null;
}
get majorityDate(): string {
const dob = this.minorDob ?? this.clientDob;
if (!dob) return '';
@@ -426,7 +443,7 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
if (result) {
const duplicate = this.relatedClients.some((c) => c.clientCif && c.clientCif === result.clientCif);
if (duplicate) {
alert(`Partner with CIF ${result.clientCif} is already added.`);
this.alertService.alert({ type: 'Error', message: `Partner with CIF ${result.clientCif} is already added.` });
return;
}
this.relatedClients = [
@@ -520,7 +537,7 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
value.guardianName = this.guardianName;
value.guardianCifNumber = this.guardianCif;
value.guardianRelationship = this.guardianRelationship;
value.minorDateOfBirth = this.minorDob ? this.dateUtils.formatDate(this.minorDob, 'yyyy-MM-dd') : null;
value.minorDateOfBirth = this.minorDob ? this.dateUtils.formatDate(this.minorDob, 'dd MMMM yyyy') : null;
}
// non-individual: partners are a separate dataset
@@ -649,54 +649,6 @@
</div>
}
<!-- ══ 7. Non-Individual Details (if applicable) ════════════════ -->
@if (currentAccount?.partners?.length > 0) {
<div class="preview-section">
<div class="preview-section__header">
<i class="fas fa-building preview-section__icon"></i>
<span class="preview-section__title">Non-Individual Account Details</span>
</div>
<div class="preview-body">
<!-- Partners -->
<div class="preview-ni-label">Partners / Members</div>
<div class="preview-ni-table-wrap">
<table class="preview-ni-tbl">
<thead>
<tr>
<th>Partner Name</th>
<th>CIF No</th>
<th>Ownership %</th>
<th>Signing Authority</th>
</tr>
</thead>
<tbody>
@for (p of currentAccount.partners; track p.clientId) {
<tr>
<td>{{ p.clientName || '—' }}</td>
<td class="preview-mono">{{ p.clientCif || '—' }}</td>
<td>{{ p.sharePercentage }}%</td>
<td>
<span class="preview-badge" [class.preview-badge--yes]="p.isMandatory">
{{ p.isMandatory ? 'Mandatory' : 'Optional' }}
</span>
</td>
</tr>
}
</tbody>
</table>
</div>
<!-- Signatory Rights -->
@if (currentAccount?.signatoryRights) {
<div class="preview-ni-mode">
<i class="fas fa-how_to_vote"></i>
<span class="preview-ni-mode__label">Mode of Operation:</span>
<strong>{{ currentAccount.signatoryRights }}</strong>
</div>
}
</div>
</div>
}
<!-- ══ 8. Digital Facilities ════════════════════════════════════ -->
@if (hasDigitalSection) {
<div class="preview-section">