ita-social-projects / Home

Home - is an all-in-one social service that will cover all aspects of your communication with your home and neighbors.
http://www.home-project-engineering.tech/api/0/apidocs/index.html
MIT License
26 stars 30 forks source link

Implement cooperation taxes constructor #476

Open vladyslavyarets opened 2 years ago

vladyslavyarets commented 2 years ago

As a cooperation admin I want to set and change cooperation taxes so that i need a functionality to set and change this data

Description Every member of cooperation pays cooperation taxes. This taxes evaluation due to statute and this price decided by services which every cooperation consumes. This payments is unique for every cooperation and evaluates for every property by it's area in relation to all house area which consumes concrete service.

Acceptance Criteria

I want to have an ability to set and change tax prices in my cooperation. The price paid by the cooperation must be divided between all property holders equally. So, we need a tool which will calculate price per meter for every service cooperation consumes. By this price-per-meter we should have an ability to calculate total price of every service for every property depends on it's area and type (apartment/non-living property/service rooms).

Tasks

  1. Create an endopint cooperations/settings/taxes which will give a CRUD functionality for setting and updating taxes information. Required fields:

Create :

Read:

Update:

Delete:

  1. create following tables into Database: image.png
    • services (stores services in relation to cooperation). Required fields:
    • id (PK)
    • service_name (varchar(255))
    • cooperation_id (integer/FK) references cooperations(id)

-price_per_meter (stores price per meter for every established rate)

  1. Implement API layer in CooperationApiImpl for functionality described above with following methods:

    • createServices(Long cooperationId, CreateSettings settings) to add new services with it's properties into Database. Returns:
    • HTTP 201 if service created
    • HTTP 401 if client is unauthorized
    • HTTP 403 if we try to access not allowed cooperation
    • HTTP 500 in other cases
    • queryServices(Long cooperationId) get all cooperation services. Returns:
    • HTTP 200 and list of Services if it exist or empty list if not
    • HTTP 401 if client is unauthorized
    • HTTP 403 if we try to access not allowed cooperation
    • HTTP 500 in other cases
    • getServiceById(Long cooperationId, Long serviceId). Returns:
    • HTTP 200 and Service if exist
    • HTTP 401 if client is unauthorized
    • HTTP 403 if we try to access not allowed cooperation
    • HTTP 404 if current service was not found
    • HTTP 500 in other cases
    • updateService(Long cooperationId, Long serviceId, UpdateService updatedService) updates service by it's ID. Returns:
    • HTTP 200 if service was updated
    • HTTP 401 if client is unauthorized
    • HTTP 403 if we try to access not allowed cooperation
    • HTTP 404 if current service was not found
    • HTTP 500 in other cases
    • deactivateServiceById(Long cooperationId, Long serviceId) set service as disabled
    • HTTP 200 if service was deactivated
    • HTTP 401 if client is unauthorized
    • HTTP 403 if we try to access not allowed cooperation
    • HTTP 404 if current service was not found
    • HTTP 500 in other cases
  2. Implement service layer. Constraints:

    • Only one active price-per-meter should exist for one service in within the bounds of one cooperation at the same time
    • Ones services' rate is updated, rate_end_date for previous record should be settled.
    • Two same services for the the one cooperation should NOT exist
    • If price_per_meter was calculated with incorrect data this calculation should be disabled to not display this in the taxes history
  3. Cover all logic with Api tests