diff --git a/src/main/java/com/application/munera/data/Expense.java b/src/main/java/com/application/munera/data/Expense.java index 9ac3c49..7fc2dce 100644 --- a/src/main/java/com/application/munera/data/Expense.java +++ b/src/main/java/com/application/munera/data/Expense.java @@ -69,8 +69,8 @@ public class Expense extends AbstractEntity { private LocalDateTime paymentDate; /** - * the isResolved field starts as always false + * the isPaid field starts as always false */ - @Column(name = "isResolved", nullable = false) - private Boolean isResolved = false; + @Column(name = "isPaid", nullable = false) + private Boolean isPaid = false; } diff --git a/src/main/java/com/application/munera/repositories/ExpenseRepository.java b/src/main/java/com/application/munera/repositories/ExpenseRepository.java index cbc9f26..98c4468 100644 --- a/src/main/java/com/application/munera/repositories/ExpenseRepository.java +++ b/src/main/java/com/application/munera/repositories/ExpenseRepository.java @@ -21,12 +21,12 @@ public interface ExpenseRepository extends JpaRepository, JpaSpec @Query("SELECT e FROM Expense e WHERE YEAR(e.date) = :year") List findAllByYear(@Param("year") int year); - @Query("SELECT e FROM Expense e JOIN e.creditors c WHERE c.id = :personId AND e.isResolved = false") + @Query("SELECT e FROM Expense e JOIN e.creditors c WHERE c.id = :personId AND e.isPaid = false") Set findUnpaidCreditorsExpensesByPersonId(@Param("personId") Long personId); - @Query("SELECT e FROM Expense e JOIN e.debtors d WHERE d.id = :personId AND e.isResolved = false") + @Query("SELECT e FROM Expense e JOIN e.debtors d WHERE d.id = :personId AND e.isPaid = false") Set findUnpaidDebtorsExpensesByPersonId(@Param("personId") Long personId); - boolean existsByIdAndIsResolvedTrue(Long id); + boolean existsByIdAndIsPaidTrue(Long id); List findAllByOrderByDateDesc();} \ No newline at end of file diff --git a/src/main/java/com/application/munera/services/ExpenseService.java b/src/main/java/com/application/munera/services/ExpenseService.java index 9297484..c57b43f 100644 --- a/src/main/java/com/application/munera/services/ExpenseService.java +++ b/src/main/java/com/application/munera/services/ExpenseService.java @@ -52,7 +52,7 @@ public class ExpenseService { public List findAll() {return repository.findAll();} public void update(Expense entity) { - if (Boolean.TRUE.equals(entity.getIsResolved())) entity.setPaymentDate(LocalDateTime.now()); + if (Boolean.TRUE.equals(entity.getIsPaid())) entity.setPaymentDate(LocalDateTime.now()); repository.save(entity); } @@ -77,7 +77,7 @@ public class ExpenseService { } public boolean isExpenseResolved(final Expense expense) { - return this.repository.existsByIdAndIsResolvedTrue(expense.getId()); + return this.repository.existsByIdAndIsPaidTrue(expense.getId()); } public List findAllOrderByDateDescending() { diff --git a/src/main/java/com/application/munera/views/expenses/ExpensesView.java b/src/main/java/com/application/munera/views/expenses/ExpensesView.java index 98ffbb3..c52b851 100644 --- a/src/main/java/com/application/munera/views/expenses/ExpensesView.java +++ b/src/main/java/com/application/munera/views/expenses/ExpensesView.java @@ -67,7 +67,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver { private ComboBox category; private TextArea description; private Checkbox isPeriodic; - private Checkbox isResolved; + private Checkbox isPaid; private ComboBox periodUnit; private TextField periodInterval; private DatePicker date; @@ -123,7 +123,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver { // We set initial value of isPeriodic to true and show period fields isPeriodic.setValue(false); - isResolved.setValue(false); + isPaid.setValue(false); periodUnit.setVisible(false); periodInterval.setVisible(false); @@ -247,8 +247,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver { // Horizontal layout for checkboxes HorizontalLayout checkboxLayout = new HorizontalLayout(); isPeriodic = new Checkbox("Is Periodic"); - isResolved = new Checkbox("Paid"); - checkboxLayout.add(isPeriodic, isResolved); + isPaid = new Checkbox("Paid"); + checkboxLayout.add(isPeriodic, isPaid); formLayout.add(name, cost, category, description, checkboxLayout, periodUnit, periodInterval, date, creditors, debtors, event); editorDiv.add(formLayout); 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 e1bdd5b..163e4c1 100644 --- a/src/main/java/com/application/munera/views/people/PeopleView.java +++ b/src/main/java/com/application/munera/views/people/PeopleView.java @@ -78,7 +78,7 @@ public class PeopleView extends Div implements BeforeEnterObserver { grid.addColumn(this::getNodeCost).setHeader("Total Expenses Value").setSortable(true); grid.addColumn(new ComponentRenderer<>(persona -> { if (persona instanceof Person) return createPersonBadge(personService.calculateNetBalance((Person) persona)); - else return createExpenseBadge(((Expense) persona).getIsResolved()); + else return createExpenseBadge(((Expense) persona).getIsPaid()); })).setHeader("Balance Status"); List people = (List) personService.findAll();