Esempio n. 1
0
        protected virtual IEnumerable dummyCustomAction(PXAdapter adapter)
        {
            SOShipment      shipment        = Base.Document.Current;
            SOOrderShipment soOrderShipment = PXSelect <SOOrderShipment,
                                                        Where <SOOrderShipment.shipmentNbr, Equal <Required <SOOrderShipment.shipmentNbr> > > > .
                                              Select(Base, shipment.ShipmentNbr);

            ARInvoice arInvoice = PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >,
                                                              And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .
                                  Select(Base, soOrderShipment.InvoiceNbr, "INV");

            PXLongOperation.StartOperation(Base, delegate()
            {
                SOInvoiceEntry soInvoiceGraph   = PXGraph.CreateInstance <SOInvoiceEntry>();
                SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance <SOShipmentEntry>();
                //Release Sales Invoice
                soInvoiceGraph.Clear();
                soInvoiceGraph.Document.Current = soInvoiceGraph.Document.Search <ARInvoice.docType, ARInvoice.refNbr>(arInvoice.DocType, arInvoice.RefNbr);
                soInvoiceGraph.release.Press();
                //Update IN on Shipment
                soShipmentGraph.Clear();
                soShipmentGraph.Document.Current = soShipmentGraph.Document.Search <SOShipment.shipmentNbr>(shipment.ShipmentNbr);
                soShipmentGraph.UpdateIN.Press();
            });
            return(adapter.Get());
        }
        private static void UpdateFeedStatus(SubmitFeedParamaters objParams)
        {
            if (objParams != null && objParams.importOrderStatus)
            {
                SOShipment currentshipment = objParams.objPartialMaint.Shipment.Select(objParams.shipmentType, objParams.shipmentNbr);
                if (currentshipment != null)
                {
                    SOShipmentAmazonExt currentshipmentext = currentshipment.GetExtension <SOShipmentAmazonExt>();
                    if (currentshipmentext != null)
                    {
                        objParams.objPartialMaint.Shipment.SetValueExt <SOShipmentAmazonExt.usrSubmitFeedupdate>(currentshipment, true);
                        objParams.objPartialMaint.Shipment.Cache.Update(currentshipment);
                    }
                }
            }
            SOSubmitProcessLog processUpdateCount = null;

            if (objParams != null && objParams.objSOAmazonSetup != null && objParams.processID != null)
            {
                processUpdateCount = objParams.objPartialMaint.UpdateFeedProcessLog.Select(objParams.objSOAmazonSetup.IntegrationID, objParams.processID);
            }
            if (processUpdateCount == null)
            {
                return;
            }
            processUpdateCount.SubmitRecordsCount       = objParams.importOrderStatus ? processUpdateCount.SubmitRecordsCount + 1 : processUpdateCount.SubmitRecordsCount;
            processUpdateCount.SubmitFailedRecordsCount = objParams.importOrderStatus == false ? processUpdateCount.SubmitFailedRecordsCount + 1 : processUpdateCount.SubmitFailedRecordsCount;
            objParams.objPartialMaint.UpdateFeedProcessLog.Update(processUpdateCount);
        }
        public ODataShipment GetAPIShipment(SOShipment shipment, SOPackageDetail package, PXResultset <SOLine> lines)
        {
            var wrapper     = new ODataShipment();
            var apiShipment = new KCAPIShipment()
            {
                ShippedDateUtc  = shipment.ShipDate,
                TrackingNumber  = package?.TrackNumber,
                ShippingCarrier = shipment.ShipVia,
                ShippingClass   = shipment.ShipVia,
                DeliveryStatus  = "Complete"
            };
            var apiItems = new List <KCAPIShipmentItem>();

            foreach (PXResult <SOLine> line in lines)
            {
                SOLine     soLine   = line.GetItem <SOLine>();
                SOShipLine shipLine = line.GetItem <SOShipLine>();
                DAC.KNSIKCInventoryItem kcInventoryItem    = line.GetItem <DAC.KNSIKCInventoryItem>();
                InventoryItem           inventoryItem      = line.GetItem <InventoryItem>();
                InventoryItemPCExt      inventoryItemPcExt = inventoryItem.GetExtension <InventoryItemPCExt>();
                SOLinePCExt             soLinePcExt        = soLine.GetExtension <SOLinePCExt>();

                int quantity = Convert.ToInt32(shipLine.ShippedQty.GetValueOrDefault());

                if ((soLine.LineNbr != soLinePcExt?.UsrKNMasterLineNbr && ParentIsGrouped(lines, soLinePcExt)) ||
                    (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.ConfigurableProduct && soLine.LineNbr == soLinePcExt?.UsrKNMasterLineNbr))
                {
                    continue;
                }

                if (inventoryItemPcExt?.UsrKNCompositeType == KCConstants.GroupedProduct && quantity == 0)
                {
                    SOShipLine childItem = lines.Where(x => x.GetItem <SOLine>().GetExtension <SOLinePCExt>().UsrKNMasterLineNbr == soLine.LineNbr &&
                                                       x.GetItem <SOLine>().LineNbr != soLine.LineNbr).RowCast <SOShipLine>().FirstOrDefault();

                    if (childItem != null)
                    {
                        KCDataExchangeMaint     graph          = PXGraph.CreateInstance <KCDataExchangeMaint>();
                        List <KNSIGroupedItems> origChildItems = graph.GroupedChildItems.Select(inventoryItem.InventoryID).RowCast <KNSIGroupedItems>().ToList();
                        quantity = Convert.ToInt32(childItem.ShippedQty / origChildItems.Where(x => x.MappedInventoryID == childItem.InventoryID).FirstOrDefault().Quantity);
                    }
                    else
                    {
                        throw new KCCorruptedShipmentException();
                    }
                }

                apiItems.Add(new KCAPIShipmentItem
                {
                    ProductID   = kcInventoryItem?.UsrKCCAID.ToString(),
                    OrderItemID = soLine?.GetExtension <KCSOLineExt>()?.UsrKCOrderItemID.ToString(),
                    Quantity    = shipLine == null ? 0 : Convert.ToInt32(quantity)
                });
            }

            apiShipment.Items = apiItems;
            wrapper.Value     = apiShipment;

            return(wrapper);
        }
        public void ShipPackages(SOShipment shiporder, Action <SOShipment> baseMethod)
        {
            if (shiporder.Operation == SOOperation.Issue)
            {
                if (String.IsNullOrEmpty(shiporder.ShipVia) || shiporder.ShipVia == "FREESHIP" || shiporder.ShipVia == "GROUND" || shiporder.ShipVia == "OVERNIGHT" || shiporder.ShipVia == "2DAY")
                {
                    Base.Clear();
                    Base.Document.Current = Base.Document.Search <SOShipment.shipmentNbr>(shiporder.ShipmentNbr);
                    shiporder             = Base.Document.Current;

                    SOPackageDetail p = Base.Packages.SelectSingle();
                    if (p == null)
                    {
                        throw new PXException(PX.Objects.SO.Messages.PackageIsRequired);
                    }

                    SelectLeastExpensiveShipVia();
                }
                else
                {
                    PXTrace.WriteInformation("Skipping rate shopping because a Ship Via is already selected.");
                }
            }

            var sw = new Stopwatch();

            sw.Start();
            baseMethod(shiporder);
            sw.Stop();
            PXTrace.WriteInformation($"ShipPackages took {sw.ElapsedMilliseconds}ms.");
        }
        protected void SOShipment_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting baseMethod)
        {
            baseMethod(cache, e);

            SOShipment row = e.Row as SOShipment;

            if (row != null && e.Operation == PXDBOperation.Insert)
            {
                SOShipmentExt shipmentExt = row.GetExtension <SOShipmentExt>();
                foreach (PXResult <SOOrderShipment, SOOrder> result in Base.OrderList.Select())
                {
                    var order    = (SOOrder)result;
                    var orderExt = order.GetExtension <SOOrderExt>();

                    // As soon as we encounter an order marked Prime, we consider the shipment to be an Amazon Prime shipment.
                    if (orderExt.UsrISPrimeOrder == true)
                    {
                        shipmentExt.UsrISPrimeOrder = true;
                    }

                    if (shipmentExt.UsrDeliverByDate == null || orderExt.UsrDeliverByDate < shipmentExt.UsrDeliverByDate)
                    {
                        shipmentExt.UsrDeliverByDate = orderExt.UsrDeliverByDate;
                    }

                    if (orderExt.UsrGuaranteedDelivery == true)
                    {
                        shipmentExt.UsrGuaranteedDelivery = true;
                    }
                }
            }
        }
 private void UpdateShipmentTotals(SOShipment shipment)
 {
     shipment.ShipmentQty = GetLinesQty(Base.Transactions.Select().RowCast <SOShipLine>().ToList());
     shipment.ControlQty  = GetLinesQty(Base.Transactions.Select().RowCast <SOShipLine>().ToList());
     foreach (SOOrderShipment line in Base.OrderList.Select().RowCast <SOOrderShipment>())
     {
         line.ShipmentQty = GetLinesQty(Base.Transactions.Select().RowCast <SOShipLine>().Where(x => x.OrigOrderNbr.Equals(line.OrderNbr)).ToList());
     }
 }
        public virtual IEnumerable viewShipment(PXAdapter adapter)
        {
            if (SubmitFeedList.Current != null)
            {
                SOShipmentEntry graph    = PXGraph.CreateInstance <SOShipmentEntry>();
                SOShipment      shipment = PXSelect <SOShipment, Where <SOShipment.shipmentNbr, Equal <Required <SOShipment.shipmentNbr> > > > .Select(graph, SubmitFeedList.Current.ShipmentNbr);

                graph.Document.Current = shipment;
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            return(adapter.Get());
        }
Esempio n. 8
0
        public bool CheckShippingCarrier(KCShipmentAPIHelper helper, SOShipment shipment)
        {
            APIResultOfArrayOfShippingCarrier carriers = helper.GetShippingCarriers();

            if (shipment.ShipVia != null)
            {
                return(carriers.ResultData.Any(x => x.CarrierName.Equals(shipment.ShipVia)));
            }
            else
            {
                return(true);
            }
        }
Esempio n. 9
0
 public void ShipPackages(SOShipment shiporder, ShipPackagesBaseDelegate BaseInvoke)
 {
     #region Custom-code-to-rotate-retrieved-Label
     PXGraph.InstanceCreated.AddHandler <UploadFileMaintenance>((fileGraph) =>
     {
         fileGraph.RowInserted.AddHandler <UploadFileRevision>((sender, e) =>
         {
             UploadFileRevision fileData = (UploadFileRevision)e.Row;
         });
     });
     #endregion
     //Invoke base method
     BaseInvoke(shiporder);
 }
Esempio n. 10
0
        public static SOShipment GetSOShipment(SOOrder acumaticaOrder, KCAPIFulfillment fulfillment,
                                               SOShipment acumaticaShipment)
        {
            SOOrderEntry      orderGraph  = PXGraph.CreateInstance <SOOrderEntry>();
            KCSiteMasterMaint masterGraph = PXGraph.CreateInstance <KCSiteMasterMaint>();

            acumaticaShipment.Operation          = INDocType.Issue;
            acumaticaShipment.CustomerID         = acumaticaOrder.CustomerID;
            acumaticaShipment.CustomerLocationID = acumaticaOrder.CustomerLocationID;
            acumaticaShipment.SiteID             = masterGraph.SiteMaster.SelectSingle().SiteID;
            acumaticaShipment.ShipDate           = fulfillment.UpdatedDateUtc.DateTime;

            acumaticaShipment.GetExtension <KCSOShipmentExt>().UsrKCCAFulfillmentID = fulfillment.ID;

            return(acumaticaShipment);
        }
        public void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder, Action <SOOrderEntry, SOShipment> baseMethod)
        {
            baseMethod(docgraph, shiporder);

            SOPackageDetail TNbr = FirstTrackingNumber.Select(shiporder.ShipmentNbr);

            if (TNbr != null)
            {
                SOOrderShipment ShipNbr = OrderShipment.Select(shiporder.ShipmentType, shiporder.ShipmentNbr);
                if (ShipNbr != null)
                {
                    ShipNbr.GetExtension <SOOrderShipmentExt>().UsrShipmentTrackingNbr = TNbr.TrackNumber;
                    OrderShipment.Cache.Update(ShipNbr);
                    Base.Save.Press();
                }
            }
        }
Esempio n. 12
0
        public virtual INRegisterEntryBase GetOrCreateINRegisterEntry(SOShipment shipment)
        {
            if (shipment.ShipmentType == _lastShipmentType)
            {
                _lastCreatedGraph.Clear();
                return(_lastCreatedGraph);
            }

            var ie = (shipment.ShipmentType == SOShipmentType.Transfer)
                                ? (INRegisterEntryBase)PXGraph.CreateInstance <INTransferEntry>()
                                : (INRegisterEntryBase)PXGraph.CreateInstance <INIssueEntry>();

            _shipGraph.MergeCachesWithINRegisterEntry(ie);

            _lastShipmentType = shipment.ShipmentType;
            _lastCreatedGraph = ie;

            return(ie);
        }
 public void ShipPackages(SOShipment shiporder, ShipPackagesBaseDelegate BaseInvoke)
 {
     #region Custom-code-to-rotate-retrieved-Label
     //Identify specified Ship-Via/Carrier Shipment is working with
     var carrier = Carrier.PK.Find(Base, shiporder.ShipVia);
     //If specified Ship-Via/Carrier is API/Plug-In based
     if (carrier?.IsExternal == true)
     {
         //Identify Connected Carrier Plug-In
         var plugin = CarrierPlugin.PK.Find(Base, carrier.CarrierPluginID);
         //If Plug-In is working with UPS
         if (plugin?.PluginTypeName?.Trim() == typeof(PX.UpsCarrier.UpsCarrier).FullName)
         {
             PXGraph.InstanceCreated.AddHandler <UploadFileMaintenance>((fileGraph) =>
             {
                 fileGraph.RowInserted.AddHandler <UploadFileRevision>((sender, e) =>
                 {
                     UploadFile fileInfo = (UploadFile)sender.Graph.Caches <UploadFile>()?.Current;
                     if (fileInfo != null)
                     {
                         if (fileInfo.Name.StartsWith("Label #") && (fileInfo.Extansion.ToUpper() == "GIF"))
                         {
                             UploadFileRevision fileData = (UploadFileRevision)e.Row;
                             using (MemoryStream fileMemoryStream = new MemoryStream(fileData?.Data))
                             {
                                 Image labelImage = Image.FromStream(fileMemoryStream);
                                 if (labelImage != null)
                                 {
                                     labelImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                                     ImageConverter imgConverter = new ImageConverter();
                                     fileData.Data = (byte[])imgConverter.ConvertTo(labelImage, typeof(byte[]));
                                 }
                             }
                         }
                     }
                 });
             });
         }
     }
     #endregion
     //Invoke base method
     BaseInvoke(shiporder);
 }
Esempio n. 14
0
        public static T GetSOPackageDetail <T>(KCAPIFulfillment fulfillment, T acumaticaPackage, SOShipment shipment, string boxID)
        {
            KCSiteMasterMaint graph     = PXGraph.CreateInstance <KCSiteMasterMaint>();
            decimal?          boxWeight = KCGeneralDataHelper.GetBoxWeight(graph, boxID);

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(acumaticaPackage))
            {
                switch (property.DisplayName)
                {
                case "Confirmed":
                    property.SetValue(acumaticaPackage, true);
                    break;

                case "Weight":
                    property.SetValue(acumaticaPackage, boxWeight + shipment.ShipmentWeight);
                    break;

                case "TrackNumber":
                    property.SetValue(acumaticaPackage, fulfillment.TrackingNumber);
                    break;

                case "ShipmentNbr":
                    property.SetValue(acumaticaPackage, shipment.ShipmentNbr);
                    break;
                }
            }

            return(acumaticaPackage);
        }
Esempio n. 15
0
        public void ExportShipments(KCStore store)
        {
            if (store.DateTo < store.DateFrom)
            {
                throw new PXException(KCMessages.DateToBiggerThanDateFrom);
            }
            if (store.DateTo.GetValueOrDefault() != default)
            {
                store.DateTo = store.DateTo.GetValueOrDefault().AddDays(1);
            }
            bool anyExported             = false;
            KCDataExchangeMaint    graph = PXGraph.CreateInstance <KCDataExchangeMaint>();
            SOOrderShipmentProcess orderShipmentGraph = PXGraph.CreateInstance <SOOrderShipmentProcess>();

            KCSiteMaster        connection     = graph.Connection.Select().RowCast <KCSiteMaster>().Where(x => x.SiteMasterCD.Equals(store.SiteMasterCD)).First();
            KCARestClient       client         = new KCARestClient(connection);
            KCOrderAPIHelper    helperOrder    = new KCOrderAPIHelper(client);
            KCShipmentAPIHelper helperShipment = new KCShipmentAPIHelper(client);

            List <SOOrder> orders = graph.Orders.Select().RowCast <SOOrder>().Where(x =>
                                                                                    x.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("/Non-FBA") == true).ToList();

            foreach (SOOrder order in orders)
            {
                IEnumerable <SOOrderShipment> orderShipments = KCGeneralDataHelper.GetOrderShipmentsByOrderNbr(graph, order.OrderNbr);
                if (orderShipments == null)
                {
                    continue;
                }

                foreach (SOOrderShipment orderShipment in orderShipments)
                {
                    if (!CheckData(orderShipment, store.DateFrom, store.DateTo))
                    {
                        continue;
                    }
                    PXResultset <SOLine> lines    = graph.OrderLines.Select(orderShipment.ShipmentNbr);
                    SOShipment           shipment = KCGeneralDataHelper.GetShipmentByShipmentNbr(orderShipmentGraph, orderShipment.ShipmentNbr);
                    if (!CheckShippingCarrier(helperShipment, shipment))
                    {
                        logger.Information(KCMessages.ShipViaDoesnotExist(shipment.ShipmentNbr));
                        continue;
                    }
                    KCSOShipmentExt shipmentKCExt  = shipment?.GetExtension <KCSOShipmentExt>();
                    SOPackageDetail package        = KCGeneralDataHelper.GetPackageByShipmentNbr(orderShipmentGraph, orderShipment.ShipmentNbr);
                    KCSOOrderExt    orderExt       = order.GetExtension <KCSOOrderExt>();
                    KCMapShipment   shipmentMapper = new KCMapShipment();

                    int?customerOrderNbr = Convert.ToInt32(order.CustomerOrderNbr);

                    if (shipment != null && orderShipment.Confirmed.GetValueOrDefault() &&
                        KCGeneralDataHelper.GetExistingCAOrderById(helperOrder, customerOrderNbr) != null && shipmentKCExt?.UsrKCExported != true)

                    {
                        string          log;
                        KCErrorResponse response = new KCErrorResponse();
                        logger.SetParentAndEntityIds(order.OrderNbr, shipment.ShipmentNbr);

                        try
                        {
                            response = helperShipment.MarkTheOrderAsShipped(shipmentMapper.GetAPIShipment(shipment, package, lines), customerOrderNbr);
                        }
                        catch (Exception ex)
                        {
                            log = KCMessages.CorruptedShipment(shipment.ShipmentNbr);
                            logger.Information(log);
                            continue;
                        }


                        if (response != null)
                        {
                            log = KCMessages.ShipmentExportFailure(shipment.ShipmentNbr, response.Error.Message);
                        }
                        else
                        {
                            shipmentKCExt.UsrKCExported = true;
                            orderShipmentGraph.Shipments.Update(shipment);
                            orderShipmentGraph.Save.Press();
                            anyExported = true;
                            log         = KCMessages.ShipmentExported(shipment.ShipmentNbr);
                        }

                        logger.Information(log);
                    }
                }
            }

            logger.ClearLoggingIds();
            logger.Information(anyExported ? KCMessages.ShipmentExportSuccess : KCMessages.NoShipmentsToExport);
        }
        protected virtual void SOShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
        {
            baseHandler?.Invoke(sender, e);

            if (e.Row == null)
            {
                return;
            }

            SOShipment      row           = (SOShipment)e.Row;
            KCSOShipmentExt rowKCExt      = row.GetExtension <KCSOShipmentExt>();
            SOOrderShipment orderShipment = PXSelect <SOOrderShipment, Where <SOOrderShipment.shipmentNbr,
                                                                              Equal <Required <SOOrderShipment.shipmentNbr> > > > .Select(Base, row.ShipmentNbr);

            if (orderShipment != null)
            {
                SOOrder order = PXSelect <SOOrder, Where <SOOrder.orderNbr,
                                                          Equal <Required <SOOrder.orderNbr> > > > .Select(Base, orderShipment.OrderNbr);

                bool?FBA         = order?.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("/FBA");
                var  buttonMenus = (Base.Actions["action"].GetState(null) as PXButtonState)?.Menus;

                if (FBA == true)
                {
                    bool enable = Base.Accessinfo.ScreenID == "KC.50.10.00";

                    var reportMenus = (Base.report.GetState(null) as PXButtonState)?.Menus;

                    foreach (var action in reportMenus)
                    {
                        action.Enabled = enable;
                    }

                    foreach (var action in buttonMenus)
                    {
                        if (action.Text != "Prepare Invoice")
                        {
                            action.Enabled = enable;
                        }
                    }

                    Base.Actions["InventorySummary"].SetEnabled(enable);
                    Base.Actions["LSSOShipLine_binLotSerial"].SetEnabled(enable);
                    Base.CarrierRatesExt.recalculatePackages.SetEnabled(enable);
                    Base.UpdateIN.SetEnabled(enable);
                    Base.Delete.SetEnabled(enable);

                    sender.AllowUpdate = enable;

                    Base.Transactions.Cache.AllowInsert = enable;
                    Base.Transactions.Cache.AllowUpdate = enable;
                    Base.Transactions.Cache.AllowDelete = enable;

                    Base.OrderList.View.AllowInsert = enable;
                    Base.OrderList.View.AllowUpdate = enable;
                    Base.OrderList.View.AllowDelete = enable;
                }
                else if (rowKCExt?.UsrKCExported == true)
                {
                    foreach (var action in buttonMenus)
                    {
                        if (action.Text.Equals("Correct Shipment"))
                        {
                            action.Enabled = false;
                        }
                    }
                }
            }
        }
        public virtual void AmazonSubmitFeed(List <ProjectionShipmentDAC> list, SubmitFeedFilter currentFilter)
        {
            SOPartialMaint logGraph  = PXGraph.CreateInstance <SOPartialMaint>();
            int?           processId = list.Count > 0 ? SOLogService.LogSubmitCount(logGraph, currentFilter.IntegrationID, list.Count) : null;

            if (!(processId > 0))
            {
                return;
            }
            SubmitFeedParamaters objSubmitFeedParams = null;
            StringBuilder        sbXmlFeedData       = new StringBuilder();

            objEnvelope = new AmazonEnvelope();
            objHeader   = new Header();
            objHeader.DocumentVersion = SOConstants.documentVersion;
            objEnvelope.MessageType   = SOConstants.orderFulfillment;
            objEnvelope.Header        = objHeader;
            List <Message> liMsgContent       = new List <Message>();
            UTF8Encoding   encoding           = new UTF8Encoding();
            double         megaBytesLength    = 0.0d;
            bool           isErrorOccured     = false;
            Regex          xmlEmptytagsRemove = new Regex(@"(\s)*<(\w:\w|\w)*(\s)*/>");

            AMSubmitFeedServiceCall.AmazonEnvelope resAMEnv = null;
            List <Item> listItems = null;

            foreach (ProjectionShipmentDAC currentRecord in list)
            {
                SOAmazonSetup objSOAmazonSetup = null;
                Item          objitem          = null;
                SOHelper.MarketplaceConfigurations(logGraph, currentFilter.IntegrationID, out objSOAmazonSetup);
                objHeader.MerchantIdentifier = objSOAmazonSetup.SellerId;
                objSubmitFeedParams          = new SubmitFeedParamaters();
                listItems = new List <Item>();
                try
                {
                    logGraph.Clear();
                    foreach (PXResult <SOShipment, SOShipLine, Carrier, SOPackageDetail> result in PXSelectJoin <SOShipment, InnerJoin <SOShipLine, On <SOShipment.shipmentType, Equal <SOShipLine.shipmentType>,
                                                                                                                                                        And <SOShipment.shipmentNbr, Equal <SOShipLine.shipmentNbr> > >,
                                                                                                                                        InnerJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >,
                                                                                                                                                   LeftJoin <SOPackageDetail, On <SOPackageDetail.shipmentNbr, Equal <SOShipLine.shipmentNbr> > > > >,
                                                                                                                 Where <SOShipLine.shipmentNbr, Equal <Required <SOShipLine.shipmentNbr> > >,
                                                                                                                 OrderBy <Desc <SOPackageDetail.lineNbr> > > .Select(logGraph, currentRecord.ShipmentNbr))
                    {
                        SOShipment      objShipment       = (SOShipment)result;
                        SOShipLine      objShipLine       = (SOShipLine)result;
                        Carrier         objCarrier        = (Carrier)result;
                        SOPackageDetail objPackageDetails = (SOPackageDetail)result;
                        objitem = null;
                        if (objShipment != null && objShipLine != null && objPackageDetails != null && objPackageDetails.Confirmed != null && objPackageDetails.Confirmed == true && !string.IsNullOrEmpty(objPackageDetails.TrackNumber))
                        {
                            SOShipmentAmazonExt objShipmentExt = PXCache <SOShipment> .GetExtension <SOShipmentAmazonExt>(objShipment);

                            objSubmitFeedParams.soType       = objShipLine.OrigOrderType;
                            objSubmitFeedParams.acmOrderNbr  = objShipLine.OrigOrderNbr;
                            objSubmitFeedParams.shipmentType = objShipment.ShipmentType;
                            objSubmitFeedParams.shipmentNbr  = objShipment.ShipmentNbr;
                            objSubmitFeedParams.shipmentDate = objShipment.ShipDate;
                            objSubmitFeedParams.carrierCode  = !String.IsNullOrEmpty(objShipmentExt.UsrAmazonCarrierCode) ?
                                                               objShipmentExt.UsrAmazonCarrierCode : objShipment.ShipVia;
                            objSubmitFeedParams.shipVia = (objCarrier == null || String.IsNullOrEmpty(objCarrier.PluginMethod)) ?
                                                          objShipment.ShipVia : objCarrier.PluginMethod;
                            objSubmitFeedParams.trackingNbr = objPackageDetails.TrackNumber;
                            SOShipLineAmazonExt objShLineExt = objShipLine.GetExtension <SOShipLineAmazonExt>();
                            objSubmitFeedParams.amazonOrderID = objShLineExt != null && !string.IsNullOrEmpty(objShLineExt.UsrAmazonOrderID) ?
                                                                objShLineExt.UsrAmazonOrderID : string.Empty;
                            objitem = new Item();
                            objitem.AmazonOrderItemCode = objShLineExt != null && !string.IsNullOrEmpty(objShLineExt.UsrAMOrderItemID) ?
                                                          objShLineExt.UsrAMOrderItemID : string.Empty;
                            objitem.Quantity = objShipLine != null?Convert.ToInt32(objShipLine.ShippedQty) : 0;

                            listItems.Add(objitem);
                        }
                        else
                        {
                            throw new PXException(SOMessages.shipmentDetailsMissing);
                        }
                    }
                    objSubmitFeedParams.objPartialMaint     = logGraph;
                    objSubmitFeedParams.indexOfCurrentOrder = list.IndexOf(currentRecord);
                    objSubmitFeedParams.objSOAmazonSetup    = objSOAmazonSetup;
                    objSubmitFeedParams.processID           = processId;
                    if (listItems != null && listItems.Count > 0)
                    {
                        objSubmitFeedParams.liShipItem = listItems;
                    }
                    Message objMessage = GetListOfMessagesContent(objSubmitFeedParams);
                    if (objMessage.MessageID != null)
                    {
                        liMsgContent.Add(objMessage);
                    }
                }
                catch (Exception ex)
                {
                    isErrorOccured = true;
                    objSubmitFeedParams.feedMessage       = ex.Message;
                    objSubmitFeedParams.importOrderStatus = false;
                    objSubmitFeedParams.xmlMessage        = string.Empty;
                    SOLogService.LogSubmitStatus(objSubmitFeedParams);
                    PXProcessing <ProjectionShipmentDAC> .SetError(list.IndexOf(currentRecord), ex.Message);
                }
            }
            objEnvelope.MessageBody = SOConstants.messagebody;
            string resultFeed = SOHelper.ObjectToXMLConversion(objEnvelope, SOConstants.amazonEnvelope, false);

            if (liMsgContent.Count > 0)
            {
                foreach (Message listobj in liMsgContent)
                {
                    if (megaBytesLength >= SOConstants.feedSize)
                    {
                        break;
                    }
                    sbXmlFeedData.Append(SOHelper.ObjectToXMLConversion(listobj, SOConstants.messageBody, true) + SOConstants.getNewLine);
                    var byteData = encoding.GetBytes(sbXmlFeedData.ToString());
                    megaBytesLength = (byteData.Length / 1024f) / 1024f;
                }
                string xmlFeedContent = xmlEmptytagsRemove.Replace(resultFeed.Replace(SOConstants.msgbodyTag, Convert.ToString(sbXmlFeedData)), string.Empty);
                PXTrace.WriteInformation(xmlFeedContent);
                resAMEnv = new AMSubmitFeedServiceCall(clientFeed).InvokeServicesCalls(objSubmitFeedParams, xmlFeedContent);
            }
            if (resAMEnv != null && resAMEnv.Message != null && resAMEnv.Message.ProcessingReport != null && resAMEnv.Message.ProcessingReport.ProcessingSummary != null &&
                resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesProcessed == resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesSuccessful &&
                resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesWithError == 0)
            {
                foreach (ProjectionShipmentDAC currentRecord in list)
                {
                    UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, null);
                }
            }
            else if (resAMEnv != null && resAMEnv.Message != null && resAMEnv.Message.ProcessingReport != null &&
                     (resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesWithError > 0 ||
                      resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesSuccessful > 0))
            {
                bool isSubmitted;
                foreach (ProjectionShipmentDAC currentRecord in list)
                {
                    isSubmitted = false;
                    foreach (var item in resAMEnv.Message.ProcessingReport.Result.AsEnumerable().Where(x => x.MessageID == currentRecord.ShipmentNbr))
                    {
                        isSubmitted    = true;
                        isErrorOccured = true;
                        UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, item);
                    }
                    if (!isSubmitted)
                    {
                        UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, null);
                    }
                }
            }
            if (isErrorOccured)
            {
                throw new PXException(SOMessages.showErrorMsgFeeds);
            }
        }