Feature #1525

Updated by Pavan Rikhi 9 months ago

Now that we have to pay sales tax per state instead of just for VA, we'll pick a sales tax software to do the calculations & filing for us.

Avalara has nice guide & API docs. We'll probably just need the CreateCustomer, CreateTransaction & RefundTransaction routes at first:



And they use swagger to document this so we can use swagger-codegen to automatically generate a client using Haskell: https://sandbox-rest.avatax.com/swagger/ui/index.html

TaxJar seems simpler:


Need to wait til the office decides which to pick, if any at all. If we don't pick one, we need a more complex tax calculation that discriminates by county.


We picked Avalara:

* https://developer.avalara.com/avatax/dev-guide/getting-started-with-avatax/
* https://developer.avalara.com/avatax/calculating-tax/
* https://developer.avalara.com/avatax/client-headers/
* https://developer.avalara.com/avatax/filtering-in-rest/
* https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Definitions/ListTaxCodes/
* https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/
* https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/RefundTransaction/

Add an @Avalara@ module to the server, with an @avalaraRequest@ function in the @Server@ module which is responsible for running the requests. Use @req@ or @hreq@ haskell libraries for making the requests.

Hook into the CartDetails, Checkout, & Refund routes, hitting avalara for sales tax quotes & collection recording for orders with non-zero sub-totals.

For now, we can rely on avalara website for assigning tax codes to products. If easy or we have extra time, we should add dropdowns to the Add/Edit product page, allowing us to pick from a limited set of tax codes that are applicable to our products(the 3 categories of seeds, cds, dvds, books, tangible property).