refactor: isResolved changed to isPaid
This commit is contained in:
parent
742450b672
commit
261024efe1
5 changed files with 13 additions and 13 deletions
|
@ -69,8 +69,8 @@ public class Expense extends AbstractEntity {
|
||||||
private LocalDateTime paymentDate;
|
private LocalDateTime paymentDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the isResolved field starts as always false
|
* the isPaid field starts as always false
|
||||||
*/
|
*/
|
||||||
@Column(name = "isResolved", nullable = false)
|
@Column(name = "isPaid", nullable = false)
|
||||||
private Boolean isResolved = false;
|
private Boolean isPaid = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,12 @@ public interface ExpenseRepository extends JpaRepository<Expense, Long>, JpaSpec
|
||||||
@Query("SELECT e FROM Expense e WHERE YEAR(e.date) = :year")
|
@Query("SELECT e FROM Expense e WHERE YEAR(e.date) = :year")
|
||||||
List<Expense> findAllByYear(@Param("year") int year);
|
List<Expense> 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<Expense> findUnpaidCreditorsExpensesByPersonId(@Param("personId") Long personId);
|
Set<Expense> 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<Expense> findUnpaidDebtorsExpensesByPersonId(@Param("personId") Long personId);
|
Set<Expense> findUnpaidDebtorsExpensesByPersonId(@Param("personId") Long personId);
|
||||||
|
|
||||||
boolean existsByIdAndIsResolvedTrue(Long id);
|
boolean existsByIdAndIsPaidTrue(Long id);
|
||||||
|
|
||||||
List<Expense> findAllByOrderByDateDesc();}
|
List<Expense> findAllByOrderByDateDesc();}
|
|
@ -52,7 +52,7 @@ public class ExpenseService {
|
||||||
public List<Expense> findAll() {return repository.findAll();}
|
public List<Expense> findAll() {return repository.findAll();}
|
||||||
|
|
||||||
public void update(Expense entity) {
|
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);
|
repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class ExpenseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpenseResolved(final Expense expense) {
|
public boolean isExpenseResolved(final Expense expense) {
|
||||||
return this.repository.existsByIdAndIsResolvedTrue(expense.getId());
|
return this.repository.existsByIdAndIsPaidTrue(expense.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Expense> findAllOrderByDateDescending() {
|
public List<Expense> findAllOrderByDateDescending() {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
private ComboBox<Category> category;
|
private ComboBox<Category> category;
|
||||||
private TextArea description;
|
private TextArea description;
|
||||||
private Checkbox isPeriodic;
|
private Checkbox isPeriodic;
|
||||||
private Checkbox isResolved;
|
private Checkbox isPaid;
|
||||||
private ComboBox<PeriodUnit> periodUnit;
|
private ComboBox<PeriodUnit> periodUnit;
|
||||||
private TextField periodInterval;
|
private TextField periodInterval;
|
||||||
private DatePicker date;
|
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
|
// We set initial value of isPeriodic to true and show period fields
|
||||||
isPeriodic.setValue(false);
|
isPeriodic.setValue(false);
|
||||||
isResolved.setValue(false);
|
isPaid.setValue(false);
|
||||||
periodUnit.setVisible(false);
|
periodUnit.setVisible(false);
|
||||||
periodInterval.setVisible(false);
|
periodInterval.setVisible(false);
|
||||||
|
|
||||||
|
@ -247,8 +247,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
// Horizontal layout for checkboxes
|
// Horizontal layout for checkboxes
|
||||||
HorizontalLayout checkboxLayout = new HorizontalLayout();
|
HorizontalLayout checkboxLayout = new HorizontalLayout();
|
||||||
isPeriodic = new Checkbox("Is Periodic");
|
isPeriodic = new Checkbox("Is Periodic");
|
||||||
isResolved = new Checkbox("Paid");
|
isPaid = new Checkbox("Paid");
|
||||||
checkboxLayout.add(isPeriodic, isResolved);
|
checkboxLayout.add(isPeriodic, isPaid);
|
||||||
|
|
||||||
formLayout.add(name, cost, category, description, checkboxLayout, periodUnit, periodInterval, date, creditors, debtors, event);
|
formLayout.add(name, cost, category, description, checkboxLayout, periodUnit, periodInterval, date, creditors, debtors, event);
|
||||||
editorDiv.add(formLayout);
|
editorDiv.add(formLayout);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class PeopleView extends Div implements BeforeEnterObserver {
|
||||||
grid.addColumn(this::getNodeCost).setHeader("Total Expenses Value").setSortable(true);
|
grid.addColumn(this::getNodeCost).setHeader("Total Expenses Value").setSortable(true);
|
||||||
grid.addColumn(new ComponentRenderer<>(persona -> {
|
grid.addColumn(new ComponentRenderer<>(persona -> {
|
||||||
if (persona instanceof Person) return createPersonBadge(personService.calculateNetBalance((Person) 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");
|
})).setHeader("Balance Status");
|
||||||
|
|
||||||
List<Person> people = (List<Person>) personService.findAll();
|
List<Person> people = (List<Person>) personService.findAll();
|
||||||
|
|
Loading…
Reference in a new issue