コード例 #1
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);
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
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);
        }