Interface BudgetServiceInterface
- All Known Implementing Classes:
BudgetService
public interface BudgetServiceInterface
A Service that handles all business logic for Budget Models
- Author:
- Omari Grant
-
Method Summary
Modifier and TypeMethodDescriptionvoidcalculateResults(Budget budget, LocalDate baseDate) Function to calculate the results from a budget and attach the results to the budget.voidDelete a budget from the databasebooleandoesBudgetBelongToUser(User user, Long budgetId) Checks that the budget belongs to the user to prevent users affecting items that are not theirs.findAll()Return all BudgetDTO to the userGet Budget output model by idhandleControllerInputAndSave(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.voidRecalculate all budgetsSave Budget model to database.update(Long id, BudgetInputDTO updatedBudget, LocalDate baseDate) Update a Budget and return the output model.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.
-
Method Details
-
recalculateAll
void recalculateAll()Recalculate all budgets -
findAll
Return all BudgetDTO to the user- Returns:
- List of BudgetDTOs to output to user
-
findById
Get Budget output model by id- Parameters:
budgetId- The id of Budget model- Returns:
- BudgetDTO output model to return to user
-
save
Save Budget model to database.- Parameters:
budget- Budget modelbaseDate- date to apply calculations against- Returns:
- BudgetDTO model to output to user.
-
update
Update a Budget and return the output model.- Parameters:
id- ID of Budget model to updateupdatedBudget- The Budget input model with updated fieldsbaseDate- date to apply calculations against- Returns:
- BudgetDTO an output model that has been updated.
-
delete
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 inputbaseDate- date to apply calculations againstuser- User model to attach budget too- Returns:
- BudgetDTO which displays all the information to the user.
-
viewCalculationOnly
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 inputbaseDate- date to apply calculations against- Returns:
- BudgetDTO which displays all the information to the user.
-
calculateResults
Function to calculate the results from a budget and attach the results to the budget.- Parameters:
budget- Budget modelbaseDate- date to apply calculations against
-
doesBudgetBelongToUser
Checks that the budget belongs to the user to prevent users affecting items that are not theirs.- Parameters:
user- User modelbudgetId- Id of budget to check- Returns:
- true if the budget belongs to user
-