From 3c5cdf84cc6a4ac140b383071400dbc5c6679c79 Mon Sep 17 00:00:00 2001 From: effe Date: Fri, 13 Sep 2024 09:19:32 -0400 Subject: [PATCH] fix: paymentDate class --- src/main/java/com/application/munera/data/Expense.java | 2 +- src/main/java/com/application/munera/services/CSVService.java | 2 +- .../java/com/application/munera/services/ExpenseService.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/application/munera/data/Expense.java b/src/main/java/com/application/munera/data/Expense.java index be44a20..8364766 100644 --- a/src/main/java/com/application/munera/data/Expense.java +++ b/src/main/java/com/application/munera/data/Expense.java @@ -60,7 +60,7 @@ public class Expense { private LocalDate date; @Column(name = "PaymentDate") - private LocalDateTime paymentDate; + private LocalDate paymentDate; @Column(name = "isPaid", nullable = false) private Boolean isPaid = false; diff --git a/src/main/java/com/application/munera/services/CSVService.java b/src/main/java/com/application/munera/services/CSVService.java index e596471..011db21 100644 --- a/src/main/java/com/application/munera/services/CSVService.java +++ b/src/main/java/com/application/munera/services/CSVService.java @@ -27,7 +27,7 @@ public class CSVService { expense.getCost(), expense.getCategory() != null ? expense.getCategory().getName() : "", expense.getDate(), - expense.getPaymentDate() != null ? expense.getPaymentDate().toLocalDate() : "Unpaid" + expense.getPaymentDate() != null ? expense.getPaymentDate() : "Unpaid" ); } } catch (Exception e) { diff --git a/src/main/java/com/application/munera/services/ExpenseService.java b/src/main/java/com/application/munera/services/ExpenseService.java index 4a8da53..88a375f 100644 --- a/src/main/java/com/application/munera/services/ExpenseService.java +++ b/src/main/java/com/application/munera/services/ExpenseService.java @@ -15,6 +15,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import javax.annotation.Nonnull; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Year; import java.util.ArrayList; @@ -144,7 +145,7 @@ public class ExpenseService { * @param entity the expense to update */ public void update(Expense entity) { - if (Boolean.TRUE.equals(entity.getIsPaid())) entity.setPaymentDate(LocalDateTime.now()); + if (Boolean.TRUE.equals(entity.getIsPaid())) entity.setPaymentDate(LocalDate.now()); this.setExpenseType(entity); expenseRepository.save(entity); }