This commit is contained in:
xds
2025-10-31 15:31:55 +03:00
parent 040da34ff7
commit 7972ea0fdf
117 changed files with 3691 additions and 2013 deletions

View File

@@ -2,35 +2,43 @@ package space.luminic.finance.models
import org.springframework.data.annotation.CreatedBy
import org.springframework.data.annotation.CreatedDate
import org.springframework.data.annotation.Id
import org.springframework.data.annotation.LastModifiedBy
import org.springframework.data.annotation.LastModifiedDate
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.annotation.Transient
import space.luminic.finance.dtos.UserDTO
import java.math.BigDecimal
import java.text.Bidi
import java.time.Instant
import java.time.LocalDate
@Document(collection = "goals")
data class Goal(
@Id val id: String? = null,
val spaceId: String,
var id: Int? = null,
val space: Space? = null,
val type: GoalType,
val name: String,
val description: String? = null,
val goalAmount: BigDecimal,
val goalDate: LocalDate,
@CreatedBy val createdById: String,
@Transient val createdBy: User? = null,
@CreatedDate val createdAt: Instant? = null,
@LastModifiedBy val updatedById: String,
@Transient val updatedBy: User? = null,
@LastModifiedDate val updatedAt: Instant? = null,
val amount: BigDecimal,
val components: List<GoalComponent> = emptyList(),
val transactions: List<Transaction> = emptyList(),
val untilDate: LocalDate,
@CreatedBy var createdBy: User? = null,
@CreatedDate var createdAt: Instant? = null,
@LastModifiedBy var updatedBy: User? = null,
@LastModifiedDate var updatedAt: Instant? = null,
) {
var currentAmount: BigDecimal = {
this.transactions.sumOf { it.amount }
} as BigDecimal
data class GoalComponent(
val id: Int? = null,
val name: String,
val amount: BigDecimal,
val isDone: Boolean = false,
val date: LocalDate = LocalDate.now(),
)
enum class GoalType(val displayName: String, val icon: String) {
AUTO("Авто", "🏎️"),
VACATION("Отпуск", "🏖️"),