import { Injectable } from '@nestjs/common'; import { CreateExpenseDto } from './dto/create-expense.dto'; import { UpdateExpenseDto } from './dto/update-expense.dto'; import { ExpenseDataService } from './expense-data.service'; import { Expense } from './entities/expense.entity'; @Injectable() export class ExpensesService { public constructor(private expenseDataService: ExpenseDataService) { } public async findAll(): Promise { return await this.expenseDataService.getAll(); } public async findById(id: string): Promise { const expense = await this.expenseDataService.getById(id); if (!expense) { throw new Error('No expense found'); } return expense; } public async create(expense: CreateExpenseDto): Promise { return await this.expenseDataService.create(expense); } public async update(expense: UpdateExpenseDto): Promise { return await this.expenseDataService.update(expense); } public async remove(id: string): Promise { await this.expenseDataService.delete(id); } }