Files
luminic-back/src/main/kotlin/space/luminic/budgerapp/models/Budget.kt
2025-02-17 17:58:07 +03:00

47 lines
1.5 KiB
Kotlin

package space.luminic.budgerapp.models
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.DBRef
import org.springframework.data.mongodb.core.mapping.Document
import java.time.LocalDate
import java.time.LocalDateTime
import kotlin.collections.mutableListOf
data class BudgetDTO(
var id: String? = null,
var space: Space? = null,
var name: String,
var dateFrom: LocalDate,
var dateTo: LocalDate,
val createdAt: LocalDateTime = LocalDateTime.now(),
var plannedExpenses: MutableList<Transaction>? = null,
var plannedIncomes: MutableList<Transaction>? = null,
var categories: MutableList<BudgetCategory> = mutableListOf(),
var incomeCategories: MutableList<BudgetCategory> = mutableListOf(),
var transactions: MutableList<Transaction>? = null,
)
@Document("budgets")
data class Budget(
@Id var id: String? = null,
@DBRef var space: Space? = null,
var name: String,
var dateFrom: LocalDate,
var dateTo: LocalDate,
val createdAt: LocalDateTime = LocalDateTime.now(),
var categories: MutableList<BudgetCategory> = mutableListOf(),
var incomeCategories: MutableList<BudgetCategory> = mutableListOf(),
)
data class BudgetCategory(
@Transient var currentSpent: Double? = null,
var currentLimit: Double,
@Transient var currentPlanned: Double? = null,
@DBRef var category: Category
)
class BudgetNotFoundException(message: String) : NotFoundException(message)