/// <summary>
        /// For a given posku, this will determine if it should be sent through and, if so, sets the ActivityCode appropriately
        /// </summary>
        private void CompareFinelinePOSkuData(POFineLineSkuOutput currentSku, bool parentPOUpdated, POFineLineOutput priorPO, CompareLogic comparisson)
        {
            POFineLineSkuOutput poskutobecompared = null;

            if (priorPO.POSkus != null && priorPO.POSkus.Count > 0)
            {
                //grab the previously sent version for this sku
                poskutobecompared = priorPO.POSkus.Find(posku => posku.SKUNumber == currentSku.SKUNumber);
            }
            else
            {
                _logger.LogInformation($"CompareFinelinePOSkuData - Skipping output for PO - {priorPO.PurchaseOrder}; no SKUs were found.");
                return;
            }

            ////grab the previously sent version for this sku
            //var poskutobecompared = priorPO.POSkus.Find(posku => posku.SKUNumber == currentSku.SKUNumber);
            if (poskutobecompared == null)
            {
                //Never sent before.  Only send if its status is open
                if (currentSku.StatusCode == "OP")
                {
                    currentSku.ActivityCode = "";
                }
            }
            else if (currentSku.StatusCode == "CN" || currentSku.StatusCode == "VD")
            {
                //Cancelled/voided.  Send as "X", but only if it wasn't cancelled or voided when we last sent it
                if (poskutobecompared.StatusCode != "CN" && poskutobecompared.StatusCode != "VD")
                {
                    currentSku.ActivityCode = "X";
                }
            }
            else if (parentPOUpdated)
            {
                //Parent PO was modified, so all the child skus are considered modified
                currentSku.ActivityCode = "";
            }
            else
            {
                //Parent PO hasn't changed.  See if this sku line was itself modified
                var diffposkus    = comparisson.Compare(currentSku, poskutobecompared).Differences;
                var diffpoproduct = comparisson.Compare(currentSku.POProduct, poskutobecompared.POProduct).Differences;

                if (diffposkus?.Count > 0 || diffpoproduct?.Count > 0)
                {
                    currentSku.ActivityCode = "";
                }
            }
        }
        public async Task <POFineLineOutput> UpdatePOObject(POFineLineOutput poobject, MMSProductEvent product, POSkus posku)
        {
            try
            {
                var prodhierarchy = await _lookUpService.GetProductHierarchy(product.SubClass);

                var productlabel = await _lookUpService.GetProductLabelDescription(product.LabelType);

                //check if exists
                if (poobject.POSkus != null && poobject.POSkus.Count > 0 && poobject.POSkus.Exists(y => y.SKUNumber == posku.SKU))
                {
                    var poskutobeupdated = poobject.POSkus.Find(y => y.SKUNumber == posku.SKU);
                    poskutobeupdated.POProduct.SKUDescription    = product?.SkuDescShrt;
                    poskutobeupdated.POProduct.SubClassID        = product?.SubClass;
                    poskutobeupdated.POProduct.TicketType        = productlabel?.Code;
                    poskutobeupdated.POProduct.TicketDescription = productlabel?.Description;
                    poskutobeupdated.POProduct.VendorNumber      = posku.POProduct?.APVendor;
                    poskutobeupdated.POProduct.Size                = product?.Size;
                    poskutobeupdated.POProduct.ISOCountryCode      = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.CountryOfOrigin;
                    poskutobeupdated.POProduct.ClassID             = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class;
                    poskutobeupdated.POProduct.ClassDescription    = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description;
                    poskutobeupdated.POProduct.VendorStyleNumber   = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.VendorSkuCode;
                    poskutobeupdated.POProduct.SubClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription;
                    poskutobeupdated.POProduct.SubVendorNumber     = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.SubVendor;
                    poskutobeupdated.POProduct.TicketRetail        = posku.GetRetailPrice();
                    return(poobject);
                }
                else
                {
                    POFineLineProductOutput poFLProductOutput = new POFineLineProductOutput
                    {
                        VendorNumber        = posku.POProduct?.APVendor,
                        SubVendorNumber     = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.SubVendor,
                        SKUDescription      = product?.SkuDescShrt,
                        VendorStyleNumber   = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.VendorSkuCode,
                        TicketType          = productlabel?.Code,
                        TicketDescription   = productlabel?.Description,
                        ClassID             = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class,
                        ClassDescription    = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description,
                        SubClassID          = product?.SubClass,
                        SubClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription,
                        Size           = product?.Size,
                        ISOCountryCode = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.CountryOfOrigin,
                        TicketRetail   = posku.GetRetailPrice()
                    };
                    POFineLineSkuOutput POFLSkusOutput = new POFineLineSkuOutput
                    {
                        SKUNumber               = posku.SKU,
                        PurchaseOrderDate       = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?(),
                        PurchaseOrderReviseDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?(),
                        OrderQuantity           = posku.BuyQuantity != null?Convert.ToInt32(posku.BuyQuantity) : 0,
                        POProduct               = poFLProductOutput,
                        StatusCode              = posku.StatusCode,
                    };

                    if (poobject.POSkus == null)
                    {
                        poobject.POSkus = new System.Collections.Generic.List <POFineLineSkuOutput>();
                    }
                    poobject.POSkus.Add(POFLSkusOutput);
                    return(poobject);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpdatePOObject - Failed Updating FineLinePO: {Reason} -- {PONumber} -- {Sku }", ex.Message, poobject.PurchaseOrder, posku.SKU);
                return(null);
            }
        }