Interface BudgetServiceInterface

All Known Implementing Classes:
BudgetService

public interface BudgetServiceInterface
A Service that handles all business logic for Budget Models
Author:
Omari Grant
  • Method Details

    • recalculateAll

      void recalculateAll()
      Recalculate all budgets
    • findAll

      List<BudgetDTO> findAll()
      Return all BudgetDTO to the user
      Returns:
      List of BudgetDTOs to output to user
    • findById

      BudgetDTO findById(Long budgetId)
      Get Budget output model by id
      Parameters:
      budgetId - The id of Budget model
      Returns:
      BudgetDTO output model to return to user
    • save

      BudgetDTO save(Budget budget, LocalDate baseDate)
      Save Budget model to database.
      Parameters:
      budget - Budget model
      baseDate - date to apply calculations against
      Returns:
      BudgetDTO model to output to user.
    • update

      BudgetDTO update(Long id, BudgetInputDTO updatedBudget, LocalDate baseDate)
      Update a Budget and return the output model.
      Parameters:
      id - ID of Budget model to update
      updatedBudget - The Budget input model with updated fields
      baseDate - date to apply calculations against
      Returns:
      BudgetDTO an output model that has been updated.
    • delete

      void delete(Long id)
      Delete a budget from the database
      Parameters:
      id - Budget id
    • handleControllerInputAndSave

      BudgetDTO handleControllerInputAndSave(BudgetInputDTO budgetInputDTO, LocalDate baseDate, User user)
      This functions primary use is for functions, so an input model is given, processed and saved before returning an output model to the user.
      Parameters:
      budgetInputDTO - An input model for users to input
      baseDate - date to apply calculations against
      user - User model to attach budget too
      Returns:
      BudgetDTO which displays all the information to the user.
    • viewCalculationOnly

      BudgetDTO viewCalculationOnly(BudgetInputDTO budgetInputDTO, LocalDate baseDate)
      This functions primary use is for functions, so an input model is given, processed and an output model is returned to the user. This would be used when saving is not required.
      Parameters:
      budgetInputDTO - An input model for users to input
      baseDate - date to apply calculations against
      Returns:
      BudgetDTO which displays all the information to the user.
    • calculateResults

      void calculateResults(Budget budget, LocalDate baseDate)
      Function to calculate the results from a budget and attach the results to the budget.
      Parameters:
      budget - Budget model
      baseDate - date to apply calculations against
    • doesBudgetBelongToUser

      boolean doesBudgetBelongToUser(User user, Long budgetId)
      Checks that the budget belongs to the user to prevent users affecting items that are not theirs.
      Parameters:
      user - User model
      budgetId - Id of budget to check
      Returns:
      true if the budget belongs to user