diff --git a/server/AyaNova/biz/PMBiz.cs b/server/AyaNova/biz/PMBiz.cs index b4006d35..01df19eb 100644 --- a/server/AyaNova/biz/PMBiz.cs +++ b/server/AyaNova/biz/PMBiz.cs @@ -4775,14 +4775,14 @@ namespace AyaNova.Biz .Where(z => z.GenerateDate < checkUpToDate && z.Active == true) .Select(z => z.Id) .ToListAsync(); -#if (DEBUG) + if (l.Count > 0) - log.LogInformation($"Found {l.Count} inventory checkable PM orders for subscription id {sub.Id}"); -#endif + log.LogDebug($"Found {l.Count} inventory checkable PM orders for subscription id {sub.Id}"); + //Get the translations for this user List transl = new List(); - transl.Add("Part"); + transl.Add("PartPartNumber"); transl.Add("PartWarehouse"); transl.Add("QuantityRequired"); var Trans = await TranslationBiz.GetSubsetForUserStaticAsync(transl, sub.UserId); @@ -4790,21 +4790,17 @@ namespace AyaNova.Biz //process those pms foreach (long pmid in l) { -#if (DEBUG) - log.LogInformation($"processing pm id {pmid}"); -#endif - //############### TODO UNCOMMENT THIS AFTER TESTING ############################ - // //look for same delivery already made and skip if already notified (sb one time only but will repeat for > 90 days as delivery log gets pruned) - // if (await ct.NotifyDeliveryLog.AnyAsync(z => z.NotifySubscriptionId == sub.Id && z.ObjectId == pmid)) - // { - // log.LogTrace($"PM {pmid} insufficient inventory already notified to subscriber within last 90 days, no need to send again, skipping"); + log.LogDebug($"processing pm id {pmid}"); - // #if (DEBUG) - // log.LogInformation($"PM {pmid} insufficient inventory already notified to subscriber within last 90 days, no need to send again, skipping"); - // #endif - // continue; - // } + + + //look for same delivery already made and skip if already notified (sb one time only but will repeat for > 90 days as delivery log gets pruned) + if (await ct.NotifyDeliveryLog.AnyAsync(z => z.NotifySubscriptionId == sub.Id && z.ObjectId == pmid)) + { + log.LogDebug($"PM {pmid} insufficient inventory already notified to subscriber within last 90 days, no need to send again, skipping"); + continue; + } //Ok, it's worth checking out and could be a potential notification @@ -4820,11 +4816,12 @@ namespace AyaNova.Biz log.LogError($"PM was not fetchable when attempting to process PM id: {pmid}, deleted during processing?"); continue; } - - //check inventory and notify - //if so, iterate pm examine inventory and determine if short of anything and build a notification for it line by line to send as message: - //title = pm insufficient and id and object link to pm - //message = list: part name, -xx (short quantity), no text if possible so no translate needed + //Tag match? (will be true if no sub tags so always safe to call this) + if (!NotifyEventHelper.ObjectHasAllSubscriptionTags(p.Tags, sub.Tags)) + { + log.LogDebug($"PM tags don't match subscription required tags PM id: {pmid}, skipping"); + continue; + } //collect the parts on the pm List PartsOnPM = new List(); @@ -4862,7 +4859,7 @@ namespace AyaNova.Biz var part = await ct.Part.AsNoTracking().Where(x => x.Id == i.PartId).Select(x => x.PartNumber).FirstOrDefaultAsync(); var whs = await ct.PartWarehouse.AsNoTracking().Where(x => x.Id == i.WarehouseId).Select(x => x.Name).FirstOrDefaultAsync(); var qty = (i.QuantityRequired - dBalance).ToString("G29", System.Globalization.CultureInfo.InvariantCulture); - sb.Append($"{Trans["Part"]}: {part}, {Trans["PartWarehouse"]}: {whs}, {Trans["QuantityRequired"]}: {qty}\n"); + sb.Append($"{Trans["PartPartNumber"]}: {part}, {Trans["PartWarehouse"]}: {whs}, {Trans["QuantityRequired"]}: {qty}\n"); } } if (sb.Length > 0)