feat(accounts): add Modify Application for rejected Current/Savings/FD/RD accounts
- Add 'Modify Application' button in kebab menu for rejected accounts (all 4 types)
- Rewrite edit components with tab-based UI matching create form
- Pre-populate all create-time values in edit form: product, account status,
customer segment, account type, joint holders, nominees, introducer,
deposit account link, senior citizen rate, tenure, flags (msme/balanceSwap/autoDebit)
- Fix edit mode detection using accountNo presence
- Add preselectedIntroducer @Input to IntroducerSearchComponent for pre-fill
- Support both camelCase and lowercase keys for joint holders (MySQL queryForList)
- Fix account number display: actual accountNo before previewAccountNo
- Fix cbsAccountType restore: cbsAccountType only, avoid Fineract enum object
- Add nominees fetch via /clients/{id}/nominees API in all 4 edit components
- Fix RD/FD Interest Rate Chart: SimpleChanges to prevent reset race condition
- Pre-check Senior Citizen checkbox in edit form from isSeniorCitizen DB field
- Auto-calculate rate when tenure pre-filled in edit mode
- FD calculator: use backend calculate-fd-interest API for all compounding types
- Support interestCompoundingPeriodInMonths=0 (daily) in FD calculator API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
3be2f96210
commit
260fabaa48
+35
-1
@@ -29,6 +29,7 @@ export class CurrentAccountCurrencyStepComponent implements OnChanges {
|
||||
@Input() currentAccountProductTemplate: any;
|
||||
@Input() primaryClientId: number | null = null;
|
||||
@Input() isNonIndividualClient = false;
|
||||
@Input() existingAccount: any = null;
|
||||
@ViewChild(NomineeFormComponent) nomineeFormComp: NomineeFormComponent;
|
||||
|
||||
nominees: any[] = [];
|
||||
@@ -41,8 +42,29 @@ export class CurrentAccountCurrencyStepComponent implements OnChanges {
|
||||
msme = false;
|
||||
autoDebitFacility = false;
|
||||
|
||||
private existingAccountApplied = false;
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['currentAccountProductTemplate']?.currentValue) {
|
||||
if (changes['existingAccount']?.currentValue) {
|
||||
const ea = changes['existingAccount'].currentValue;
|
||||
this.existingAccountApplied = true;
|
||||
if (ea.balanceSwapOption !== undefined) {
|
||||
this.balanceSwapOption = !!ea.balanceSwapOption;
|
||||
}
|
||||
if (ea.msme !== undefined) {
|
||||
this.msme = !!ea.msme;
|
||||
}
|
||||
if (ea.autoDebitFacility !== undefined) {
|
||||
this.autoDebitFacility = !!ea.autoDebitFacility;
|
||||
}
|
||||
// nominees: try array first, then parse nomineeData JSON string
|
||||
const nominees =
|
||||
Array.isArray(ea.nominees) && ea.nominees.length > 0 ? ea.nominees : this.parseNomineeData(ea.nomineeData);
|
||||
if (nominees.length > 0) {
|
||||
this.nominees = [...nominees];
|
||||
}
|
||||
}
|
||||
if (changes['currentAccountProductTemplate']?.currentValue && !this.existingAccountApplied) {
|
||||
const pt = changes['currentAccountProductTemplate'].currentValue;
|
||||
this.balanceSwapOption = !!pt.balanceSwapOption;
|
||||
this.msme = !!pt.msme;
|
||||
@@ -50,6 +72,18 @@ export class CurrentAccountCurrencyStepComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
private parseNomineeData(nomineeData: any): any[] {
|
||||
if (!nomineeData) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const parsed = typeof nomineeData === 'string' ? JSON.parse(nomineeData) : nomineeData;
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
get totalShare(): number {
|
||||
return this.nominees.reduce((sum, n) => sum + (+n.percentageShare || 0), 0);
|
||||
}
|
||||
|
||||
+4
-1
@@ -124,7 +124,7 @@
|
||||
<mat-label>Account No</mat-label>
|
||||
<input
|
||||
matInput
|
||||
[value]="productTemplate?.previewAccountNo || currentAccountTemplate?.accountNo || 'Auto-generated'"
|
||||
[value]="currentAccountTemplate?.accountNo || productTemplate?.previewAccountNo || 'Auto-generated'"
|
||||
readonly
|
||||
/>
|
||||
</mat-form-field>
|
||||
@@ -167,6 +167,9 @@
|
||||
@if (productTemplate?.introducerRequired) {
|
||||
<mifosx-introducer-search
|
||||
[excludedClientIds]="primaryClientId ? [primaryClientId] : []"
|
||||
[preselectedIntroducer]="
|
||||
introducerId ? { clientId: introducerId, displayName: introducerName, cifNumber: introducerCif } : null
|
||||
"
|
||||
(introducerChange)="onIntroducerChange($event)"
|
||||
></mifosx-introducer-search>
|
||||
}
|
||||
|
||||
+121
-3
@@ -65,6 +65,7 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
|
||||
introducerId: number | null = null;
|
||||
introducerName: string | null = null;
|
||||
introducerCif: string | null = null;
|
||||
private isEditMode = false;
|
||||
|
||||
// ── Non-Individual (existing) ──────────────────────────────────────────
|
||||
isNonIndividualClient = false;
|
||||
@@ -201,11 +202,29 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
|
||||
|
||||
if (this.currentAccountTemplate) {
|
||||
this.productData = this.currentAccountTemplate.productOptions;
|
||||
if (this.currentAccountTemplate.currentAccountProductId) {
|
||||
const existingProductId =
|
||||
this.currentAccountTemplate.currentAccountProductId ?? this.currentAccountTemplate.productId;
|
||||
// Edit mode: account response always has accountNo; pure template has previewAccountNo only
|
||||
if (this.currentAccountTemplate.accountNo) {
|
||||
this.isEditMode = true;
|
||||
}
|
||||
if ((!this.productData || this.productData.length === 0) && existingProductId) {
|
||||
this.isEditMode = true;
|
||||
this.productData = [
|
||||
{
|
||||
id: existingProductId,
|
||||
name:
|
||||
this.currentAccountTemplate.productName ??
|
||||
this.currentAccountTemplate.currentAccountProductName ??
|
||||
'Product'
|
||||
}
|
||||
];
|
||||
}
|
||||
if (existingProductId) {
|
||||
this.currentAccountDetailsForm.patchValue({
|
||||
productId: this.currentAccountTemplate.currentAccountProductId,
|
||||
productId: existingProductId,
|
||||
submittedOnDate:
|
||||
this.currentAccountTemplate.timeline.submittedOnDate &&
|
||||
this.currentAccountTemplate.timeline?.submittedOnDate &&
|
||||
new Date(this.currentAccountTemplate.timeline.submittedOnDate),
|
||||
externalId: this.currentAccountTemplate.externalId
|
||||
});
|
||||
@@ -273,10 +292,106 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
|
||||
} else {
|
||||
this.currentAccountDetailsForm.get('fieldOfficerId').patchValue('');
|
||||
}
|
||||
// === Restore existing account values when in edit/modify mode ===
|
||||
this.restoreExistingAccountValues();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private restoreExistingAccountValues(): void {
|
||||
const ea = this.currentAccountTemplate;
|
||||
// Edit mode: API returns `productId`, create template uses `currentAccountProductId`
|
||||
if (!ea?.currentAccountProductId && !ea?.productId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const strVal = (v: any): string => (typeof v === 'object' && v !== null ? (v.value ?? '') : (v ?? ''));
|
||||
|
||||
const accountStatus = strVal(ea.accountStatus);
|
||||
if (accountStatus) {
|
||||
this.selectedAccountStatus = accountStatus;
|
||||
}
|
||||
|
||||
const customerSegment = strVal(ea.customerSegment);
|
||||
if (customerSegment) {
|
||||
this.selectedCustomerSegment = customerSegment;
|
||||
}
|
||||
|
||||
// cbsAccountType is the CBS descriptive type ("Standard Account", etc.)
|
||||
// ea.accountType is Fineract's enum-based type ({id,value:"Individual"}) — do NOT use as fallback
|
||||
const accountType = ea.cbsAccountType ? strVal(ea.cbsAccountType) : null;
|
||||
if (accountType) {
|
||||
this.selectedAccountType = accountType;
|
||||
}
|
||||
|
||||
if (accountStatus === 'JOINT') {
|
||||
const modeOfOp = strVal(ea.modeOfOperation);
|
||||
if (modeOfOp) {
|
||||
this.modeOfOperation = modeOfOp;
|
||||
}
|
||||
// jointHolders may not be returned by backend — skip if absent
|
||||
if (Array.isArray(ea.jointHolders) && ea.jointHolders.length > 0) {
|
||||
// Support both camelCase and lowercase keys (MySQL queryForList returns lowercase)
|
||||
const isPH = (h: any) => h.isPrimary ?? h.isprimary ?? false;
|
||||
const primary = ea.jointHolders.find((h: any) => isPH(h));
|
||||
const ps = primary?.sharePercentage ?? primary?.sharepercentage;
|
||||
if (ps) {
|
||||
this.primaryHolderShare = +ps;
|
||||
}
|
||||
this.jointHolders = ea.jointHolders
|
||||
.filter((h: any) => !isPH(h))
|
||||
.map((h: any) => ({
|
||||
clientId: h.clientId ?? h.clientid,
|
||||
clientName: h.displayName ?? h.displayname ?? h.clientName ?? '',
|
||||
clientCif: h.cifNumber ?? h.cifnumber ?? h.clientCif ?? '',
|
||||
sharePercentage: +(h.sharePercentage ?? h.sharepercentage ?? 0),
|
||||
isMandatory: !!(h.isMandatory ?? h.ismandatory)
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (accountStatus === 'INDIVIDUAL_MALE' && ea.specialCategory) {
|
||||
this.selectedSpecialCategory = ea.specialCategory;
|
||||
}
|
||||
if (accountStatus === 'INDIVIDUAL_FEMALE' && ea.weakerSection) {
|
||||
this.selectedWeakerSection = ea.weakerSection;
|
||||
}
|
||||
if (accountStatus === 'MINOR') {
|
||||
if (ea.guardianClientId) {
|
||||
this.guardianClientId = ea.guardianClientId;
|
||||
}
|
||||
if (ea.guardianName) {
|
||||
this.guardianName = ea.guardianName;
|
||||
}
|
||||
if (ea.guardianCifNumber) {
|
||||
this.guardianCif = ea.guardianCifNumber;
|
||||
}
|
||||
if (ea.guardianRelationship) {
|
||||
this.guardianRelationship = ea.guardianRelationship;
|
||||
}
|
||||
if (ea.minorDateOfBirth) {
|
||||
const d = new Date(ea.minorDateOfBirth);
|
||||
if (!isNaN(d.getTime())) {
|
||||
this.minorDob = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
// API returns introducerClientId, not introducerId
|
||||
const introId = ea.introducerId ?? ea.introducerClientId;
|
||||
if (introId) {
|
||||
this.introducerId = introId;
|
||||
this.introducerName = ea.introducerName ?? null;
|
||||
this.introducerCif = ea.introducerCifNumber ?? null;
|
||||
}
|
||||
this.currentAccountDetailsForm.patchValue({
|
||||
balanceSwapOption: !!ea.balanceSwapOption,
|
||||
msme: !!ea.msme,
|
||||
autoDebitFacility: !!ea.autoDebitFacility,
|
||||
...(ea.establishmentDate ? { establishmentDate: new Date(ea.establishmentDate) } : {}),
|
||||
...(ea.startOperationDate ? { startOperationDate: new Date(ea.startOperationDate) } : {})
|
||||
});
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
|
||||
private extractOptions(options: any[], fallback?: string): string[] {
|
||||
if (Array.isArray(options) && options.length > 0) {
|
||||
return options.map((o: any) => o.value ?? o.name ?? o);
|
||||
@@ -317,6 +432,9 @@ export class CurrentAccountDetailsStepComponent implements OnInit {
|
||||
}
|
||||
|
||||
private autoDetectAccountStatus(): void {
|
||||
if (this.isEditMode) {
|
||||
return;
|
||||
}
|
||||
if (this.clientAge === null) return;
|
||||
if (this.clientAge < 18) {
|
||||
this.selectedAccountStatus = 'MINOR';
|
||||
|
||||
+10
-1
@@ -40,10 +40,19 @@ const DEFAULT_FACILITY_CONFIG = {
|
||||
})
|
||||
export class CurrentAccountDigitalStepComponent {
|
||||
facilityConfig = { ...DEFAULT_FACILITY_CONFIG };
|
||||
private hasExistingAccount = false;
|
||||
|
||||
@Input()
|
||||
set existingAccount(value: any) {
|
||||
if (value?.accountFacilityConfig) {
|
||||
this.hasExistingAccount = true;
|
||||
this.facilityConfig = { ...DEFAULT_FACILITY_CONFIG, ...value.accountFacilityConfig };
|
||||
}
|
||||
}
|
||||
|
||||
@Input()
|
||||
set currentAccountProductTemplate(value: any) {
|
||||
if (value?.accountFacilityConfig) {
|
||||
if (!this.hasExistingAccount && value?.accountFacilityConfig) {
|
||||
this.facilityConfig = { ...DEFAULT_FACILITY_CONFIG, ...value.accountFacilityConfig };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,16 @@ export class CurrentAccountButtonsConfiguration {
|
||||
}
|
||||
];
|
||||
break;
|
||||
case 'Rejected':
|
||||
case 'rejected':
|
||||
this.buttonsArray = [
|
||||
{
|
||||
name: 'Modify Application',
|
||||
icon: 'pen',
|
||||
taskPermissionName: 'UPDATE_CURRENTACCOUNT'
|
||||
}
|
||||
];
|
||||
break;
|
||||
default:
|
||||
this.buttonsArray = [];
|
||||
}
|
||||
|
||||
+139
-69
@@ -6,76 +6,146 @@
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
|
||||
<div class="container">
|
||||
<mat-stepper
|
||||
orientation="vertical"
|
||||
[linear]="false"
|
||||
class="mat-elevation-z8"
|
||||
labelPosition="bottom"
|
||||
#currentAccountProductStepper
|
||||
<div class="cca-container">
|
||||
<!-- Hero -->
|
||||
<div class="cca-header">
|
||||
<fa-icon icon="university" class="cca-header__icon"></fa-icon>
|
||||
<div>
|
||||
<h2 class="cca-header__title">Modify Current Account Application</h2>
|
||||
<div class="cca-header__sub">
|
||||
Review and update the account details, currency settings and digital channels before resubmitting.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Wizard tabs -->
|
||||
<mat-tab-group
|
||||
class="cca-tabs"
|
||||
animationDuration="200ms"
|
||||
[preserveContent]="true"
|
||||
[(selectedIndex)]="selectedTabIndex"
|
||||
>
|
||||
<ng-template matStepperIcon="number">
|
||||
<fa-icon icon="pencil-alt" size="sm"></fa-icon>
|
||||
</ng-template>
|
||||
|
||||
<ng-template matStepperIcon="edit">
|
||||
<fa-icon icon="pencil-alt" size="sm"></fa-icon>
|
||||
</ng-template>
|
||||
|
||||
<ng-template matStepperIcon="done">
|
||||
<fa-icon icon="check" size="sm"></fa-icon>
|
||||
</ng-template>
|
||||
|
||||
<ng-template matStepperIcon="error">
|
||||
<fa-icon icon="exclamation-triangle" size="lg"></fa-icon>
|
||||
</ng-template>
|
||||
|
||||
<ng-template matStepperIcon="preview">
|
||||
<fa-icon icon="eye" size="sm"></fa-icon>
|
||||
</ng-template>
|
||||
|
||||
<mat-step [stepControl]="currentAccountDetailsForm">
|
||||
<ng-template matStepLabel>{{ 'labels.inputs.DETAILS' | translate }}</ng-template>
|
||||
|
||||
<mifosx-current-account-details-step
|
||||
[currentAccountTemplate]="currentAccountAndTemplate"
|
||||
(currentAccountProductTemplate)="setTemplate($event)"
|
||||
>
|
||||
</mifosx-current-account-details-step>
|
||||
</mat-step>
|
||||
|
||||
<mat-step [stepControl]="currentAccountTermsForm">
|
||||
<ng-template matStepLabel>{{ 'labels.inputs.TERMS' | translate }}</ng-template>
|
||||
|
||||
<mifosx-current-account-terms-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
[currentAccountTemplate]="currentAccountAndTemplate"
|
||||
></mifosx-current-account-terms-step>
|
||||
</mat-step>
|
||||
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>{{ 'labels.inputs.CHARGES' | translate }}</ng-template>
|
||||
|
||||
<mifosx-current-account-charges-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
[currentAccountTemplate]="currentAccountAndTemplate"
|
||||
[currencyCode]="currentAccountTermsForm.get('currencyCode')"
|
||||
>
|
||||
</mifosx-current-account-charges-step>
|
||||
</mat-step>
|
||||
|
||||
@if (currentAccountFormValidAndNotPristine) {
|
||||
<mat-step completed>
|
||||
<ng-template matStepLabel>{{ 'labels.inputs.PREVIEW' | translate }}</ng-template>
|
||||
<mifosx-current-account-preview-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
<!-- Tab 1: Product Classification + Details -->
|
||||
<mat-tab>
|
||||
<ng-template mat-tab-label>
|
||||
<fa-icon icon="check-square" class="cca-tab__icon"></fa-icon>
|
||||
Product
|
||||
</ng-template>
|
||||
<div class="cca-tab-body">
|
||||
<mifosx-current-account-details-step
|
||||
[currentAccountTemplate]="currentAccountAndTemplate"
|
||||
[currentAccountTermsForm]="currentAccountTermsForm"
|
||||
[currentAccount]="currentAccount"
|
||||
(submitEvent)="submit()"
|
||||
[hideButtons]="true"
|
||||
(currentAccountProductTemplate)="setTemplate($event)"
|
||||
>
|
||||
</mifosx-current-account-preview-step>
|
||||
</mat-step>
|
||||
}
|
||||
</mat-stepper>
|
||||
</mifosx-current-account-details-step>
|
||||
|
||||
<div class="cca-actions">
|
||||
<span class="cca-actions__spacer"></span>
|
||||
<button mat-raised-button color="primary" [disabled]="!currentAccountProductTemplate" (click)="next()">
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
<fa-icon icon="arrow-right" class="m-l-10"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
<!-- Tab 2: Currency -->
|
||||
<mat-tab [disabled]="!currentAccountProductTemplate">
|
||||
<ng-template mat-tab-label>
|
||||
<fa-icon icon="dollar-sign" class="cca-tab__icon"></fa-icon>
|
||||
Currency
|
||||
</ng-template>
|
||||
<div class="cca-tab-body">
|
||||
@if (currentAccountProductTemplate) {
|
||||
<mifosx-current-account-currency-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
[primaryClientId]="currentAccountAndTemplate?.clientId ?? null"
|
||||
[isNonIndividualClient]="currentAccountDetailsStep.isNonIndividualClient"
|
||||
[existingAccount]="currentAccountAndTemplate"
|
||||
></mifosx-current-account-currency-step>
|
||||
}
|
||||
|
||||
<div class="cca-actions">
|
||||
<button mat-stroked-button (click)="prev()">
|
||||
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Previous' | translate }}
|
||||
</button>
|
||||
<span class="cca-actions__spacer"></span>
|
||||
<button mat-raised-button color="primary" (click)="next()">
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
<fa-icon icon="arrow-right" class="m-l-10"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
<!-- Tab 3: Digital -->
|
||||
<mat-tab [disabled]="!currentAccountProductTemplate">
|
||||
<ng-template mat-tab-label>
|
||||
<fa-icon icon="mobile-alt" class="cca-tab__icon"></fa-icon>
|
||||
Digital
|
||||
</ng-template>
|
||||
<div class="cca-tab-body">
|
||||
@if (currentAccountProductTemplate) {
|
||||
<mifosx-current-account-digital-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
[existingAccount]="currentAccountAndTemplate"
|
||||
></mifosx-current-account-digital-step>
|
||||
}
|
||||
|
||||
<div class="cca-actions">
|
||||
<button mat-stroked-button (click)="prev()">
|
||||
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Previous' | translate }}
|
||||
</button>
|
||||
<span class="cca-actions__spacer"></span>
|
||||
<button mat-raised-button color="primary" (click)="next()">
|
||||
{{ 'labels.buttons.Next' | translate }}
|
||||
<fa-icon icon="arrow-right" class="m-l-10"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
<!-- Tab 4: Preview -->
|
||||
<mat-tab [disabled]="!currentAccountProductTemplate">
|
||||
<ng-template mat-tab-label>
|
||||
<fa-icon icon="eye" class="cca-tab__icon"></fa-icon>
|
||||
{{ 'labels.inputs.PREVIEW' | translate }}
|
||||
</ng-template>
|
||||
<div class="cca-tab-body">
|
||||
@if (currentAccountProductTemplate) {
|
||||
<mifosx-current-account-preview-step
|
||||
[currentAccountProductTemplate]="currentAccountProductTemplate"
|
||||
[currentAccountTemplate]="currentAccountAndTemplate"
|
||||
[currentAccountTermForm]="currentAccountTermForm"
|
||||
[currentAccountSettingsForm]="currentAccountSettingsForm"
|
||||
[currentAccountTermsForm]="currentAccountTermsForm"
|
||||
[currentAccount]="currentAccount"
|
||||
[currentAccountDigital]="currentAccountDigital"
|
||||
[currentAccountNominees]="currentAccountCurrencyStep?.nominees ?? []"
|
||||
[currentAccountCurrencyFlags]="currentAccountCurrencyFlags"
|
||||
[hideButtons]="true"
|
||||
(submitEvent)="submit()"
|
||||
>
|
||||
</mifosx-current-account-preview-step>
|
||||
}
|
||||
|
||||
<div class="cca-actions">
|
||||
<button mat-stroked-button (click)="prev()">
|
||||
<fa-icon icon="arrow-left" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Previous' | translate }}
|
||||
</button>
|
||||
<span class="cca-actions__spacer"></span>
|
||||
<button mat-stroked-button [routerLink]="['../']">
|
||||
{{ 'labels.buttons.Cancel' | translate }}
|
||||
</button>
|
||||
<button mat-raised-button color="primary" class="preview-submit-row__primary" (click)="submit()">
|
||||
<fa-icon icon="check" class="m-r-10"></fa-icon>
|
||||
{{ 'labels.buttons.Submit' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
|
||||
@@ -5,3 +5,164 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
$navy: #0d1b2a;
|
||||
$blue: #1e88e5;
|
||||
$blue-d: #1e40af;
|
||||
$indigo: #4f46e5;
|
||||
$border: #e2e8f0;
|
||||
|
||||
.cca-container {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
/* ─── Hero header (matches Nexora pages) ────────────────────────────── */
|
||||
.cca-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
&__icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, $blue 0%, $indigo 100%);
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
box-shadow: 0 2px 8px rgb(29 78 216 / 25%);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
color: $navy;
|
||||
line-height: 1.1;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
&__sub {
|
||||
margin-top: 2px;
|
||||
font-size: 12.5px;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Wizard tab strip ──────────────────────────────────────────────── */
|
||||
.cca-tabs {
|
||||
background: #fff;
|
||||
border: 1px solid $border;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 1px 3px rgb(15 23 42 / 4%);
|
||||
overflow: hidden;
|
||||
|
||||
::ng-deep {
|
||||
.mat-mdc-tab-header {
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid $border;
|
||||
}
|
||||
|
||||
.mat-mdc-tab {
|
||||
min-width: 140px;
|
||||
height: 50px;
|
||||
padding: 0 22px;
|
||||
font-size: 13px !important;
|
||||
font-weight: 600 !important;
|
||||
letter-spacing: 0.01em;
|
||||
color: #475569 !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
.mat-mdc-tab:hover:not(.mdc-tab--active, .mat-mdc-tab-disabled) {
|
||||
background: rgb(30 64 175 / 5%);
|
||||
color: $navy !important;
|
||||
}
|
||||
|
||||
.mat-mdc-tab.mdc-tab--active {
|
||||
.mdc-tab__text-label {
|
||||
color: $blue-d !important;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.mdc-tab-indicator__content--underline {
|
||||
border-color: $blue-d !important;
|
||||
border-top-width: 3px !important;
|
||||
}
|
||||
|
||||
.mat-mdc-tab.mat-mdc-tab-disabled {
|
||||
opacity: 0.45 !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.mat-mdc-tab-body-wrapper {
|
||||
min-height: 320px;
|
||||
}
|
||||
|
||||
.mat-mdc-tab-body,
|
||||
.mat-mdc-tab-body-content {
|
||||
overflow: visible !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cca-tab__icon {
|
||||
margin-right: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ─── Tab body + action bar ─────────────────────────────────────────── */
|
||||
.cca-tab-body {
|
||||
padding: 24px;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.cca-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 24px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
|
||||
&__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 40px !important;
|
||||
border-radius: 10px !important;
|
||||
font-weight: 600 !important;
|
||||
padding: 0 18px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.m-l-10 {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.m-r-10 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
button.preview-submit-row__primary,
|
||||
.mat-mdc-raised-button.mat-primary.preview-submit-row__primary,
|
||||
.preview-submit-row__primary {
|
||||
background: linear-gradient(135deg, #10b981 0%, #047857 100%) !important;
|
||||
|
||||
--mdc-protected-button-container-color: transparent !important;
|
||||
--mdc-filled-button-container-color: transparent !important;
|
||||
|
||||
color: #fff !important;
|
||||
box-shadow: 0 4px 12px -2px rgb(4 120 87 / 35%) !important;
|
||||
}
|
||||
|
||||
@@ -9,23 +9,26 @@
|
||||
/** Angular Imports */
|
||||
import { Component, ViewChild, inject } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { ClientsService } from 'app/clients/clients.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { CurrentAccountDetailsStepComponent } from '../current-account-stepper/current-account-details-step/current-account-details-step.component';
|
||||
import { CurrentAccountTermsStepComponent } from '../current-account-stepper/current-account-terms-step/current-account-terms-step.component';
|
||||
import { CurrentAccountChargesStepComponent } from '../current-account-stepper/current-account-charges-step/current-account-charges-step.component';
|
||||
import { CurrentAccountCurrencyStepComponent } from '../current-account-stepper/current-account-currency-step/current-account-currency-step.component';
|
||||
import { CurrentAccountDigitalStepComponent } from '../current-account-stepper/current-account-digital-step/current-account-digital-step.component';
|
||||
|
||||
/** Custom Services */
|
||||
import { CurrentAccountsService } from '../current-accounts.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper';
|
||||
import { AlertService } from 'app/core/alert/alert.service';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
||||
import { CurrentAccountPreviewStepComponent } from '../current-account-stepper/current-account-preview-step/current-account-preview-step.component';
|
||||
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
|
||||
/**
|
||||
* Edit Current Account Component
|
||||
* Edit Current Account Component — same tab UI as Create, pre-populated with existing data.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-edit-current-account-account',
|
||||
@@ -33,14 +36,11 @@ import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
||||
styleUrls: ['./edit-current-account.component.scss'],
|
||||
imports: [
|
||||
...STANDALONE_SHARED_IMPORTS,
|
||||
MatStepper,
|
||||
MatStepperIcon,
|
||||
MatTabsModule,
|
||||
FaIconComponent,
|
||||
MatStep,
|
||||
MatStepLabel,
|
||||
CurrentAccountDetailsStepComponent,
|
||||
CurrentAccountTermsStepComponent,
|
||||
CurrentAccountChargesStepComponent,
|
||||
CurrentAccountCurrencyStepComponent,
|
||||
CurrentAccountDigitalStepComponent,
|
||||
CurrentAccountPreviewStepComponent
|
||||
]
|
||||
})
|
||||
@@ -50,109 +50,172 @@ export class EditCurrentAccountComponent {
|
||||
private dateUtils = inject(Dates);
|
||||
private currentAccountsService = inject(CurrentAccountsService);
|
||||
private settingsService = inject(SettingsService);
|
||||
private alertService = inject(AlertService);
|
||||
private clientsService = inject(ClientsService);
|
||||
|
||||
/** Current Account Template */
|
||||
/** Full account data + template from resolver */
|
||||
currentAccountAndTemplate: any;
|
||||
/** Current Account Product Template */
|
||||
/** Product template emitted by details step */
|
||||
currentAccountProductTemplate: any;
|
||||
/** Currently visible wizard tab (0-indexed). */
|
||||
selectedTabIndex = 0;
|
||||
private readonly totalTabs = 4;
|
||||
|
||||
/** Current Account Details Step */
|
||||
@ViewChild(CurrentAccountDetailsStepComponent, { static: true })
|
||||
currentAccountDetailsStep: CurrentAccountDetailsStepComponent;
|
||||
/** Current Account Terms Step */
|
||||
@ViewChild(CurrentAccountTermsStepComponent, { static: true })
|
||||
currentAccountTermsStep: CurrentAccountTermsStepComponent;
|
||||
/** Current Account Charges Step */
|
||||
@ViewChild(CurrentAccountChargesStepComponent, { static: true })
|
||||
currentAccountChargesStep: CurrentAccountChargesStepComponent;
|
||||
|
||||
/**
|
||||
* Fetches current account template from `resolve`
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
* @param {Dates} dateUtils Date Utils
|
||||
* @param {CurrentAccountsService} currentAccountsService Current Accounts Service
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
@ViewChild(CurrentAccountCurrencyStepComponent)
|
||||
currentAccountCurrencyStep: CurrentAccountCurrencyStepComponent;
|
||||
|
||||
@ViewChild(CurrentAccountDigitalStepComponent)
|
||||
currentAccountDigitalStep: CurrentAccountDigitalStepComponent;
|
||||
|
||||
constructor() {
|
||||
this.route.data.subscribe((data: { currentAccountAndTemplate: any }) => {
|
||||
this.currentAccountAndTemplate = data.currentAccountAndTemplate;
|
||||
const account = data.currentAccountAndTemplate;
|
||||
this.currentAccountAndTemplate = account;
|
||||
if (account?.clientId && account?.accountNo) {
|
||||
this.clientsService
|
||||
.getClientNominees(String(account.clientId), account.accountNo, 'CB')
|
||||
.subscribe((nominees: any[]) => {
|
||||
if (Array.isArray(nominees) && nominees.length > 0) {
|
||||
this.currentAccountAndTemplate = { ...this.currentAccountAndTemplate, nominees };
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current account product template.
|
||||
* @param {any} $event API response
|
||||
*/
|
||||
setTemplate($event: any) {
|
||||
this.currentAccountProductTemplate = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves current account details form.
|
||||
*/
|
||||
next(): void {
|
||||
if (this.selectedTabIndex < this.totalTabs - 1) {
|
||||
this.selectedTabIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
prev(): void {
|
||||
if (this.selectedTabIndex > 0) {
|
||||
this.selectedTabIndex -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
get currentAccountDetailsForm() {
|
||||
return this.currentAccountDetailsStep.currentAccountDetailsForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves current account terms form.
|
||||
*/
|
||||
get currentAccountTermsForm() {
|
||||
return this.currentAccountTermsStep.currentAccountTermsForm;
|
||||
get currentAccountTermForm(): FormGroup {
|
||||
return new FormGroup({});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks validity and pristinity of overall current account form .
|
||||
*/
|
||||
get currentAccountFormValidAndNotPristine() {
|
||||
return (
|
||||
this.currentAccountDetailsForm.valid &&
|
||||
this.currentAccountTermsForm.valid &&
|
||||
(!this.currentAccountDetailsForm.pristine ||
|
||||
!this.currentAccountTermsForm.pristine ||
|
||||
!this.currentAccountChargesStep.pristine)
|
||||
);
|
||||
get currentAccountSettingsForm(): FormGroup {
|
||||
return new FormGroup({});
|
||||
}
|
||||
|
||||
get currentAccountTermsForm(): FormGroup {
|
||||
return new FormGroup({});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves current account object.
|
||||
*/
|
||||
get currentAccount() {
|
||||
return { ...this.currentAccountDetailsStep.currentAccountDetails };
|
||||
}
|
||||
|
||||
get currentAccountDigital() {
|
||||
return this.currentAccountDigitalStep?.currentAccountDigital ?? null;
|
||||
}
|
||||
|
||||
get currentAccountCurrencyFlags() {
|
||||
return {
|
||||
...this.currentAccountDetailsStep.currentAccountDetails,
|
||||
...this.currentAccountTermsStep.currentAccountTerms,
|
||||
...this.currentAccountChargesStep.currentAccountCharges
|
||||
balanceSwapOption: this.currentAccountCurrencyStep?.balanceSwapOption ?? false,
|
||||
msme: this.currentAccountCurrencyStep?.msme ?? false,
|
||||
autoDebitFacility: this.currentAccountCurrencyStep?.autoDebitFacility ?? false
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new share account.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
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;
|
||||
}
|
||||
if (
|
||||
!this.currentAccountDetailsStep.isNonIndividualClient &&
|
||||
this.currentAccountProductTemplate?.nominationFacility &&
|
||||
(this.currentAccountCurrencyStep?.nominees ?? []).length === 0
|
||||
) {
|
||||
this.alertService.alert({
|
||||
type: 'Error',
|
||||
message: 'Nomination Facility is enabled for this product. Please add at least one nominee before submitting.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.currentAccountProductTemplate?.introducerRequired && !this.currentAccountDetailsStep.introducerId) {
|
||||
this.alertService.alert({
|
||||
type: 'Error',
|
||||
message: 'Introducer is required for this product. Please select an introducer before submitting.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const monthDayFormat = 'dd MMMM';
|
||||
const currentAccount = {
|
||||
...this.currentAccount,
|
||||
charges: this.currentAccount.charges.map((charge: any) => ({
|
||||
chargeId: charge.id,
|
||||
amount: charge.amount,
|
||||
dueDate: this.dateUtils.formatDate(charge.dueDate, dateFormat),
|
||||
feeOnMonthDay: this.dateUtils.formatDate(charge.feeOnMonthDay, dateFormat),
|
||||
feeInterval: charge.feeInterval
|
||||
})),
|
||||
submittedOnDate: this.dateUtils.formatDate(this.currentAccount.submittedOnDate, dateFormat),
|
||||
const details = this.currentAccount;
|
||||
|
||||
const currentAccount: any = {
|
||||
...details,
|
||||
...this.currentAccountCurrencyStep.currencyStepData,
|
||||
...(this.currentAccountDigitalStep?.currentAccountDigital ?? {}),
|
||||
charges: [],
|
||||
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);
|
||||
}
|
||||
|
||||
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.currentAccountAndTemplate.clientId) {
|
||||
currentAccount.clientId = this.currentAccountAndTemplate.clientId;
|
||||
} else {
|
||||
currentAccount.groupId = this.currentAccountAndTemplate.groupId;
|
||||
}
|
||||
|
||||
const nominees = this.currentAccountCurrencyStep?.nominees ?? [];
|
||||
if (nominees.length > 0) {
|
||||
currentAccount.nominees = nominees.map((n: any) => ({
|
||||
nomineeClientId: n.nomineeClientId,
|
||||
nominationType: n.nominationType,
|
||||
relationshipId: n.relationshipId,
|
||||
percentageShare: n.percentageShare,
|
||||
nomineeIsMinor: n.nomineeIsMinor,
|
||||
...(n.guardianClientId ? { guardianClientId: n.guardianClientId } : {}),
|
||||
remarks: n.remarks
|
||||
}));
|
||||
}
|
||||
|
||||
this.currentAccountsService
|
||||
.updateCurrentAccount(this.currentAccountAndTemplate.id, currentAccount)
|
||||
.subscribe((response: any) => {
|
||||
|
||||
Reference in New Issue
Block a user