docs: added javadocs and TODOs
This commit is contained in:
parent
0377d15501
commit
7e15be27c1
3 changed files with 19 additions and 4 deletions
|
@ -183,6 +183,12 @@ public class ExpenseService {
|
|||
return (int) expenseRepository.count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the yearly net expenses of the user
|
||||
* @param loggedInPerson the logged-in user
|
||||
* @param year the year from which we want the expenses
|
||||
* @return the list of expenses of that user in that year
|
||||
*/
|
||||
public List<Expense> fetchExpensesForDashboard(Person loggedInPerson, Year year) {
|
||||
List<Expense> totalExpenses = new ArrayList<>();
|
||||
final var yearValue = year.getValue();
|
||||
|
@ -218,7 +224,6 @@ public class ExpenseService {
|
|||
if (userDetails == null) {
|
||||
throw new IllegalStateException("No logged-in user found");
|
||||
}
|
||||
|
||||
// Fetch the logged-in user
|
||||
final var loggedInUserId = userRepository.findByUsername(userDetails.getUsername()).getId();
|
||||
Person loggedInPerson = this.personRepository.findByUserId(loggedInUserId).orElse(null);
|
||||
|
|
|
@ -37,6 +37,10 @@ public class UserService {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the user's data and its connected person entity
|
||||
* @param user the user of which we update the data
|
||||
*/
|
||||
public void updateUser(User user) {
|
||||
userRepository.save(user);
|
||||
final var person = personRepository.findByUserId(user.getId())
|
||||
|
@ -46,7 +50,13 @@ public class UserService {
|
|||
personRepository.save(person);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a user and connected person entity
|
||||
* @param user the user of which we update the data
|
||||
*/
|
||||
public void saveUserAndConnectedPerson(User user) {
|
||||
//TODO: look if this method can substitute the one above: updateUser, they seem to do similar things
|
||||
|
||||
// Check if the user already exists in the database
|
||||
final var existingUserOptional = userRepository.findOptionalByUsername(user.getUsername());
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ class PersonServiceTest {
|
|||
person2.setLastName("second");
|
||||
person2.setFirstName("person");
|
||||
|
||||
Person person3 = new Person();
|
||||
person3.setLastName("third");
|
||||
person3.setFirstName("person");
|
||||
// Person person3 = new Person();
|
||||
// person3.setLastName("third");
|
||||
// person3.setFirstName("person");
|
||||
|
||||
Expense expense1 = mock(Expense.class);
|
||||
when(expense1.getPayer()).thenReturn(person);
|
||||
|
|
Loading…
Reference in a new issue