modeling out expense entities and dtos

This commit is contained in:
Joe Arndt 2025-12-10 16:31:28 -06:00
parent acdb7ad9c9
commit 7011e44662
10 changed files with 83 additions and 14 deletions

View file

@ -1 +0,0 @@
export class CreateExpenseDto {}

View file

@ -0,0 +1,19 @@
import { PartialType } from '@nestjs/mapped-types';
export class CreateExpenseDto {
year: string;
month: string;
day: string;
cents: number;
category: string;
subcategory?: string[];
merchant?: string;
tags?: string[];
description?: string;
}
export class UpdateExpenseDto extends PartialType(CreateExpenseDto) { }
export class GetExpenseDto extends CreateExpenseDto{
id: number;
}

View file

@ -0,0 +1,32 @@
export class Expense {
id: number;
year: string;
month: string;
day: string;
cents: number;
category: Category;
subcategory?: SubCategory[];
merchant?: Merchant;
tags?: Tag[];
description?: string;
}
export class Category {
id: number;
category: string;
}
export class SubCategory {
id: number;
subcategory: string;
}
export class Merchant {
id: number;
merchant: string;
}
export class Tag {
id: number;
tag: string;
}

View file

@ -1 +0,0 @@
export class Expense {}

View file

@ -1,7 +1,6 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { ExpensesService } from '../../services/expenses.service';
import { CreateExpenseDto } from './create-expense.dto';
import { UpdateExpenseDto } from './update-expense.dto';
import { CreateExpenseDto, GetExpenseDto, UpdateExpenseDto } from './expense.dto';
@Controller('expenses')
export class ExpensesController {
@ -13,7 +12,7 @@ export class ExpensesController {
}
@Get()
findAll() {
findAll(): GetExpenseDto[] {
return this.expensesService.findAll();
}

View file

@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateExpenseDto } from './create-expense.dto';
export class UpdateExpenseDto extends PartialType(CreateExpenseDto) {}