# US sales tax and Litium

**URL:** https://forum.litium.com/t/us-sales-tax-and-litium/3031
**Category:** Questions
**Tags:** litium-8
**Created:** [August 25, 2023, 11:20am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031 "2023-08-25T11:20:27Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)
#### Post date: [August 25, 2023, 11:20am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/1 "2023-08-25T11:20:28Z")

</div>

We’re selling products in the US and in some states/areas we need to add sales tax to the orders. It’s not easy to keep track on all the different sales taxes they have in the US and when to add them so we use a third party partner for this called Avalara.

I’m curious if someone else has done an integration between Litium and Avalara?

Also where, in Litium 8, would be the best place to add the sales tax and calculations? I’m guessing that the best place would be to do it where the VAT is added and calculated. Where in the Litium code does that happen? And is there a way override that when an order is placed for the US?

Litium version: 8

---

<div class="post-metadata">

### Author: ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)
#### Post date: [August 25, 2023, 12:25pm UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/2 "2023-08-25T12:25:26Z")

</div>

The entry point for VAT calculations is the `Litium.Sales.Calculator.IVatRuleFactory`, that have one method that you can override and return the vat rule that should be used for the order.

---

<div class="post-metadata">

### Author: ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)
#### Post date: [August 28, 2023, 10:21am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/3 "2023-08-28T10:21:28Z")

</div>

Thanks. Also found this that was helpful, [Calculating VAT (litium.com)](https://docs.litium.com/platform/areas/sales/order-placement/calculating-vat).

Wondering if it would be possible to get the code for the CalculateVat method of the default VatRule used in Litium? It would be great for guidance when writing our own.

---

<div class="post-metadata">

### Author: ![wiseby](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/wiseby/32/959_2.png) [@wiseby](https://forum.litium.com/u/wiseby)
#### Post date: [September 14, 2023, 8:11am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/4 "2023-09-14T08:11:43Z")

</div>

I’m also interested in how the default implementation looks like, to have something to start with. In my case there is only small tweaks that I need to make.

---

<div class="post-metadata">

### Author: ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)
#### Post date: [September 26, 2023, 10:58am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/5 "2023-09-26T10:58:36Z")

</div>

What do you think @patric.forsgard, would it be possible to get the code for the CalculateVat method of the default VatRule?

---

<div class="post-metadata">

### Author: ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)
#### Post date: [October 19, 2023, 6:36am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/6 "2023-10-19T06:36:45Z")

</div>

I have updated the following article with sample code:

> **[Calculating VAT](https://docs.litium.com/platform/areas/sales/order-placement/calculating-vat)**
>
> Calculating VAT

---

<div class="post-metadata">

### Author: ![samuel](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/samuel/32/479_2.png) [@samuel](https://forum.litium.com/u/samuel)
#### Post date: [November 8, 2023, 8:29am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/7 "2023-11-08T08:29:12Z")

</div>

Thanks @anusha.ganegoda!

Just one note. Why do you put out example code where you populate obsolete members?

For example in CalculateVat method.

```auto
row.CalculateByTotalIncludingVat(currencyCode, _roundOffService);
#pragma warning disable CS0618 // Type or member is obsolete
row.VatSummary = new Dictionary<decimal, decimal> { { vatRates[0], row.TotalVat } };
#pragma warning restore CS0618 // Type or member is obsolete
row.VatDetails = new List<VatDetail> { new VatDetail { VatRate = vatRates[0], AmountIncludingVat = row.TotalIncludingVat, Vat = row.TotalVat } };

```

Same thing is in the methods CalculateForProRata and CalculateForOrderDiscountProRata.

Also, if you grab the example code and put it in the Accelerator project there are a lot of things that can’t be found by Visual Studio. Not sure if we also need to add some new library for this? Which one(s) in that case?

For example:  
Where is the RoundOffService?  
Where is the CalculationExtensionContext?

There’s also a bunch of, what looks like, extension methods it can’t figure out.  
IncludedInProRataCalc  
AppliedForProRataCalc  
IsOrderDiscountRow  
… and more.

It’s kind of difficult to use it as a starting point if it doesn’t work.

---

<div class="post-metadata">

### Author: ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)
#### Post date: [November 30, 2023, 11:07am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/8 "2023-11-30T11:07:53Z")

</div>

I have updated the article here on how to use default VAT rule.  
the default calculation is too complex to explain and re-implement, so I have taken away the code that did not compile.

> **[Calculating VAT](https://docs.litium.com/platform/areas/sales/order-placement/calculating-vat)**
>
> Calculating VAT

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)
#### Post date: [December 28, 2023, 11:08am UTC](https://forum.litium.com/t/us-sales-tax-and-litium/3031/9 "2023-12-28T11:08:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
