Skip to content

Commit 5cc9f37

Browse files
authored
EMBCESSMOD-4997: shelter and needs changes in reports (#1978)
1 parent cda2313 commit 5cc9f37

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

ess/src/API/EMBC.ESS/Resources/Reports/Contract.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,23 @@ public class Evacuee
153153
[Display(Name = "Pets")]
154154
public int NumberOfPets { get; set; }
155155

156-
[Display(Name = "Able to Provide Accommodation")]
157-
public bool CanProvideAccommodation { get; set; }
156+
[Display(Name = "Requires Shelter Referral")]
157+
public bool? RequiresShelterReferral { get; set; }
158158

159-
[Display(Name = "Able to Provide Clothing")]
160-
public bool CanProvideClothing { get; set; }
159+
[Display(Name = "Requires Shelter Allowance")]
160+
public bool? RequiresShelterAllowance { get; set; }
161161

162-
[Display(Name = "Able to Provide Food")]
163-
public bool CanProvideFood { get; set; }
162+
[Display(Name = "Requires Clothing")]
163+
public bool? RequiresClothing { get; set; }
164164

165-
[Display(Name = "Able to Provide Incidentals")]
166-
public bool CanProvideIncidentals { get; set; }
165+
[Display(Name = "Requires Food")]
166+
public bool? RequiresFood { get; set; }
167167

168-
[Display(Name = "Able to Provide Transportation")]
169-
public bool CanProvideTransportation { get; set; }
168+
[Display(Name = "Requires Incidentals")]
169+
public bool? RequiresIncidentals { get; set; }
170+
171+
[Display(Name = "Requires Transportation")]
172+
public bool? RequiresTransportation { get; set; }
170173

171174
[Display(Name = "Supports Provided")]
172175
public int NumberOfSupports { get; set; }

ess/src/API/EMBC.ESS/Resources/Reports/Mappings.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using AutoMapper;
34
using EMBC.ESS.Utilities.Dynamics.Microsoft.Dynamics.CRM;
45
using EMBC.Utilities.Extensions;
@@ -52,25 +53,18 @@ public Mappings()
5253
? InsuranceOption.Unknown
5354
: Enum.Parse<InsuranceOption>(((InsuranceOptionOptionSet)s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_insurancecoverage).ToString())))
5455
.ForMember(d => d.NumberOfPets, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_animal_ESSFileid.Count))
55-
.ForMember(d => d.CanProvideAccommodation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidelodging))
56-
.ForMember(d => d.CanProvideClothing, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideclothing))
57-
.ForMember(d => d.CanProvideFood, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidefood))
58-
.ForMember(d => d.CanProvideIncidentals, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideincidentals))
59-
.ForMember(d => d.CanProvideTransportation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid == null ? null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidetransportation))
56+
.ForMember(d => d.RequiresClothing, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideclothing.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False))
57+
.ForMember(d => d.RequiresFood, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidefood.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False))
58+
.ForMember(d => d.RequiresIncidentals, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovideincidentals.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False))
59+
.ForMember(d => d.RequiresTransportation, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_canevacueeprovidetransportation.GetValueOrDefault(0) == (int)NeedTrueFalseOptionSet.False))
60+
.ForMember(d => d.RequiresShelterReferral, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_shelteroptions.GetValueOrDefault(0) == (int)ShelterOptionSet.Referral))
61+
.ForMember(d => d.RequiresShelterAllowance, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? (bool?)null : s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_shelteroptions.GetValueOrDefault(0) == (int)ShelterOptionSet.Allowance))
6062
.ForMember(d => d.NumberOfSupports, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Count))
6163
.ForMember(d => d.SupportsTotalAmount, opts => opts.Ignore())
6264
.AfterMap((s, d) =>
6365
{
6466
d.RegistrationCompleted = !string.IsNullOrEmpty(d.TaskNumber);
65-
decimal total = 0;
66-
if (s.era_EvacuationFileid != null)
67-
{
68-
foreach (var support in s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId)
69-
{
70-
total += support.era_totalamount.HasValue ? support.era_totalamount.Value : 0;
71-
}
72-
}
73-
d.SupportsTotalAmount = total;
67+
d.SupportsTotalAmount = s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Select(s => s.era_totalamount ?? 0).Sum();
7468
});
7569

7670
Func<int?, string> resolveSupportType = s =>
@@ -236,6 +230,18 @@ public enum EraTwoOptions
236230
No = 174360001
237231
}
238232

233+
public enum NeedTrueFalseOptionSet
234+
{
235+
True = 174360000,
236+
False = 174360001
237+
}
238+
239+
public enum ShelterOptionSet
240+
{
241+
Allowance = 174360000,
242+
Referral = 174360001
243+
}
244+
239245
#pragma warning restore CA1008 // Enums should have zero value
240246

241247
public class GenderConverter : IValueConverter<string, int?>, IValueConverter<int?, string>

ess/src/API/EMBC.Tests.Integration.ESS/Managers/ReportsManagerTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using EMBC.ESS.Shared.Contracts.Reports;
1+
using System;
2+
using System.IO;
3+
using EMBC.ESS.Shared.Contracts.Reports;
24
using EMBC.Utilities.Messaging;
35
using Microsoft.Extensions.DependencyInjection;
46

@@ -18,13 +20,13 @@ public async Task CanGetEvacueeReport()
1820
{
1921
var reportId = await messagingClient.Send(new RequestEvacueeReportCommand
2022
{
21-
TaskNumber = "1234",
23+
//TaskNumber = "1234",
2224
//FileId = "101010",
2325
//EvacuatedFrom = "9e6adfaf-9f97-ea11-b813-005056830319",
2426
//EvacuatedTo = "9e6adfaf-9f97-ea11-b813-005056830319",
2527
//IncludePersonalInfo = false,
26-
//From = DateTime.UtcNow.AddDays(-1),
27-
//To = DateTime.UtcNow,
28+
From = DateTime.UtcNow.AddDays(-30),
29+
To = DateTime.UtcNow,
2830
});
2931

3032
reportId.ShouldNotBeEmpty();
@@ -39,6 +41,8 @@ public async Task CanGetEvacueeReport()
3941
report.ContentType.ShouldBe("text/csv");
4042
success = true;
4143

44+
await File.WriteAllBytesAsync("./evacuees.csv", report.Content);
45+
4246
break;
4347
}
4448
catch (ServerException e)

0 commit comments

Comments
 (0)