Skip to content

sergioasantiago/capitalgainstaxcalculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capital Gains Tax Calculator

This project calculates capital gains tax based on a series of buy and sell operations represented by JSON data.

The program receives lists as input, one per line, of stock market transactions in json format via standard input ( stdin ).

For each input line, the program must return a list containing the tax paid for each operation performed.

An input example can be found at example/input.txt.

Libraries

This projects uses the following libraries:

  1. jackson-databind: To parses the JSON input string and write the output as JSON.

  2. junit-jupiter-api: To create and run unit tests.

  3. lombok: Used to reduce boilerplate code. e.g: getters/setters

Rounding decimals

This project rounds decimals using half up and 2 decimal places. To implement this, the BigDecimal java class was used with a predefined scale of 2 and RoundingMode.HALF_UP.

Requirements:

Or build using docker

Building

make build

Running

Expecting user input:

make run

Using an input.txt file:

make run < example/input.txt

Running Tests

make test

Running with Docker

Build the docker image:

docker build -t capitalgainstax .

Running docker expecting user input:

docker run --rm -i  capitalgainstax

Running docker using input.txt file:

docker run --rm -i  capitalgainstax < example/input.txt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published