2
votes

I am trying to get a way to obtain the discount code from the web service API, i.e would there be a function call that could tell me which discount code to apply?

I am otherwise attempting to retrieve the discount codes but they can be by Item or By Item Price Class and Customer etc etc which is making the code longer than expected.

Hopeing there is a "GetBestDiscount" facility in the API that could help me?

Thanks, G

3

3 Answers

2
votes

At this moment Acumatica Discount Engine is deactivated for any Web Service call. Due to this fact, entering an order line without any discount will not populate the discount code.

However, at Acumatica University there is the GetSalesPrice.zip customization package made specifically to retrieving the price of an Item for a Customer (attached to the I200 Screen-Based Web Services 5.3 and the I210 Contract-Based Web Services 5.3 sources).

Sample call for Screen-Based API:

Content getSalesPriceSchema = context.GetSchema();
var commands = new Command[]
{
    new Value
    {
        Value = customer,
        LinkedCommand =getSalesPriceSchema.RequiredInputParameters.Customer
    },
    new Value
    {
        Value = inventoryID,
        LinkedCommand =getSalesPriceSchema.RequiredInputParameters.InventoryID
    },
    getSalesPriceSchema.OutputPrice.Price
};
Content price = context.Submit(commands)[0];

Sample call for Contract-Based API:

GetSalesPriceInquiry priceToBeGet = new GetSalesPriceInquiry
{
    Customer = new StringValue { Value = customer },
    InventoryID = new StringValue { Value = inventoryID }
};
GetSalesPriceInquiry stockItemPrice = (GetSalesPriceInquiry)soapClient.Put(priceToBeGet);
1
votes

I tried creating a temporary Sales order line via API Order Entry Screen without saving it as Gabriel suggestion. I can retrieve the set price no problems but the Discount Percentage and Discount Code is not returned. The discount percentage returned is zero and the discount Code is blank.

This is because the Acumatica Discount Engine is deactivated for any Web Service call I guess.

Any reason why the Acumatica Discount Engine is deactivated for any Web Service calls?

0
votes

There is no such API, however you could use the sales order entry screen API to create a temporary sales order, add one line to it and retrieve the set price or discount without saving the order. This will be the most accurate information, since discounts and price can also depend on the date, quantity and also on other products being ordered at the same time.