Exemplo n.º 1
0
        private void UpdateOrderBalances(SOOrder order)
        {
            if (order == null)
            {
                return;
            }
            bool?     isFromCA = order.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA");
            ARPayment payment  = KCOrderPayment.Select(order.CustomerOrderNbr);

            if (isFromCA == true && payment != null)
            {
                order.PaymentTotal = order.CuryPaymentTotal = payment.CuryOrigDocAmt;
            }

            order.DocBal        = order.CuryDocBal = order.CuryOrderTotal;
            order.UnpaidBalance = order.CuryUnpaidBalance = 0;

            foreach (ARTran line in Base.Transactions.Select())
            {
                SOLine      sOLine      = KCSOLineByOrderNbrAndLineNbr.SelectSingle(line.SOOrderNbr, line.SOOrderLineNbr);
                SOLinePCExt SOLinePCExt = sOLine.GetExtension <SOLinePCExt>();
                if (SOLinePCExt.UsrKNMasterLineNbr == sOLine.LineNbr)
                {
                    line.CuryExtPrice = sOLine.CuryExtPrice;
                    line.CuryTranAmt  = sOLine.CuryLineAmt;
                }
            }
        }
        private void SetSOHeaderObjectsData(PrepareAndImportOrdersParams orderParams)
        {
            SOOrder newOrder = new SOOrder();

            if (orderParams.objSOOrderEntry.sosetup.Current != null)
            {
                SOSetupAmazonExt objSOOSetupext = orderParams.objSOOrderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>();
                if (objSOOSetupext != null && objSOOSetupext.UsrGuestCustID.HasValue)
                {
                    newOrder.OrderType  = orderParams.objSOAmazonSetup.OrderType;
                    newOrder            = (SOOrder)orderParams.objSOOrderEntry.Document.Cache.Insert(newOrder);
                    newOrder.CustomerID = objSOOSetupext.UsrGuestCustID;
                }
                else
                {
                    throw new PXException(SOMessages.guestCustomerErrorMsg);
                }
            }
            AssignValueAsPerIntegrationMapping(orderParams.objliUsrMapping, newOrder, orderParams.ObjCurrentOrder, null, orderParams.objSOOrderEntry.Document.View.Name);
            newOrder.OrderDesc = !string.IsNullOrEmpty(orderParams.ObjCurrentOrder.FulfillmentChannel) ?
                                 orderParams.ObjCurrentOrder.FulfillmentChannel == SOConstants.fulfillmentChannelAFN ?
                                 string.IsNullOrEmpty(newOrder.OrderDesc) ? SOMessages.fbaOrder : newOrder.OrderDesc + " - " + SOMessages.fbaOrder :
                                 orderParams.ObjCurrentOrder.FulfillmentChannel == SOConstants.fulfillmentChannelMFN ?
                                 string.IsNullOrEmpty(newOrder.OrderDesc) ? SOMessages.fbmOrder : newOrder.OrderDesc + " - " + SOMessages.fbmOrder :
                                 newOrder.OrderDesc : newOrder.OrderDesc;
            newOrder.DefaultSiteID = orderParams.objSOAmazonSetup.DfltWarehouseID;
            SOOrderAmazonExt newOrderExt = newOrder.GetExtension <SOOrderAmazonExt>();

            if (newOrderExt != null)
            {
                newOrderExt.UsrAmazonOrderID = orderParams.ObjCurrentOrder.AmazonOrderId;
            }
            orderParams.objSOOrderEntry.Document.Current = newOrder;
            orderParams.objSOOrderEntry.Document.Update(orderParams.objSOOrderEntry.Document.Current);
        }
Exemplo n.º 3
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);
        }
        public void CreatePaymentProcess(PrepareAndImportOrdersParams orderParams)
        {
            SOOrder          order    = orderParams.objSOOrderEntry.Document.Current;
            SOOrderAmazonExt OrderExt = order.GetExtension <SOOrderAmazonExt>();

            if (orderParams.objSOOrderEntry.sosetup.Current != null)
            {
                SOSetupAmazonExt objSOOSetupext = orderParams.objSOOrderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>();
                if (objSOOSetupext != null && !string.IsNullOrEmpty(objSOOSetupext.UsrAmazonPaymentMethodID))
                {
                    string paymentType = ARPaymentType.Payment;
                    orderParams.paymentGraph.Clear();
                    ARPayment payment = new ARPayment()
                    {
                        DocType = paymentType
                    };
                    payment = PXCache <ARPayment> .CreateCopy(orderParams.paymentGraph.Document.Insert(payment));

                    payment.CustomerID         = order.CustomerID;
                    payment.CustomerLocationID = order.CustomerLocationID;
                    payment.PaymentMethodID    = objSOOSetupext.UsrAmazonPaymentMethodID;
                    payment.PMInstanceID       = order.PMInstanceID;
                    payment.CuryOrigDocAmt     = 0m;
                    payment.ExtRefNbr          = OrderExt != null ? OrderExt.UsrAmazonOrderID : order.OrderNbr;
                    payment.DocDesc            = order.OrderDesc;
                    payment = orderParams.paymentGraph.Document.Update(payment);
                    SOAdjust adj = new SOAdjust()
                    {
                        AdjdOrderType = order.OrderType.Trim(),
                        AdjdOrderNbr  = order.OrderNbr.Trim()
                    };
                    orderParams.paymentGraph.SOAdjustments.Insert(adj);
                    if (payment.CuryOrigDocAmt == 0m)
                    {
                        payment.CuryOrigDocAmt = payment.CurySOApplAmt;
                        payment = orderParams.paymentGraph.Document.Update(payment);
                    }
                    orderParams.paymentGraph.Actions.PressSave();
                    if (orderParams.paymentGraph.Actions.Contains("Release"))
                    {
                        orderParams.paymentGraph.Actions["Release"].Press();
                    }
                }
            }
        }
        public virtual decimal?GetSalesPrice(PXCache sender, SOOrder order, SOLine line)
        {
            if (line == null ||
                order == null)
            {
                return(null);
            }

            var extension = order.GetExtension <SOOrderDAExtension>();

            if (extension == null)
            {
                return(null);
            }

            return(ARSalesPriceMaint.CalculateSalesPrice(sender, extension.DAPriceClassID, order.CustomerID, line.InventoryID,
                                                         Base.currencyinfo.Select(), line.UOM, line.Qty, order.OrderDate.GetValueOrDefault(), line.CuryUnitPrice) ?? 0m);
        }
Exemplo n.º 6
0
        protected virtual void SOTaxTran_RowDeleting(PXCache sender, PXRowDeletingEventArgs e, PXRowDeleting baseHandler)
        {
            if (!(e.Row is SOTaxTran row))
            {
                return;
            }
            SOOrder order    = KCOrderByOrderNbr.Select(row.OrderNbr);
            bool?   isFromCA = order.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA");

            if (isFromCA.GetValueOrDefault() && order != null && e.ExternalCall == false)
            {
                Base.Caches["SOTaxTran"].SetStatus(row, PXEntryStatus.Notchanged);
            }
            else
            {
                baseHandler?.Invoke(sender, e);
            }
        }
        protected virtual void SOShipment_UsrKCOrderRefNbr_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (!(e.Row is SOShipment))
            {
                return;
            }

            string  orderNbr   = Base.OrderListSimple.SelectSingle()?.OrderNbr;
            SOOrder order      = KCOrder.SelectSingle(orderNbr);
            string  caOrderId  = order?.CustomerOrderNbr;
            string  caSiteName = order?.GetExtension <KCSOOrderExt>()?.UsrKCSiteName;

            string val = caOrderId;

            val += string.IsNullOrWhiteSpace(val) ? caSiteName : $" ({caSiteName})";

            e.ReturnValue = val;
        }
        protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
        {
            SOOrder row = e.Row as SOOrder;

            if (BaseEvent != null)
            {
                BaseEvent(sender, e);
            }

            if (row == null)
            {
                return;
            }
            SOOrderAmazonExt objSOAmazonOrderext = row.GetExtension <SOOrderAmazonExt>();

            if (objSOAmazonOrderext != null && !string.IsNullOrEmpty(objSOAmazonOrderext.UsrAmazonOrderID))
            {
                PXUIFieldAttribute.SetVisible <SOOrderAmazonExt.usrSyncNote>(sender, null, true);
                PXUIFieldAttribute.SetEnabled <SOOrder.customerRefNbr>(sender, row, false);
            }
        }
Exemplo n.º 9
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 RestoreTaxes(SOOrder order)
        {
            bool?isFromCA = order.GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA");

            if (!isFromCA.GetValueOrDefault())
            {
                return;
            }
            ARPayment payment = KCOrderPayment.Select(order.CustomerOrderNbr);

            if (payment != null)
            {
                UpdateOrderTotals(order);

                if (isFromCA == true && Base.Taxes.Select().Count == 0)
                {
                    IEnumerator taxCache = Base.Taxes.Cache.Cached.GetEnumerator();
                    if (taxCache.MoveNext())
                    {
                        Base.Taxes.Cache.SetStatus(taxCache.Current, PXEntryStatus.Inserted);
                    }
                }
            }
        }
        protected virtual void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
        {
            //baseHandler?.Invoke(sender, e);

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

            SOOrder      row      = (SOOrder)e.Row;
            KCSOOrderExt rowKCExt = row.GetExtension <KCSOOrderExt>();
            bool?        FBA      = rowKCExt.UsrKCSiteName?.EndsWith("/FBA");

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

                var reportMenus = (Base.report.GetState(null) as PXButtonState)?.Menus;
                var buttonMenus = (Base.Actions["action"].GetState(null) as PXButtonState)?.Menus;

                if (reportMenus != null)
                {
                    foreach (var action in reportMenus)
                    {
                        action.Enabled = enable;
                    }
                }
                if (buttonMenus != null)
                {
                    foreach (var action in buttonMenus)
                    {
                        action.Enabled = enable;
                    }
                }

                Base.quickProcess.SetEnabled(enable);
                Base.createPayment.SetEnabled(enable);
                Base.createPrepayment.SetEnabled(enable);
                Base.addInvBySite.SetEnabled(enable);
                Base.recalculateDiscountsAction.SetEnabled(enable);
                Base.prepareInvoice.SetEnabled(enable);
                Base.validateAddresses.SetEnabled(enable);

                if (Base.Actions.Contains("LSSOLine_binLotSerial"))
                {
                    Base.Actions["LSSOLine_binLotSerial"]?.SetEnabled(enable);
                }
                if (Base.Actions.Contains("RecalcExternalTax"))
                {
                    Base.Actions["RecalcExternalTax"]?.SetEnabled(enable);
                }

                foreach (Type field in Base.Document.Cache.BqlFields)
                {
                    if (field.Name != "usrKNShowHide")
                    {
                        PXUIFieldAttribute.SetEnabled(sender, field.Name, enable);
                    }
                }

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

                Base.Taxes.View.AllowInsert = enable;
                Base.Taxes.View.AllowUpdate = enable;
                Base.Taxes.View.AllowDelete = enable;

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

                Base.Billing_Contact.Cache.AllowUpdate = enable;
                Base.Billing_Address.Cache.AllowUpdate = enable;

                Base.Shipping_Contact.Cache.AllowUpdate = enable;
                Base.Shipping_Address.Cache.AllowUpdate = enable;

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

                Base.Adjustments.Cache.AllowInsert = enable;
                Base.Adjustments.Cache.AllowUpdate = enable;
                Base.Adjustments.Cache.AllowDelete = enable;
            }
        }
        private void ReviewWarehouseAvailability(SOOrderEntry orderEntryGraph, SOOrder order)
        {
            //Exclude orders that have a preferred warehouse set (ex: NAFTA warehouse orders)
            if (order.DefaultSiteID == null)
            {
                PXTrace.WriteInformation("*Reviewing warehouse availability for order " + order.OrderType + " " + order.OrderNbr);

                orderEntryGraph.Clear();
                orderEntryGraph.Document.Current = orderEntryGraph.Document.Search <SOOrder.orderNbr>(order.OrderNbr, order.OrderType);

                var sortedSiteList   = new List <int?>();
                var availabilityInfo = new Dictionary <Tuple <int?, int?>, decimal>();

                var sitesThatCanShipComplete = new List <int>();
                foreach (INSite site in PXSelect <INSite, Where <INSite.active, Equal <True>, And <INSiteExt.usrAllowShippingAutoSelection, Equal <True> > >, OrderBy <Desc <INSite.siteCD> > > .Select(Base))
                {
                    sortedSiteList.Add(site.SiteID);
                    bool canShipComplete = true;

                    // Check if current warehouse can fulfill the order *completely*
                    foreach (PXResult <SOLine, INSiteStatus> res in PXSelectJoin <SOLine,
                                                                                  LeftJoin <INSiteStatus, On <SOLine.inventoryID, Equal <INSiteStatus.inventoryID>,
                                                                                                              And <SOLine.subItemID, Equal <INSiteStatus.subItemID>,
                                                                                                                   And <INSiteStatus.siteID, Equal <Required <INSiteStatus.siteID> > > > > >,
                                                                                  Where <SOLine.orderType, Equal <Current <SOOrder.orderType> >,
                                                                                         And <SOLine.orderNbr, Equal <Current <SOOrder.orderNbr> >,
                                                                                              And <SOLine.operation, Equal <Required <SOLine.operation> > > > > > .Select(orderEntryGraph, site.SiteID, SOOperation.Issue))
                    {
                        SOLine       line = (SOLine)res;
                        INSiteStatus ss   = (INSiteStatus)res;

                        //We cache availability info for later use, in case we're unable to completely fulfill order
                        //from this site we'll fulfill it from closest site.
                        decimal qtyHardAvail = ss == null ? 0 : ss.QtyHardAvail.GetValueOrDefault();
                        var     key          = new Tuple <int?, int?>(line.InventoryID, site.SiteID);
                        if (!availabilityInfo.ContainsKey(key)) //Same Item/Site may be on the order more than once
                        {
                            availabilityInfo.Add(key, qtyHardAvail);
                        }

                        if (line.BaseOpenQty > qtyHardAvail && line.Completed.GetValueOrDefault() == false && line.IsStockItem == true)
                        {
                            PXTrace.WriteInformation("Not enough inventory available for item " + line.TranDesc + " in warehouse " + site.SiteCD + " (QtyHardAvail: " + qtyHardAvail + ")");
                            canShipComplete = false;
                        }
                    }

                    if (canShipComplete)
                    {
                        sitesThatCanShipComplete.Add(site.SiteID.Value);
                    }
                }

                if (sitesThatCanShipComplete.Count == 0)
                {
                    //We haven't found a single warehouse that can fulfill this order completely. Assign based on availability.
                    PXTrace.WriteInformation("No warehouse can fulfill order " + order.OrderNbr + " completely. Assigning on a per-item basis.");
                    int?createShipmentSiteID = null;
                    foreach (SOLine line in orderEntryGraph.Transactions.Select())
                    {
                        if (line.Operation == SOOperation.Issue && line.Completed.GetValueOrDefault() == false && line.IsStockItem == true)
                        {
                            bool foundSiteWithAvailability = false;
                            foreach (int?currentSiteId in sortedSiteList)
                            {
                                decimal qtyHardAvail;
                                if (availabilityInfo.TryGetValue(new Tuple <int?, int?>(line.InventoryID, currentSiteId), out qtyHardAvail))
                                {
                                    if (qtyHardAvail >= line.BaseOpenQty)
                                    {
                                        if (createShipmentSiteID == null)
                                        {
                                            createShipmentSiteID = currentSiteId;
                                        }

                                        if (line.SiteID != currentSiteId)
                                        {
                                            line.SiteID = currentSiteId;
                                            orderEntryGraph.Transactions.Update(line);
                                        }

                                        foundSiteWithAvailability = true;
                                        break;
                                    }
                                }
                            }

                            if (!foundSiteWithAvailability)
                            {
                                //Dropship if possible -- we only dropship if quantity available at vendor exceeds demand for this order
                                decimal?qtyDropshippable = GetQuantityAvailableForDropship(line.InventoryID, line.SubItemID, line.SiteID);
                                PXTrace.WriteInformation("Item " + line.TranDesc + " can't be fulfilled from any warehouse. Quantity available for dropshipping: " + qtyDropshippable);
                                if (qtyDropshippable >= line.BaseOpenQty)
                                {
                                    line.POCreate = true;
                                    line.POSource = INReplenishmentSource.DropShipToOrder;
                                    orderEntryGraph.Transactions.Update(line);
                                }
                                else if (order.ShipComplete == SOShipComplete.ShipComplete)
                                {
                                    //If order is set to ShipComplete, we don't want to make ANY shipment to give the opportunity for a manual review of the order (and potentially replenish from NAFTA warehouse...)
                                    throw new SOShipmentException("Order can't be dropshipped or shipped in full.");
                                }
                            }
                        }
                    }
                }
                else if (sitesThatCanShipComplete.Count == 1)
                {
                    //TODO: Do a rate check, and pick warehouse based on
                    PXTrace.WriteInformation("Warehouse " + sitesThatCanShipComplete[0] + " can fulfill order completely");
                    AssignSiteToOpenStockItems(orderEntryGraph, sitesThatCanShipComplete[0]);
                }
                else
                {
                    PXTrace.WriteInformation("Multiple warehouses can fulfill order completely -- do a rate check");

                    if (Base.Document.Current.IsManualPackage == true)
                    {
                        PXTrace.WriteInformation("Order is set for manual packaging. Automated Rate Shopping can't be done; selecting warehouse used the packages.");
                        AssignSiteToOpenStockItems(orderEntryGraph, sitesThatCanShipComplete[0]);
                    }
                    else
                    {
                        var sw = new Stopwatch();
                        sw.Start();

                        var orderExt = order.GetExtension <SOOrderExt>();
                        AssignSiteToOpenStockItems(orderEntryGraph, SelectLeastExpensiveShipWarehouse(sitesThatCanShipComplete, orderExt.UsrDeliverByDate, orderExt.UsrGuaranteedDelivery.GetValueOrDefault()));

                        sw.Stop();
                        PXTrace.WriteInformation($"Rate shopping took {sw.ElapsedMilliseconds}ms");
                    }
                }

                //We do not want to recalculate taxes here. We'll have recalculation and write off when Invoice is created
                //So we restore all the tax flags to their initial values
                orderEntryGraph.Document.Current.IsTaxValid         = order.IsTaxValid;
                orderEntryGraph.Document.Current.IsOpenTaxValid     = order.IsOpenTaxValid;
                orderEntryGraph.Document.Current.IsUnbilledTaxValid = order.IsUnbilledTaxValid;
                orderEntryGraph.Document.Current.IsFreightTaxValid  = order.IsFreightTaxValid;

                //Save the order
                orderEntryGraph.Actions.PressSave();
            }
        }
        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;
                        }
                    }
                }
            }
        }