Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVOPS-43: Responder Portal Support Limits #2504

Merged
merged 9 commits into from
Nov 1, 2024
4 changes: 4 additions & 0 deletions ess/src/API/EMBC.ESS/Resources/Tasks/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ public record EssTask : Task
public bool RemoteExtensionsEnabled { get; set; }
public bool SelfServeEnabled { get; set; }
public IEnumerable<SupportConfiguration> EnabledSupports { get; set; } = [];
public IEnumerable<SupportConfiguration> SupportLimits { get; set; } = [];
}

public record SupportConfiguration
{
public SupportType SupportType { get; set; }
public DateTime SupportLimitStartDate { get; set; }
public DateTime SupportLimitEndDate { get; set; }
public bool ExtensionAvailable { get; set; }
}

public enum SupportType
Expand Down
18 changes: 18 additions & 0 deletions ess/src/API/EMBC.ESS/Resources/Tasks/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,28 @@ public Mappings()
.ForMember(d => d.SelfServeEnabled, opts => opts.MapFrom(s => s.era_selfservetoggle))
.ForMember(d => d.AutoApprovedEnabled, opts => opts.Ignore())
.ForMember(d => d.EnabledSupports, opts => opts.MapFrom(s => s.era_era_task_era_selfservesupportlimits_Task.Where(sl => sl.statuscode == 1)))
.ForMember(d => d.SupportLimits, opts => opts.MapFrom(s => s.era_era_task_era_supportlimit_Task.Where(sl => sl.statuscode == 1)))
;

CreateMap<era_selfservesupportlimits, SupportConfiguration>()
.ForMember(d => d.SupportType, opts => opts.MapFrom(s => s.era_supporttypeoption))
.ForMember(d => d.ExtensionAvailable, opts => opts.MapFrom(s => s.era_extensionavailable))
.ForMember(d => d.SupportLimitStartDate, opts => opts.MapFrom(s => s.era_supportlimitstartdate.HasValue ? s.era_supportlimitstartdate.Value.UtcDateTime : (DateTime?)null))
.ForMember(d => d.SupportLimitEndDate, opts => opts.MapFrom(s => s.era_supportlimitenddate.HasValue ? s.era_supportlimitenddate.Value.UtcDateTime : (DateTime?)null))
;

CreateMap<era_supportlimit, SupportConfiguration>()
.ForMember(d => d.SupportType, opts => opts.MapFrom(s => s.era_supporttypeoption))
.ForMember(d => d.ExtensionAvailable, opts => opts.MapFrom(s => s.era_extensionavailable))
.ForMember(d => d.SupportLimitStartDate, opts => opts.MapFrom(s => s.era_supportlimitstartdate.HasValue ? s.era_supportlimitstartdate.Value.UtcDateTime : (DateTime?)null))
.ForMember(d => d.SupportLimitEndDate, opts => opts.MapFrom(s => s.era_supportlimitenddate.HasValue ? s.era_supportlimitenddate.Value.UtcDateTime : (DateTime?)null))
;

CreateMap<EMBC.ESS.Resources.Tasks.SupportConfiguration, EMBC.ESS.Shared.Contracts.Events.SupportLimits>()
.ForMember(dest => dest.SupportType, opts => opts.MapFrom(src => src.SupportType))
.ForMember(dest => dest.SupportLimitStartDate, opts => opts.MapFrom(src => src.SupportLimitStartDate))
.ForMember(dest => dest.SupportLimitEndDate, opts => opts.MapFrom(src => src.SupportLimitEndDate))
.ForMember(dest => dest.ExtensionAvailable, opts => opts.MapFrom(src => src.ExtensionAvailable))
;
}
}
4 changes: 4 additions & 0 deletions ess/src/API/EMBC.ESS/Resources/Tasks/TaskRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ private async Task<IEnumerable<era_task>> QueryTasks(TaskQuery query, Cancellati
essContext.era_tasks
.Expand(t => t.era_JurisdictionID)
.Expand(t => t.era_era_task_era_selfservesupportlimits_Task)
.Expand(t => t.era_era_task_era_supportlimit_Task)
.Where(t => t.era_name == query.ById)
.GetAllPagesAsync(ct)).ToList();

await Parallel.ForEachAsync(tasks, ct, async (t, ct1) =>
{
var selfServeSupports = (await essContext.era_selfservesupportlimitses.Expand(sl => sl.era_SupportType).Where(sl => sl._era_task_value == t.era_taskid).GetAllPagesAsync(ct1)).ToList();
t.era_era_task_era_selfservesupportlimits_Task = new System.Collections.ObjectModel.Collection<era_selfservesupportlimits>(selfServeSupports);

var supportLimits = (await essContext.era_supportlimits.Expand(sl => sl.era_SupportType).Where(sl => sl._era_task_value == t.era_taskid).GetAllPagesAsync(ct1)).ToList();
t.era_era_task_era_supportlimit_Task = new System.Collections.ObjectModel.Collection<era_supportlimit>(supportLimits);
});

return tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public async Task<ActionResult<ESSTask>> GetTask(string taskId)
if (task == null) return NotFound(taskId);
var mappedTask = mapper.Map<ESSTask>(task);
mappedTask.Workflows = GetTaskWorkflows(task);
mappedTask.SupportLimits = GetTaskSupportLimits(task);
return Ok(mappedTask);
}

Expand All @@ -60,6 +61,24 @@ private static IEnumerable<TaskWorkflow> GetTaskWorkflows(IncidentTask incidentT
return workflows;
}

private static IEnumerable<SupportLimits> GetTaskSupportLimits(IncidentTask incidentTask)
{
if (incidentTask.SupportLimits == null || !incidentTask.SupportLimits.Any())
{
return Enumerable.Empty<SupportLimits>();
}

var supportLimits = incidentTask.SupportLimits.Select(sl => new SupportLimits
{
SupportType = sl.SupportType,
SupportLimitStartDate = sl.SupportLimitStartDate,
SupportLimitEndDate = sl.SupportLimitEndDate,
ExtensionAvailable = sl.ExtensionAvailable
});

return supportLimits;
}

[HttpGet("{taskId}/suppliers")]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand Down Expand Up @@ -96,6 +115,7 @@ public class ESSTask
public string Description { get; set; }
public string Status { get; set; }
public IEnumerable<TaskWorkflow> Workflows { get; set; } = Array.Empty<TaskWorkflow>();
public IEnumerable<SupportLimits> SupportLimits { get; set; } = Array.Empty<SupportLimits>();
}

public class TaskWorkflow
Expand Down Expand Up @@ -125,7 +145,8 @@ public class TaskMapping : Profile
public TaskMapping()
{
CreateMap<IncidentTask, ESSTask>()
.ForMember(d => d.Workflows, opts => opts.Ignore());
.ForMember(d => d.Workflows, opts => opts.Ignore())
.ForMember(d => d.SupportLimits, opts => opts.MapFrom(s => s.SupportLimits));
CreateMap<SupplierDetails, SuppliersListItem>();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* tslint:disable */
/* eslint-disable */
import { TaskWorkflow } from '../models/task-workflow';
import { SupportLimit } from './support-limit';
export interface EssTask {
communityCode?: string | null;
description?: string | null;
Expand All @@ -9,4 +10,5 @@ export interface EssTask {
startDate?: string;
status?: string | null;
workflows?: Array<TaskWorkflow> | null;
supportLimits?: Array<SupportLimit> | null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* tslint:disable */
/* eslint-disable */
import { SupportSubCategory } from './support-sub-category';
export interface SupportLimit {
supportLimitStartDate: Date;
supportLimitEndDate: Date;
extensionAvailable: boolean;
supportType: SupportSubCategory
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { DateConversionService } from 'src/app/core/services/utility/dateConvers
import { ComputeRulesService } from 'src/app/core/services/computeRules.service';
import { AppBaseService } from 'src/app/core/services/helper/appBase.service';
import { EvacueeSessionService } from 'src/app/core/services/evacuee-session.service';
import { SupportLimit } from 'src/app/core/api/models/support-limit';

@Injectable({ providedIn: 'root' })
export class StepSupportsService {
Expand All @@ -41,6 +42,8 @@ export class StepSupportsService {
private supportDetailsVal: SupportDetailsModel;
private supportDeliveryVal: SupportDeliveryModel;
private selectedSupportDetailVal: Support;
private supportLimitsVal: BehaviorSubject<SupportLimit[]> = new BehaviorSubject<SupportLimit[]>([]);
private supportLimitsVal$: Observable<SupportLimit[]> = this.supportLimitsVal.asObservable();

constructor(
private essFileService: EssFileService,
Expand Down Expand Up @@ -89,6 +92,36 @@ export class StepSupportsService {
return this.existingSupportListVal$;
}

setStoredSupportLimits(supportLimits: SupportLimit[]): void {
this.supportLimitsVal.next(supportLimits);
}

getStoredSupportLimits(): Observable<SupportLimit[]> {
return this.supportLimitsVal$;
}

fetchSupportLimits(): Observable<SupportLimit[]> {
return this.taskService
.tasksGetTask({
taskId: this.userService?.currentProfile?.taskNumber
})
.pipe(
map((task) => {
const supportLimits: SupportLimit[] = task.supportLimits.map((supportLimit) => {
return {
supportLimitStartDate: supportLimit.supportLimitStartDate,
supportLimitEndDate: supportLimit.supportLimitEndDate,
extensionAvailable: supportLimit.extensionAvailable,
supportType: supportLimit.supportType
};
});

this.setStoredSupportLimits(supportLimits);
return supportLimits;
})
);
}

set supportTypeToAdd(supportTypeToAddVal: Code) {
this.supportTypeToAddVal = supportTypeToAddVal;
this.cacheService.set('supportType', JSON.stringify(supportTypeToAddVal));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,38 +377,50 @@
</p>
</div>
</div>

<div class="row">
<div class="col-md-12">
<mat-checkbox
id="allMembers"
[checked]="isChecked()"
[indeterminate]="isIndeterminate()"
(change)="$event ? selectAll($event) : null"
><span class="bold">All household members</span></mat-checkbox
>
</div>
<div class="col-md-4" *ngIf="showLoader">
<app-loader [strokeWidth]="3" [diameter]="25" [showLoader]="showLoader" [color]="color">
</app-loader>
</div>
@for (member of evacueeSessionService?.evacFile?.needsAssessment?.householdMembers; track member) {
<div *ngIf="!showLoader">
<div class="row">
<div class="col-md-12">
<mat-checkbox
(click)="$event.stopPropagation()"
(change)="$event ? onChange($event, member) : null"
[checked]="exists(member)"
>
{{ member.lastName | uppercase }}, {{ member.firstName | titlecase }}</mat-checkbox
id="allMembers"
[checked]="isChecked()"
[indeterminate]="isIndeterminate()"
(change)="selectAll($event)"
><span class="bold">All household members</span></mat-checkbox
>
</div>
</div>
}
@if (
supportDetailsFormControl.members.invalid &&
supportDetailsFormControl.members.hasError('noSelection')
) {
<mat-error class="custom-mat-error"> Required</mat-error>
}

@for (member of evacueeSessionService?.evacFile?.needsAssessment?.householdMembers; track member) {
<div class="row">
<div class="col-md-12">
<mat-checkbox
(click)="$event.stopPropagation()"
(change)="$event ? onChange($event, member) : null"
[disabled]="!isHouseholdMemberEligibleForSupport(member)"
[checked]="exists(member)"
>
{{ member.lastName | uppercase }}, {{ member.firstName | titlecase }}
</mat-checkbox>
<!-- Display error message if the checkbox is disabled -->
@if (!isHouseholdMemberEligibleForSupport(member)) {
<mat-error class="custom-mat-info">
{{ member.firstName | titlecase }} {{ member.lastName | titlecase }} has already received
this support. Extensions for this support are not available at this time.
</mat-error>
}
</div>
</div>
}
@if (
supportDetailsFormControl.members.invalid &&
supportDetailsFormControl.members.hasError('noSelection')
) {
<mat-error class="custom-mat-error"> Required</mat-error>
}
</div>
<div>
@switch (stepSupportsService?.supportTypeToAdd?.value) {
<!-- Shelter-Allowance -->
Expand Down
Loading
Loading