Files
luminic-space-back-v2/src/main/kotlin/space/luminic/finance/mappers/TransactionMapper.kt
2025-11-17 15:02:47 +03:00

24 lines
766 B
Kotlin

package space.luminic.finance.mappers
import space.luminic.finance.dtos.TransactionDTO
import space.luminic.finance.mappers.CategoryMapper.toDto
import space.luminic.finance.mappers.UserMapper.toDto
import space.luminic.finance.models.Transaction
object TransactionMapper {
fun Transaction.toDto() = TransactionDTO(
id = this.id,
parentId = this.parent?.id,
type = this.type,
kind = this.kind,
category = this.category?.toDto(),
comment = this.comment,
amount = this.amount,
fees = this.fees,
date = this.date,
isDone = this.isDone,
createdBy = this.createdBy?.toDto() ?: throw IllegalStateException("created by null"),
updatedBy = this.updatedBy?.toDto()
)
}