GithubHelp home page GithubHelp logo

vat-calculator's Introduction

Austrian VAT Calculator

A microservice to calculate Value Added Tax (VAT) for Austria.

How does it work?

The API receives one of the netAmount, grossAmount or vatAmount and additionally a valid Austrian vatRate (10%, 13%, 20%). The other two amounts (net/gross/VAT) are calculated by the system and returned to the client.

Example

Request:

curl --location 'https://localhost:8081/valueaddedtax' \
--header 'Content-Type: application/json' \
--data '{
    "grossAmount": 1100,
    "vatRate": 10
}'

Response:

{
    "grossAmount": 1100,
    "netAmount": 1000,
    "vatAmount": 100,
    "vatRate": 10
}

How to run?

To run this application, clone this project, open the root folder in the terminal, and follow one of the instructions below:

  • If you have a .NET 8 environment in your machine:
 dotnet run --project .\src\VatCalculator.WebApi\VatCalculator.WebApi.csproj
  • If you have Docker installed in your machine:
docker-compose up

Architecture

The proposed solution is composed of a three-layer architecture: WebApi, Application, and Domain, using a Clean Architecture approach.

WebApi layer

The WebApi layer is the startup layer and exposes a REST API. It registers the application layer. It also registers a global exception handler.

Application layer

The Application layer exposes the Use Cases provided by the application and used by the WebApi layer. To make validation in a fluent and decoupled way, I've used the library FluentValidation. For handling predictable errors, the Result pattern is being used through the ErrorOr library. The library Mapperly is used to automate the mapping between Application types and Domain types.

Domain layer

The Domain layer contains the business logic which is orchestred by the application layer.

Considerations

  • For unit testing, I've chosen to work with xUnit as the runner, and NSubstitute for mocking.

  • I only implemented Unit Testing for the Domain and Application layers. For the Presentation layer, I think Integration Testing will bring more benefits but it still was not implemented.

  • All logs will be the output in the console. In case we need a structured log, we could use a library such as Serilog.

  • I have not added but could be a benefit to add some Monitoring besides logs, such as Health Checkers, APM metrics and Tracing.

vat-calculator's People

Contributors

gabrielcalegari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.