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?
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.
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.
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.
Just one note. Why do you put out example code where you populate obsolete members?
For example in CalculateVat method.
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.
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.