ms-taxes
v1.0.5
Published
Tax Microservice
Downloads
3
Readme
:toc: macro :toc-title: :toclevels: 99
ms-taxes image:https://travis-ci.com/Groupe-Atallah/ms-taxes.svg?token=y5pe7uGwsidVcw4pszW1&branch=v1["Build Status", link="https://travis-ci.com/Groupe-Atallah/ms-taxes"]
http://ac9c6f8e39fc311e7933702bb3bd0e5d-153786183.us-west-2.elb.amazonaws.com/docs/swagger[api reference] | https://todo[monitoring]
QA: https://rpm.newrelic.com/accounts/1410690/applications/72100340[monitoring]
toc::[]
About
The ms-taxes
microservice is responsible for maintaining tax rates and applying trivial rules. For example some Canadian provinces work with a single sales tax that combines federal and provincial rates called the "Harmonized Sales Tax" or HST. ms-taxes
takes care of this. However more involved rules like Quebec's compound taxation pre January 1 2013 are not handled. This is probably a missing feature. Refer to the first TODO below.
Features
- Return the taxation rates for a given country and region (AKA sub-division).
- Handle Canadian HST rules
Examples
❯ http "http://ac9c6f8e39fc311e7933702bb3bd0e5d-153786183.us-west-2.elb.amazonaws.com/rates?country=ca®ion=qc"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 97
Date: Mon, 25 Sep 2017 03:01:12 GMT
content-type: application/json; charset=utf-8
{
"combinatedRate": 0.14975,
"rates": [
{
"amount": 0.05,
"name": "gst"
},
{
"amount": 0.09975,
"name": "pst"
}
]
}
❯ http "http://ac9c6f8e39fc311e7933702bb3bd0e5d-153786183.us-west-2.elb.amazonaws.com/rates?country=ca®ion=on"
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 62
Date: Mon, 25 Sep 2017 03:00:33 GMT
content-type: application/json; charset=utf-8
{
"combinatedRate": 0.13,
"rates": [
{
"amount": 0.13,
"name": "hst"
}
]
}
Design Principals
Although SSENSE does not collect sales tax in every country (or even every region in countries that it does collect federal tax), the client does not need to know this. The client need only provide a well formed country and region combination, and ms-taxes
will return tax rates data. As SSENSE ceases to/begins to collect taxes in varying regions or countries, the client should not have to change.
TODOs
These are TODOs for the next engineering squad that works on this microservice.
. The current model only returns rates but does not handle applying them to a price. This means it falls onto the caller to know how to apply tax rates. In the above example about Quebec compound sales tax, the client would need to know this! It is currently envisioned that a parent aggregation layer (e.g. ag-fees
) will sit in front of ms-taxes
and ms-duties
and coordinate their correct usage. Perhaps this layer could contain the knowledge of how to apply tax rates. Otherwise the API interface of ms-taxes
must be significantly refactored to:
.. require the client price
param
.. calculate the amount to pay for each applicable tax rate
. Validate the tax rates of some countries since it is inconsistent between the database and HQM service result. It includes: Australia, China, Puerto Rico and Russia. Some comments can be found in TestData.ts
.
. The quality of this micro-service is draft level, having gone through only a partial sprint of work from engineers unfamiliar with the conventions used in this project. We think another few days of refinement is necessary, and feel uncomfortable not being explicit about this.
. Get the test coverage higher.