Thanks to visit codestin.com
Credit goes to github.com

Skip to content

le-christine/fiscally-fit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fiscally Fit

This is an API for calculating income tax based on salary and tax year. It provides a single endpoint that accepts two query parameters: income and year.

Example Usage

http://localhost:8080/calculate?income=100000&year=2022

{
  "effectiveTaxRate":18,
  "taxesByBracket":
  { 
  "Tax band: $0.00 to $50197.00":"$7529.55",
  "Tax band: $50197.00 to $100392.00":"$10209.61"
  },
  "totalTaxes":"$17739.17"}

How to Run

Prerequisites

A mock API provides tax bracket data by year, which runs on port 5000.

Local Install

There are two options:

  1. Clone the repo and run the following from the root directory:
go run main.go
  1. Clone the repo and execute the binary:
./main

API Specification

openapi: 3.0.0
info:
  version: 1.0.0
  title: Tax Calculator API
  description: An API for calculating income tax based on salary and tax year
paths:
  /calculate:
    get:
      summary: Calculate income tax for a given salary and tax year
      parameters:
        - name: income
          in: query
          description: The annual income to calculate taxes for
          required: true
          schema:
            type: integer
            minimum: 0
        - name: year
          in: query
          description: The tax year to use for calculating taxes
          required: true
          schema:
            type: integer
            enum: [2019, 2020, 2021, 2022]
      responses:
        '200':
          description: Returns the total taxes owed for the salary
          content:
            application/json:
              schema:
                type: object
                properties:
                  totalTaxes:
                    type: number
                  taxesByBracket:
                    type: object
                  effectiveTaxRate:
                    type: number
        '400':
          description: Invalid parameters provided
        '500':
          description: Internal server error

Directory Structure

.
├── README.md
├── app
│   ├── handlers // Contains logic for handling HTTP requests
│   ├── models // Responsible for data representation, storage, and handling
│   └── services // Interacts with the model layer to perform business logic
├── go.mod
├── go.sum
└── main.go // Entry Point of the application

Testing

From the root directory, run the following:

go test ./app/services
go test ./app/config

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages