コード例 #1
0
 public async void UpdatePOObjectForVendor(POAPLLOutput poobject, MMSSubVendorEvent vendor)
 {
     try
     {
         poobject.VendName = vendor.VendName;
         //poobject.ActivityCode = "U";
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "UpdatePOObjectForVendor - Failed Updating APLPO: {Reason}", ex.Message);
     }
 }
コード例 #2
0
        public static void UpdatePOAPLPoSkuData(this POAPLLOutput poapl, List <POSkus> poskus)
        {
            if (poskus != null && poskus.Count > 0)
            {
                List <POSkusOutput> poskustobeaddedtoPO = new List <POSkusOutput>();
                poapl.POSkus.ForEach(x =>
                {
                    var skutobeupdatefrom = poskus.Find(y => y.SKU == x.ItemNumber);
                    if (skutobeupdatefrom != null)
                    {
                        x.DeliveryDate        = skutobeupdatefrom.DeliveryDate?.ToString();
                        x.UnitCost            = skutobeupdatefrom.FirstCost != null ? Math.Round(skutobeupdatefrom.FirstCost.GetValueOrDefault(), 2).ToString(): "0";
                        x.RetailPrice         = skutobeupdatefrom.RetailPrice?.ToString();
                        x.ItemQty             = skutobeupdatefrom.BuyQuantity.HasValue ? skutobeupdatefrom.BuyQuantity.ToString() : "0";
                        x.ItemTotalQuantity   = skutobeupdatefrom.BuyQuantity.HasValue? skutobeupdatefrom.BuyQuantity.ToString() : "0";
                        x.CreateDate          = skutobeupdatefrom.CreateDate?.ToString();
                        x.ModifiedDate        = skutobeupdatefrom.ModifiedDate?.ToString();
                        x.ApprovalLetter      = skutobeupdatefrom.ApprovalLetter?.ToString();
                        x.SamplesRequired     = skutobeupdatefrom.SamplesRequired?.ToString();
                        x.EstimatedLandedCost = skutobeupdatefrom.EstimatedLandedCost != null? Math.Round(skutobeupdatefrom.EstimatedLandedCost.GetValueOrDefault(), 2).ToString() : "0";
                        x.DutyPctOfFOB        = skutobeupdatefrom.DutyPctOfFOB?.ToString();
                    }
                });

                //add the poskus if applicable
                var poskustobeadded = poskus.Where(x => !poapl.POSkus.Any(y => y.ItemNumber == x.SKU));
                poskustobeadded?.ToList().ForEach(y =>
                {
                    poskustobeaddedtoPO.Add(new POSkusOutput
                    {
                        ItemNumber          = y.SKU,
                        DeliveryDate        = y.DeliveryDate?.ToString(),
                        UnitCost            = y.FirstCost != null ? Math.Round(y.FirstCost.GetValueOrDefault(), 2).ToString() : "0",
                        RetailPrice         = y.RetailPrice?.ToString(),
                        ItemQty             = y.BuyQuantity.HasValue ? y.BuyQuantity.ToString() : "0",
                        ItemTotalQuantity   = y.BuyQuantity.HasValue ? y.BuyQuantity.ToString() : "0",
                        CreateDate          = y.CreateDate?.ToString(),
                        ModifiedDate        = y.ModifiedDate?.ToString(),
                        ApprovalLetter      = y.ApprovalLetter?.ToString(),
                        SamplesRequired     = y.SamplesRequired?.ToString(),
                        EstimatedLandedCost = y.EstimatedLandedCost != null ? Math.Round(y.EstimatedLandedCost.GetValueOrDefault(), 2).ToString() : "0",
                        DutyPctOfFOB        = y.DutyPctOfFOB?.ToString()
                    });
                });

                if (poskustobeadded?.ToList().Count > 0)
                {
                    poapl.POSkus.AddRange(poskustobeaddedtoPO);
                }
            }
        }
コード例 #3
0
        public static void UpdatePOAPL(this POAPLLOutput poapl, MMSPOEvent model)
        {
            poapl.StatusCode = model.StatusCode;
            //poapl.Mi9ChannelCode = model.Mi9ChannelCode;
            poapl.SubVendorNumber = model.SubVendorNumber;
            //poapl.Approved = model.Approved;
            poapl.WarehouseDueDate = model.DeliveryDate?.FormatTo();
            poapl.LastShipDate     = model.CancelDate?.FormatTo();
            poapl.EarlyShipDate    = model.ShipDate?.FormatTo();
            poapl.StoreCode        = model.LocationNumber;
            //poapl.Mi9POType = model.Mi9POType;
            //poapl.Terms = model.Terms;
            //poapl.PointofOwnership = model.PointofOwnership;
            poapl.BuyerCode = model.EmployeeID;
            //poapl.SeasonCode = model.SeasonCode;
            //poapl.CurrencyCode = model.CurrencyCode;
            //poapl.CalculatePOExtraCosts = model.CalculatePOExtraCosts;
            //poapl.AutoCloseFlag = model.AutoCloseFlag;

            //TODO
            //poapl.LOB=model.LOB;
        }
コード例 #4
0
 public static POAPLLOutput MapEventtoOutput(this MMSPOEvent entity, POAPLLOutput poapl)
 {
     poapl.UpdatePOAPL(entity);
     return(poapl);
 }
コード例 #5
0
 public static POAPLLOutput MapEventtoOutput(this MMSPOSkuEvent entity, POAPLLOutput poapl)
 {
     //POSkuevent will not come so this will never be called
     //poapl.UpdatePOAPLPoSkuData(entity);
     return(poapl);
 }
コード例 #6
0
 public static bool CheckPoStatus(this POAPLLOutput output)
 {
     return(output.StatusCode == "OP");
 }
コード例 #7
0
        public async void UpdatePOObject(POAPLLOutput 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.POProduct.Sku == posku.SKU))
                {
                    var poskutobeupdated = poobject.POSkus.Find(y => y.POProduct.Sku == posku.SKU);

                    poskutobeupdated.POProduct.CountryOfOrigin = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.CountryOfOrigin;
                    poskutobeupdated.POProduct.CasePackQty     = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.MasterPackQuantity.ToString();
                    poskutobeupdated.POProduct.VendorName      = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.SubVendor;

                    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.ItemDescription = product?.SkuDesc;
                    poskutobeupdated.POProduct.TariffCode      = product?.HTSCode;
                    // poskutobeupdated.ActivityCode = "U";
                }
                else
                {
                    POProductOutput poProductOutput = new POProductOutput
                    {
                        CountryOfOrigin = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.CountryOfOrigin,
                        CasePackQty     = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.MasterPackQuantity.ToString(),
                        VendorName      = product.ProductVendors.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendorNumber)?.SubVendor,

                        ClassCode      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Class,
                        DepartmentName = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Description,
                        ClassName      = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Description,
                        DepartmentCode = prodhierarchy.Find(y => y.SubClass == product.SubClass)?.Department,

                        ItemDescription = product?.SkuDesc,

                        TariffCode = product?.HTSCode,
                    };
                    POSkusOutput POSkusOutput = new POSkusOutput
                    {
                        PONumber          = posku.PONumber.ToString(),
                        ItemNumber        = posku.SKU,
                        ItemQty           = posku.BuyQuantity.HasValue ? posku.BuyQuantity.ToString() : "0",
                        ItemTotalQuantity = posku.BuyQuantity.HasValue ? posku.BuyQuantity.ToString() : "0",
                        UnitCost          = Math.Round(posku.FirstCost.GetValueOrDefault(), 2).ToString(),
                        POProduct         = poProductOutput,
                        //ActivityCode = "A",
                    };
                    if (poobject.POSkus == null)
                    {
                        poobject.POSkus = new System.Collections.Generic.List <POSkusOutput>();
                    }
                    poobject.POSkus.Add(POSkusOutput);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpdatePOObject - Failed Updating APLPO: {Reason}", ex.Message);
            }
        }
コード例 #8
0
        //mehod to compare 2 APL objects and return the POskulines that would be sent back
        public POAPLLOutput CompareAPLLData(POAPLLOutput outputcurrent, POAPLLOutput outputprevious)
        {
            try
            {
                bool         poupdated       = false;
                int          propertyCount   = typeof(POAPLLOutput).GetProperties().Length;
                CompareLogic basicComparison = new CompareLogic()
                {
                    Config = new ComparisonConfig()
                    {
                        MaxDifferences = propertyCount
                    }
                };
                List <Difference> diffs = basicComparison.Compare(outputcurrent, outputprevious).Differences;

                if (outputcurrent.POSkus != null && outputcurrent.POSkus.Count > 0)
                {
                    //deliberately set the activty code for poskus to null. later it will be "A"/"U" as applicable

                    outputcurrent.POSkus.ForEach(y =>
                    {
                        y.ActivityCode = null;
                    });
                }
                else
                {
                    _logger.LogInformation($"CompareAPLLData - Skipping output for PO - {outputcurrent.PONumber}; no SKUs were found.");
                    return(new POAPLLOutput());
                }
                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

                    outputcurrent.POSkus.ForEach(y =>
                    {
                        //Look for the prior version sent
                        var poskutobecompared = outputprevious.POSkus.Find(posku => posku.ItemNumber == y.ItemNumber);

                        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(POSkusOutput).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 = outputcurrent.POSkus.Where(posku => posku.ActivityCode != null);
                if (finalupdated != null)
                {
                    POAPLLOutput outputtosend = new POAPLLOutput
                    {
                        BuyerCode           = outputcurrent.BuyerCode,
                        ConsigneeNumber     = outputcurrent.ConsigneeNumber,
                        DutyPerPiece        = outputcurrent.DutyPerPiece,
                        EarlyShipDate       = outputcurrent.EarlyShipDate,
                        LastShipDate        = outputcurrent.LastShipDate,
                        PartialShipmentFlag = outputcurrent.PartialShipmentFlag,
                        PONumber            = outputcurrent.PONumber,
                        POSkus           = finalupdated.ToList(),
                        StatusCode       = outputcurrent.StatusCode,
                        StoreCode        = outputcurrent.StoreCode,
                        SubVendorNumber  = outputcurrent.SubVendorNumber,
                        VendName         = outputcurrent.VendName,
                        VendorShipDate   = outputcurrent.VendorShipDate,
                        WarehouseDueDate = outputcurrent.WarehouseDueDate
                    };
                    return(outputtosend);
                }

                return(new POAPLLOutput());
            }
            catch (Exception ex)
            {
                _logger.LogError("Method Name -- CompareAPLLData : {Reason}", ex.Message);
                return(new POAPLLOutput());
            }
        }