Net Price Calculator (netcalculator) as a web service for any company which provides financial services across currencies, be it international or even worldwide. Developed with Java 17. It is a service which allows consumers to calculate the net price based on the input gross price and VAT (MWSt).
The simplest interface for the net price formula expects two parameters from end users or integrated services:
- gross price
- ISO country code
The formula is listed below:
'''netPrice = calculateNetPrice(grossPrice, countryIso);'''
'''81 = calculateNetPrice(100, DE); 1.6 = calculateNetPrice(1.99, FR);'''
This service accesses
taxRateProviderservice which returns the current VAT rate required to calculate the net price for a given country. The tax data used by the
taxRateProvideris represented as a simple map of country code to tax rate.
- "DE":"0.19", // Germany has 19% VAT on standard taxable goods
- "FR":"0.20", // France has 20% VAT on standard taxable goods
It is a fully runnable (with mvn) and testable Java implementation along with the instructions required for a reviewer.
eureka
: Eureka server for service discoveryapi-gateway
: to welcome incoming requests for servicesnet-calculator
: to present the net price data to consumerstax-rate-provider
: to retrieve VAT rate for specified country
- Inside eureka project directory: Run
mvn install
. - Inside api-gateway project directory: Run
mvn install
. - Inside net-calculator project directory: Run
mvn install
. - Inside tax-rate-provider project directory: Run
mvn install
.
The services should be started in the following order to ensure smooth functioning:
- Start eureka project as a Java Application or Spring Boot App.
- Start api-gateway project as a Java Application or Spring Boot App.
- Start net-calculator project as a Java Application or Spring Boot App.
- Start tax-rate-provider project as a Java Application or Spring Boot App.
Hit the following URLs with a modern web browser or a REST client:
- http://localhost:8999/nc/de/129
- http://localhost:8999/nc/fe/1.39
- http://localhost:8999/tr/fr
- http://localhost:8999/tr/de
The last two parts of URL paths signify the following semantics:
de
/fr
: country codes129
/1.39
: gross prices
In response, respective net prices are be returned. You may try other values of country code and gross price as well. Also, we may together think over how to make this library more versatile as a value generator for clients.
- Translate the app into Kotlin.
- Translate the app into Go (Golang) to observe performance gain, if any (just for fun).
- Try to add more testing scenarios.
- LinkedIn: https://www.linkedin.com/in/rishirajopenminds
- X: https://twitter.com/RishiRajDevOps
- Start Page: https://bio.link/rishiraj49de
- GitHub: https://github.com/rishiraj88