Files
cbsnexora/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts
T
nitesh ff781e50e3 feat(savings,deposits,current-accounts): streamline account activation flow
Matches the backend change that stopped auto-depositing money at
activation: removes the opening-balance field from every Activate
screen (Savings, Current, FD, RD) since funding now happens as a
separate deposit afterward, and removes the Digital-Facility step from
every Create wizard since every facility starts disabled by default
and gets turned on later through Edit Nominee & Features.

Also merges Approve+Activate into a single action for Savings,
Current, FD and RD accounts -- one click takes the account straight to
Active instead of two separate screens.
2026-08-19 10:39:52 +05:30

107 lines
3.5 KiB
TypeScript

/**
* Copyright since 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/.
*/
/** Angular Imports */
import { Component, OnInit, inject } from '@angular/core';
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { Dates } from 'app/core/utils/dates';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
/** Custom Services */
import { SavingsService } from 'app/savings/savings.service';
import { SettingsService } from 'app/settings/settings.service';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/**
* Activate Savings Account Component
*
* Nexora redesign: gradient green hero + section card with form fields and
* a primary/secondary action row.
*/
@Component({
selector: 'mifosx-activate-savings-account',
templateUrl: './activate-savings-account.component.html',
styleUrls: ['./activate-savings-account.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
FaIconComponent
]
})
export class ActivateSavingsAccountComponent implements OnInit {
private formBuilder = inject(UntypedFormBuilder);
private savingsService = inject(SavingsService);
private dateUtils = inject(Dates);
private route = inject(ActivatedRoute);
private router = inject(Router);
private settingsService = inject(SettingsService);
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Activate Savings Account form. */
activateSavingsAccountForm: UntypedFormGroup;
/** Savings Account Id */
accountId: any;
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SavingsService} savingsService Savings Service
* @param {Dates} dateUtils Date Utils
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor() {
this.accountId = this.route.snapshot.params['savingAccountId'];
}
/**
* Creates the activate savings form.
*/
ngOnInit() {
this.maxDate = this.settingsService.businessDate;
this.createActivateSavingsAccountForm();
}
/**
* Creates the activate savings account form.
*/
createActivateSavingsAccountForm() {
this.activateSavingsAccountForm = this.formBuilder.group({
activatedOnDate: [
'',
Validators.required
]
});
}
/**
* Submits the form and activates the saving account,
* if successful redirects to the saving account.
*/
submit() {
const activateSavingsAccountFormData = this.activateSavingsAccountForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevActivatedOnDate: Date = this.activateSavingsAccountForm.value.activatedOnDate;
if (activateSavingsAccountFormData.activatedOnDate instanceof Date) {
activateSavingsAccountFormData.activatedOnDate = this.dateUtils.formatDate(prevActivatedOnDate, dateFormat);
}
const data: any = {
...activateSavingsAccountFormData,
dateFormat,
locale
};
this.savingsService.executeSavingsAccountCommand(this.accountId, 'activate', data).subscribe(() => {
this.router.navigate(['../../transactions'], { relativeTo: this.route });
});
}
}