diff --git a/server/AyaNova/biz/UnitMeterReadingBiz.cs b/server/AyaNova/biz/UnitMeterReadingBiz.cs index 866684c7..477031b2 100644 --- a/server/AyaNova/biz/UnitMeterReadingBiz.cs +++ b/server/AyaNova/biz/UnitMeterReadingBiz.cs @@ -198,8 +198,7 @@ namespace AyaNova.Biz ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger(); if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return; log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]"); - - await Task.CompletedTask; + //SPECIFIC EVENTS FOR THIS OBJECT //UnitMeterReadingMultipleExceeded event @@ -222,7 +221,9 @@ namespace AyaNova.Biz var lastMeterReading = await ct.UnitMeterReading.AsNoTracking() .Where(x => x.UnitId == proposedObj.UnitId) .OrderByDescending(z => z.MeterDate) - .Take(1).FirstOrDefaultAsync(); + .Skip(1)//because it's already saved this current reading by the time it gets here + .Take(1) + .FirstOrDefaultAsync(); long lastReading = 0; if (lastMeterReading != null) lastReading = lastMeterReading.Meter; diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index dae04d36..15924f1d 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -223,7 +223,7 @@ namespace AyaNova.Biz if (ne.EventType == NotifyEventType.CustomerServiceImminent) TranslationKeysToFetch.Add("NotifyEventCustomerServiceImminentMessage"); - if (ne.DecValue != 0) + if (ne.DecValue != 0 && ne.EventType == NotifyEventType.WorkorderTotalExceedsThreshold) { TranslationKeysToFetch.Add("Total"); } @@ -253,10 +253,16 @@ namespace AyaNova.Biz AgeDisplay = $"({AyaNova.Util.DateUtil.FormatTimeSpan(ageValue, LT["TimeSpanDays"], LT["TimeSpanHours"], LT["TimeSpanMinutes"], LT["TimeSpanSeconds"])})\n"; - //DecValue (only for TheAndy for now workorder exceedsthreshold so not putting a lot of localization effort in; in app will localize properly) + //DecValue string DecDisplay = ""; + //could be money or integer depending on typ if (ne.DecValue != 0) - DecDisplay = $"{LT["Total"]}: {ne.DecValue.ToString("N2", System.Globalization.CultureInfo.InvariantCulture)}\n"; + { + if (ne.EventType == NotifyEventType.WorkorderTotalExceedsThreshold) + DecDisplay = $"{LT["Total"]}: {ne.DecValue.ToString("N2", System.Globalization.CultureInfo.InvariantCulture)}\n"; + else if (ne.EventType == NotifyEventType.UnitMeterReadingMultipleExceeded) + DecDisplay = $"{System.Convert.ToInt64(ne.DecValue).ToString()}\n"; + } string subject = "";