From 38532ae9cacdbaa9da52111cef7da67573e88a97 Mon Sep 17 00:00:00 2001 From: KKAYFISH Date: Tue, 5 Sep 2023 11:59:46 -0700 Subject: [PATCH] EMBCESSMOD-4653: Added Check on Dupe Support to treat FoodGroeries and FoodRestaurant as similar supports for purposes of duplicate check. --- .../DuplicateSupportComplianceCheck.cs | 19 +++++++++++++++++-- .../Events/Supports.cs | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ess/src/API/EMBC.ESS/Engines/Supporting/SupportCompliance/DuplicateSupportComplianceCheck.cs b/ess/src/API/EMBC.ESS/Engines/Supporting/SupportCompliance/DuplicateSupportComplianceCheck.cs index 8f210245f..7c6f54281 100644 --- a/ess/src/API/EMBC.ESS/Engines/Supporting/SupportCompliance/DuplicateSupportComplianceCheck.cs +++ b/ess/src/API/EMBC.ESS/Engines/Supporting/SupportCompliance/DuplicateSupportComplianceCheck.cs @@ -34,13 +34,28 @@ public async Task> CheckCompliance(Support support) var type = checkedSupport.era_supporttype.Value; var householdMembers = checkedSupport.era_era_householdmember_era_evacueesupport.ToArray(); - var similarSupports = (await ((DataServiceQuery)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)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)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)); diff --git a/shared/src/EMBC.ESS.Shared.Contracts/Events/Supports.cs b/shared/src/EMBC.ESS.Shared.Contracts/Events/Supports.cs index 5948916d0..89a4f4d24 100644 --- a/shared/src/EMBC.ESS.Shared.Contracts/Events/Supports.cs +++ b/shared/src/EMBC.ESS.Shared.Contracts/Events/Supports.cs @@ -109,6 +109,21 @@ public abstract class Support public IEnumerable Flags { get; set; } = Array.Empty(); } + 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))] public abstract class SupportDelivery {