Ejemplo n.º 1
0
        protected virtual IEnumerable CreateDCLShipment(PXAdapter adapter)
        {
            List <SOOrder> list = adapter.Get <SOOrder>().ToList();

            var adapterSlice = (adapter.MassProcess, adapter.QuickProcessFlow, adapter.AllowRedirect);

            for (int i = 0; i < list.Count; i++)
            {
                var order = list[i];
                if (adapterSlice.MassProcess)
                {
                    PXProcessing <SOOrder> .SetCurrentItem(order);
                }

                DCLShipmentRequestEntity model = new DCLShipmentRequestEntity();
                CombineDLCShipmentEntity(model, order);
                PXNoteAttribute.SetNote(Base.Document.Cache, order, APIHelper.GetJsonString(model));
                order.GetExtension <SOOrderExt>().UsrDCLShipmentCreated = true;


                #region  Send Data to DCL for Create Shipment(Implement)

                //var dclResult = DCLHelper.CallDCLToCreateShipment(this.DCLSetup.Select().RowCast<LUMVendCntrlSetup>().FirstOrDefault(), model);
                //var response = APIHelper.GetObjectFromString<DCLShipmentResponseEntity>(dclResult.ContentResult);
                //if (dclResult.StatusCode == System.Net.HttpStatusCode.OK)
                //    order.GetExtension<SOOrderExt>().UsrDCLShipmentCreated = true;
                //else
                //    throw new PXException(response.error_message);

                #endregion
                Base.Document.Cache.Update(order);
            }

            Base.Persist();
            return(adapter.Get());
        }
Ejemplo n.º 2
0
        /// <summary> Call DCL To Create Shipment </summary>
        public static LumAPIResultModel CallDCLToCreateShipment(LUMVendCntrlSetup setup, DCLShipmentRequestEntity metadataShipemt)
        {
            var config = new DCL_Config()
            {
                RequestMethod = HttpMethod.Post,
                RequestUrl    = setup.SecureURLbatches,
                AuthType      = setup.AuthType,
                Token         = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{setup.ClientID}:{setup.ClientSecret}"))
            };
            var caller = new APICaller(config);

            return(caller.CallApi(metadataShipemt));
        }
Ejemplo n.º 3
0
        /// <summary> Combine DCL Shipment MetaData(JSON) </summary>
        /// Shipping Carrier and Server Rule : soOrder.OrderWeight >= 150 -> UPS FREIGHT ;other -> UPS(Default or ShipVia)
        public void CombineDLCShipmentEntity(DCLShipmentRequestEntity model, SOOrder soOrder)
        {
            if (model == null)
            {
                return;
            }

            var soLine = SelectFrom <SOLine> .Where <SOLine.orderNbr.IsEqual <P.AsString>
                                                     .And <SOLine.orderType.IsEqual <P.AsString> > >
                         .View
                         .Select(Base, soOrder.OrderNbr, soOrder.OrderType)
                         .RowCast <SOLine>()
                         .ToList();

            var shippingContact = SOShippingContact.PK.Find(Base, soOrder.CustomerID) ?? new SOShippingContact();
            var shippingAddress = SOShippingAddress.PK.Find(Base, soOrder.ShipAddressID) ?? new SOShippingAddress();
            var billingContact  = SOBillingContact.PK.Find(Base, soOrder.ContactID) ?? new SOBillingContact();
            var billingAddress  = SOBillingAddress.PK.Find(Base, soOrder.BillAddressID) ?? new SOBillingAddress();

            model.allow_partial = true;
            model.location      = "LA";

            List <APILibrary.Model.Line> dclLines = soLine.Any() ? new List <APILibrary.Model.Line>() : null;
            int count = 1;

            foreach (var item in soLine)
            {
                var inventory = InventoryItem.PK.Find(Base, item.InventoryID);
                APILibrary.Model.Line dclItem = new APILibrary.Model.Line()
                {
                    line_number = count++,
                    item_number = inventory.InventoryCD == "5-884-4-01-02" ? "5-884-4-01-00" : inventory.InventoryCD,
                    description = inventory.Descr,
                    quantity    = (int)item?.OrderQty,
                    price       = (double?)item.UnitPrice
                };
                dclLines.Add(dclItem);
            }

            string shippingCarrier = string.Empty;
            string shippingService = string.Empty;

            if (soOrder.OrderWeight >= 150 || soOrder.ShipVia == "UPSFREIGHT")
            {
                shippingCarrier = "UPS FREIGHT";
                shippingService = "STANDARD";
            }
            else if (soOrder.ShipVia == "UPSGROUND")
            {
                shippingCarrier = "UPS";
                shippingService = "GROUND";
            }
            model.orders = new List <Order>()
            {
                new Order()
                {
                    order_number          = soOrder.OrderNbr,
                    account_number        = soOrder.ShipVia == "UPSGROUND" ?"19311" : "19310",
                    ordered_date          = soOrder.OrderDate?.ToString("yyyy-MM-dd"),
                    po_number             = soOrder.CustomerOrderNbr,
                    customer_number       = GetCurrAcctCD(soOrder.CustomerID),
                    acknowledgement_email = "*****@*****.**",
                    freight_account       = "00500",
                    shipping_carrier      = shippingCarrier,
                    shipping_service      = shippingService,
                    system_id             = "P",
                    shipping_address      = new ShippingAddress()
                    {
                        company        = shippingContact.FullName?.Length > 40 ? shippingContact.FullName.Substring(0, 40) : shippingContact.FullName,
                        attention      = shippingContact.Attention?.Length > 40 ? shippingContact.Attention.Substring(0, 40) : shippingContact.FullName,
                        address1       = shippingAddress.AddressLine1,
                        address2       = shippingAddress.AddressLine2,
                        phone          = shippingContact.Phone1,
                        email          = shippingContact.Email,
                        state_province = shippingAddress.State,
                        postal_code    = shippingAddress.PostalCode,
                        country_code   = "US"
                    },
                    billing_address = new BillingAddress()
                    {
                        company        = billingContact.FullName?.Length > 40 ?  billingContact.FullName?.Substring(0, 40) : billingContact.FullName,
                        attention      = billingContact.Attention?.Length > 40 ?  billingContact.Attention?.Substring(0, 40) : billingContact.Attention,
                        address1       = billingAddress.AddressLine1,
                        address2       = billingAddress.AddressLine2,
                        phone          = billingContact.Phone1,
                        email          = billingContact.Email,
                        state_province = billingAddress.State,
                        postal_code    = billingAddress.PostalCode,
                        country_code   = "US"
                    },
                    international_code           = 0,
                    order_subtotal               = (double?)soOrder.OrderTotal,
                    shipping_handling            = (double?)soOrder.FreightAmt,
                    sales_tax                    = (double?)soOrder.TaxTotal,
                    international_handling       = 0,
                    total_due                    = (double?)soOrder.LineTotal,
                    amount_paid                  = 0,
                    net_due_currency             = 0,
                    balance_due_us               = 0,
                    international_declared_value = 0,
                    insurance                    = 0,
                    payment_type                 = string.Empty,
                    terms                 = string.Empty,
                    fob                   = string.Empty,
                    custom_field1         = soOrder.OrderNbr,
                    packing_list_type     = 0,
                    packing_list_comments = string.Empty,
                    shipping_instructions = $@"1.Please note that use the plastic wrapper to secure all cartons onto the pallets for this order.\r\n
2.Please contact {shippingContact.FullName}@{shippingContact.Phone1} for delivery.",
                    lines                 = dclLines
                }
            };
        }