Acumatica在创建销售订单时更改运输条款 [英] Acumatica change Shipping Terms on Sales Order creation

查看:77
本文介绍了Acumatica在创建销售订单时更改运输条款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Acumatica基于合同的API从ASP.net应用程序创建销售订单。创建订单时,我需要更新销售订单上运输设置选项卡下的运输条款字段(请参见下文),但是找不到通过该属性提供的ASP.net对象上使用的属性。基于合同的API。我将如何实现?





下面的示例显示了如何通过 默认 基于合同的端点更改销售订单的运输条款使用 CustomFields 集合:

 使用(var client = new DefaultSoapClient ())
{
client.Login( admin, 123,null,null,null);
尝试
{
var order = new SalesOrder()
{
OrderType = new StringSearch {值= SO},
OrderNbr = new StringSearch {值= SO003729}
};
order = client.Get(order)as SalesOrder;
order.CustomFields =新的CustomField []
{
新的CustomStringField
{
fieldName = ShipTermsID,
viewName = CurrentDocument,
值=新的StringValue {值= FLATRATE2}
}
};
client.Put(order);
}
最终
{
client.Logout();
}
}

更新销售订单时我的端部也没有发现任何问题在新的Acumatica ERP 6.1实例上具有 默认 基于合同的端点的运输条款

 使用(var client = new DefaultSoapClient())
{
client.Login( admin, 123,null,null,null );
尝试
{
var order = new SalesOrder()
{
OrderType = new StringSearch {值= SO},
OrderNbr = new StringSearch {值= SO003729}
};
order = client.Get(order)as SalesOrder;
order.ShippingTerms =新的StringValue {值= FLATRATE1};
client.Put(order);
}
最终
{
client.Logout();
}
}

作为参考,添加了我扩展后的 默认 端点,用于更新 SalesOrder 实体中的运输条款




I'm using Acumatica's contract based API to create sales order from an ASP.net application. I need to update the "Shipping Terms" field under the "Shipping Settings" tab on a Sales Order when I create it (see below), but I can not find the property to use on the ASP.net objects that are provided through the contract based API. How would I accomplish this?

Here is my current code for how I create the sales order:

using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
    //Sales order data
    string customerID = "CUST1234;
    string orderDescription = "Automated Order";
    string customerOrder = "TEST";

    var orderDetails = new List<SalesOrderDetail>();

    foreach(var lineItem in order.line_items)
    {
        orderDetails.Add(new SalesOrderDetail {
            InventoryID = new StringValue { Value = lineItem.sku },
            Quantity = new DecimalValue { Value = lineItem.quantity },
            UnitPrice = new DecimalValue { Value = Decimal.Parse(lineItem.price) }, //TODO this should only be done for MHR owned sites
            UOM = new StringValue { Value = "EACH" },

        });
    }


    //Specify the values of a new sales order
    SalesOrder orderToBeCreated = new SalesOrder
    {
        OrderType = new StringValue { Value = "SO" },
        CustomerID = new StringValue { Value = customerID },
        Description = new StringValue { Value = orderDescription },
        CustomerOrder = new StringValue { Value = customerOrder },
        ExternalReference = new StringValue { Value = order.order_number.ToString() },
        Details = orderDetails.ToArray<SalesOrderDetail>(),
        ShippingAddressOverride = new BooleanValue { Value = true },
        ShippingContactOverride = new BooleanValue { Value = true },
        ShippingContact = new Contact()
        {
            DisplayName = new StringValue { Value = order.shipping_address.first_name + " " + order.shipping_address.last_name },
            FirstName = new StringValue { Value = order.shipping_address.first_name },
            LastName = new StringValue { Value = order.shipping_address.last_name },
            Address = new Address()
            {
                AddressLine1 = new StringValue { Value = order.shipping_address.address_1 },
                AddressLine2 = new StringValue { Value = order.shipping_address.address_2 },
                City = new StringValue { Value = order.shipping_address.city },
                State = new StringValue { Value = order.shipping_address.state },
                Country = new StringValue { Value = order.shipping_address.country },
                PostalCode = new StringValue { Value = order.shipping_address.postcode }
            }
        },

    };

    client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);

    //Create a sales order with the specified values
    try
    {
        SalesOrder newOrder = (SalesOrder)await client.PutAsync(orderToBeCreated);

        client.Logout();

        return newOrder;
    }
    catch (Exception e)
    {
        //order addition to Acumatica failed, update the order status in Woo Commerce
        client.Logout();
        Console.WriteLine("Acumatica could not add specified entity: " + e);
        return null;
    }

}

UPDATE: Based on PatrickChen's comment, I created a new web service endpoint in Acumatica "SalesOrderCustom", where I used all of the default fields and then added "ShippingTerms" to the list as well. I then imported that web service into my .net project (with some headache due to this issue) and was able to use the service to GET the sales order I wanted to add shipping terms to, and try to update it. The code executes ok, but after the PUT operation is done, the object is NOT updated in Acumatica and the ShippingTerms property is returned as NULL. What am I doing wrong? Code below:

public async Task<SalesOrderCustom> UpdateShippingTerms(string customerOrder, string originStore, string shippingSpeed)
{
    var binding = CreateNewBinding(true, 655360000, 655360000);

    var address = new EndpointAddress(ConfigurationManager.AppSettings["AcumaticaCustomUrl"]);

    var soToBeFound = new SalesOrderCustom()
    {
        OrderType = new StringSearch { Value = "SO" },
        CustomerOrder = new StringSearch { Value = customerOrder }
    };

    using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
    {
        client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);

        try
        {
            var soToBeUpdated = (SalesOrderCustom) await client.GetAsync(soToBeFound);

            soToBeUpdated.ShippingTerms = new StringValue { Value = "USPS 1 CLS" };

            var updatedOrder = (SalesOrderCustom)await client.PutAsync(soToBeUpdated);
            //ShippingTerms is still NULL on returned object even after updating the object!!! WHY???

            client.Logout();
            return updatedOrder;
        }
        catch (Exception e)
        {
            client.Logout();
            Console.WriteLine("Acumatica could not find specified entity: " + e);
            return null;
        }
    }
}

解决方案

Starting Acumatica 6, it's possible to update any field, not included into the Default endpoint. This feature is only available for endpoints implementing system contract of the 2nd version:

Below is the sample showing how to change Shipping Terms for a Sales Order with the Default Contract-Based endpoint by working with the CustomFields collection:

using (var client = new DefaultSoapClient())
{
    client.Login("admin", "123", null, null, null);
    try
    {
        var order = new SalesOrder()
        {
            OrderType = new StringSearch { Value = "SO" },
            OrderNbr = new StringSearch { Value = "SO003729" }
        };
        order = client.Get(order) as SalesOrder;
        order.CustomFields = new CustomField[]
        {
            new CustomStringField
            {
                fieldName = "ShipTermsID",
                viewName = "CurrentDocument",
                Value = new StringValue { Value = "FLATRATE2" }
            }
        };
        client.Put(order);
    }
    finally
    {
        client.Logout();
    }
}

No issues also noticed on my end when updating Sales Order Shipping Terms with the extended Default Contract-Based endpoint on a brand new Acumatica ERP 6.1 instance:

using (var client = new DefaultSoapClient())
{
    client.Login("admin", "123", null, null, null);
    try
    {
        var order = new SalesOrder()
        {
            OrderType = new StringSearch { Value = "SO" },
            OrderNbr = new StringSearch { Value = "SO003729" }
        };
        order = client.Get(order) as SalesOrder;
        order.ShippingTerms = new StringValue { Value = "FLATRATE1" };
        client.Put(order);
    }
    finally
    {
        client.Logout();
    }
}

For reference, adding screenshot of my extended Default endpoint used to update Shipping Terms in the SalesOrder entity:

这篇关于Acumatica在创建销售订单时更改运输条款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆