WEB-745: Fix unable to assign staff to active savings account (#3179)

This commit is contained in:
Krishna Mewara
2026-02-17 12:08:54 -06:00
committed by GitHub
parent d4be63c23b
commit aaace0f27b
17 changed files with 66 additions and 17 deletions
+8 -4
View File
@@ -720,12 +720,16 @@ export class OrganizationService {
return this.http.get(`/groups`, { params: httpParams }); 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. * @returns {Observable<any>} Staff data.
*/ */
getStaff(officeId: any): Observable<any> { getStaff(officeId: number | string, isLoanOfficer?: boolean): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId.toString()); 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 }); return this.http.get('/staff', { params: httpParams });
} }
@@ -11,10 +11,14 @@ import { Injectable, inject } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router'; import { ActivatedRouteSnapshot } from '@angular/router';
/** rxjs Imports */ /** rxjs Imports */
import { Observable, forkJoin } from 'rxjs'; import { Observable, forkJoin, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
/** Custom Services */ /** Custom Services */
import { SavingsService } from '../savings.service'; 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. * Savings Account Actions data resolver.
@@ -22,6 +26,9 @@ import { SavingsService } from '../savings.service';
@Injectable() @Injectable()
export class SavingsAccountActionsResolver { export class SavingsAccountActionsResolver {
private savingsService = inject(SavingsService); private savingsService = inject(SavingsService);
private clientsService = inject(ClientsService);
private groupsService = inject(GroupsService);
private organizationService = inject(OrganizationService);
/** /**
* Returns the Savings account actions data. * Returns the Savings account actions data.
@@ -34,7 +41,23 @@ export class SavingsAccountActionsResolver {
route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId'); route.paramMap.get('savingAccountId') || route.parent.parent.paramMap.get('savingAccountId');
switch (actionName) { switch (actionName) {
case 'Assign Staff': 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': case 'Add Charge':
return this.savingsService.getSavingsChargeTemplateResource(savingAccountId); return this.savingsService.getSavingsChargeTemplateResource(savingAccountId);
case 'Withdrawal': case 'Withdrawal':
@@ -20,6 +20,12 @@
</mat-option> </mat-option>
} }
</mat-select> </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>
<mat-form-field (click)="assignmentDatePicker.open()"> <mat-form-field (click)="assignmentDatePicker.open()">
@@ -7,9 +7,9 @@
*/ */
/** Angular Imports */ /** Angular Imports */
import { Component, OnInit, Input, inject } from '@angular/core'; import { Component, OnInit, inject } from '@angular/core';
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { UntypedFormGroup, UntypedFormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Dates } from 'app/core/utils/dates'; import { Dates } from 'app/core/utils/dates';
/** Custom Services */ /** Custom Services */
@@ -78,7 +78,10 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
*/ */
createSavingsAssignStaffForm() { createSavingsAssignStaffForm() {
this.savingsAssignStaffForm = this.formBuilder.group({ this.savingsAssignStaffForm = this.formBuilder.group({
toSavingsOfficerId: [''], toSavingsOfficerId: [
'',
Validators.required
],
assignmentDate: [ assignmentDate: [
'', '',
Validators.required Validators.required
@@ -91,16 +94,16 @@ export class SavingsAccountAssignStaffComponent implements OnInit {
* if successful redirects to the saving account. * if successful redirects to the saving account.
*/ */
submit() { submit() {
const savingsAssignStaffFormData = this.savingsAssignStaffForm.value;
const locale = this.settingsService.language.code; const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat; const dateFormat = this.settingsService.dateFormat;
const prevAssignmentDate: Date = this.savingsAssignStaffForm.value.assignmentDate; const formValue = this.savingsAssignStaffForm.value;
if (savingsAssignStaffFormData.assignmentDate instanceof Date) { const assignmentDate =
savingsAssignStaffFormData.assignmentDate = this.dateUtils.formatDate(prevAssignmentDate, dateFormat); formValue.assignmentDate instanceof Date
} ? this.dateUtils.formatDate(formValue.assignmentDate, dateFormat)
: formValue.assignmentDate;
const data = { const data = {
...savingsAssignStaffFormData, toSavingsOfficerId: formValue.toSavingsOfficerId,
fromSavingsOfficerId: '', assignmentDate,
dateFormat, dateFormat,
locale locale
}; };
+1
View File
@@ -2697,6 +2697,7 @@
"Working with Code": "Práce s kódem" "Working with Code": "Práce s kódem"
}, },
"menus": { "menus": {
"Unassign Staff": "Zrušit přidělení personálu",
"Accounting": "Účetnictví", "Accounting": "Účetnictví",
"Account Overview": "Přehled účtu", "Account Overview": "Přehled účtu",
"Activate": "aktivovat", "Activate": "aktivovat",
+1
View File
@@ -2698,6 +2698,7 @@
"Working with Code": "Arbeiten mit Code" "Working with Code": "Arbeiten mit Code"
}, },
"menus": { "menus": {
"Unassign Staff": "Personalzuweisung aufheben",
"Accounting": "Buchhaltung", "Accounting": "Buchhaltung",
"Account Overview": "Kontoübersicht", "Account Overview": "Kontoübersicht",
"Activate": "aktivieren Sie", "Activate": "aktivieren Sie",
+1
View File
@@ -2707,6 +2707,7 @@
"Working with Code": "Working with Code" "Working with Code": "Working with Code"
}, },
"menus": { "menus": {
"Unassign Staff": "Unassign Staff",
"Accounting": "Accounting", "Accounting": "Accounting",
"Account Overview": "Account Overview", "Account Overview": "Account Overview",
"Activate": "Activate", "Activate": "Activate",
+1
View File
@@ -2697,6 +2697,7 @@
"Working with Code": "Trabajar con código" "Working with Code": "Trabajar con código"
}, },
"menus": { "menus": {
"Unassign Staff": "Desasignar Asesor",
"Accounting": "Contabilidad", "Accounting": "Contabilidad",
"Account Overview": "Descripción de cuenta", "Account Overview": "Descripción de cuenta",
"Activate": "Activar", "Activate": "Activar",
+1
View File
@@ -2700,6 +2700,7 @@
"Working with Code": "Trabajar con código" "Working with Code": "Trabajar con código"
}, },
"menus": { "menus": {
"Unassign Staff": "Desasignar Asesor",
"Accounting": "Contabilidad", "Accounting": "Contabilidad",
"Account Overview": "Descripción de cuenta", "Account Overview": "Descripción de cuenta",
"Activate": "Activar", "Activate": "Activar",
+1
View File
@@ -2699,6 +2699,7 @@
"Working with Code": "Travailler avec du code" "Working with Code": "Travailler avec du code"
}, },
"menus": { "menus": {
"Unassign Staff": "Annuler l'affectation du personnel",
"Accounting": "Comptabilité", "Accounting": "Comptabilité",
"Account Overview": "Aperçu du compte", "Account Overview": "Aperçu du compte",
"Activate": "Activer", "Activate": "Activer",
+1
View File
@@ -2695,6 +2695,7 @@
"Working with Code": "Lavorare con il codice" "Working with Code": "Lavorare con il codice"
}, },
"menus": { "menus": {
"Unassign Staff": "Annulla assegnazione del personale",
"Accounting": "Contabilità", "Accounting": "Contabilità",
"Account Overview": "Panoramica dell'Account", "Account Overview": "Panoramica dell'Account",
"Activate": "Attivare", "Activate": "Attivare",
+1
View File
@@ -2697,6 +2697,7 @@
"Working with Code": "코드 작업" "Working with Code": "코드 작업"
}, },
"menus": { "menus": {
"Unassign Staff": "직원 할당 해제",
"Accounting": "회계", "Accounting": "회계",
"Account Overview": "계정 개요", "Account Overview": "계정 개요",
"Activate": "활성화", "Activate": "활성화",
+1
View File
@@ -2696,6 +2696,7 @@
"Working with Code": "Darbas su kodu" "Working with Code": "Darbas su kodu"
}, },
"menus": { "menus": {
"Unassign Staff": "Atšaukti personalo priskyrimą",
"Accounting": "Apskaita", "Accounting": "Apskaita",
"Account Overview": "Sąskaitos apžvalga", "Account Overview": "Sąskaitos apžvalga",
"Activate": "Suaktyvinti", "Activate": "Suaktyvinti",
+1
View File
@@ -2696,6 +2696,7 @@
"Working with Code": "Darbs ar kodu" "Working with Code": "Darbs ar kodu"
}, },
"menus": { "menus": {
"Unassign Staff": "Atcelt personāla piešķiršanu",
"Accounting": "Grāmatvedība", "Accounting": "Grāmatvedība",
"Account Overview": "Konta pārskats", "Account Overview": "Konta pārskats",
"Activate": "Aktivizēt", "Activate": "Aktivizēt",
+1
View File
@@ -2694,6 +2694,7 @@
"Working with Code": "Code मा काम गर्नुहुन्छ" "Working with Code": "Code मा काम गर्नुहुन्छ"
}, },
"menus": { "menus": {
"Unassign Staff": "कर्मचारी नियुक्ति रद्द गर्नुहोस्",
"Accounting": "लेखा", "Accounting": "लेखा",
"Account Overview": "खाता अवलोकन", "Account Overview": "खाता अवलोकन",
"Activate": "अलग गर्नु", "Activate": "अलग गर्नु",
+1
View File
@@ -2695,6 +2695,7 @@
"Working with Code": "Trabalhando com código" "Working with Code": "Trabalhando com código"
}, },
"menus": { "menus": {
"Unassign Staff": "Cancelar atribuição de equipe",
"Accounting": "Contabilidade", "Accounting": "Contabilidade",
"Account Overview": "visão geral da conta", "Account Overview": "visão geral da conta",
"Activate": "Ativar", "Activate": "Ativar",
+1
View File
@@ -2693,6 +2693,7 @@
"Working with Code": "Kufanya kazi na Kanuni" "Working with Code": "Kufanya kazi na Kanuni"
}, },
"menus": { "menus": {
"Unassign Staff": "Batilisha Wafanyikazi",
"Accounting": "Uhasibu", "Accounting": "Uhasibu",
"Account Overview": "Muhtasari wa akaunti", "Account Overview": "Muhtasari wa akaunti",
"Activate": "Amilisha", "Activate": "Amilisha",