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.
115 lines
4.1 KiB
TypeScript
115 lines
4.1 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';
|
|
|
|
/** Custom Services */
|
|
import { FixedDepositsService } from 'app/deposits/fixed-deposits/fixed-deposits.service';
|
|
import { SettingsService } from 'app/settings/settings.service';
|
|
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
|
|
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
|
|
|
/**
|
|
* Approve Fixed Deposits Account Component
|
|
*/
|
|
@Component({
|
|
selector: 'mifosx-approve-fixed-deposits-account',
|
|
templateUrl: './approve-fixed-deposits-account.component.html',
|
|
styleUrls: ['./approve-fixed-deposits-account.component.scss'],
|
|
imports: [
|
|
...STANDALONE_SHARED_IMPORTS,
|
|
CdkTextareaAutosize
|
|
]
|
|
})
|
|
export class ApproveFixedDepositsAccountComponent implements OnInit {
|
|
private formBuilder = inject(UntypedFormBuilder);
|
|
private fixedDepositsService = inject(FixedDepositsService);
|
|
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();
|
|
/** Approve Fixed Deposits Account form. */
|
|
approveFixedDepositsAccountForm: UntypedFormGroup;
|
|
/** Fixed Deposits Account Id */
|
|
accountId: any;
|
|
|
|
/**
|
|
* @param {FormBuilder} formBuilder Form Builder
|
|
* @param {FixedDepositsService} fixedDepositsService Fixed Deposits Service
|
|
* @param {Dates} dateUtils Date Utils
|
|
* @param {ActivatedRoute} route Activated Route
|
|
* @param {Router} router Router
|
|
* @param {SettingsService} settingsService Settings Service
|
|
*/
|
|
constructor() {
|
|
this.accountId = this.route.parent.snapshot.params['fixedDepositAccountId'];
|
|
}
|
|
|
|
/**
|
|
* Creates the approve fixed deposits form.
|
|
*/
|
|
ngOnInit() {
|
|
this.maxDate = this.settingsService.businessDate;
|
|
this.createApproveFixedDepositsAccountForm();
|
|
}
|
|
|
|
/**
|
|
* Creates the approve fixed deposits account form.
|
|
*/
|
|
createApproveFixedDepositsAccountForm() {
|
|
this.approveFixedDepositsAccountForm = this.formBuilder.group({
|
|
approvedOnDate: [
|
|
'',
|
|
Validators.required
|
|
],
|
|
note: ['']
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Submits the form, approves the fixed deposit account, then immediately activates it on the
|
|
* same date -- Approve and Activate are still two separate Fineract commands underneath (each
|
|
* shows up in the audit trail), but the officer only sees and clicks through one step.
|
|
*/
|
|
submit() {
|
|
const approveFixedDepositsAccountFormData = this.approveFixedDepositsAccountForm.value;
|
|
const locale = this.settingsService.language.code;
|
|
const dateFormat = this.settingsService.dateFormat;
|
|
const prevApprovedOnDate: Date = this.approveFixedDepositsAccountForm.value.approvedOnDate;
|
|
if (approveFixedDepositsAccountFormData.approvedOnDate instanceof Date) {
|
|
approveFixedDepositsAccountFormData.approvedOnDate = this.dateUtils.formatDate(prevApprovedOnDate, dateFormat);
|
|
}
|
|
const data = {
|
|
...approveFixedDepositsAccountFormData,
|
|
dateFormat,
|
|
locale
|
|
};
|
|
this.fixedDepositsService.executeFixedDepositsAccountCommand(this.accountId, 'approve', data).subscribe(() => {
|
|
const activationData = {
|
|
activatedOnDate: approveFixedDepositsAccountFormData.approvedOnDate,
|
|
dateFormat,
|
|
locale
|
|
};
|
|
this.fixedDepositsService
|
|
.executeFixedDepositsAccountCommand(this.accountId, 'activate', activationData)
|
|
.subscribe(() => {
|
|
this.router.navigate(['../../'], { relativeTo: this.route });
|
|
});
|
|
});
|
|
}
|
|
}
|