From 73d1811d043908523f6cd9c507a3d068bc97620b Mon Sep 17 00:00:00 2001 From: effe Date: Sat, 14 Sep 2024 10:46:31 -0400 Subject: [PATCH] feat: added userId to entities --- src/main/java/com/application/munera/data/Category.java | 3 +++ src/main/java/com/application/munera/data/Expense.java | 3 +++ src/main/java/com/application/munera/data/Person.java | 2 +- .../java/com/application/munera/services/ExpenseService.java | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/application/munera/data/Category.java b/src/main/java/com/application/munera/data/Category.java index cb9b46b..6cbb74e 100644 --- a/src/main/java/com/application/munera/data/Category.java +++ b/src/main/java/com/application/munera/data/Category.java @@ -21,4 +21,7 @@ public class Category { @Column(name = "Description") private String description; + + @Column(name = "userId", nullable = false, unique = true) + private Long userId; } diff --git a/src/main/java/com/application/munera/data/Expense.java b/src/main/java/com/application/munera/data/Expense.java index 0d75762..a424a9f 100644 --- a/src/main/java/com/application/munera/data/Expense.java +++ b/src/main/java/com/application/munera/data/Expense.java @@ -64,4 +64,7 @@ public class Expense { @Enumerated(EnumType.STRING) @Column(name = "expenseType", nullable = false) private ExpenseType expenseType; + + @Column(name = "userId", nullable = false, unique = true) + private Long userId; } \ No newline at end of file diff --git a/src/main/java/com/application/munera/data/Person.java b/src/main/java/com/application/munera/data/Person.java index f5a30e1..248b18f 100644 --- a/src/main/java/com/application/munera/data/Person.java +++ b/src/main/java/com/application/munera/data/Person.java @@ -49,7 +49,7 @@ public class Person { @Column(name = "Username", unique = true) private String username; // This field will link to the User entity - @Column(name = "UserId", unique = true) + @Column(name = "UserId", unique = true, nullable = false) private Long userId; // Reference to the User entity @Override diff --git a/src/main/java/com/application/munera/services/ExpenseService.java b/src/main/java/com/application/munera/services/ExpenseService.java index 88a375f..b75aeb3 100644 --- a/src/main/java/com/application/munera/services/ExpenseService.java +++ b/src/main/java/com/application/munera/services/ExpenseService.java @@ -146,6 +146,7 @@ public class ExpenseService { */ public void update(Expense entity) { if (Boolean.TRUE.equals(entity.getIsPaid())) entity.setPaymentDate(LocalDate.now()); + else entity.setPaymentDate(null); this.setExpenseType(entity); expenseRepository.save(entity); }