From 5a53d412368fdcd4e6d85eceb002e8a3f5a5652f Mon Sep 17 00:00:00 2001 From: effe Date: Sat, 14 Sep 2024 14:17:04 -0400 Subject: [PATCH] docs: ExpenseFacade --- .../munera/facades/ExpenseFacade.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/application/munera/facades/ExpenseFacade.java b/src/main/java/com/application/munera/facades/ExpenseFacade.java index 65a6c10..c6f2ea7 100644 --- a/src/main/java/com/application/munera/facades/ExpenseFacade.java +++ b/src/main/java/com/application/munera/facades/ExpenseFacade.java @@ -1,11 +1,14 @@ package com.application.munera.facades; import com.application.munera.data.Expense; +import com.application.munera.data.Person; import com.application.munera.services.ExpenseService; import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.treegrid.TreeGrid; import org.springframework.stereotype.Component; +import java.util.List; + @Component public class ExpenseFacade { public final ExpenseService expenseService; @@ -14,6 +17,12 @@ public class ExpenseFacade { this.expenseService = expenseService; } + /** + * Sets an expense as paid + * @param expense the expense to set as paid + * @param grid the grid reference to update + * @param userId the id of the user related to the expense + */ public void setExpensePaid(Expense expense, TreeGrid grid, Long userId) { expense.setIsPaid(true); this.expenseService.update(expense, userId); @@ -21,4 +30,13 @@ public class ExpenseFacade { grid.select(null); grid.getDataProvider().refreshAll(); } + + /** + * Finds all expenses related to a person, both where the person is a payer and a beneficiary. + * @param person the person of the expenses + * @return the list of expenses found + */ + public List findExpensesByPerson(final Person person) { + return this.expenseService.findExpensesByPerson(person); + } } \ No newline at end of file