Add expense to Category
This commit is contained in:
parent
23af0efb0f
commit
017cec7d3d
1 changed files with 10 additions and 6 deletions
|
@ -1,7 +1,6 @@
|
|||
package com.wbrawner.budgetserver.category
|
||||
|
||||
import com.wbrawner.budgetserver.account.Account
|
||||
import com.wbrawner.budgetserver.account.AccountResponse
|
||||
import com.wbrawner.budgetserver.transaction.Transaction
|
||||
import javax.persistence.*
|
||||
|
||||
|
@ -13,7 +12,8 @@ data class Category(
|
|||
val description: String? = null,
|
||||
val amount: Long = 0,
|
||||
@ManyToOne val account: Account,
|
||||
@OneToMany(mappedBy = "category") val transactions: List<Transaction> = emptyList()
|
||||
@OneToMany(mappedBy = "category") val transactions: List<Transaction> = emptyList(),
|
||||
val expense: Boolean? = true
|
||||
) : Comparable<Category> {
|
||||
override fun compareTo(other: Category): Int = title.compareTo(other.title)
|
||||
}
|
||||
|
@ -23,14 +23,16 @@ data class CategoryResponse(
|
|||
val title: String,
|
||||
val description: String?,
|
||||
val amount: Long,
|
||||
val accountId: Long
|
||||
val accountId: Long,
|
||||
val expense: Boolean? = true
|
||||
) {
|
||||
constructor(category: Category) : this(
|
||||
category.id!!,
|
||||
category.title,
|
||||
category.description,
|
||||
category.amount,
|
||||
category.account.id!!
|
||||
category.account.id!!,
|
||||
category.expense
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -38,11 +40,13 @@ data class NewCategoryRequest(
|
|||
val title: String,
|
||||
val description: String?,
|
||||
val amount: Long,
|
||||
val accountId: Long
|
||||
val accountId: Long,
|
||||
val expense: Boolean? = true
|
||||
)
|
||||
|
||||
data class UpdateCategoryRequest(
|
||||
val title: String?,
|
||||
val description: String?,
|
||||
val amount: Long?
|
||||
val amount: Long?,
|
||||
val expense: Boolean?
|
||||
)
|
Loading…
Reference in a new issue