refactor: services and facades

This commit is contained in:
filippo-ferrari 2024-09-22 15:52:03 +02:00
parent 68f0d5629f
commit ba4876bf8c
2 changed files with 4 additions and 11 deletions

View file

@ -134,7 +134,7 @@ public class PersonFacade {
*/
public void setCreditPaid(Person person, TreeGrid<Object> grid, Long userId) {
try {
List<Expense> expenses = expenseService.findExpensesWhereBeneficiary(person).stream().toList();
List<Expense> expenses = (List<Expense>) expenseService.findExpensesWhereBeneficiary(person);
for (Expense expense : expenses) {
expense.setIsPaid(true);
expenseService.update(expense, userId);

View file

@ -216,15 +216,8 @@ public class ExpenseService {
Person beneficiary = expense.getBeneficiary();
// Determine the expense type
if (payer.equals(loggedInPerson) && !beneficiary.equals(loggedInPerson)) {
// Logged-in user is the payer, and the beneficiary is someone else
expense.setExpenseType(ExpenseType.CREDIT);
} else if (!payer.equals(loggedInPerson) && beneficiary.equals(loggedInPerson)) {
// Logged-in user is the beneficiary, and the payer is someone else
expense.setExpenseType(ExpenseType.DEBIT);
} else if (payer.equals(loggedInPerson) && beneficiary.equals(loggedInPerson)) {
// Both payer and beneficiary are the logged-in user
expense.setExpenseType(ExpenseType.NONE);
}
if (payer.equals(loggedInPerson) && !beneficiary.equals(loggedInPerson)) expense.setExpenseType(ExpenseType.CREDIT); // Logged-in user is the payer, and the beneficiary is someone else
else if (!payer.equals(loggedInPerson) && beneficiary.equals(loggedInPerson)) expense.setExpenseType(ExpenseType.DEBIT); // Logged-in user is the beneficiary, and the payer is someone else
else if (payer.equals(loggedInPerson)) expense.setExpenseType(ExpenseType.NONE); // Both payer and beneficiary are the logged-in user
}
}