Skip to content

Commit

Permalink
EMBCESSMOD-4653: Added Check on Dupe Support to treat FoodGroeries an…
Browse files Browse the repository at this point in the history
…d FoodRestaurant as similar supports for purposes of duplicate check.
  • Loading branch information
KyleKayfish committed Sep 5, 2023
1 parent a89c08e commit 38532ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,28 @@ public async Task<IEnumerable<SupportFlag>> CheckCompliance(Support support)
var type = checkedSupport.era_supporttype.Value;
var householdMembers = checkedSupport.era_era_householdmember_era_evacueesupport.ToArray();

var similarSupports = (await ((DataServiceQuery<era_evacueesupport>)ctx.era_evacueesupports.Where(s =>
var similarSupports = new era_evacueesupport[0];

//EMBCESSMOD-4653 - treat 'Food - Groceries' and 'Food - Restaurant Meals' as the same support type
if (type == (int)SupportType.Food_Groceries ||
type == (int)SupportType.Food_Restaurant)
{
similarSupports = (await ((DataServiceQuery<era_evacueesupport>)ctx.era_evacueesupports.Where(s =>
s.era_name != checkedSupport.era_name && (s.era_supporttype == (int)SupportType.Food_Groceries || s.era_supporttype == (int)SupportType.Food_Restaurant) &&
s.statuscode != (int)SupportStatus.Cancelled && s.statuscode != (int)SupportStatus.Void &&
((s.era_validfrom >= from && s.era_validfrom <= to) ||
(s.era_validto >= from && s.era_validto <= to))))
.GetAllPagesAsync()).ToArray();
}
else
{
similarSupports = (await ((DataServiceQuery<era_evacueesupport>)ctx.era_evacueesupports.Where(s =>
s.era_name != checkedSupport.era_name && s.era_supporttype == type &&
s.statuscode != (int)SupportStatus.Cancelled && s.statuscode != (int)SupportStatus.Void &&
((s.era_validfrom >= from && s.era_validfrom <= to) ||
(s.era_validto >= from && s.era_validto <= to))))
.GetAllPagesAsync()).ToArray();

}
foreach (var similarSupport in similarSupports)
{
await ctx.LoadPropertyAsync(similarSupport, nameof(era_evacueesupport.era_era_householdmember_era_evacueesupport));
Expand Down
15 changes: 15 additions & 0 deletions shared/src/EMBC.ESS.Shared.Contracts/Events/Supports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ public abstract class Support
public IEnumerable<SupportFlag> Flags { get; set; } = Array.Empty<SupportFlag>();
}

public enum SupportType
{
#pragma warning disable CA1707 // Identifiers should not contain underscores
Food_Groceries = 174360000,
Food_Restaurant = 174360001,
Lodging_Hotel = 174360002,
Lodging_Billeting = 174360003,
Lodging_Group = 174360004,
Incidentals = 174360005,
Clothing = 174360006,
Transportation_Taxi = 174360007,
Transportation_Other = 174360008,
#pragma warning restore CA1707 // Identifiers should not contain underscores
}

[JsonConverter(typeof(PolymorphicJsonConverter<SupportDelivery>))]
public abstract class SupportDelivery
{
Expand Down

0 comments on commit 38532ae

Please sign in to comment.