Skip to content

Commit

Permalink
EMBCESSMOD-4997: shelter and needs changes in reports (#1978)
Browse files Browse the repository at this point in the history
  • Loading branch information
ytqsl authored Apr 6, 2024
1 parent cda2313 commit 5cc9f37
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
23 changes: 13 additions & 10 deletions ess/src/API/EMBC.ESS/Resources/Reports/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,23 @@ public class Evacuee
[Display(Name = "Pets")]
public int NumberOfPets { get; set; }

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

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

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

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

[Display(Name = "Able to Provide Transportation")]
public bool CanProvideTransportation { get; set; }
[Display(Name = "Requires Incidentals")]
public bool? RequiresIncidentals { get; set; }

[Display(Name = "Requires Transportation")]
public bool? RequiresTransportation { get; set; }

[Display(Name = "Supports Provided")]
public int NumberOfSupports { get; set; }
Expand Down
34 changes: 20 additions & 14 deletions ess/src/API/EMBC.ESS/Resources/Reports/Mappings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using AutoMapper;
using EMBC.ESS.Utilities.Dynamics.Microsoft.Dynamics.CRM;
using EMBC.Utilities.Extensions;
Expand Down Expand Up @@ -52,25 +53,18 @@ public Mappings()
? InsuranceOption.Unknown
: Enum.Parse<InsuranceOption>(((InsuranceOptionOptionSet)s.era_EvacuationFileid.era_CurrentNeedsAssessmentid.era_insurancecoverage).ToString())))
.ForMember(d => d.NumberOfPets, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_animal_ESSFileid.Count))
.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))
.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))
.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))
.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))
.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))
.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))
.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))
.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))
.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))
.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))
.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))
.ForMember(d => d.NumberOfSupports, opts => opts.MapFrom(s => s.era_EvacuationFileid == null ? 0 : s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Count))
.ForMember(d => d.SupportsTotalAmount, opts => opts.Ignore())
.AfterMap((s, d) =>
{
d.RegistrationCompleted = !string.IsNullOrEmpty(d.TaskNumber);
decimal total = 0;
if (s.era_EvacuationFileid != null)
{
foreach (var support in s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId)
{
total += support.era_totalamount.HasValue ? support.era_totalamount.Value : 0;
}
}
d.SupportsTotalAmount = total;
d.SupportsTotalAmount = s.era_EvacuationFileid.era_era_evacuationfile_era_evacueesupport_ESSFileId.Select(s => s.era_totalamount ?? 0).Sum();
});

Func<int?, string> resolveSupportType = s =>
Expand Down Expand Up @@ -236,6 +230,18 @@ public enum EraTwoOptions
No = 174360001
}

public enum NeedTrueFalseOptionSet
{
True = 174360000,
False = 174360001
}

public enum ShelterOptionSet
{
Allowance = 174360000,
Referral = 174360001
}

#pragma warning restore CA1008 // Enums should have zero value

public class GenderConverter : IValueConverter<string, int?>, IValueConverter<int?, string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using EMBC.ESS.Shared.Contracts.Reports;
using System;
using System.IO;
using EMBC.ESS.Shared.Contracts.Reports;
using EMBC.Utilities.Messaging;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -18,13 +20,13 @@ public async Task CanGetEvacueeReport()
{
var reportId = await messagingClient.Send(new RequestEvacueeReportCommand
{
TaskNumber = "1234",
//TaskNumber = "1234",
//FileId = "101010",
//EvacuatedFrom = "9e6adfaf-9f97-ea11-b813-005056830319",
//EvacuatedTo = "9e6adfaf-9f97-ea11-b813-005056830319",
//IncludePersonalInfo = false,
//From = DateTime.UtcNow.AddDays(-1),
//To = DateTime.UtcNow,
From = DateTime.UtcNow.AddDays(-30),
To = DateTime.UtcNow,
});

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

await File.WriteAllBytesAsync("./evacuees.csv", report.Content);

break;
}
catch (ServerException e)
Expand Down

0 comments on commit 5cc9f37

Please sign in to comment.