Search code examples
acumaticaavalara

How to override the tax details when adding a sales order through web service API


When I was trying to add our e-commerce orders into Acumatica through Acumatica Web service API, the tax details including totals were always automatically calculated in Acumatica based on product and customer information I send from our e-commerce system to Acumatica.

Since our customers have already paid full amount of the payment including the tax for their orders on our e-commerce site, I would like to override those tax related information with whatever data, such as tax total and tax amount for each item, which I get from e-commerce to avoid potential conflict between e-commerce and Acumatica (the tax calculation should be exactly same in two system at most of the times but it may be different due to some configuration or system error occasionally), however, I tried different ways but none of them worked.

Anybody knows how to do that? Part of my code is as follows:

SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();

List<Command> cmds = new List<Command>();

cmds.Add(new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType });
cmds.Add(new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr });
cmds.Add(new Value { Value = "ABCD", LinkedCommand = SO301000.OrderSummary.Customer });
cmds.Add(new Value { Value = "ABCD1234", LinkedCommand = SO301000.OrderSummary.Location }); 

//please note I could add extra tax item as below:
cmds.Add(SO301000.TaxDetails.ServiceCommands.NewRow);
cmds.Add(new Value { Value = "0.5", LinkedCommand = SO301000.TaxDetails.TaxAmount });
cmds.Add(new Value { Value = "ON HST", LinkedCommand = SO301000.TaxDetails.TaxID });
cmds.Add(new Value { Value = "10", LinkedCommand = SO301000.TaxDetails.TaxRate });
cmds.Add(new Value { Value = "289", LinkedCommand = SO301000.TaxDetails.TaxableAmount });

//however when I was trying to add the number for tax total, it doesn't work
cmds.Add(new Value { Value = "1.5", LinkedCommand = SO301000.OrderSummary.TaxTotal });
cmds.Add(new Value { Value = "GST", LinkedCommand = SO301000.TaxDetails.TaxID });
//the two lines above do not work

//add line items
foreach (OrderItem item in orderInfo.OrderItems)
{
    cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
    cmds.Add(new Value { Value = item.InventoryCD, LinkedCommand = SO301000.DocumentDetails.InventoryID });
    cmds.Add(new Value { Value = item.Quantity.ToString(), LinkedCommand = SO301000.DocumentDetails.Quantity });

}

cmds.Add(SO301000.Actions.Save);
cmds.Add(SO301000.OrderSummary.OrderNbr);

SO301000Content[] SO30100content = context.SO301000Submit(cmds.ToArray());

Thanks.


Solution

  • TaxTotal is a calculated field based off the total of the tax tab line items. Without some customization work to enable that field and remove the calculations I don't believe it will be possible to override the calculated value.

    A couple options that I could see 1) Manually enter all the tax lines based off the Tax totals for your line items 2) Modify the line items to INCLUDE the tax and set the tax category as "NONTAXABLE" or create a new category for "PRETAXED/INCLUDINGTAX" or something along those lines so tax isn't automatically calculated. 3) Let Acumatica auto calculate the tax based off the tax rules.

    In the past I've leaned toward #2 and #3 depending on the requirements.