init
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.relational.core.mapping.Column
|
||||
import org.springframework.data.relational.core.mapping.Table
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
|
||||
@Table(name = "accounts")
|
||||
data class Account (
|
||||
@Id val id: Int? = null,
|
||||
@Column("space_id")
|
||||
val spaceId: Int,
|
||||
val name: String,
|
||||
val type: AccountType = AccountType.COLLECTING,
|
||||
@Column("currency_code")
|
||||
val currencyCode: String,
|
||||
|
||||
var amount: BigDecimal,
|
||||
@Column("goal_id")
|
||||
var goalId: Int? = null,
|
||||
@Column("is_deleted")
|
||||
var isDeleted: Boolean = false,
|
||||
@Column("created_by")
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
val createdAt: Instant? = null,
|
||||
@Column("updated_by")
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
val updatedAt: Instant? = null,
|
||||
|
||||
) {
|
||||
@ReadOnlyProperty var goal: Goal? = null
|
||||
@ReadOnlyProperty var currency: Currency? = null
|
||||
@ReadOnlyProperty var transactions: List<Transaction>? = null
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
enum class AccountType(displayName: String) {
|
||||
SALARY("Зарплатный"),
|
||||
COLLECTING("Накопительный"),
|
||||
LOANS("Долговой"),
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
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.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.relational.core.mapping.Column
|
||||
import org.springframework.data.relational.core.mapping.Table
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
|
||||
|
||||
@Table( "budgets")
|
||||
data class Budget(
|
||||
@Id var id: Int? = null,
|
||||
@Column("space_id")
|
||||
val spaceId: Int,
|
||||
val type: BudgetType = BudgetType.SPECIAL,
|
||||
var name: String,
|
||||
var description: String? = null,
|
||||
@Column("date_from")
|
||||
var dateFrom: LocalDate,
|
||||
@Column("date_to")
|
||||
var dateTo: LocalDate,
|
||||
val transactions: List<Transaction> = listOf(),
|
||||
val categories: List<BudgetCategory> = listOf(),
|
||||
@Column("is_deleted")
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy
|
||||
@Column("created_by")
|
||||
val createdById: Int? = null,
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
var createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
@Column("updated_by")
|
||||
var updatedById: Int? = null,
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
var updatedAt: Instant? = null,
|
||||
) {
|
||||
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
data class BudgetCategory(
|
||||
val categoryId: String,
|
||||
val limit: BigDecimal
|
||||
) {
|
||||
@ReadOnlyProperty var category: Category? = null
|
||||
}
|
||||
|
||||
enum class BudgetType(val displayName: String) {
|
||||
MONTHLY("Месячный"),
|
||||
SPECIAL("Специальный")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,35 +2,24 @@ 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.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.time.Instant
|
||||
|
||||
|
||||
@Document(collection = "categories")
|
||||
data class Category(
|
||||
@Id val id: String? = null,
|
||||
val spaceId: String,
|
||||
var id: Int? = null,
|
||||
val space: Space? = null,
|
||||
val type: CategoryType,
|
||||
val name: String,
|
||||
val description: String,
|
||||
val icon: String,
|
||||
var isDeleted: Boolean = false,
|
||||
|
||||
@CreatedBy
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
val createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
val updatedAt: Instant? = null,
|
||||
@CreatedBy var createdBy: User? = null,
|
||||
@CreatedDate var createdAt: Instant? = null,
|
||||
@LastModifiedBy var updatedBy: User? = null,
|
||||
@LastModifiedDate var updatedAt: Instant? = null,
|
||||
) {
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
enum class CategoryType(val displayName: String) {
|
||||
INCOME("Поступления"),
|
||||
@@ -38,9 +27,8 @@ data class Category(
|
||||
}
|
||||
|
||||
|
||||
@Document(collection = "categories_etalon")
|
||||
data class CategoryEtalon(
|
||||
@Id val id: String? = null,
|
||||
var id: Int? = null,
|
||||
val type: CategoryType,
|
||||
val name: String,
|
||||
val icon: String
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.math.BigDecimal
|
||||
|
||||
@Document(collection = "currencies_ref")
|
||||
|
||||
data class Currency(
|
||||
@Id val code: String,
|
||||
val code: String,
|
||||
val name: String,
|
||||
val symbol: String
|
||||
)
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.math.BigDecimal
|
||||
import java.time.LocalDate
|
||||
|
||||
@Document(collection = "currency_rates")
|
||||
|
||||
data class CurrencyRate(
|
||||
@Id val id: String? = null,
|
||||
val currencyCode: String,
|
||||
var id: Int? = null,
|
||||
val currency: Currency,
|
||||
val rate: BigDecimal,
|
||||
val date: LocalDate
|
||||
)
|
||||
{
|
||||
@ReadOnlyProperty var currency: Currency? = null
|
||||
}
|
||||
)
|
||||
@@ -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("Отпуск", "🏖️"),
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
|
||||
data class RecurrentOperation(
|
||||
val id: Int? = null,
|
||||
val space: Space,
|
||||
val category: Category,
|
||||
val name: String,
|
||||
val amount: BigDecimal,
|
||||
val date: Int,
|
||||
val createdBy: User? = null,
|
||||
val createdAt: Instant? = null,
|
||||
val updatedBy: User? = null,
|
||||
val updatedAt: Instant? = null,
|
||||
)
|
||||
@@ -2,35 +2,21 @@ 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.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.time.Instant
|
||||
|
||||
|
||||
@Document(collection = "spaces")
|
||||
data class Space (
|
||||
@Id val id: String? = null,
|
||||
data class Space (
|
||||
var id: Int? = null,
|
||||
val name: String,
|
||||
val ownerId: String,
|
||||
val participantsIds: List<String> = emptyList(),
|
||||
val owner: User,
|
||||
var participants: Set<User>,
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy val createdById: String? = null,
|
||||
@CreatedDate val createdAt: Instant? = null,
|
||||
@LastModifiedBy val updatedById: String? = null,
|
||||
@LastModifiedDate var updatedAt: Instant? = null,
|
||||
@CreatedBy var createdBy: User? = null,
|
||||
@CreatedDate var createdAt: Instant? = null,
|
||||
@LastModifiedBy var updatedBy: User? = null,
|
||||
@LastModifiedDate var updatedAt: Instant ? = null,
|
||||
) {
|
||||
@ReadOnlyProperty var owner: User? = null
|
||||
|
||||
@ReadOnlyProperty var participants: List<User>? = null
|
||||
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
|
||||
override fun equals(other: Any?) = this === other || (other is Space && id != null && id == other.id)
|
||||
override fun hashCode() = id?.hashCode() ?: 0
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import java.time.Instant
|
||||
|
||||
@Document(collection = "subscriptions")
|
||||
data class Subscription(
|
||||
@Id val id: String? = null,
|
||||
@DBRef val user: User? = null,
|
||||
var id: Int? = null,
|
||||
val user: User,
|
||||
val endpoint: String,
|
||||
val auth: String,
|
||||
val p256dh: String,
|
||||
var isActive: Boolean,
|
||||
val createdAt: Instant = Instant.now(),
|
||||
)
|
||||
@CreatedDate val createdAt: Instant? = null,
|
||||
@LastModifiedDate val updatedAt: Instant? = null,
|
||||
|
||||
)
|
||||
|
||||
|
||||
data class SubscriptionDTO (
|
||||
val endpoint: String,
|
||||
val keys: Map<String, String>
|
||||
)
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.time.LocalDateTime
|
||||
import java.time.Instant
|
||||
|
||||
@Document(collection = "tokens")
|
||||
data class Token(
|
||||
@Id
|
||||
val id: String? = null,
|
||||
var id: Int? = null,
|
||||
val token: String,
|
||||
val username: String,
|
||||
val issuedAt: LocalDateTime,
|
||||
val expiresAt: LocalDateTime,
|
||||
val user: User,
|
||||
val issuedAt: Instant = Instant.now(),
|
||||
val expiresAt: Instant,
|
||||
val status: TokenStatus = TokenStatus.ACTIVE
|
||||
) {
|
||||
|
||||
|
||||
@@ -2,49 +2,31 @@ 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.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
|
||||
@Document(collection = "transactions")
|
||||
data class Transaction(
|
||||
@Id val id: String? = null,
|
||||
val spaceId: String,
|
||||
var parentId: String? = null,
|
||||
var id: Int? = null,
|
||||
val space: Space? = null,
|
||||
var parent: Transaction? = null,
|
||||
val type: TransactionType = TransactionType.EXPENSE,
|
||||
val kind: TransactionKind = TransactionKind.INSTANT,
|
||||
val categoryId: String,
|
||||
|
||||
val category: Category,
|
||||
val comment: String,
|
||||
val amount: BigDecimal,
|
||||
val fees: BigDecimal = BigDecimal.ZERO,
|
||||
val fromAccountId: String,
|
||||
val toAccountId: String? = null,
|
||||
val date: Instant = Instant.now(),
|
||||
val date: LocalDate = LocalDate.now(),
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
val createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
val updatedAt: Instant? = null,
|
||||
val isDone: Boolean = false,
|
||||
@CreatedBy var createdBy: User? = null,
|
||||
@CreatedDate var createdAt: Instant? = null,
|
||||
@LastModifiedBy var updatedBy: User? = null,
|
||||
@LastModifiedDate var updatedAt: Instant? = null,
|
||||
) {
|
||||
|
||||
@ReadOnlyProperty var category: Category? = null
|
||||
@ReadOnlyProperty var toAccount: Account? = null
|
||||
@ReadOnlyProperty var fromAccount: Account? = null
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
|
||||
|
||||
enum class TransactionType(val displayName: String) {
|
||||
INCOME("Поступления"),
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Document("users")
|
||||
|
||||
data class User(
|
||||
@Id
|
||||
var id: String? = null,
|
||||
var id: Int? = null,
|
||||
val username: String,
|
||||
var firstName: String,
|
||||
var tgId: String? = null,
|
||||
var tgUserName: String? = null,
|
||||
var password: String,
|
||||
var password: String? = null,
|
||||
var isActive: Boolean = true,
|
||||
var regDate: LocalDate = LocalDate.now(),
|
||||
val createdAt: LocalDateTime = LocalDateTime.now(),
|
||||
var roles: MutableList<String> = mutableListOf(),
|
||||
@CreatedDate val createdAt: Instant? = null,
|
||||
@LastModifiedDate var updatedAt: Instant? = null,
|
||||
var roles: List<String> = listOf(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user