Fix missing empty constructors for entity classes

This commit is contained in:
William Brawner 2020-02-15 11:12:24 -07:00
parent bb160448be
commit 37b45e0c22
3 changed files with 15 additions and 7 deletions

View file

@ -16,7 +16,9 @@ data class Budget(
@OneToMany(mappedBy = "budget") val transactions: Set<Transaction> = TreeSet(), @OneToMany(mappedBy = "budget") val transactions: Set<Transaction> = TreeSet(),
@OneToMany(mappedBy = "budget") val categories: Set<Category> = TreeSet(), @OneToMany(mappedBy = "budget") val categories: Set<Category> = TreeSet(),
@ManyToMany val users: Set<User> = mutableSetOf(), @ManyToMany val users: Set<User> = mutableSetOf(),
@ManyToOne val owner: User @Column(nullable = false)
@ManyToOne
val owner: User? = null
) )
data class NewBudgetRequest(val name: String, val description: String?, val userIds: Set<Long>) data class NewBudgetRequest(val name: String, val description: String?, val userIds: Set<Long>)

View file

@ -11,7 +11,9 @@ data class Category(
val title: String = "", val title: String = "",
val description: String? = null, val description: String? = null,
val amount: Long = 0, val amount: Long = 0,
@ManyToOne val budget: Budget, @Column(nullable = false)
@ManyToOne
val budget: Budget? = null,
@OneToMany(mappedBy = "category") val transactions: Set<Transaction> = emptySet(), @OneToMany(mappedBy = "category") val transactions: Set<Transaction> = emptySet(),
val expense: Boolean? = true val expense: Boolean? = true
) : Comparable<Category> { ) : Comparable<Category> {
@ -31,7 +33,7 @@ data class CategoryResponse(
category.title, category.title,
category.description, category.description,
category.amount, category.amount,
category.budget.id!!, category.budget!!.id!!,
category.expense category.expense
) )
} }

View file

@ -15,8 +15,12 @@ data class Transaction(
val amount: Long = 0, val amount: Long = 0,
@ManyToOne val category: Category? = null, @ManyToOne val category: Category? = null,
val expense: Boolean = true, val expense: Boolean = true,
@ManyToOne val createdBy: User, @ManyToOne
@ManyToOne val budget: Budget @Column(nullable = false)
val createdBy: User? = null,
@ManyToOne
@Column(nullable = false)
val budget: Budget? = null
) : Comparable<Transaction> { ) : Comparable<Transaction> {
override fun compareTo(other: Transaction): Int = this.date.compareTo(other.date) override fun compareTo(other: Transaction): Int = this.date.compareTo(other.date)
} }
@ -39,9 +43,9 @@ data class TransactionResponse(
transaction.date.toString(), transaction.date.toString(),
transaction.amount, transaction.amount,
transaction.expense, transaction.expense,
transaction.budget.id!!, transaction.budget!!.id!!,
if (transaction.category != null) transaction.category.id!! else null, if (transaction.category != null) transaction.category.id!! else null,
transaction.createdBy.id!! transaction.createdBy!!.id!!
) )
} }