diff --git a/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.html b/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.html index cf07e419f..343fe2e78 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.html +++ b/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.html @@ -123,7 +123,12 @@ Cancel - + Add diff --git a/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.ts b/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.ts index 6c1ee80de..4cf81f5a9 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.ts +++ b/src/app/current-accounts/current-account-stepper/current-account-currency-step/current-account-currency-step.component.ts @@ -83,6 +83,10 @@ export class CurrentAccountCurrencyStepComponent implements OnChanges { return; } } + if (!data.percentageShare || data.percentageShare < 1) { + this.nomineeError = 'Share must be at least 1%.'; + return; + } const newTotal = this.totalShare + (+data.percentageShare || 0); if (newTotal > 100) { this.nomineeError = `Total share cannot exceed 100%. Remaining: ${this.remainingShare}%`; diff --git a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.html b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.html index 284d49784..798a94250 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.html +++ b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.html @@ -301,13 +301,18 @@ % + @if (primaryHolderShare !== null && primaryHolderShare !== undefined && primaryHolderShare < 1) { + Min 1% + } @@ -370,8 +375,8 @@ {{ totalJointSharePercentage }}% @@ -395,10 +400,14 @@ } - @if (totalJointSharePercentage !== 100) { + @if (!isJointOwnershipValid) { warning_amber - Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + @if (totalJointSharePercentage !== 100) { + Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + } @else { + Each holder must have at least 1% ownership share. + } } @else { diff --git a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.scss b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.scss index 859832e06..e20b2721d 100644 --- a/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.scss +++ b/src/app/current-accounts/current-account-stepper/current-account-details-step/current-account-details-step.component.scss @@ -1118,6 +1118,12 @@ $ni-bg: #f9fafb; margin-left: 2px; } +.soa-pct-error { + font-size: 11px; + color: #ef4444; + margin-top: 2px; +} + .soa-no-action { color: #cbd5e1; font-size: 16px; 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 6a8787230..63994c088 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 @@ -99,7 +99,7 @@ export class CurrentAccountDetailsStepComponent implements OnInit { primaryClientName = ''; primaryClientCif = ''; primaryClientId: number | null = null; - primaryHolderShare = 0; + primaryHolderShare = 50; // ── Status of Account (RBI) ──────────────────────────────────────────── readonly accountStatusOptions = [ @@ -412,6 +412,53 @@ export class CurrentAccountDetailsStepComponent implements OnInit { return (this.primaryHolderShare || 0) + this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); } + onPrimaryShareInput(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (val > 100) { + val = 100; + input.value = '100'; + } + this.primaryHolderShare = val; + if (val >= 1) this.redistributeCoHolders(); + } + + onPrimaryShareBlur(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (!val || val < 1) { + val = 1; + input.value = '1'; + this.primaryHolderShare = 1; + this.redistributeCoHolders(); + } + } + + private redistributeCoHolders(): void { + if (this.jointHolders.length === 0) return; + const remaining = 100 - this.primaryHolderShare; + const totalCo = this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); + if (totalCo === 0) return; + let allocated = 0; + this.jointHolders.forEach((h, i) => { + if (i === this.jointHolders.length - 1) { + h.sharePercentage = Math.max(0, remaining - allocated); + } else { + const share = Math.round((h.sharePercentage / totalCo) * remaining); + h.sharePercentage = Math.max(0, share); + allocated += h.sharePercentage; + } + }); + } + + get isJointOwnershipValid(): boolean { + return ( + this.totalJointSharePercentage === 100 && + this.primaryHolderShare >= 1 && + this.jointHolders.every((h) => h.sharePercentage >= 1) + ); + } + get mandatoryJointCount(): number { return this.jointHolders.filter((h) => h.isMandatory).length; } diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html index 459161453..095dc5a02 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.html @@ -108,7 +108,12 @@ Cancel - + Add diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts index 3c7fbb142..7bd2ffca1 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-currency-step/fixed-deposit-account-currency-step.component.ts @@ -80,6 +80,10 @@ export class FixedDepositAccountCurrencyStepComponent implements OnChanges { return; } } + if (!data.percentageShare || data.percentageShare < 1) { + this.nomineeError = 'Share must be at least 1%.'; + return; + } const newTotal = this.totalShare + (+data.percentageShare || 0); if (newTotal > 100) { this.nomineeError = `Total share cannot exceed 100%. Remaining: ${this.remainingShare}%`; diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html index be608125a..dc49e8bd7 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.html @@ -411,13 +411,18 @@ % + @if (primaryHolderShare !== null && primaryHolderShare !== undefined && primaryHolderShare < 1) { + Min 1% + } @@ -479,8 +484,8 @@ {{ totalJointSharePercentage }}% @@ -504,10 +509,14 @@ } - @if (totalJointSharePercentage !== 100) { + @if (!isJointOwnershipValid) { warning_amber - Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + @if (totalJointSharePercentage !== 100) { + Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + } @else { + Each holder must have at least 1% ownership share. + } } @else { diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss index c64960323..f78fa7fce 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.scss @@ -1033,6 +1033,12 @@ $gray-900: #202124; margin-left: 3px; } +.soa-pct-error { + font-size: 11px; + color: #ef4444; + margin-top: 2px; +} + .soa-pct-badge { display: inline-flex; padding: 2px 8px; diff --git a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts index c6e23c9f4..21b6b7435 100644 --- a/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts +++ b/src/app/deposits/fixed-deposits/fixed-deposit-account-stepper/fixed-deposit-account-details-step/fixed-deposit-account-details-step.component.ts @@ -99,7 +99,7 @@ export class FixedDepositAccountDetailsStepComponent implements OnInit { primaryClientName = ''; primaryClientCif = ''; primaryClientId: number | null = null; - primaryHolderShare = 0; + primaryHolderShare = 50; // ── Status of Account (RBI) ──────────────────────────────────────────── readonly accountStatusOptions = [ @@ -528,6 +528,53 @@ export class FixedDepositAccountDetailsStepComponent implements OnInit { return (this.primaryHolderShare || 0) + this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); } + onPrimaryShareInput(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (val > 100) { + val = 100; + input.value = '100'; + } + this.primaryHolderShare = val; + if (val >= 1) this.redistributeCoHolders(); + } + + onPrimaryShareBlur(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (!val || val < 1) { + val = 1; + input.value = '1'; + this.primaryHolderShare = 1; + this.redistributeCoHolders(); + } + } + + private redistributeCoHolders(): void { + if (this.jointHolders.length === 0) return; + const remaining = 100 - this.primaryHolderShare; + const totalCo = this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); + if (totalCo === 0) return; + let allocated = 0; + this.jointHolders.forEach((h, i) => { + if (i === this.jointHolders.length - 1) { + h.sharePercentage = Math.max(0, remaining - allocated); + } else { + const share = Math.round((h.sharePercentage / totalCo) * remaining); + h.sharePercentage = Math.max(0, share); + allocated += h.sharePercentage; + } + }); + } + + get isJointOwnershipValid(): boolean { + return ( + this.totalJointSharePercentage === 100 && + this.primaryHolderShare >= 1 && + this.jointHolders.every((h) => h.sharePercentage >= 1) + ); + } + get mandatoryJointCount(): number { return this.jointHolders.filter((h) => h.isMandatory).length; } diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.html index a10155424..37228451c 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.html @@ -110,7 +110,12 @@ Cancel - + Add diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.ts index 7efb8a4af..8ca90813f 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-currency-step/recurring-deposits-account-currency-step.component.ts @@ -78,6 +78,10 @@ export class RecurringDepositsAccountCurrencyStepComponent implements OnChanges return; } } + if (!data.percentageShare || data.percentageShare < 1) { + this.nomineeError = 'Share must be at least 1%.'; + return; + } const newTotal = this.totalShare + (+data.percentageShare || 0); if (newTotal > 100) { this.nomineeError = `Total share cannot exceed 100%. Remaining: ${this.remainingShare}%`; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.html b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.html index 875ffc7b5..ee854d2ac 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.html +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.html @@ -406,13 +406,18 @@ % + @if (primaryHolderShare !== null && primaryHolderShare !== undefined && primaryHolderShare < 1) { + Min 1% + } @@ -474,8 +479,8 @@ {{ totalJointSharePercentage }}% @@ -499,10 +504,14 @@ } - @if (totalJointSharePercentage !== 100) { + @if (!isJointOwnershipValid) { warning_amber - Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + @if (totalJointSharePercentage !== 100) { + Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + } @else { + Each holder must have at least 1% ownership share. + } } @else { diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.scss b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.scss index 116518005..b6e1a6c0d 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.scss +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.scss @@ -985,6 +985,12 @@ $gray-900: #202124; margin-left: 2px; } +.soa-pct-error { + font-size: 11px; + color: #ef4444; + margin-top: 2px; +} + .soa-no-action { color: #cbd5e1; font-size: 16px; diff --git a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts index 258c03b39..18d37b66a 100644 --- a/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts +++ b/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-details-step/recurring-deposits-account-details-step.component.ts @@ -88,7 +88,7 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit { primaryClientName = ''; primaryClientCif = ''; primaryClientId: number | null = null; - primaryHolderShare = 0; + primaryHolderShare = 50; // ── Status of Account (RBI) ──────────────────────────────────────────── readonly accountStatusOptions = [ @@ -485,6 +485,53 @@ export class RecurringDepositsAccountDetailsStepComponent implements OnInit { return (this.primaryHolderShare || 0) + this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); } + onPrimaryShareInput(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (val > 100) { + val = 100; + input.value = '100'; + } + this.primaryHolderShare = val; + if (val >= 1) this.redistributeCoHolders(); + } + + onPrimaryShareBlur(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (!val || val < 1) { + val = 1; + input.value = '1'; + this.primaryHolderShare = 1; + this.redistributeCoHolders(); + } + } + + private redistributeCoHolders(): void { + if (this.jointHolders.length === 0) return; + const remaining = 100 - this.primaryHolderShare; + const totalCo = this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); + if (totalCo === 0) return; + let allocated = 0; + this.jointHolders.forEach((h, i) => { + if (i === this.jointHolders.length - 1) { + h.sharePercentage = Math.max(0, remaining - allocated); + } else { + const share = Math.round((h.sharePercentage / totalCo) * remaining); + h.sharePercentage = Math.max(0, share); + allocated += h.sharePercentage; + } + }); + } + + get isJointOwnershipValid(): boolean { + return ( + this.totalJointSharePercentage === 100 && + this.primaryHolderShare >= 1 && + this.jointHolders.every((h) => h.sharePercentage >= 1) + ); + } + get mandatoryJointCount(): number { return this.jointHolders.filter((h) => h.isMandatory).length; } diff --git a/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.html b/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.html index 34db80a41..fd171a692 100644 --- a/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.html +++ b/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.html @@ -104,7 +104,12 @@ Cancel - + Add diff --git a/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.ts index 0b6005861..8ba58f1a6 100644 --- a/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-currency-step/savings-account-currency-step.component.ts @@ -65,6 +65,10 @@ export class SavingsAccountCurrencyStepComponent { return; } } + if (!data.percentageShare || data.percentageShare < 1) { + this.nomineeError = 'Share must be at least 1%.'; + return; + } const newTotal = this.totalShare + (+data.percentageShare || 0); if (newTotal > 100) { this.nomineeError = `Total share cannot exceed 100%. Remaining: ${this.remainingShare}%`; diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.html b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.html index 0ed525221..89fa66639 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.html +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.html @@ -261,13 +261,18 @@ % + @if (primaryHolderShare !== null && primaryHolderShare !== undefined && primaryHolderShare < 1) { + Min 1% + } @@ -332,8 +337,8 @@ {{ totalJointSharePercentage }}% @@ -357,10 +362,14 @@ } - @if (totalJointSharePercentage !== 100) { + @if (!isJointOwnershipValid) { warning_amber - Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + @if (totalJointSharePercentage !== 100) { + Total ownership is {{ totalJointSharePercentage }}%. It must equal 100%. + } @else { + Each holder must have at least 1% ownership share. + } } @else { diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.scss b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.scss index ff42ba281..f600fd51d 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.scss +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.scss @@ -514,6 +514,12 @@ $gray-900: #202124; margin-left: 2px; } +.soa-pct-error { + font-size: 11px; + color: #ef4444; + margin-top: 2px; +} + .soa-no-action { color: #cbd5e1; font-size: 16px; diff --git a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts index a8182a518..55fb52cce 100644 --- a/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts +++ b/src/app/savings/savings-account-stepper/savings-account-details-step/savings-account-details-step.component.ts @@ -81,7 +81,7 @@ export class SavingsAccountDetailsStepComponent implements OnInit { primaryClientName = ''; primaryClientCif = ''; primaryClientId: number | null = null; - primaryHolderShare = 0; + primaryHolderShare = 50; /** 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. */ @@ -428,6 +428,53 @@ export class SavingsAccountDetailsStepComponent implements OnInit { return (this.primaryHolderShare || 0) + this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); } + onPrimaryShareInput(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (val > 100) { + val = 100; + input.value = '100'; + } + this.primaryHolderShare = val; + if (val >= 1) this.redistributeCoHolders(); + } + + onPrimaryShareBlur(event: Event): void { + const input = event.target as HTMLInputElement; + let val = +input.value; + if (!val || val < 1) { + val = 1; + input.value = '1'; + this.primaryHolderShare = 1; + this.redistributeCoHolders(); + } + } + + private redistributeCoHolders(): void { + if (this.jointHolders.length === 0) return; + const remaining = 100 - this.primaryHolderShare; + const totalCo = this.jointHolders.reduce((sum, h) => sum + (h.sharePercentage || 0), 0); + if (totalCo === 0) return; + let allocated = 0; + this.jointHolders.forEach((h, i) => { + if (i === this.jointHolders.length - 1) { + h.sharePercentage = Math.max(0, remaining - allocated); + } else { + const share = Math.round((h.sharePercentage / totalCo) * remaining); + h.sharePercentage = Math.max(0, share); + allocated += h.sharePercentage; + } + }); + } + + get isJointOwnershipValid(): boolean { + return ( + this.totalJointSharePercentage === 100 && + this.primaryHolderShare >= 1 && + this.jointHolders.every((h) => h.sharePercentage >= 1) + ); + } + get mandatoryJointCount(): number { return this.jointHolders.filter((h) => h.isMandatory).length; } diff --git a/src/app/shared/account-nominees-tab/account-nominees-tab.component.html b/src/app/shared/account-nominees-tab/account-nominees-tab.component.html index ab31deef4..a36df6205 100644 --- a/src/app/shared/account-nominees-tab/account-nominees-tab.component.html +++ b/src/app/shared/account-nominees-tab/account-nominees-tab.component.html @@ -143,7 +143,9 @@ Share % - @if (editShare && editShare > maxShareForEdit(i)) { + @if (editShare !== null && editShare !== undefined && editShare < 1) { + Share must be at least 1% + } @else if (editShare && editShare > maxShareForEdit(i)) { Max {{ maxShareForEdit(i) }}% } @@ -152,7 +154,7 @@ color="primary" type="button" class="nom-edit-save" - [disabled]="!editRelId || !editShare || editShare > maxShareForEdit(i)" + [disabled]="!editRelId || !editShare || editShare < 1 || editShare > maxShareForEdit(i)" (click)="saveEdit(nominee, i)" > check @@ -317,7 +319,9 @@ Share % - @if (nomineeShare && nomineeShare > maxAllowedShare) { + @if (nomineeShare !== null && nomineeShare !== undefined && nomineeShare < 1) { + Share must be at least 1% + } @else if (nomineeShare && nomineeShare > maxAllowedShare) { Max {{ maxAllowedShare }}% } @@ -398,6 +402,7 @@ [disabled]=" !nomineeRelationshipId || !nomineeShare || + nomineeShare < 1 || nomineeSaving || nomineeShare > maxAllowedShare || (nomineeIsMinor && !selectedGuardian) || diff --git a/src/app/shared/account-nominees-tab/account-nominees-tab.component.ts b/src/app/shared/account-nominees-tab/account-nominees-tab.component.ts index 1c1ace418..afbfccc59 100644 --- a/src/app/shared/account-nominees-tab/account-nominees-tab.component.ts +++ b/src/app/shared/account-nominees-tab/account-nominees-tab.component.ts @@ -351,7 +351,7 @@ export class AccountNomineesTabComponent implements OnInit { } saveNominee(): void { - if (!this.selectedClient || !this.nomineeRelationshipId || !this.nomineeShare) return; + if (!this.selectedClient || !this.nomineeRelationshipId || !this.nomineeShare || this.nomineeShare < 1) return; if (this.totalShare + this.nomineeShare > 100) return; if (this.guardianSameAsNominee) return; @@ -429,7 +429,8 @@ export class AccountNomineesTabComponent implements OnInit { } saveEdit(nominee: any, index: number): void { - if (!this.editRelId || !this.editShare || this.editShare > this.maxShareForEdit(index)) return; + if (!this.editRelId || !this.editShare || this.editShare < 1 || this.editShare > this.maxShareForEdit(index)) + return; const payload: any = { relationshipId: this.editRelId, diff --git a/src/app/shared/nominee-form/nominee-form.component.html b/src/app/shared/nominee-form/nominee-form.component.html index 48583fa00..a8c004134 100644 --- a/src/app/shared/nominee-form/nominee-form.component.html +++ b/src/app/shared/nominee-form/nominee-form.component.html @@ -162,8 +162,12 @@ Share % - @if (percentageShare && (percentageShare < 1 || percentageShare > 100)) { - 1–100 + @if ( + percentageShare !== null && + percentageShare !== undefined && + (percentageShare < 1 || percentageShare > 100) + ) { + Share must be 1–100% } diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/pending-account/pending-account.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/pending-account/pending-account.component.ts index fde54a567..bc8336ae0 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/pending-account/pending-account.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/pending-account/pending-account.component.ts @@ -166,6 +166,10 @@ export class PendingAccountComponent { const d = new Date(date[0], date[1] - 1, date[2]); return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }); } + const d = new Date(date); + if (!isNaN(d.getTime())) { + return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }); + } return date; } diff --git a/src/app/tasks/checker-inbox-and-tasks-tabs/rejected-account/rejected-account.component.ts b/src/app/tasks/checker-inbox-and-tasks-tabs/rejected-account/rejected-account.component.ts index 04fe2ad91..3494f9a67 100644 --- a/src/app/tasks/checker-inbox-and-tasks-tabs/rejected-account/rejected-account.component.ts +++ b/src/app/tasks/checker-inbox-and-tasks-tabs/rejected-account/rejected-account.component.ts @@ -82,6 +82,10 @@ export class RejectedAccountComponent { const d = new Date(date[0], date[1] - 1, date[2]); return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }); } + const d = new Date(date); + if (!isNaN(d.getTime())) { + return d.toLocaleDateString('en-IN', { day: '2-digit', month: 'short', year: 'numeric' }); + } return date; } }