Files
cbsnexora/src/app/deposits/recurring-deposits/recurring-deposits-account-stepper/recurring-deposits-account-settings-step/recurring-deposits-account-settings-step.component.ts
T
Felix van Hove 7fd1486c08 Upgrading to Angular 20:
Replaced checked in package-lock.json by regenerated one.
Ran ng update @angular/core@20 @angular/cli@20
Ran npm install @angular-builders/jest@^20.0.0 @fortawesome/angular-fontawesome@^3.0.0 @swimlane/ngx-graph@^11
Ran npm install ngx-mat-select-search@^8.0.2.
Ran ng update @angular/material@20.
Updated all eslint and typescript to the latest versions.
Removed @angular-devkit/schematics.
Updated fontawesome.
Updated rxjs and tslib.
Moved required node version from 16 to 20.
Updated jest-preset-angular.
Set preserveWhitespaces to false.
Corrected two type declarations in two typescript files to make ng serve run without errors.
Removed unused angular-devkit/schematics from view-user.component.ts .
Updated list of supported browsers.
Upgraded prettier.
Ran prettier . --write the first time.
Ran prettier . --write the second time.
Ran ng generate @angular/core:inject with defaults, excepted a handful of files.
Fixed remaining eslint problems.
Added dist directory to ignores in eslint.config.js.
Let prettier fix formatting, almost everything is just line breaks.
Made htmlhint ignore @if and @for Angular constructs.
Updated node version in Github workflow to 22.12.0 (build.yml).
Updated .env.ts.
Updated Angular datetime format strings from YYYY-MM-DD to yyyy-MM-dd.
Merged changes from dev into angular20 branch.
2025-12-08 11:01:01 +01:00

232 lines
9.5 KiB
TypeScript

/** Angular Imports */
import { Component, OnInit, Input, OnChanges, inject } from '@angular/core';
import {
UntypedFormGroup,
UntypedFormBuilder,
Validators,
UntypedFormControl,
ReactiveFormsModule
} from '@angular/forms';
import { SettingsService } from 'app/settings/settings.service';
import { Currency } from 'app/shared/models/general.model';
import { MatCheckbox } from '@angular/material/checkbox';
import { InputAmountComponent } from '../../../../shared/input-amount/input-amount.component';
import { MatDivider } from '@angular/material/divider';
import { MatStepperPrevious, MatStepperNext } from '@angular/material/stepper';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/** Custom Services */
/**
* Recurring Deposits Account Settings Step
*/
@Component({
selector: 'mifosx-recurring-deposits-account-settings-step',
templateUrl: './recurring-deposits-account-settings-step.component.html',
styleUrls: ['./recurring-deposits-account-settings-step.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
MatCheckbox,
InputAmountComponent,
MatDivider,
MatStepperPrevious,
FaIconComponent,
MatStepperNext
]
})
export class RecurringDepositsAccountSettingsStepComponent implements OnInit, OnChanges {
private formBuilder = inject(UntypedFormBuilder);
private settingsService = inject(SettingsService);
@Input() isNew = true;
@Input() recurringDepositsAccountTemplate: any;
@Input() recurringDepositsAccountProductTemplate: any;
/** Recurring Deposits Account Settings Form */
recurringDepositAccountSettingsForm: UntypedFormGroup;
/** Minimum date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Lockin Period Frequency Type Data */
lockinPeriodFrequencyTypeData: any;
/** Period Frequency Type Data */
periodFrequencyTypeData: any;
/** Preclosure Penal Interest Type on Data */
preClosurePenalInterestOnTypeData: any;
/** Tax Group */
taxGroup: any;
currency: Currency | null = null;
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {SettingsService} settingsService Settings Service
*/
constructor() {
this.createRecurringDepositAccountSettingsForm();
this.buildDependencies();
}
ngOnChanges() {
const recurringDepositsAccount: any = this.isNew
? this.recurringDepositsAccountProductTemplate
: this.recurringDepositsAccountTemplate;
if (recurringDepositsAccount) {
this.currency = recurringDepositsAccount.currency;
this.recurringDepositAccountSettingsForm.patchValue({
isMandatoryDeposit: recurringDepositsAccount.isMandatoryDeposit,
adjustAdvanceTowardsFuturePayments: recurringDepositsAccount.adjustAdvanceTowardsFuturePayments,
allowWithdrawal: recurringDepositsAccount.allowWithdrawal,
lockinPeriodFrequency: recurringDepositsAccount.lockinPeriodFrequency,
lockinPeriodFrequencyType: recurringDepositsAccount.lockinPeriodFrequencyType
? recurringDepositsAccount.lockinPeriodFrequencyType.id
: '',
minDepositTerm: recurringDepositsAccount.minDepositTerm,
minDepositTermTypeId: recurringDepositsAccount.minDepositTermType
? recurringDepositsAccount.minDepositTermType.id
: '',
inMultiplesOfDepositTerm: recurringDepositsAccount.inMultiplesOfDepositTerm,
inMultiplesOfDepositTermTypeId: recurringDepositsAccount.inMultiplesOfDepositTermType
? recurringDepositsAccount.inMultiplesOfDepositTermType.id
: '',
maxDepositTerm: recurringDepositsAccount.maxDepositTerm,
maxDepositTermTypeId: recurringDepositsAccount.maxDepositTermType
? recurringDepositsAccount.maxDepositTermType.id
: '',
preClosurePenalApplicable: recurringDepositsAccount.preClosurePenalApplicable,
preClosurePenalInterest: recurringDepositsAccount.preClosurePenalInterest,
preClosurePenalInterestOnTypeId: recurringDepositsAccount.preClosurePenalInterestOnType
? recurringDepositsAccount.preClosurePenalInterestOnType.id
: '',
minBalanceForInterestCalculation: recurringDepositsAccount.minBalanceForInterestCalculation,
depositPeriod: recurringDepositsAccount.minDepositTerm,
depositPeriodFrequencyId: recurringDepositsAccount.minDepositTermType.id,
expectedFirstDepositOnDate:
recurringDepositsAccount.expectedFirstDepositOnDate &&
new Date(recurringDepositsAccount.expectedFirstDepositOnDate),
recurringFrequency: recurringDepositsAccount.recurringFrequency,
recurringFrequencyType: recurringDepositsAccount.recurringFrequencyType
? recurringDepositsAccount.recurringFrequencyType.id
: ''
});
if (recurringDepositsAccount.withHoldTax) {
this.recurringDepositAccountSettingsForm.addControl('withHoldTax', new UntypedFormControl(false));
this.recurringDepositAccountSettingsForm.get('withHoldTax').valueChanges.subscribe((value: boolean) => {
if (value) {
this.recurringDepositAccountSettingsForm.addControl(
'taxGroupId',
new UntypedFormControl({ value: '', disabled: true })
);
this.recurringDepositAccountSettingsForm
.get('taxGroupId')
.patchValue(recurringDepositsAccount.taxGroup && recurringDepositsAccount.taxGroup.name);
} else {
this.recurringDepositAccountSettingsForm.removeControl('taxGroupId');
}
});
this.recurringDepositAccountSettingsForm
.get('withHoldTax')
.patchValue(this.recurringDepositsAccountTemplate.withHoldTax);
} else {
this.recurringDepositAccountSettingsForm.removeControl('withHoldTax');
}
this.taxGroup = recurringDepositsAccount.taxGroup;
this.setOptions(recurringDepositsAccount);
}
}
ngOnInit() {
this.maxDate = this.settingsService.businessDate;
if (this.recurringDepositsAccountTemplate) {
this.recurringDepositAccountSettingsForm.patchValue({
lockinPeriodFrequency: this.recurringDepositsAccountTemplate.lockinPeriodFrequency,
lockinPeriodFrequencyType:
this.recurringDepositsAccountTemplate.lockinPeriodFrequencyType &&
this.recurringDepositsAccountTemplate.lockinPeriodFrequencyType.id,
mandatoryRecommendedDepositAmount: this.recurringDepositsAccountTemplate.mandatoryRecommendedDepositAmount
});
}
}
/**
* Creates recurring deposits account terms form.
*/
createRecurringDepositAccountSettingsForm() {
this.recurringDepositAccountSettingsForm = this.formBuilder.group({
isMandatoryDeposit: [''],
adjustAdvanceTowardsFuturePayments: [''],
allowWithdrawal: [''],
lockinPeriodFrequency: [''],
lockinPeriodFrequencyType: [''],
mandatoryRecommendedDepositAmount: [
'',
Validators.required
],
depositPeriod: [
'',
Validators.required
],
depositPeriodFrequencyId: [
'',
Validators.required
],
isCalendarInherited: [''],
expectedFirstDepositOnDate: [''],
recurringFrequency: [
'',
Validators.required
],
recurringFrequencyType: [
'',
Validators.required
],
minDepositTerm: [{ value: '', disabled: true }],
minDepositTermTypeId: [{ value: '', disabled: true }],
inMultiplesOfDepositTerm: [{ value: '', disabled: true }],
inMultiplesOfDepositTermTypeId: [{ value: '', disabled: true }],
maxDepositTerm: [{ value: '', disabled: true }],
maxDepositTermTypeId: [{ value: '', disabled: true }],
preClosurePenalApplicable: [{ value: '', disabled: true }],
preClosurePenalInterest: [{ value: '', disabled: true }],
preClosurePenalInterestOnTypeId: [{ value: '', disabled: true }],
minBalanceForInterestCalculation: [{ value: '', disabled: true }]
});
}
/**
* Sets all select dropdown options.
*/
setOptions(recurringDepositsAccount: any) {
this.lockinPeriodFrequencyTypeData = recurringDepositsAccount.lockinPeriodFrequencyTypeOptions;
this.periodFrequencyTypeData = recurringDepositsAccount.periodFrequencyTypeOptions;
this.preClosurePenalInterestOnTypeData = recurringDepositsAccount.preClosurePenalInterestOnTypeOptions;
}
/**
* Subscribes to value changes and sets new form controls accordingly.
*/
buildDependencies() {
this.recurringDepositAccountSettingsForm
.get('isCalendarInherited')
.valueChanges.subscribe((isCalendarInherited: any) => {
if (isCalendarInherited) {
this.recurringDepositAccountSettingsForm.removeControl('expectedFirstDepositOnDate');
this.recurringDepositAccountSettingsForm.removeControl('recurringFrequency');
this.recurringDepositAccountSettingsForm.removeControl('recurringFrequencyType');
} else {
this.recurringDepositAccountSettingsForm.addControl('expectedFirstDepositOnDate', new UntypedFormControl());
this.recurringDepositAccountSettingsForm.addControl('recurringFrequency', new UntypedFormControl(''));
this.recurringDepositAccountSettingsForm.addControl('recurringFrequencyType', new UntypedFormControl(''));
}
});
}
/**
* Returns recurring deposits account settings form value.
*/
get recurringDepositAccountSettings() {
return this.recurringDepositAccountSettingsForm.value;
}
}