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

1.8k views Asked by At

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.

4

There are 4 answers

1
Jeff Williams On BEST ANSWER

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.

1
srodionov On

Let me clarify how the tax calculation in Acumatica works. Acumatica calculates the taxes based on Customer Tax Zone property form Financial Setting tab.

The main question for you how you will report taxes to Tax Agency, as Jeff wrote you have a couple of options.

If you just need to have only full tax amount for document and you do not want to control which taxes been used in document, then next approach for you:

  1. Create DEFAULT tax with DEFAULT tax zone and tax category.
  2. Set start date from the past, tax rate = 0
  3. For any new SO from Ecommerce, set Customer Tax Zone = Default
  4. Then when you save document acumatica based on tax setting will create a line under Tax Details with 0 tax amount, so you can edit it. Probably you can also create that line on the fly during api calls.

Notice: if you need more detailed data, like to have all taxes for SO from Ecommerce (State tax, county tax + etc) you ca use the same approach but you will need to create on the fly your taxes/tax zones.

Another option could be is using Avalara tax provider.

I hope this info will be helpful.

0
seanvalencourt On

For someone else looking for a solution to this issue, we ran into a similar problem where we were getting the following error: "No lines match the tax" when trying to manually enter a tax amount on the sales order header. The solution was to find the tax ID we were using in Taxes > Profiles > Taxes, go to the categories tab, and make sure we had added every tax category to that ID.

0
amontalvo On

This is an old post, but I thought I would post the answer that worked for me with 2019 R2. For some reason, Acumatica doesn't allow you to update the TaxDetails Tax Amount field at the time of the Sales Order creation. Once the sales order is created with your assigned Tax Zone, the "Tax Amount" field can only be updated using the Tax Details object ID. Therefore, you'll need to GET the sales order's tax details by expanding the "Tax Details" using the ODATA query $expand=TaxDetails

Then update the sales order using a PUT and send the Tax amount to the "TaxAmount" key-value using the object's existing "id". Depending on how you write your code, this will work every time perfectly. Below is a screenshot referring to the TaxDetails object id.

JSON Example Showing TaxDetails Object id