コード例 #1
0
        /// <summary>
        /// For a given posku, this will determine if it should be sent through and, if so, sets the ActivityCode appropriately
        /// </summary>
        private void CompareContempoPOSkuData(POContempoSkuOutput currentSku, bool parentPOUpdated, POContempoOutput priorPO, CompareLogic comparisson)
        {
            //grab the previously sent version for this sku
            var poskutobecompared = priorPO.POSkus != null?priorPO.POSkus.Find(posku => posku.SKU == currentSku.SKU) : null;

            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 = "";
                }
            }
        }
コード例 #2
0
        public async Task <POContempoOutput> UpdatePOObject(POContempoOutput poobject, MMSProductEvent product, POSkus posku)
        {
            try
            {
                var prodhierarchy = await _lookUpService.GetProductHierarchy(product.SubClass);

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

                //check if exists
                if (poobject.POSkus != null && poobject.POSkus.Count > 0 && poobject.POSkus.Exists(y => y.SKU == posku.SKU) &&
                    (product?.Department == "JEP" || product?.Department == "JSF") && product?.SubClass != "JOSAC")
                {
                    var poskutobeupdated = poobject.POSkus.Find(y => y.SKU == posku.SKU);
                    poskutobeupdated.POProduct.Class           = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class;
                    poskutobeupdated.POProduct.CountryOfOrigin = product?.ProductVendors?.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendor)?.CountryOfOrigin;
                    poskutobeupdated.POProduct.SubClass        = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubClass;
                    poskutobeupdated.POProduct.APVendor        = posku.POProduct?.APVendor;
                    poskutobeupdated.POProduct.VendorSKUCode   = product?.ProductVendors?.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendor)?.VendorSkuCode;
                    poskutobeupdated.POProduct.ClassLevelDesc  = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description;
                    poskutobeupdated.POProduct.Size            = posku.POProduct?.Size;
                    poskutobeupdated.POProduct.LabelType       = product?.LabelType;
                    //TODO
                    //This LabelDescription value should be populated from "MMSProductEvent" ProductVendors objects labeldescription
                    //For now, it is coming from database so that we know the value is populating.
                    poskutobeupdated.POProduct.LabelDescription  = productlabelcode?.Description;
                    poskutobeupdated.POProduct.SkuDesc           = product?.SkuDescShrt;
                    poskutobeupdated.POProduct.SubClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription;
                    poskutobeupdated.POProduct.RetailPrice       = posku.GetRetailPrice();
                    //Update CreateDate value once it is available in POSkus object
                    poskutobeupdated.CreateDate   = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?();
                    poskutobeupdated.ModifiedDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?();
                }
                else
                {
                    if ((product?.Department == "JEP" || product?.Department == "JSF") && product?.SubClass != "JOSAC")
                    {
                        POContempoProductOutput poProductOutput = new POContempoProductOutput
                        {
                            LabelType = product?.LabelType,
                            //TODO - need to figure out how we're getting these from MMS
                            //This LabelDescription value should be populated from "MMSProductEvent" ProductVendors objects labeldescription
                            //For now, it is coming from database so that we know the value is populating.
                            LabelDescription  = productlabelcode?.Description,
                            Class             = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class,
                            CountryOfOrigin   = posku.POProduct?.CountryOfOrigin,
                            SubClass          = prodhierarchy.Find(y => y.SubClass == product?.SubClass)?.SubClass,
                            APVendor          = posku.POProduct?.APVendor,
                            VendorSKUCode     = product?.ProductVendors?.Find(y => y.Sku == product?.Sku && y.SubVendor == poobject.SubVendor)?.VendorSkuCode,
                            ClassLevelDesc    = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description,
                            Size              = posku.POProduct?.Size,
                            SkuDesc           = product?.SkuDescShrt,
                            SubClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription,
                            RetailPrice       = posku.GetRetailPrice()
                        };
                        POContempoSkuOutput POSkusOutput = new POContempoSkuOutput
                        {
                            SKU        = posku.SKU,
                            BuyQuanity = posku.BuyQuantity != null?Convert.ToInt32(posku.BuyQuantity) : 0,
                                             POProduct = poProductOutput,
                                             //Update CreateDate value once it is available in POSkus object
                                             CreateDate   = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?(),
                                             ModifiedDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?(),
                                             StatusCode   = posku.StatusCode,
                        };

                        if (poobject.POSkus == null)
                        {
                            poobject.POSkus = new System.Collections.Generic.List <POContempoSkuOutput>();
                        }
                        poobject.POSkus.Add(POSkusOutput);
                    }
                }
                return(poobject);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpdatePOObject - Failed Updating ContempoPO: {Reason}", ex.Message);
                return(null);
            }
        }