diff --git a/src/app/current-accounts/create-current-account/create-current-account.component.ts b/src/app/current-accounts/create-current-account/create-current-account.component.ts index 1329e5312..4c4c17a11 100644 --- a/src/app/current-accounts/create-current-account/create-current-account.component.ts +++ b/src/app/current-accounts/create-current-account/create-current-account.component.ts @@ -135,20 +135,37 @@ export class CreateCurrentAccountComponent { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; const monthDayFormat = 'dd MMMM'; - const currentAccount = { - ...this.currentAccount, + const details = this.currentAccount; + + const currentAccount: any = { + ...details, ...this.currentAccountCurrencyStep.currencyStepData, + ...(this.currentAccountDigitalStep?.currentAccountDigital ?? {}), charges: [], - submittedOnDate: this.dateUtils.formatDate(this.currentAccount.submittedOnDate, dateFormat), + submittedOnDate: this.dateUtils.formatDate(details.submittedOnDate, dateFormat), dateFormat, monthDayFormat, locale }; + + if (details.establishmentDate) { + currentAccount.establishmentDate = this.dateUtils.formatDate(details.establishmentDate, dateFormat); + } + if (details.startOperationDate) { + currentAccount.startOperationDate = this.dateUtils.formatDate(details.startOperationDate, dateFormat); + } + + // strip UI-only flags not needed by backend + delete currentAccount.isNonIndividualClient; + if (this.currentAccountTemplate.clientId) { currentAccount.clientId = this.currentAccountTemplate.clientId; } else { currentAccount.groupId = this.currentAccountTemplate.groupId; } + + console.log('Current Account Payload:', JSON.stringify(currentAccount, null, 2)); + this.currentAccountsService.createCurrentAccount(currentAccount).subscribe((response: any) => { this.router.navigate( [ diff --git a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.ts b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.ts index 3cc5083de..cd2f8d1e4 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.ts +++ b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.ts @@ -117,6 +117,8 @@ export class CurrentAccountDetailsStepComponent implements OnInit { clientCif: string; sharePercentage: number; isMandatory: boolean; + signingAuthority?: string; + role?: string; }> = []; modeOfOperation = ''; @@ -159,7 +161,12 @@ export class CurrentAccountDetailsStepComponent implements OnInit { guardianRelationship = ''; minorDob: Date | null = null; - readonly guardianRelationshipOptions = ['Father', 'Mother', 'Legal Guardian', 'Court Appointed Guardian']; + readonly guardianRelationshipOptions = [ + 'Father', + 'Mother', + 'Legal Guardian', + 'Court Appointed Guardian' + ]; constructor() { this.createCurrentAccountDetailsForm(); @@ -209,8 +216,14 @@ export class CurrentAccountDetailsStepComponent implements OnInit { createCurrentAccountDetailsForm() { this.currentAccountDetailsForm = this.formBuilder.group({ - productId: ['', Validators.required], - submittedOnDate: ['', Validators.required], + productId: [ + '', + Validators.required + ], + submittedOnDate: [ + '', + Validators.required + ], fieldOfficerId: [''], externalId: [''], balanceSwapOption: [false], @@ -357,7 +370,9 @@ export class CurrentAccountDetailsStepComponent implements OnInit { alert(`Account holder with CIF ${result.clientCif} is already added.`); return; } - this.jointHolders = [...this.jointHolders, { ...result, isMandatory: false }]; + this.jointHolders = [ + ...this.jointHolders, + { ...result, isMandatory: false }]; this.autoSetModeOfOperation(); } }); @@ -414,7 +429,9 @@ export class CurrentAccountDetailsStepComponent implements OnInit { alert(`Partner with CIF ${result.clientCif} is already added.`); return; } - this.relatedClients = [...this.relatedClients, { ...result, isMandatory: false }]; + this.relatedClients = [ + ...this.relatedClients, + { ...result, isMandatory: false }]; this.autoSetSignatoryRights(); } }); @@ -457,6 +474,48 @@ export class CurrentAccountDetailsStepComponent implements OnInit { value.introducerName = this.introducerName; value.introducerCif = this.introducerCif; } + value.isNonIndividualClient = this.isNonIndividualClient; + + // accountStatus applies to all client types + value.accountStatus = this.selectedAccountStatus || null; + if (this.selectedAccountStatus === 'INDIVIDUAL_MALE' && this.selectedSpecialCategory) + value.specialCategory = this.selectedSpecialCategory; + if (this.selectedAccountStatus === 'INDIVIDUAL_FEMALE' && this.selectedWeakerSection) + value.weakerSection = this.selectedWeakerSection; + if (this.selectedAccountStatus === 'JOINT') { + value.modeOfOperation = this.modeOfOperation || null; + value.jointHolders = [ + { + clientId: this.primaryClientId, + clientName: this.primaryClientName, + clientCif: this.primaryClientCif, + sharePercentage: this.primaryHolderShare, + isMandatory: true, + isPrimary: true, + signingAuthority: 'Mandatory', + role: 'Primary Account Holder' + }, + ...this.jointHolders.map((h) => ({ + clientId: h.clientId, + clientName: h.clientName, + clientCif: h.clientCif, + sharePercentage: h.sharePercentage, + isMandatory: h.isMandatory, + isPrimary: false, + signingAuthority: h.signingAuthority || (h.isMandatory ? 'Mandatory' : 'Optional'), + role: h.role || 'Co-Holder' + })) + ]; + } + if (this.selectedAccountStatus === 'MINOR') { + value.guardianClientId = this.guardianClientId; + value.guardianName = this.guardianName; + value.guardianCif = this.guardianCif; + value.guardianRelationship = this.guardianRelationship; + value.minorDob = this.minorDob ? this.dateUtils.formatDate(this.minorDob, 'yyyy-MM-dd') : null; + } + + // non-individual: partners are a separate dataset if (this.isNonIndividualClient) { value.signatoryRights = this.signatoryRights || null; value.partners = this.relatedClients.map((c) => ({ @@ -466,33 +525,6 @@ export class CurrentAccountDetailsStepComponent implements OnInit { sharePercentage: c.sharePercentage, isMandatory: c.isMandatory })); - } else { - if (this.selectedAccountStatus) value.accountStatus = this.selectedAccountStatus; - if (this.selectedAccountStatus === 'INDIVIDUAL_MALE' && this.selectedSpecialCategory) - value.specialCategory = this.selectedSpecialCategory; - if (this.selectedAccountStatus === 'INDIVIDUAL_FEMALE' && this.selectedWeakerSection) - value.weakerSection = this.selectedWeakerSection; - if (this.selectedAccountStatus === 'JOINT') { - value.modeOfOperation = this.modeOfOperation || null; - value.jointHolders = [ - { - clientId: this.primaryClientId, - clientName: this.primaryClientName, - clientCif: this.primaryClientCif, - sharePercentage: this.primaryHolderShare, - isMandatory: true, - isPrimary: true - }, - ...this.jointHolders.map((h) => ({ ...h, isPrimary: false })) - ]; - } - if (this.selectedAccountStatus === 'MINOR') { - value.guardianClientId = this.guardianClientId; - value.guardianName = this.guardianName; - value.guardianCif = this.guardianCif; - value.guardianRelationship = this.guardianRelationship; - value.minorDob = this.minorDob ? this.dateUtils.formatDate(this.minorDob, 'yyyy-MM-dd') : null; - } } return value; } diff --git a/src/app/current-accounts/current-account-stepper/current-account-preview-step/current-account-preview-step.component.html b/src/app/current-accounts/current-account-stepper/current-account-preview-step/current-account-preview-step.component.html index 222c0c142..04797de4c 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-preview-step/current-account-preview-step.component.html +++ b/src/app/current-accounts/current-account-stepper/current-account-preview-step/current-account-preview-step.component.html @@ -42,6 +42,18 @@ Unassigned } + @if (currentAccount?.establishmentDate) { +
| Sr. | +Holder Name | +CIF No. | +Ownership % | +Signing | +Role | +
|---|---|---|---|---|---|
| {{ i + 1 }} | ++ {{ holder.clientName || holder.displayName || '—' }} + @if (holder.isPrimary) { + Primary + } + | +{{ holder.clientCif || holder.cifNumber || '—' }} | +{{ holder.sharePercentage ?? '—' }}% | ++ + {{ holder.signingAuthority || (holder.isMandatory ? 'Mandatory' : 'Optional') }} + + | ++ {{ holder.role || (holder.isPrimary ? 'Primary Account Holder' : 'Co-Holder') }} + | +
| Sr. | +Partner / Client Name | +CIF No. | +Ownership % | +Signing | +
|---|---|---|---|---|
| {{ i + 1 }} | +{{ p.clientName || '—' }} | +{{ p.clientCif || '—' }} | +{{ p.sharePercentage ?? '—' }}% | ++ + {{ p.isMandatory ? 'Mandatory' : 'Optional' }} + + | +
No related clients / partners added.
+ } +