From 0d828e0519032d0cab991b08751f4ba0a760e2fb Mon Sep 17 00:00:00 2001 From: effe Date: Tue, 10 Sep 2024 10:10:57 -0400 Subject: [PATCH] feat: added individual expenses button --- .../munera/views/people/PeopleView.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/application/munera/views/people/PeopleView.java b/src/main/java/com/application/munera/views/people/PeopleView.java index fa44f8a..88c32d2 100644 --- a/src/main/java/com/application/munera/views/people/PeopleView.java +++ b/src/main/java/com/application/munera/views/people/PeopleView.java @@ -88,6 +88,10 @@ public class PeopleView extends Div implements BeforeEnterObserver { Button setDebtPaidButton = new Button("Set all debt as paid", event -> setDebtPaid((Person) persona)); setDebtPaidButton.addThemeVariants(ButtonVariant.LUMO_SMALL, ButtonVariant.LUMO_PRIMARY); return setDebtPaidButton; + } else if (persona instanceof Expense) { + Button setExpensePaidButton = new Button("Set as paid", event -> setExpensePaid((Expense) persona)); + setExpensePaidButton.addThemeVariants(ButtonVariant.LUMO_SMALL); + return setExpensePaidButton; } else return new Span(); })); @@ -261,6 +265,7 @@ public class PeopleView extends Div implements BeforeEnterObserver { } } + //TODO: this needs to be in the person service? private void setDebtPaid(Person person) { try { List expenses = expenseService.findExpensesWherePayer(person).stream().toList(); @@ -277,6 +282,15 @@ public class PeopleView extends Div implements BeforeEnterObserver { } } + //TODO: this needs to be in the expense service? + private void setExpensePaid(Expense expense) { + expense.setIsPaid(true); + this.expenseService.update(expense); + Notification.show("Expense " + expense.getName() + " set as paid" ); + refreshGrid(); + } + + //TODO: this needs to be in the person service? private void setCreditPaid(Person person) { try { List expenses = expenseService.findExpensesWhereBeneficiary(person).stream().toList();