package space.luminic.finance.services.telegram import org.springframework.beans.factory.annotation.Qualifier import org.springframework.stereotype.Service import space.luminic.finance.dtos.TransactionDTO import space.luminic.finance.models.Transaction import space.luminic.finance.repos.TransactionRepo import space.luminic.finance.services.CategoryServiceImpl @Service("transactionsServiceTelegram") class TransactionsServiceImpl( private val transactionRepo: TransactionRepo, @Qualifier("spaceServiceTelegram") private val spaceService: SpaceService, private val categoryService: CategoryServiceImpl ): TransactionService { override fun createTransaction( spaceId: Int, userId: Int, transaction: TransactionDTO.CreateTransactionDTO, chatId: Long, messageId: Long ): Int { val space = spaceService.getSpace(spaceId, userId) val category = transaction.categoryId?.let { categoryService.getCategory(spaceId, it) } val transaction = Transaction( space = space, type = transaction.type, kind = transaction.kind, category = category, comment = transaction.comment, amount = transaction.amount, fees = transaction.fees, date = transaction.date, tgChatId = chatId, tgMessageId = messageId, ) print(transaction) return transactionRepo.create(transaction, userId) } }