예제 #1
0
        public virtual void openDocument()
        {
            FSPostDoc postingBatchDetailRow = BatchDetailsInfo.Current;

            if (postingBatchDetailRow.PostedTO == ID.Batch_PostTo.SO)
            {
                if (PXAccess.FeatureInstalled <FeaturesSet.distributionModule>())
                {
                    SOOrderEntry graphSOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                    graphSOOrderEntry.Document.Current = graphSOOrderEntry.Document.Search <SOOrder.orderNbr>(postingBatchDetailRow.PostRefNbr, postingBatchDetailRow.PostDocType);
                    throw new PXRedirectRequiredException(graphSOOrderEntry, null)
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
            else if (postingBatchDetailRow.PostedTO == ID.Batch_PostTo.AR)
            {
                ARInvoiceEntry graphARInvoiceEntry = PXGraph.CreateInstance <ARInvoiceEntry>();
                graphARInvoiceEntry.Document.Current = graphARInvoiceEntry.Document.Search <ARInvoice.refNbr>(postingBatchDetailRow.PostRefNbr, postingBatchDetailRow.PostDocType);
                throw new PXRedirectRequiredException(graphARInvoiceEntry, null)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (postingBatchDetailRow.PostedTO == ID.Batch_PostTo.AP)
            {
                APInvoiceEntry graphAPInvoiceEntry = PXGraph.CreateInstance <APInvoiceEntry>();
                graphAPInvoiceEntry.Document.Current = graphAPInvoiceEntry.Document.Search <APInvoice.refNbr>(postingBatchDetailRow.PostRefNbr, postingBatchDetailRow.PostDocType);
                throw new PXRedirectRequiredException(graphAPInvoiceEntry, null)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
        }
예제 #2
0
        /// <summary>
        /// Create an sales order from external logistic.
        /// </summary>
        public static void ImportRecords(LUM3DCartSetup curSetup, LUM3DCartProcessOrder processOrder)
        {
            try
            {
                SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();

                SOOrder order = orderEntry.Document.Cache.CreateInstance() as SOOrder;

                order.OrderType        = curSetup.OrderType;
                order.CustomerID       = curSetup.CustomerID;
                order.CustomerOrderNbr = processOrder.OrderID;
                order.DocDate          = processOrder.OrderDate;

                order = orderEntry.Document.Insert(order);

                CreateOrderDetail(orderEntry, curSetup, order);

                orderEntry.Save.Press();

                CreatePaymentProcess(order);
            }
            catch (PXException ex)
            {
                PXProcessing.SetError <LUM3DCartProcessOrder>(ex.Message);
                throw;
            }
        }
        public virtual void openDocument()
        {
            ContractPostBatchDetail fsContractPostDocRow = ContractPostDocRecords.Current;

            if (fsContractPostDocRow == null)
            {
                return;
            }

            if (fsContractPostDocRow.PostedTO == ID.Batch_PostTo.SO)
            {
                if (PXAccess.FeatureInstalled <FeaturesSet.distributionModule>())
                {
                    SOOrderEntry graphSOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                    graphSOOrderEntry.Document.Current = graphSOOrderEntry.Document.Search <SOOrder.orderNbr>(fsContractPostDocRow.PostRefNbr, fsContractPostDocRow.PostDocType);
                    throw new PXRedirectRequiredException(graphSOOrderEntry, null)
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
            else if (fsContractPostDocRow.PostedTO == ID.Batch_PostTo.AR)
            {
                ARInvoiceEntry graphARInvoiceEntry = PXGraph.CreateInstance <ARInvoiceEntry>();
                graphARInvoiceEntry.Document.Current = graphARInvoiceEntry.Document.Search <ARInvoice.refNbr>(fsContractPostDocRow.PostRefNbr, fsContractPostDocRow.PostDocType);
                throw new PXRedirectRequiredException(graphARInvoiceEntry, null)
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
        }
예제 #4
0
        protected void _(Events.RowDeleting <POOrder> e)
        {
            var row = e.Row as POOrder;

            if (row == null)
            {
                return;
            }

            var        curPOOrder = (POOrder)Base.Caches[typeof(POOrder)].Current;
            POOrderExt pOOrderExt = curPOOrder.GetExtension <POOrderExt>();

            if ((bool)pOOrderExt.UsrICSOCreated)
            {
                var curUserName   = PXLogin.ExtractUsername(PXContext.PXIdentity.IdentityName);
                var curLMICVendor = PXSelect <LMICVendor, Where <LMICVendor.vendorid, Equal <Required <LMICVendor.vendorid> > > > .Select(Base, curPOOrder.VendorID).TopFirst;

                using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICVendor.LoginName}"))
                {
                    SOOrderEntry sOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>();

                    // check the shipment base on this SO is created or not
                    var isShipmentCreated = PXSelect <SOOrderShipment, Where <SOOrderShipment.orderNbr, Equal <Required <SOOrderShipment.orderNbr> > > > .Select(sOOrderEntry, row.VendorRefNbr).Count() > 0 ? true : false;

                    if (isShipmentCreated)
                    {
                        throw new PXException("You cannot delete the PO because there is shipment created in IC SO.");
                    }
                }
            }
        }
 private void openDocument(FSPostDet fsPostDetRow)
 {
     if (fsPostDetRow.SOPosted == true)
     {
         if (PXAccess.FeatureInstalled <FeaturesSet.distributionModule>())
         {
             SOOrderEntry graphSOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>();
             graphSOOrderEntry.Document.Current = graphSOOrderEntry.Document.Search <SOOrder.orderNbr>(fsPostDetRow.SOOrderNbr, fsPostDetRow.SOOrderType);
             throw new PXRedirectRequiredException(graphSOOrderEntry, null)
                   {
                       Mode = PXBaseRedirectException.WindowMode.NewWindow
                   };
         }
     }
     else if (fsPostDetRow.ARPosted == true)
     {
         ARInvoiceEntry graphARInvoiceEntry = PXGraph.CreateInstance <ARInvoiceEntry>();
         graphARInvoiceEntry.Document.Current = graphARInvoiceEntry.Document.Search <ARInvoice.refNbr>(fsPostDetRow.ARRefNbr, fsPostDetRow.ARDocType);
         throw new PXRedirectRequiredException(graphARInvoiceEntry, null)
               {
                   Mode = PXBaseRedirectException.WindowMode.NewWindow
               };
     }
     else if (fsPostDetRow.APPosted == true)
     {
         APInvoiceEntry graphAPInvoiceEntry = PXGraph.CreateInstance <APInvoiceEntry>();
         graphAPInvoiceEntry.Document.Current = graphAPInvoiceEntry.Document.Search <APInvoice.refNbr>(fsPostDetRow.APRefNbr, fsPostDetRow.APDocType);
         throw new PXRedirectRequiredException(graphAPInvoiceEntry, null)
               {
                   Mode = PXBaseRedirectException.WindowMode.NewWindow
               };
     }
 }
예제 #6
0
        internal static string GetStateID(SOOrderEntry graph, string stateName, string countryId)
        {
            State objstate = PXSelect <State, Where2 <Where <State.countryID, Equal <Required <State.countryID> > >,
                                                      And <Where <State.stateID, Equal <Required <State.stateID> >,
                                                                  Or <State.name, Equal <Required <State.name> > > > > > > .Select(graph, countryId, stateName, stateName);

            return(objstate != null && !string.IsNullOrEmpty(objstate.StateID) ? objstate.StateID : string.Empty);
        }
예제 #7
0
        /// <summary>
        /// Override billing, shipping contact & address.
        /// </summary>
        public static void UpdateSOContactAddress(SOOrderEntry orderEntry, List <MyArray> list, SOOrder order)
        {
            SOBillingContact billContact = orderEntry.Billing_Contact.Current;
            SOBillingAddress billAddress = orderEntry.Billing_Address.Current;

            order.ContactID = CreateSOContact(order.CustomerID, list[0]);

            billContact.OverrideContact = true;
            billContact.Attention       = list[0].BillingFirstName + "," + list[0].BillingLastName;
            billContact.FullName        = list[0].BillingCompany;
            billContact.Phone1          = list[0].BillingPhoneNumber;
            billContact.Email           = list[0].BillingEmail;

            orderEntry.Billing_Contact.Update(billContact);

            billAddress.OverrideAddress = true;
            billAddress.AddressLine1    = list[0].BillingAddress;
            billAddress.AddressLine2    = list[0].BillingAddress2;
            billAddress.City            = list[0].BillingCity;
            billAddress.CountryID       = list[0].BillingCountry;
            billAddress.PostalCode      = list[0].BillingZipCode;
            billAddress.State           = list[0].BillingState;

            orderEntry.Billing_Address.Update(billAddress);

            var shipList = list.Find(x => x.ShipmentList.Count > 0).ShipmentList;

            SOShippingContact shipContact = orderEntry.Shipping_Contact.Current;
            SOShippingAddress shipAddress = orderEntry.Shipping_Address.Current;

            for (int i = 0; i < shipList.Count; i++)
            {
                order.OrderDesc = string.IsNullOrEmpty(shipList[i].ShipmentTrackingCode) ? null : string.Format("Tracking Nbr. : {0}", shipList[i].ShipmentTrackingCode);

                orderEntry.Document.Cache.SetValueExt <SOOrder.curyPremiumFreightAmt>(order, (decimal)shipList[i].ShipmentCost);

                shipContact.OverrideContact = true;
                shipContact.Attention       = shipList[i].ShipmentFirstName + "," + shipList[i].ShipmentLastName;
                shipContact.FullName        = shipList[i].ShipmentCompany;
                shipContact.Phone1          = shipList[i].ShipmentPhone;
                shipContact.Email           = shipList[i].ShipmentEmail;

                orderEntry.Shipping_Contact.Update(shipContact);

                shipAddress.OverrideAddress = true;
                shipAddress.AddressLine1    = shipList[i].ShipmentAddress;
                shipAddress.AddressLine2    = shipList[i].ShipmentAddress2;
                shipAddress.City            = shipList[i].ShipmentCity;
                shipAddress.CountryID       = shipList[i].ShipmentCountry;
                shipAddress.PostalCode      = shipList[i].ShipmentZipCode;
                shipAddress.State           = shipList[i].ShipmentState;

                orderEntry.Shipping_Address.Update(shipAddress);
            }
        }
예제 #8
0
        internal static List <SOFieldMapping> GetUsrFieldMapping(SOOrderEntry graph, string integrationID)
        {
            List <SOFieldMapping> liUsrMapping = new List <SOFieldMapping>();

            foreach (SOFieldMapping usrFieldMapping in PXSelect <SOFieldMapping, Where <SOFieldMapping.isActive, Equal <True>, And <SOFieldMapping.integrationID, Equal <Required <SOFieldMapping.integrationID>
                                                                                                                                                                         > > > > .Select(graph, integrationID))
            {
                liUsrMapping.Add(usrFieldMapping);
            }
            return(liUsrMapping);
        }
예제 #9
0
        public static void PostOrder(SOPostShipmentFilter filter, List <SOOrder> list)
        {
            SOOrderEntry docgraph             = PXGraph.CreateInstance <SOOrderEntry>();
            DocumentList <INRegister> created = new DocumentList <INRegister>(docgraph);
            INIssueEntry ie = PXGraph.CreateInstance <INIssueEntry>();

            ie.FieldVerifying.AddHandler <INTran.projectID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
            ie.FieldVerifying.AddHandler <INTran.taskID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
            foreach (SOOrder order in list)
            {
                docgraph.PostOrder(ie, order, created);
            }
        }
예제 #10
0
 public virtual IEnumerable ViewDocument(PXAdapter adapter)
 {
     if (Orders.Current != null)
     {
         SOOrderEntry docgraph = PXGraph.CreateInstance <SOOrderEntry>();
         docgraph.Document.Current = docgraph.Document.Search <SOOrder.orderNbr>(Orders.Current.OrderNbr, Orders.Current.OrderType);
         throw new PXRedirectRequiredException(docgraph, true, "Order")
               {
                   Mode = PXBaseRedirectException.WindowMode.NewWindow
               };
     }
     return(adapter.Get());
 }
예제 #11
0
 internal static bool IsSOPreferencesDetailsExist(SOOrderEntry orderEntry, SOSetupAmazonExt objSOOSetupext)
 {
     if (orderEntry.sosetup.Current != null && objSOOSetupext != null && objSOOSetupext.UsrGuestCustID.HasValue &&
         !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonTaxZoneID) && !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonTaxID) &&
         !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonShipVia) && !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonPaymentMethodID) && objSOOSetupext.UsrAmazonInitialFromDate != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #12
0
        public static SOOrder GetSOOrder(SOOrderEntry orderGraph, KCAPIOrder order, SOOrder acumaticaOrder, int?branchID, bool FBA)
        {
            KCSiteMasterMaint graph = PXGraph.CreateInstance <KCSiteMasterMaint>();
            var customer            = KCGeneralDataHelper.GetCustomerByCAOrder(graph, order);
            var paymentmethod       = KCGeneralDataHelper.GetPaymenthMethodId(graph, order);
            var mapper          = new KCDynamicOrderMapper(KCMappingEntitiesConstants.Order);
            var conversionGraph = PXGraph.CreateInstance <KCOrderConversionDataMaint>();

            mapper.Mapping.MappingValues = conversionGraph.GetEntity();
            mapper.MapOrder(acumaticaOrder, order);
            if (paymentmethod == null)
            {
                KCPaymentMethodsMappingMaint paymentMethodMappingGraph = PXGraph.CreateInstance <KCPaymentMethodsMappingMaint>();
                CustomerPaymentMethodMaint   paymentMethodGraph        = PXGraph.CreateInstance <CustomerPaymentMethodMaint>();
                try
                {
                    KCGeneralDataHelper.CreatePaymentMethod(paymentMethodGraph, paymentMethodMappingGraph, customer.BAccountID, order);
                    paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order);
                }
                catch { }
            }
            acumaticaOrder.CustomerID       = customer.BAccountID;
            acumaticaOrder.PMInstanceID     = paymentmethod?.PMInstanceID;
            acumaticaOrder.Status           = SOOrderStatus.Open;
            acumaticaOrder.CreatePMInstance = true;
            KCSOOrderEntryExt orderext  = orderGraph.GetExtension <KCSOOrderEntryExt>();
            string            orderType = new KCMarketplaceHelper().GetOrderType(order, orderGraph);

            acumaticaOrder.OrderType = orderType ?? acumaticaOrder.OrderType;

            if (order.EstimatedShipDateUtc == null)
            {
                acumaticaOrder.RequestDate = acumaticaOrder.OrderDate;
            }
            orderGraph.CurrentDocument.Current = acumaticaOrder;

            PXNoteAttribute.SetNote(orderGraph.CurrentDocument.Cache, orderGraph.CurrentDocument.Current, order.PrivateNotes);
            string       firstName      = orderext.AccountCD.SelectSingle(acumaticaOrder.CustomerID).AcctName;
            bool         isFBAFirstName = firstName.Contains("FBA");
            KCSOOrderExt orderExt       = acumaticaOrder.GetExtension <KCSOOrderExt>();

            orderExt = mapper.MapOrderCaExt(orderExt, order);
            orderExt.UsrKCSyncDate  = DateTime.Now;
            orderExt.UsrKCSiteName += FBA ? "/FBA" : "/Non-FBA";
            if ((FBA && orderExt.UsrKCSiteName.Contains("Amazon")) || isFBAFirstName)
            {
                acumaticaOrder.Status = KCCheckoutStatus.CCompleted;
            }

            return(acumaticaOrder);
        }
예제 #13
0
        public void Test_Calculation_UnitPrice()
        {
            // Prepare Data
            SOOrderEntry graph = PrepareGraph();

            InsertINUnit(graph, "KG");
            InsertINUnit(graph, "LBS");

            var stockItem = (InventoryItem)graph.Caches[typeof(InventoryItem)].Insert(
                new InventoryItem
            {
                InventoryCD = "TESTITEM",
                BasePrice   = 500,
                BaseUnit    = "KG",
                SalesUnit   = "LBS"
            });

            graph.Caches[typeof(INUnit)].Insert(
                new INUnit
            {
                UnitType    = INUnitType.InventoryItem,
                InventoryID = stockItem.InventoryID,
                FromUnit    = "LBS",
                ToUnit      = "KG",
                UnitMultDiv = "D",
                UnitRate    = 2.2m
            });
            Customer customer = InsertCustomer(graph, "TestCustmer");

            // Execute Action
            SOOrder order = graph.Document.Insert(
                new SOOrder()
            {
                CustomerID         = customer.BAccountID,
                CustomerLocationID = customer.DefLocationID
            });

            SOLine orderLine = graph.Transactions.Insert(
                new SOLine()
            {
                InventoryID = stockItem.InventoryID,
                Qty         = 1
            });

            //Check the result
            Assert.Equal("LBS", orderLine.UOM);
            Assert.InRange(orderLine.CuryUnitPrice.Value, Math.Floor(500m / 2.2m), Math.Ceiling(500m / 2.2m));
        }
예제 #14
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();
                }
            }
        }
        public virtual System.Collections.IEnumerable ViewDocument(PXAdapter adapter)
        {
            PXCache       tCache = FixedDemand.Cache;
            SOFixedDemand line   = FixedDemand.Current;

            if (line == null)
            {
                return(adapter.Get());
            }

            SOOrderEntry graph = PXGraph.CreateInstance <SOOrderEntry>();

            graph.Document.Current = graph.Document.Search <SOOrder.orderNbr>(line.OrderNbr, line.OrderType);
            throw new PXRedirectRequiredException(graph, true, "View Document")
                  {
                      Mode = PXBaseRedirectException.WindowMode.NewWindow
                  };
        }
        public virtual void UpdateReportDetails(SOGetFBATrackingNumberProcess graph, List <SOProcessOrder> list, SOTrackingReportFilter currentFilter)
        {
            if (list.Count < 0)
            {
                return;
            }
            if (currentFilter.CurrentDay == false && Convert.ToInt32((Convert.ToDateTime(currentFilter.TODate) - Convert.ToDateTime(currentFilter.FromDate)).TotalDays) > SOConstants.limitForReports)
            {
                throw new PXException(SOMessages.ReportDateValidation);
            }
            SOAmazonSetup  objSOAmazonSetupDetails = null;
            SOOrderEntry   orderEntry      = PXGraph.CreateInstance <SOOrderEntry>();
            SOPartialMaint objPartialMaint = PXGraph.CreateInstance <SOPartialMaint>();

            orderEntry.Clear();
            InvokeReporstServicesCallResponse liShipmentResponse = null;
            bool isValidConfiguration = SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objSOAmazonSetupDetails);

            if (currentFilter.IntegrationID != null && currentFilter.ProcessAllTypes == false)
            {
                if (isValidConfiguration)
                {
                    liShipmentResponse = GetShipmentInformation(graph, currentFilter, objSOAmazonSetupDetails);
                }
                UpdateTrackingNumberDetails(graph, list, objSOAmazonSetupDetails, orderEntry, objPartialMaint, liShipmentResponse);
            }
            else if (string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true)
            {
                TrackingNumberOrdersList.Cache.Clear();
                foreach (SOAmazonSetup objSOAmazonSetup in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True>, And <SOAmazonSetup.integrationType, NotEqual <SOConstants.FBMIntegrationType> > > > .Select(graph))
                {
                    try
                    {
                        liShipmentResponse = GetShipmentInformation(graph, currentFilter, objSOAmazonSetup);
                        UpdateTrackingNumberDetails(graph, list, objSOAmazonSetupDetails, orderEntry, objPartialMaint, liShipmentResponse);
                    }
                    catch (Exception ex)
                    {
                        throw new PXException(ex.Message);
                    }
                }
            }
            graph.Actions.PressSave();
        }
예제 #18
0
        private void LoadIntegrationsToPrepareAndImport(SOImportProcess.SOImportFilter row)
        {
            if (row != null)
            {
                SOOrderProcessLog getProcessId = PXSelectGroupBy <SOOrderProcessLog, Aggregate <Max <SOOrderProcessLog.processID> > > .Select(this);

                PXSelectBase <SOProcessOrder> objMaxOrder = new PXSelectGroupBy <SOProcessOrder, Where <SOProcessOrder.integrationID, Equal <Required <SOProcessOrder.integrationID> > >, Aggregate <Max <SOProcessOrder.synDatetime> > >(this);

                if (row.IntegrationID != null && row.ProcessAllTypes == true && row.LastSyncDate != null)
                {
                    throw new PXException(SOMessages.msgProcessError);
                }
                else
                {
                    SOPrepareAndImport processRecord = new SOPrepareAndImport();
                    prepareAndImport.Cache.Clear();
                    SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                    if (row.IntegrationID != null && row.ProcessAllTypes == false)
                    {
                        foreach (SOProcessOrder objLastOrder in objMaxOrder.Select(row.IntegrationID))
                        {
                            Filter.Cache.SetValue <SOImportProcess.SOImportFilter.lastSyncDate>(row, objLastOrder.SynDatetime ?? GetMaxOrderDate(orderEntry, row.IntegrationID));
                            processRecord.LastSyncDate  = GetMaxOrderDate(orderEntry, row.IntegrationID);
                            processRecord.ToDate        = Filter.Current.TODate;
                            processRecord.IntegrationID = row.IntegrationID;
                            processRecord.ProcessID     = (getProcessId != null && getProcessId.ProcessID != null) ? getProcessId.ProcessID + 1 : 1;
                            prepareAndImport.Cache.Insert(processRecord);
                        }
                    }
                    else if (string.IsNullOrEmpty(row.IntegrationID) && row.ProcessAllTypes == true)
                    {
                        int?processId = (getProcessId != null && getProcessId.ProcessID != null) ? getProcessId.ProcessID + 1 : 1;
                        foreach (SOAmazonSetup integrationrecord in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(this))
                        {
                            processRecord.LastSyncDate  = GetMaxOrderDate(orderEntry, integrationrecord.IntegrationID);
                            processRecord.ToDate        = row.TODate;
                            processRecord.IntegrationID = integrationrecord.IntegrationID;
                            processRecord.ProcessID     = processId++;
                            prepareAndImport.Cache.Insert(processRecord);
                        }
                    }
                }
            }
        }
예제 #19
0
        /// <summary>
        /// Get InventoryItem when item class = 'PACKMTRL' and attribute 'DEFBOX' = TRUE
        /// </summary>
        /// <param name="graph"></param>
        /// <returns></returns>
        public static int?GetPackMatlBox(SOOrderEntry graph)
        {
            var item = SelectFrom <InventoryItem> .InnerJoin <CSAnswers> .On <CSAnswers.refNoteID.IsEqual <InventoryItem.noteID> >
                       .InnerJoin <INItemClass> .On <INItemClass.itemClassID.IsEqual <InventoryItem.itemClassID> >
                       .Where <CSAnswers.attributeID.IsEqual <@P.AsString>
                               .And <CSAnswers.value.IsEqual <@P.AsString> >
                               .And <INItemClass.itemClassCD.StartsWith <@P.AsString> > > .View.Select(graph, ItemAttr_DefBox, Convert.ToInt32(true).ToString(), ItemClass_PackMtrl);

            if (item.Count > 1)
            {
                WebDialogResult wdr = graph.Transactions.Ask(DefBoxHeader, DefBoxInfo, MessageButtons.OKCancel);

                if (wdr == WebDialogResult.Cancel)
                {
                    return(null);
                }
            }

            return(item.TopFirst?.InventoryID);
        }
예제 #20
0
        private DateTime?GetMaxOrderDate(SOOrderEntry orderEntry, string intetgrationId)
        {
            DateTime?      maxDate         = null;
            SOProcessOrder objProcessOrder = new PXSelect <SOProcessOrder, Where <SOProcessOrder.integrationID, Equal <Required <SOProcessOrder.integrationID> > >,
                                                           OrderBy <Desc <SOProcessOrder.amazonOrderDate> > >(this).SelectSingle(intetgrationId);

            if (objProcessOrder == null || (objProcessOrder != null && objProcessOrder.AmazonOrderDate == null))
            {
                orderEntry.Clear();
                SOSetupAmazonExt objSOOSetupext = orderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>();
                if (objSOOSetupext != null && objSOOSetupext.UsrAmazonInitialFromDate != null)
                {
                    maxDate = objSOOSetupext.UsrAmazonInitialFromDate;
                }
            }
            else if (objProcessOrder != null && objProcessOrder.AmazonOrderDate.HasValue)
            {
                maxDate = objProcessOrder.AmazonOrderDate;
            }
            return(maxDate);
        }
예제 #21
0
        /// <summary>
        /// Generate sales order line.
        /// </summary>
        public static void CreateOrderDetail(SOOrderEntry orderEntry, LUM3DCartSetup curSetup, SOOrder order)
        {
            try
            {
                List <MyArray> list = GetResponse(curSetup, "3dCartWebAPI/v2/Orders/" + order.CustomerOrderNbr).Result;

                UpdateSOContactAddress(orderEntry, list, order);

                var itemList = list.Find(x => x.OrderItemList.Count > 0).OrderItemList;

                for (int i = 0; i < itemList.Count; i++)
                {
                    SOLine line = orderEntry.Transactions.Cache.CreateInstance() as SOLine;

                    line.InventoryID = GetAcuInventoryID(orderEntry, itemList[i].ItemID);
                    line.OrderQty    = (decimal)itemList[i].ItemQuantity;
                    line.UnitPrice   = (decimal)itemList[i].ItemUnitPrice;

                    orderEntry.Transactions.Insert(line);
                }

                orderEntry.Taxes.Cache.SetValueExt <SOTaxTran.curyTaxAmt>(orderEntry.Taxes.Current, list[0].SalesTax + list[0].SalesTax2);
                orderEntry.CurrentDocument.SetValueExt <SOOrder.paymentMethodID>(order, GetAcuPymtMethod(orderEntry, order.CustomerID, list[0].BillingPaymentMethod));

                string tranID = list.Find(x => x.TransactionList.Count > 0).TransactionList[0].TransactionID;
                int    index  = tranID.IndexOf(':') + 2; // Because there is a space between the ':' of transaction ID.

                order.CustomerRefNbr = tranID.Contains(PX.Objects.PO.Messages.Completed) ? tranID.Substring(index, tranID.Length - index) : null;

                // Refer to PX.AmazonIntegration project SetDocumentLevelDiscountandTaxData() to manully update SOOrder total amount fields.
                order.CuryTaxTotal    = orderEntry.Taxes.Current.CuryTaxAmt;
                order.CuryOrderTotal += order.CuryTaxTotal;
            }
            catch (PXException ex)
            {
                PXProcessing.SetError <LUM3DCartProcessOrder>(ex.Message);
                throw;
            }
        }
예제 #22
0
        protected void _(Events.RowDeleted <POOrder> e)
        {
            var row = e.Row as POOrder;

            if (row == null)
            {
                return;
            }

            var        curPOOrder = (POOrder)Base.Caches[typeof(POOrder)].Current;
            POOrderExt pOOrderExt = curPOOrder.GetExtension <POOrderExt>();

            if ((bool)pOOrderExt.UsrICSOCreated)
            {
                var curPOLines    = (POLine)Base.Caches[typeof(POLine)].Current;
                var curUserName   = PXLogin.ExtractUsername(PXContext.PXIdentity.IdentityName);
                var curLMICVendor = PXSelect <LMICVendor, Where <LMICVendor.vendorid, Equal <Required <LMICVendor.vendorid> > > > .Select(Base, curPOOrder.VendorID)?.TopFirst;

                if (curLMICVendor != null)
                {
                    using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICVendor.LoginName}"))
                    {
                        // set SOorder.ICPOCreated = False, SOOrder.Customerordernbr = Blank
                        SOOrderEntry sOOrderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                        SOOrder      sOOrder      = PXSelect <SOOrder, Where <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> > > > .Select(sOOrderEntry, row.VendorRefNbr)?.TopFirst;

                        sOOrder.CustomerOrderNbr = "IC PO had been deleted";
                        SOOrderExt sOOrderExt = sOOrder.GetExtension <SOOrderExt>();
                        sOOrderExt.UsrICPOCreated = false;
                        sOOrder = sOOrderEntry.Document.Update(sOOrder);
                        sOOrderEntry.Actions.PressSave();
                    }
                    Base.Document.Delete(curPOOrder);
                    Base.Transactions.Delete(curPOLines);
                    Base.Actions.PressSave();
                }
            }
        }
        private void FillDiscountObjectsData(SOOrderEntry orderEntry, SOLine newitems, OrderItem currentitem)
        {
            if (currentitem != null && (currentitem != null))
            {
                orderEntry.Transactions.Current = newitems;
                if (orderEntry.Transactions.Current == null)
                {
                    return;
                }
                decimal discount = decimal.Zero;
                discount += currentitem.CODFeeDiscount != null && !string.IsNullOrEmpty(currentitem.CODFeeDiscount.Amount) ? Convert.ToDecimal(currentitem.CODFeeDiscount.Amount) : 0;
                //discount += currentitem.ShippingDiscount != null && !string.IsNullOrEmpty(currentitem.ShippingDiscount.Amount) ? Convert.ToDecimal(currentitem.ShippingDiscount.Amount) : 0;

                discount += currentitem.PromotionDiscount != null && !string.IsNullOrEmpty(currentitem.PromotionDiscount.Amount) ? Convert.ToDecimal(currentitem.PromotionDiscount.Amount) : 0;

                if (discount > 0 && orderEntry.Transactions.Current != null)
                {
                    orderEntry.Transactions.Current.ManualDisc  = true;
                    orderEntry.Transactions.Current.CuryDiscAmt = discount;
                    orderEntry.Transactions.Update(orderEntry.Transactions.Current);
                }
            }
        }
        public string GetOrderType(KCAPIOrder order, SOOrderEntry orderEntry)
        {
            //string marketplaceName = order.SiteName;
            string marketplaceName = order.BillingFirstName.Split()[0];
            var    orderExt        = orderEntry.GetExtension <KCSOOrderEntryExt>();
            int?   marketplaceId   = orderExt.KCMarketplaceEntity.SelectSingle(marketplaceName)?.MarketplaceId;

            if (marketplaceId == null)
            {
                marketplaceName = order.SiteName;
                marketplaceId   = orderExt.KCMarketplaceEntity.SelectSingle(marketplaceName)?.MarketplaceId;
            }
            var marketplace = orderExt.KCMarketplaceManagement.SelectSingle(marketplaceId.ToString());

            if (marketplace != null)
            {
                return(marketplace.SOOrderType);
            }
            else
            {
                return(orderExt.KCConnection.SelectSingle().SOOrderType);
            }
        }
        public static void Process(List <SOOrder> list, bool isMassProcess)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            SOOrderEntry rg = PXGraph.CreateInstance <SOOrderEntry>();

            rg.RowSelecting.RemoveHandler <SOOrder>(rg.SOOrder_RowSelecting);
            sw.Stop();
            Debug.Print("{0} PXGraph.CreateInstance<SOOrderEntry> in {1} millisec", DateTime.Now.TimeOfDay, sw.ElapsedMilliseconds);
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    rg.Clear();
                    sw.Reset();
                    sw.Start();
                    rg.Document.Current = PXSelect <SOOrder, Where <SOOrder.orderType, Equal <Required <SOOrder.orderType> >, And <SOOrder.orderNbr, Equal <Required <SOOrder.orderNbr> > > > > .Select(rg, list[i].OrderType, list[i].OrderNbr);

                    sw.Stop();
                    Debug.Print("{0} Select SOOrder in {1} millisec", DateTime.Now.TimeOfDay, sw.ElapsedMilliseconds);
                    rg.CalculateAvalaraTax(rg.Document.Current);
                    PXProcessing <SOOrder> .SetInfo(i, ActionsMessages.RecordProcessed);
                }
                catch (Exception e)
                {
                    if (isMassProcess)
                    {
                        PXProcessing <SOOrder> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message);
                    }
                    else
                    {
                        throw new PXMassProcessException(i, e);
                    }
                }
            }
        }
예제 #26
0
        public void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder, ConfirmShipmentDelegate baseMethod)
        {
            bool packageDetailsValid = true;

            Base.Clear();
            Base.Document.Current = Base.Document.Search <SOShipment.shipmentNbr>(shiporder.ShipmentNbr);

            var packagedQuantities = new Dictionary <Tuple <int?, int?, string, string>, decimal>();

            //Get a summary of all the package details
            foreach (SOPackageDetailSplit ps in PXSelectGroupBy <SOPackageDetailSplit,
                                                                 Where <SOPackageDetailSplit.shipmentNbr, Equal <Current <SOShipment.shipmentNbr> > >,
                                                                 Aggregate <
                                                                     GroupBy <SOPackageDetailSplit.inventoryID,
                                                                              GroupBy <SOPackageDetailSplit.subItemID,
                                                                                       GroupBy <SOPackageDetailSplit.lotSerialNbr,
                                                                                                GroupBy <SOPackageDetailSplit.uOM,
                                                                                                         Sum <SOPackageDetailSplit.baseQty> > > > > > > .Select(Base))
            {
                packagedQuantities.Add(new Tuple <int?, int?, string, string>(ps.InventoryID, ps.SubItemID, ps.LotSerialNbr, ps.UOM), ps.BaseQty.GetValueOrDefault());
            }

            //We run validation only when packaging is used for the order - if left empty, we don't enforce validation
            if (packagedQuantities.Count > 0)
            {
                //Retrieve shipment details and deduct from packaged quantities
                foreach (SOShipLineSplit ls in PXSelectGroupBy <SOShipLineSplit,
                                                                Where <SOShipLineSplit.shipmentNbr, Equal <Current <SOShipment.shipmentNbr> >,
                                                                       And <SOShipLineSplit.isStockItem, Equal <True> > >,
                                                                Aggregate <
                                                                    GroupBy <SOShipLineSplit.inventoryID,
                                                                             GroupBy <SOShipLineSplit.subItemID,
                                                                                      GroupBy <SOShipLineSplit.lotSerialNbr,
                                                                                               GroupBy <SOShipLineSplit.uOM,
                                                                                                        Sum <SOShipLineSplit.baseQty> > > > > > > .Select(Base))
                {
                    //If item is not in dictionary, it will be automatically initialized and quantity deducted from 0
                    var key = new Tuple <int?, int?, string, string>(ls.InventoryID, ls.SubItemID, ls.LotSerialNbr, ls.UOM);
                    packagedQuantities[key] -= ls.BaseQty.GetValueOrDefault();
                }

                // Anything left with a quantity other than 0 need to be flagged as an error.
                foreach (var key in packagedQuantities.Keys)
                {
                    if (packagedQuantities[key] != 0)
                    {
                        packageDetailsValid = false;
                        break;
                    }
                }
            }

            if (packageDetailsValid)
            {
                baseMethod(docgraph, shiporder);
            }
            else
            {
                throw new PXException(PX.Objects.WM.Messages.PackageDetailsMismatch);
            }
        }
        public void GenerateSalesOrders(string JsonPackage, string mailFrom, DateTime orderDate)
        {
            try
            {
                SOOrderEntry soGraph = PXGraph.CreateInstance <SOOrderEntry>();
                soGraph.Clear();

                PXTrace.WriteInformation("SO Order Graph instantiated.");

                #region Variables

                JObject package = JObject.Parse(JsonPackage);

                int     countLines = 0;
                decimal qty        = 0.0M;

                //Customer
                Customer customer = PXSelect <Customer,
                                              Where <Customer.acctCD, Equal <Customer.acctCD> > > .
                                    Select(soGraph, "ABCHOLDING");


                //Customer Default Location
                Location arCustomerLocation = PXSelect <Location,
                                                        Where <Location.isActive, Equal <Required <Location.isActive> >,
                                                               And <Location.bAccountID, Equal <Required <Location.bAccountID> >,
                                                                    And <Location.locationCD, Equal <Required <Location.locationCD> > > > > > .
                                              Select(soGraph, true, customer.BAccountID, "MAIN");

                PXTrace.WriteInformation("SO Order Graph variables set.");
                #endregion

                //Header
                bool    hasError = false;
                string  ms       = "";
                SOOrder order    = new SOOrder();
                order.OrderType = "QT";

                try
                {
                    order = soGraph.Document.Insert(order);

                    soGraph.Document.Cache.SetValueExt <SOOrder.customerID>(order, customer.BAccountID);
                    soGraph.Document.Cache.SetValueExt <SOOrder.customerLocationID>(order, arCustomerLocation.LocationID);
                    soGraph.Document.Cache.SetValueExt <SOOrder.customerOrderNbr>(order, "");
                    soGraph.Document.Cache.SetValueExt <SOOrder.orderDate>(order, DateTime.Now);
                    soGraph.Document.Cache.SetValueExt <SOOrder.requestDate>(order, orderDate);

                    //Update Order
                    order = soGraph.Document.Update(order);
                }
                catch (Exception er)
                {
                    hasError = true;
                    ms       = er.Message;
                }

                if (hasError == false)
                {
                    PXTrace.WriteInformation("SO Order Header added. Starting rows. ");

                    //Details

                    SuperJSon     superJSon     = JsonConvert.DeserializeObject <SuperJSon>(package.ToString());
                    List <string> inventorydesc = new List <string>();
                    int           Myqty         = 0;
                    foreach (var item in superJSon.compositeEntities)
                    {
                        if (item.children[0].type == "product")
                        {
                            inventorydesc.Add(item.children[0].value);
                        }
                        else
                        {
                            Myqty = Convert.ToInt32(item.children[0].value);
                        }
                    }

                    //    JObject saleLine = JObject.Parse(sl);

                    var inItem = new PXSelect <InventoryItem>(this).Select().AsQueryable();

                    foreach (string item in inventorydesc)
                    {
                        inItem = inItem.Where(i => i.GetItem <InventoryItem>().Descr.Contains(item));
                    }

                    InventoryItem ResultInventory = inItem.First();


                    INSite warehouse = PXSelectReadonly <INSite,
                                                         Where <INSite.siteCD, Equal <Required <INSite.siteCD> > > > .
                                       Select(soGraph, "WHOLESALE");


                    if (inItem != null)
                    {
                        try
                        {
                            SOLine orderLine = soGraph.Transactions.Insert();

                            soGraph.Transactions.Cache.SetValueExt <SOLine.inventoryID>(orderLine, ResultInventory.InventoryID);
                            soGraph.Transactions.Cache.SetValueExt <SOLine.siteID>(orderLine, warehouse.SiteID);

                            qty = Convert.ToDecimal(Myqty);

                            soGraph.Transactions.Cache.SetValueExt <SOLine.orderQty>(orderLine, qty);

                            orderLine = soGraph.Transactions.Update(orderLine);

                            countLines++;
                        }
                        catch (Exception)
                        {
                            hasError = true;  //Failed
                        }
                    }
                    else
                    {
                        hasError = true;  //Failed
                    }
                }

                PXTrace.WriteInformation("SO Order Details added. ");

                if (hasError == false)
                {
                    //ADD EMAIL


                    order = soGraph.Document.Update(order);
                    try
                    {
                        soGraph.Actions.PressSave();
                        PXTrace.WriteInformation("Order [" + soGraph.Document.Current.RefNbr + "] created ");
                    }
                    catch (PXException pEx)
                    {
                        PXTrace.WriteInformation(pEx.Message + " " + pEx.InnerException);
                    }
                }
                else
                {
                    PXTrace.WriteInformation("Errors on order, could not save. ");
                }
            }
            catch (Exception e)
            {
                PXTrace.WriteInformation(e.Message);
            }
        }
        protected virtual void prepareRecords()
        {
            List <string>  importedRecords = new List <string>();
            SOImportFilter currentFilter   = Filter.Current;

            PXLongOperation.StartOperation(this, delegate()
            {
                SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                SOImportProcess graph   = PXGraph.CreateInstance <SOImportProcess>();
                SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>();
                if (currentFilter != null)
                {
                    if ((string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == false) || (!string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true))
                    {
                        throw new PXException(SOMessages.validationIntegrationIdandprocessall);
                    }
                    if (currentFilter.TODate.Value.Date > graph.Accessinfo.BusinessDate.Value.Date)
                    {
                        throw new PXException(SOMessages.validationTodateandBusinessDate);
                    }
                    if (currentFilter.LastSyncDate > currentFilter.TODate)
                    {
                        throw new PXException(SOMessages.validationFromandTodate);
                    }
                    try
                    {
                        orderEntry.Clear();
                        SOSetupAmazonExt objSOOSetupext = orderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>();
                        if (SOHelper.IsSOPreferencesDetailsExist(orderEntry, objSOOSetupext))
                        {
                            SOAmazonSetup objSOAmazonSetupDetails = null;
                            objOrdersParameters          = new OrdersParameters();
                            SOProcessOrder processrecord = null;
                            int?processedCount           = 0;
                            bool isValidConfiguration    = SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objSOAmazonSetupDetails);

                            // To Get the Max date & time if the same date is processed again
                            //Dhiren-4/11/2019 - We need to revisit date range Delta logic.
                            //SOProcessOrder objProcessOrder = new PXSelect<SOProcessOrder, Where<SOProcessOrder.integrationID, Equal<Required<SOProcessOrder.integrationID>>,
                            //                                                             And<SOProcessOrder.amazonOrderDate, Between<Required<SOProcessOrder.amazonOrderDate>, Required<SOProcessOrder.amazonOrderDate>>>>,
                            //                                                             OrderBy<Desc<SOProcessOrder.amazonOrderDate>>>(graph).SelectSingle(currentFilter.IntegrationID, currentFilter.LastSyncDate, currentFilter.TODate);

                            //currentFilter.FromDate = objProcessOrder != null && objProcessOrder.AmazonOrderDate.HasValue ? objProcessOrder.AmazonOrderDate : currentFilter.LastSyncDate;
                            currentFilter.FromDate = currentFilter.LastSyncDate;
                            Filter.Cache.Update(currentFilter);
                            if (currentFilter.IntegrationID != null && currentFilter.ProcessAllTypes == false)
                            {
                                if (isValidConfiguration)
                                {
                                    int?processId = SOHelper.GetProcessID(graph);
                                    PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetupDetails, processId, out processedCount, logGraph);
                                    if (processedCount > 0)
                                    {
                                        LogProcessCount(processedCount, currentFilter.IntegrationID, logGraph);
                                    }
                                    graph.Actions.PressSave();
                                }
                                else
                                {
                                    throw new PXException(SOMessages.apidetailsMissing);
                                }
                            }
                            else if (string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true)
                            {
                                ImportOrderList.Cache.Clear();
                                int?processId = SOHelper.GetProcessID(graph);
                                foreach (SOAmazonSetup objSOAmazonSetup in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(graph))
                                {
                                    try
                                    {
                                        PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetup, processId, out processedCount, logGraph);
                                        if (processedCount > 0)
                                        {
                                            LogProcessCount(processedCount, objSOAmazonSetup.IntegrationID, logGraph);
                                        }
                                        processId++;
                                        graph.Actions.PressSave();
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                                                    : SOConstants.exceptionIsEmpty);
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new PXException(SOMessages.configMissing);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message :
                                              ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message
                            : SOConstants.exceptionIsEmpty);
                    }
                }
            });
        }
예제 #29
0
 public CarrierRates CarrierRatesExt(SOOrderEntry graph)
 => graph.FindImplementation <CarrierRates>();
        public virtual void ImportAmazonRecords(SOImportProcess graph, List <SOProcessOrder> list, SOImportFilter currentFilter)
        {
            if (list.Count < 0)
            {
                return;
            }
            List <Order>          amwOrder        = null;
            List <OrderItem>      amwLineItems    = null;
            string                amwOrderID      = string.Empty;
            List <SOAmazonSetup>  liSOAmazonSetup = new List <SOAmazonSetup>();
            List <SOFieldMapping> liUsrMapping    = new List <SOFieldMapping>();
            SOAmazonSetup         objamwSetup     = null;
            SOOrderProcessLog     objProcessLog   = null;
            SOPartialMaint        logGraph        = PXGraph.CreateInstance <SOPartialMaint>();

            if (currentFilter.ProcessAllTypes == true)
            {
                foreach (SOAmazonSetup objSetup in PXSelect <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(graph))
                {
                    liSOAmazonSetup.Add(objSetup);
                }
            }
            else if (SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objamwSetup))
            {
                liSOAmazonSetup.Add(objamwSetup);
            }
            if (liSOAmazonSetup.Count > 0)
            {
                ARPaymentEntry docgraph   = PXGraph.CreateInstance <ARPaymentEntry>();
                SOOrderEntry   orderEntry = PXGraph.CreateInstance <SOOrderEntry>();
                orderEntry.RowUpdated.AddHandler <SOOrder>((sender, e) =>
                {
                    if (!sender.ObjectsEqual <SOOrder.orderDate>(e.Row, e.OldRow))
                    {
                        SOOrder order   = (SOOrder)e.Row;
                        order.OrderDate = order.OrderDate.HasValue ? order.OrderDate.Value.Date : order.OrderDate;
                    }
                });
                InvokeServicesCallResponse   objSyncOrderResponse = null;
                PrepareAndImportOrdersParams objScheduleParams    = null;
                objProcessLog                      = new SOOrderProcessLog();
                objProcessLog.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                objProcessLog.TotalRecordstoImport = list.Count;
                objProcessLog.Operation            = SOConstants.btnImport;
                objProcessLog.ImportedRecordsCount = 0;
                objProcessLog.FailedRecordsCount   = 0;

                bool          isErrorOccured = false;
                List <string> liCarriers     = PXSelect <Carrier> .Select(graph).RowCast <Carrier>().Select(c => c.CarrierID).ToList();

                foreach (SOProcessOrder currentRecord in list)
                {
                    try
                    {
                        orderEntry.Clear();
                        logGraph.Clear();
                        docgraph.Clear();
                        objProcessLog.IntegrationID = currentFilter.IntegrationID != null ? currentFilter.IntegrationID : currentRecord.IntegrationID;
                        logGraph.OrderProcessLog.Insert(objProcessLog);
                        logGraph.Actions.PressSave();

                        foreach (SOAmazonSetup objSOAmazonSetup in liSOAmazonSetup.Where(x => x.IntegrationID == currentRecord.IntegrationID))
                        {
                            if (orderEntry.sosetup.Current != null)
                            {
                                if (!SOHelper.CheckOrderExist(graph, currentRecord.AmazonOrderID, currentRecord.IntegrationID))
                                {
                                    amwOrderID = currentRecord.AmazonOrderID;
                                    if (amwLineItems != null && amwLineItems.Count > 0)
                                    {
                                        amwLineItems.Clear();
                                    }
                                    amwOrder = new List <Order>();
                                    amwOrder.Add(SOHelper.SchemaDeserialization(graph, amwOrderID));
                                    objServiceCallParams = new ServiceCallParameters();
                                    objServiceCallParams.objSOAmazonSetup = objSOAmazonSetup;
                                    objServiceCallParams.amwOrderID       = currentRecord.AmazonOrderID;
                                    objServiceCallParams.methodCall       = SOConstants.invokeListOrderItems;
                                    objSyncOrderResponse = new InvokeServicesCallResponse();
                                    objSyncOrderResponse = new SOOrdersServiceCall(clientOrder).InvokeServicesCalls(graph, objServiceCallParams);
                                    amwLineItems         = objSyncOrderResponse != null && objSyncOrderResponse.objListOrderItemsResponse != null &&
                                                           objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult != null &&
                                                           objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult.OrderItems.Count > 0 ?
                                                           objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult.OrderItems : amwLineItems;
                                    objScheduleParams = new PrepareAndImportOrdersParams();
                                    objScheduleParams.objSOPartialMaint       = logGraph;
                                    objScheduleParams.objSOAmazonSetup        = objSOAmazonSetup;
                                    objScheduleParams.objSOOrderEntry         = orderEntry;
                                    objScheduleParams.paymentGraph            = docgraph;
                                    objScheduleParams.objSOProcessOrderRecord = currentRecord;
                                    objScheduleParams.ObjCurrentOrder         = amwOrder[0];
                                    objScheduleParams.objamwLineItems         = amwLineItems;
                                    objScheduleParams.objliUsrMapping         = liUsrMapping;
                                    objScheduleParams.listOfCarriers          = liCarriers;
                                    objScheduleParams.CurrentOrderIndex       = list.IndexOf(currentRecord);
                                    CreateSO.CreateSalesOrderandPayments(objScheduleParams);
                                }
                                else
                                {
                                    isErrorOccured = true;
                                    SOLogService.LogImportStatus(objScheduleParams, true, SOMessages.recordAlreadyImported);
                                    PXProcessing <SOProcessOrder> .SetInfo(list.IndexOf(currentRecord), SOMessages.recordAlreadyImported);
                                }
                            }
                            else
                            {
                                throw new PXException(SOMessages.configMissing);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        isErrorOccured = true;
                        SOLogService.LogImportStatus(objScheduleParams, false, ex.Message);
                        PXProcessing <SOProcessOrder> .SetError(list.IndexOf(currentRecord), ex.Message);
                    }
                }
                if (isErrorOccured)
                {
                    throw new PXException(SOMessages.showErrorMsgOrders);
                }
            }
        }