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); }