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.
153 lines
5.2 KiB
TypeScript
153 lines
5.2 KiB
TypeScript
/** Angular Imports */
|
|
import { Component, ViewChild, inject } from '@angular/core';
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
|
|
/** Custom Components */
|
|
import { SavingsAccountDetailsStepComponent } from '../savings-account-stepper/savings-account-details-step/savings-account-details-step.component';
|
|
import { SavingsAccountTermsStepComponent } from '../savings-account-stepper/savings-account-terms-step/savings-account-terms-step.component';
|
|
import { SavingsAccountChargesStepComponent } from '../savings-account-stepper/savings-account-charges-step/savings-account-charges-step.component';
|
|
|
|
/** Custom Services */
|
|
import { SavingsService } from '../savings.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 { FaIconComponent } from '@fortawesome/angular-fontawesome';
|
|
import { SavingsAccountPreviewStepComponent } from '../savings-account-stepper/savings-account-preview-step/savings-account-preview-step.component';
|
|
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
|
|
|
/**
|
|
* Create Savings Account Component
|
|
*/
|
|
@Component({
|
|
selector: 'mifosx-create-savings-account',
|
|
templateUrl: './create-savings-account.component.html',
|
|
styleUrls: ['./create-savings-account.component.scss'],
|
|
imports: [
|
|
...STANDALONE_SHARED_IMPORTS,
|
|
MatStepper,
|
|
MatStepperIcon,
|
|
FaIconComponent,
|
|
MatStep,
|
|
MatStepLabel,
|
|
SavingsAccountDetailsStepComponent,
|
|
SavingsAccountTermsStepComponent,
|
|
SavingsAccountChargesStepComponent,
|
|
SavingsAccountPreviewStepComponent
|
|
]
|
|
})
|
|
export class CreateSavingsAccountComponent {
|
|
private route = inject(ActivatedRoute);
|
|
private router = inject(Router);
|
|
private dateUtils = inject(Dates);
|
|
private savingsService = inject(SavingsService);
|
|
private settingsService = inject(SettingsService);
|
|
|
|
/** Savings Account Template */
|
|
savingsAccountTemplate: any;
|
|
/** Savings Account Product Template */
|
|
savingsAccountProductTemplate: any;
|
|
|
|
/** Savings Account Details Step */
|
|
@ViewChild(SavingsAccountDetailsStepComponent, { static: true })
|
|
savingsAccountDetailsStep: SavingsAccountDetailsStepComponent;
|
|
/** Savings Account Terms Step */
|
|
@ViewChild(SavingsAccountTermsStepComponent, { static: true })
|
|
savingsAccountTermsStep: SavingsAccountTermsStepComponent;
|
|
/** Savings Account Charges Step */
|
|
@ViewChild(SavingsAccountChargesStepComponent, { static: true })
|
|
savingsAccountChargesStep: SavingsAccountChargesStepComponent;
|
|
|
|
/**
|
|
* Fetches savings account template from `resolve`
|
|
* @param {ActivatedRoute} route Activated Route
|
|
* @param {Router} router Router
|
|
* @param {Dates} dateUtils Date Utils
|
|
* @param {SavingsService} savingsService Savings Service
|
|
* @param {SettingsService} settingsService Settings Service
|
|
*/
|
|
constructor() {
|
|
this.route.data.subscribe((data: { savingsAccountTemplate: any }) => {
|
|
this.savingsAccountTemplate = data.savingsAccountTemplate;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Sets savings account product template.
|
|
* @param {any} $event API response
|
|
*/
|
|
setTemplate($event: any) {
|
|
this.savingsAccountProductTemplate = $event;
|
|
}
|
|
|
|
/**
|
|
* Retrieves savings account details form.
|
|
*/
|
|
get savingsAccountDetailsForm() {
|
|
return this.savingsAccountDetailsStep.savingsAccountDetailsForm;
|
|
}
|
|
|
|
/**
|
|
* Retrieves savings account terms form.
|
|
*/
|
|
get savingsAccountTermsForm() {
|
|
return this.savingsAccountTermsStep.savingsAccountTermsForm;
|
|
}
|
|
|
|
/**
|
|
* Checks validity of overall savings account form.
|
|
*/
|
|
get savingsAccountFormValid() {
|
|
return this.savingsAccountDetailsForm.valid && this.savingsAccountTermsForm.valid;
|
|
}
|
|
|
|
/**
|
|
* Retrieves savings account object.
|
|
*/
|
|
get savingsAccount() {
|
|
return {
|
|
...this.savingsAccountDetailsStep.savingsAccountDetails,
|
|
...this.savingsAccountTermsStep.savingsAccountTerms,
|
|
...this.savingsAccountChargesStep.savingsAccountCharges
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a new share account.
|
|
*/
|
|
submit() {
|
|
// TODO: Update once language and date settings are setup
|
|
const locale = this.settingsService.language.code;
|
|
const dateFormat = this.settingsService.dateFormat;
|
|
const monthDayFormat = 'dd MMMM';
|
|
const savingsAccount = {
|
|
...this.savingsAccount,
|
|
charges: this.savingsAccount.charges.map((charge: any) => ({
|
|
chargeId: charge.id,
|
|
amount: charge.amount,
|
|
dueDate: charge.dueDate,
|
|
feeOnMonthDay: charge.feeOnMonthDay,
|
|
feeInterval: charge.feeInterval
|
|
})),
|
|
submittedOnDate: this.dateUtils.formatDate(this.savingsAccount.submittedOnDate, dateFormat),
|
|
dateFormat,
|
|
monthDayFormat,
|
|
locale
|
|
};
|
|
if (this.savingsAccountTemplate.clientId) {
|
|
savingsAccount.clientId = this.savingsAccountTemplate.clientId;
|
|
} else {
|
|
savingsAccount.groupId = this.savingsAccountTemplate.groupId;
|
|
}
|
|
this.savingsService.createSavingsAccount(savingsAccount).subscribe((response: any) => {
|
|
this.router.navigate(
|
|
[
|
|
'../',
|
|
response.resourceId
|
|
],
|
|
{ relativeTo: this.route }
|
|
);
|
|
});
|
|
}
|
|
}
|