diff --git a/src/main/java/com/application/munera/data/Expense.java b/src/main/java/com/application/munera/data/Expense.java index 400f076..9ac3c49 100644 --- a/src/main/java/com/application/munera/data/Expense.java +++ b/src/main/java/com/application/munera/data/Expense.java @@ -7,6 +7,7 @@ import lombok.Setter; import java.math.BigDecimal; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Set; @Entity @@ -64,8 +65,11 @@ public class Expense extends AbstractEntity { @Column(name = "Date", nullable = false, columnDefinition = "DATE DEFAULT CURRENT_DATE") private LocalDate date; + @Column(name = "PaymentDate") + private LocalDateTime paymentDate; + /** - * the isResolved field starts as always false, cause at creation an expense cant be already be resolved + * the isResolved field starts as always false */ @Column(name = "isResolved", nullable = false) private Boolean isResolved = false; diff --git a/src/main/java/com/application/munera/services/ExpenseService.java b/src/main/java/com/application/munera/services/ExpenseService.java index 3c7f5be..9297484 100644 --- a/src/main/java/com/application/munera/services/ExpenseService.java +++ b/src/main/java/com/application/munera/services/ExpenseService.java @@ -8,6 +8,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -51,6 +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()); repository.save(entity); }