WEB-745: Fix unable to assign staff to active savings account (#3179)
This commit is contained in:
@@ -720,12 +720,16 @@ export class OrganizationService {
|
||||
return this.http.get(`/groups`, { params: httpParams });
|
||||
}
|
||||
|
||||
/*
|
||||
* @param {any} officeId ID of office to retrieve staff from.
|
||||
/**
|
||||
* @param {number | string} officeId ID of office to retrieve staff from.
|
||||
* @param {boolean} [isLoanOfficer] Optional flag to filter by loan officer status.
|
||||
* @returns {Observable<any>} Staff data.
|
||||
*/
|
||||
getStaff(officeId: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('officeId', officeId.toString());
|
||||
getStaff(officeId: number | string, isLoanOfficer?: boolean): Observable<any> {
|
||||
let httpParams = new HttpParams().set('officeId', officeId.toString()).set('status', 'active');
|
||||
if (isLoanOfficer !== undefined) {
|
||||
httpParams = httpParams.set('isLoanOfficer', isLoanOfficer.toString());
|
||||
}
|
||||
return this.http.get('/staff', { params: httpParams });
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,14 @@ import { Injectable, inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
|
||||
/** rxjs Imports */
|
||||
import { Observable, forkJoin } from 'rxjs';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from '../savings.service';
|
||||
import { ClientsService } from 'app/clients/clients.service';
|
||||
import { GroupsService } from 'app/groups/groups.service';
|
||||
import { OrganizationService } from 'app/organization/organization.service';
|
||||
|
||||
/**
|
||||
* Savings Account Actions data resolver.
|
||||
@@ -22,6 +26,9 @@ import { SavingsService } from '../savings.service';
|
||||
@Injectable()
|
||||
export class SavingsAccountActionsResolver {
|
||||
private savingsService = inject(SavingsService);
|
||||
private clientsService = inject(ClientsService);
|
||||
private groupsService = inject(GroupsService);
|
||||
private organizationService = inject(OrganizationService);
|
||||
|
||||
/**
|
||||
* Returns the Savings account actions data.
|
||||
@@ -34,7 +41,23 @@ export class SavingsAccountActionsResolver {
|
||||
route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId');
|
||||
switch (actionName) {
|
||||
case 'Assign Staff':
|
||||
return this.savingsService.getSavingsAccountAndTemplate(savingAccountId, true);
|
||||
return this.savingsService.getSavingsAccountData(savingAccountId).pipe(
|
||||
switchMap((account: any) => {
|
||||
if (!account.clientId && !account.groupId) {
|
||||
return of({ ...account, fieldOfficerOptions: [] });
|
||||
}
|
||||
const entityObs = account.clientId
|
||||
? this.clientsService.getClientData(account.clientId)
|
||||
: this.groupsService.getGroupData(account.groupId);
|
||||
return entityObs.pipe(
|
||||
switchMap((entity: any) => this.organizationService.getStaff(entity.officeId, true)),
|
||||
map((staff: any) => ({
|
||||
...account,
|
||||
fieldOfficerOptions: staff
|
||||
}))
|
||||
);
|
||||
})
|
||||
);
|
||||
case 'Add Charge':
|
||||
return this.savingsService.getSavingsChargeTemplateResource(savingAccountId);
|
||||
case 'Withdrawal':
|
||||
|
||||
+6
@@ -20,6 +20,12 @@
|
||||
</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
@if (savingsAssignStaffForm.controls.toSavingsOfficerId.hasError('required')) {
|
||||
<mat-error>
|
||||
{{ 'labels.inputs.To Savings Officer' | translate }} {{ 'labels.commons.is' | translate }}
|
||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
||||
</mat-error>
|
||||
}
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field (click)="assignmentDatePicker.open()">
|
||||
|
||||
+14
-11
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input, inject } from '@angular/core';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { UntypedFormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/** Custom Services */
|
||||
@@ -78,7 +78,10 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
|
||||
*/
|
||||
createSavingsAssignStaffForm() {
|
||||
this.savingsAssignStaffForm = this.formBuilder.group({
|
||||
toSavingsOfficerId: [''],
|
||||
toSavingsOfficerId: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
assignmentDate: [
|
||||
'',
|
||||
Validators.required
|
||||
@@ -91,16 +94,16 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
|
||||
* if successful redirects to the saving account.
|
||||
*/
|
||||
submit() {
|
||||
const savingsAssignStaffFormData = this.savingsAssignStaffForm.value;
|
||||
const locale = this.settingsService.language.code;
|
||||
const dateFormat = this.settingsService.dateFormat;
|
||||
const prevAssignmentDate: Date = this.savingsAssignStaffForm.value.assignmentDate;
|
||||
if (savingsAssignStaffFormData.assignmentDate instanceof Date) {
|
||||
savingsAssignStaffFormData.assignmentDate = this.dateUtils.formatDate(prevAssignmentDate, dateFormat);
|
||||
}
|
||||
const formValue = this.savingsAssignStaffForm.value;
|
||||
const assignmentDate =
|
||||
formValue.assignmentDate instanceof Date
|
||||
? this.dateUtils.formatDate(formValue.assignmentDate, dateFormat)
|
||||
: formValue.assignmentDate;
|
||||
const data = {
|
||||
...savingsAssignStaffFormData,
|
||||
fromSavingsOfficerId: '',
|
||||
toSavingsOfficerId: formValue.toSavingsOfficerId,
|
||||
assignmentDate,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user