Exemple #1
0
 public async void UpdatePOObjectForVendor(POIntertekOutput poobject, MMSSubVendorEvent vendor)
 {
     try
     {
         poobject.VendorName = vendor.VendName;
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "UpdatePOObjectForVendor - Failed Updating IntertekPO: {Reason}", ex.Message);
     }
 }
        public static void UpdatePOIntertekPoSkuData(this POIntertekOutput poIntertek, List <POSkus> poskus)
        {
            if (poskus != null && poskus.Count > 0)
            {
                List <POIntertekSKUOutput> poskustobeaddedtoPO = new List <POIntertekSKUOutput>();

                poskus.ForEach(x =>
                {
                    var updatePoSKU = poIntertek.POSkus.Find(y => y.SKU == x.SKU);
                    if (updatePoSKU != null)
                    {
                        updatePoSKU.BuyQuantity         = x.BuyQuantity.HasValue?x.BuyQuantity.Value.ToString():"0";
                        updatePoSKU.CreateDate          = x.CreateDate?.Date.ToString("yyyyMMdd");
                        updatePoSKU.DutyCost            = x.DutyCost.HasValue ? Math.Round(x.DutyCost.GetValueOrDefault(), 2).ToString(): "0";
                        updatePoSKU.FirstCost           = x.FirstCost.HasValue? Math.Round(x.FirstCost.GetValueOrDefault(), 2).ToString(): "0";
                        updatePoSKU.MasterPackCubicFeet = x.MasterPackCubicFeet.HasValue? Math.Round(x.MasterPackCubicFeet.GetValueOrDefault(), 2).ToString() : "0";
                        updatePoSKU.DutyPctOfFOB        = x.DutyPctOfFOB.HasValue ? Math.Round(x.DutyPctOfFOB.GetValueOrDefault(), 2).ToString() : "0";
                        updatePoSKU.EstimatedLandedCost = x.EstimatedLandedCost.HasValue? Math.Round(x.EstimatedLandedCost.GetValueOrDefault(), 2).ToString():"0";
                        updatePoSKU.PrepackId           = x.PrepackId;
                        updatePoSKU.ApprovalLetter      = x.ApprovalLetter.HasValue ? (x.ApprovalLetter.Value == true ? "Y" : "N") : string.Empty;
                        updatePoSKU.StatusCode          = x.StatusCode;
                    }
                });

                var poskustobeadded = poskus.Where(x => !poIntertek.POSkus.Any(y => y.SKU == x.SKU));
                poskustobeadded?.ToList().ForEach(y =>
                {
                    poskustobeaddedtoPO.Add(new POIntertekSKUOutput
                    {
                        BuyQuantity         = y.BuyQuantity.HasValue ? y.BuyQuantity.Value.ToString() : "0",
                        CreateDate          = y.CreateDate.HasValue ? Convert.ToString(y.CreateDate.Value.Date.ToString("yyyyMMdd")) : string.Empty,
                        DutyCost            = y.DutyCost.HasValue? Math.Round(y.DutyCost.GetValueOrDefault(), 2).ToString():"0",
                        FirstCost           = y.FirstCost.HasValue? Math.Round(y.FirstCost.GetValueOrDefault(), 2).ToString():"0",
                        MasterPackCubicFeet = y.MasterPackCubicFeet.HasValue ? Math.Round(y.MasterPackCubicFeet.GetValueOrDefault(), 2).ToString() : "0",
                        DutyPctOfFOB        = y.DutyPctOfFOB.HasValue ? Math.Round(y.DutyPctOfFOB.GetValueOrDefault(), 2).ToString() : "0",
                        EstimatedLandedCost = y.EstimatedLandedCost.HasValue ? Math.Round(y.EstimatedLandedCost.GetValueOrDefault(), 2).ToString() : "0",
                        PrepackId           = y.PrepackId,
                        SKU            = y.SKU,
                        ApprovalLetter = y.ApprovalLetter.HasValue ? (y.ApprovalLetter.Value == true ? "Y" : "N") : string.Empty,
                        StatusCode     = y.StatusCode
                    });
                });

                if (poskustobeadded?.ToList().Count > 0)
                {
                    poIntertek.POSkus.AddRange(poskustobeaddedtoPO);
                }
            }
        }
 public static void UpdateIntertekData(this POIntertekOutput poIntertek, MMSPOEvent model)
 {
     poIntertek.CancelDate      = model.CancelDate?.FormatTo();
     poIntertek.DeliveryDate    = model.DeliveryDate?.FormatTo();
     poIntertek.LocationNumber  = model.LocationNumber;
     poIntertek.EmployeeId      = model.EmployeeID;
     poIntertek.LocationNumber  = model.LocationNumber;
     poIntertek.PONumber        = model.PONumber;
     poIntertek.ShipDate        = model.ShipDate?.FormatTo();
     poIntertek.SubVendorNumber = model.SubVendorNumber;
     poIntertek.LOB             = model.LineOfBusiness;
     poIntertek.DistributorId   = model.DistributorId;
     poIntertek.CurrencyCode    = model.CurrencyCode;
     poIntertek.StatusCode      = model.StatusCode;
 }
Exemple #4
0
        public async void UpdatePOObject(POIntertekOutput poobject, MMSProductEvent product, POSkus posku)
        {
            try
            {
                var prodhierarchy = _lookUpService.GetProductHierarchy(product.SubClass).Result;

                //check if exists
                if (poobject.POSkus != null && poobject.POSkus.Count > 0 && poobject.POSkus.Exists(y => y.SKU == posku.SKU))
                {
                    var poskutobeupdated = poobject.POSkus.Find(y => y.SKU == posku.SKU);

                    poskutobeupdated.POProduct.ClassCode      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Class;
                    poskutobeupdated.POProduct.DepartmentName = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Description;
                    poskutobeupdated.POProduct.ClassName      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Description;
                    poskutobeupdated.POProduct.DepartmentCode = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Department;
                    poskutobeupdated.POProduct.ClassShortDesc = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.ShortDesc;

                    poskutobeupdated.POProduct.HTSCode            = product.HTSCode;
                    poskutobeupdated.POProduct.Country            = product.ProductVendors.Find(y => y.Sku == product.Sku)?.CountryOfOrigin;
                    poskutobeupdated.POProduct.SkuDesc            = product.SkuDesc;
                    poskutobeupdated.POProduct.MasterPackQuantity = product.ProductVendors.Find(y => y.Sku == product.Sku)?.MasterPackQuantity;

                    // Product Flags
                    poskutobeupdated.POProduct.ProductFlagsOutput.IntlSafetyTransitTestRequired = !string.IsNullOrEmpty((product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IntlSafetyTransitTestRequired)?.FlagValue.ConvertToString())) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IntlSafetyTransitTestRequired).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.IsChildClothCostume           = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IsChildClothCostume)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IsChildClothCostume).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.IsGlassDishAdultJewelry       = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IsGlassDishAdultJewelry)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IsGlassDishAdultJewelry).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.NonPaintTestingRequired       = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.NonPaintTestingRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.NonPaintTestingRequired).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.RandomInspectionRequired      = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.RandomInspectionRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.RandomInspectionRequired).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.CPSIATestingRequired          = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.CPSIATestingRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.CPSIATestingRequired).FlagValue.ConvertToString() : "N";
                    poskutobeupdated.POProduct.ProductFlagsOutput.Sku = product.Sku;
                }
                else
                {
                    POProductFlagsOutput productFlagsOutput = new POProductFlagsOutput
                    {
                        Sku = product.Sku,
                        IntlSafetyTransitTestRequired = !string.IsNullOrEmpty((product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IntlSafetyTransitTestRequired)?.FlagValue.ConvertToString())) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IntlSafetyTransitTestRequired).FlagValue.ConvertToString() : "N",
                        IsChildClothCostume           = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IsChildClothCostume)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IsChildClothCostume).FlagValue.ConvertToString() : "N",
                        IsGlassDishAdultJewelry       = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.IsGlassDishAdultJewelry)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.IsGlassDishAdultJewelry).FlagValue.ConvertToString() : "N",
                        NonPaintTestingRequired       = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.NonPaintTestingRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.NonPaintTestingRequired).FlagValue.ConvertToString() : "N",
                        RandomInspectionRequired      = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.RandomInspectionRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.RandomInspectionRequired).FlagValue.ConvertToString() : "N",
                        CPSIATestingRequired          = !string.IsNullOrEmpty(product?.ProductFlags?.Find(y => y.FlagKey == ProductFlagSettings.CPSIATestingRequired)?.FlagValue.ConvertToString()) ? product.ProductFlags.Find(y => y.FlagKey == ProductFlagSettings.CPSIATestingRequired).FlagValue.ConvertToString() : "N",
                    };
                    POProductOutput poProductOutput = new POProductOutput
                    {
                        ClassCode      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Class,
                        DepartmentName = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Department,
                        ClassName      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Description,
                        ClassShortDesc = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.ShortDesc,
                        DepartmentCode = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Department,

                        HTSCode            = product.HTSCode,
                        Country            = product.ProductVendors?.Find(y => y.Sku == product.Sku)?.CountryOfOrigin,
                        MasterPackQuantity = !string.IsNullOrEmpty(product.ProductVendors?.Find(y => y.Sku == product.Sku)?.MasterPackQuantity) ? product.ProductVendors?.Find(y => y.Sku == product.Sku)?.MasterPackQuantity : "0",
                        SkuDesc            = product.SkuDesc,
                        SKU = product.Sku,
                        //Product Flags
                        ProductFlagsOutput = productFlagsOutput
                    };
                    POIntertekSKUOutput POSkusOutput = new POIntertekSKUOutput
                    {
                        PONumber            = posku.PONumber.ToString(),
                        BuyQuantity         = posku.BuyQuantity.HasValue? posku.BuyQuantity.Value.ToString():"0",
                        CreateDate          = posku.CreateDate.Value.Date.ToString("yyyyMMdd"),
                        DutyCost            = posku.DutyCost.HasValue ? Math.Round(posku.DutyCost.GetValueOrDefault(), 2).ToString() :"0",
                        FirstCost           = posku.FirstCost.HasValue ? Math.Round(posku.FirstCost.GetValueOrDefault(), 2).ToString() : "0",
                        SKU                 = posku.SKU,
                        DutyPctOfFOB        = posku.DutyPctOfFOB.HasValue? Math.Round(posku.DutyPctOfFOB.GetValueOrDefault(), 2).ToString():"0",
                        EstimatedLandedCost = posku.EstimatedLandedCost.HasValue ? Math.Round(posku.EstimatedLandedCost.GetValueOrDefault(), 2).ToString() : "0",
                        MasterPackCubicFeet = posku.MasterPackCubicFeet.HasValue? Math.Round(posku.MasterPackCubicFeet.GetValueOrDefault(), 2).ToString():"0",
                        PrepackId           = posku.PrepackId,
                        ApprovalLetter      = posku.ApprovalLetter.HasValue ? (posku.ApprovalLetter.Value == true ? "Y" : "N") : "N",
                        StatusCode          = posku.StatusCode,
                        POProduct           = poProductOutput,
                    };

                    if (poobject.POSkus == null)
                    {
                        poobject.POSkus = new System.Collections.Generic.List <POIntertekSKUOutput>();
                    }
                    poobject.POSkus.Add(POSkusOutput);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpdatePOObject - Failed Updating IntertekPO: {Reason}", ex.Message);
            }
        }
Exemple #5
0
        //mehod to compare 2 Intertek objects and return the POskulines that would be sent back
        public POIntertekOutput CompareIntertekData(POIntertekOutput poskusOutputcurrent, POIntertekOutput poskusOutputprev)
        {
            try
            {
                bool         poupdated       = false;
                int          propertyCount   = typeof(POIntertekOutput).GetProperties().Length;
                CompareLogic basicComparison = new CompareLogic()
                {
                    Config = new ComparisonConfig()
                    {
                        MaxDifferences = propertyCount
                    }
                };
                List <Difference> diffs = basicComparison.Compare(poskusOutputcurrent, poskusOutputprev).Differences;

                //deliberately set the activty code for poskus to null. later it will be "A"/"U" as applicable
                if (poskusOutputcurrent.POSkus != null && poskusOutputcurrent.POSkus.Count > 0)
                {
                    poskusOutputcurrent.POSkus.ForEach(y =>
                    {
                        y.ActivityCode = null;
                    });
                }
                else
                {
                    _logger.LogInformation($"CompareIntertekData - Skipping output for PO - {poskusOutputcurrent.PONumber}; no SKUs were found.");
                    return(new POIntertekOutput());
                }

                if (diffs != null && diffs.Count() > 0)
                {
                    //check if there is a difference on PO level/then tag all POSkus as "U"
                    if (diffs.Where(x => x.ParentPropertyName == string.Empty).Count() > 0)
                    {
                        poupdated = true;
                    }

                    //go to the POSKUs collection and figure if there has been a change

                    poskusOutputcurrent.POSkus.ForEach(y =>
                    {
                        //Look for the prior version sent
                        var poskutobecompared = poskusOutputprev.POSkus.Find(posku => posku.SKU == y.SKU);

                        if (poskutobecompared == null)
                        {
                            //Never sent before.  Only send if the posku status isn't canceled/voided
                            if (y.StatusCode != "CN" && y.StatusCode != "VD")
                            {
                                y.ActivityCode = "A";
                            }
                        }
                        else
                        {
                            if ((y.StatusCode == "CN" || y.StatusCode == "VD"))
                            {
                                //This one is canceled/voided.  If it was open the last time we sent it, send as a "D".  Otherwise, we'll skip it
                                if (poskutobecompared.StatusCode == "OP")
                                {
                                    y.ActivityCode = "D";
                                }
                            }
                            else if (poupdated)
                            {
                                //Parent PO was modified, so all the child skus are considered modified
                                y.ActivityCode = "U";
                            }
                            else
                            {
                                //Parent PO hasn't changed.  See if the sku line was modified
                                int propertyCountskus = typeof(POIntertekOutput).GetProperties().Length;
                                CompareLogic basicComparisonposkus = new CompareLogic()
                                {
                                    Config = new ComparisonConfig()
                                    {
                                        MaxDifferences = propertyCountskus
                                    }
                                };
                                List <Difference> diffposkus = basicComparison.Compare(y, poskutobecompared).Differences;

                                if (diffposkus != null && diffposkus.Any(d => d.PropertyName != "ActivityCode"))//ignore the activitycode for comparison
                                {
                                    y.ActivityCode = "U";
                                }
                            }
                        }
                    });
                }
                var finalupdated = poskusOutputcurrent.POSkus.Where(posku => posku.ActivityCode != null);
                if (finalupdated != null)
                {
                    POIntertekOutput POIntertekOutputtobesent = new POIntertekOutput
                    {
                        PONumber        = poskusOutputcurrent.PONumber,
                        POSkus          = finalupdated.ToList(),
                        CancelDate      = poskusOutputcurrent.CancelDate,
                        DeliveryDate    = poskusOutputcurrent.DeliveryDate,
                        EmployeeId      = poskusOutputcurrent.EmployeeId,
                        LocationNumber  = poskusOutputcurrent.LocationNumber,
                        ShipDate        = poskusOutputcurrent.ShipDate,
                        VendorName      = poskusOutputcurrent.VendorName,
                        SubVendorNumber = poskusOutputcurrent.SubVendorNumber,
                        DistributorId   = poskusOutputcurrent.DistributorId,
                        LOB             = poskusOutputcurrent.LOB
                    };
                    return(POIntertekOutputtobesent);
                }

                return(new POIntertekOutput());
            }
            catch (Exception ex)
            {
                _logger.LogError("Method Name -- CompareIntertekData : {Reason}", ex.Message);
                return(new POIntertekOutput());
            }
        }
 public static POIntertekOutput MapEventtoOutput(this MMSPOSkuEvent entity, POIntertekOutput pointertek)
 {
     //POSkuevent will not come so this will never be called
     //pointertek.UpdatePOIntertekPoSkuData(entity);
     return(pointertek);
 }
 public static POIntertekOutput MapEventtoOutput(this MMSPOEvent entity, POIntertekOutput poIntertek)
 {
     poIntertek.UpdateIntertekData(entity);
     return(poIntertek);
 }