From fdf0efd17ffa2732b7bb7d306b4e9e4e6b742d6a Mon Sep 17 00:00:00 2001 From: Joe Arndt Date: Fri, 13 Feb 2026 11:47:12 -0600 Subject: [PATCH] removed sub-categories --- .../Categories/LOC POST Category.bru | 2 +- .../Expenses/LOC POST Expense.bru | 41 +++++----- bruno/Common Cents/Expenses/folder.bru | 1 + .../{Health.bru => Healthcheck.bru} | 2 +- bruno/Common Cents/Merchants/folder.bru | 2 +- .../LOC DELETE Sub-category.bru | 15 ---- .../Sub-categories/LOC GET Sub-categories.bru | 11 --- .../LOC GET Sub-category By ID.bru | 15 ---- .../Sub-categories/LOC POST Sub-category.bru | 17 ----- .../Sub-categories/LOC PUT Sub-category.bru | 18 ----- bruno/Common Cents/Sub-categories/folder.bru | 12 --- src/app.module.ts | 2 - src/expenses/dto/create-expense.dto.ts | 39 +++++++++- src/expenses/dto/update-expense.dto.ts | 7 +- src/expenses/entities/expense.entity.ts | 8 +- .../dto/create-sub-category.dto.ts | 3 - .../dto/update-sub-category.dto.ts | 4 - .../entities/sub-category.entity.ts | 10 --- .../sub-categories.controller.ts | 75 ------------------- src/sub-categories/sub-categories.module.ts | 14 ---- src/sub-categories/sub-categories.service.ts | 35 --------- .../sub-category-data.service.ts | 33 -------- 22 files changed, 71 insertions(+), 295 deletions(-) rename bruno/Common Cents/{Health.bru => Healthcheck.bru} (84%) delete mode 100644 bruno/Common Cents/Sub-categories/LOC DELETE Sub-category.bru delete mode 100644 bruno/Common Cents/Sub-categories/LOC GET Sub-categories.bru delete mode 100644 bruno/Common Cents/Sub-categories/LOC GET Sub-category By ID.bru delete mode 100644 bruno/Common Cents/Sub-categories/LOC POST Sub-category.bru delete mode 100644 bruno/Common Cents/Sub-categories/LOC PUT Sub-category.bru delete mode 100644 bruno/Common Cents/Sub-categories/folder.bru delete mode 100644 src/sub-categories/dto/create-sub-category.dto.ts delete mode 100644 src/sub-categories/dto/update-sub-category.dto.ts delete mode 100644 src/sub-categories/entities/sub-category.entity.ts delete mode 100644 src/sub-categories/sub-categories.controller.ts delete mode 100644 src/sub-categories/sub-categories.module.ts delete mode 100644 src/sub-categories/sub-categories.service.ts delete mode 100644 src/sub-categories/sub-category-data.service.ts diff --git a/bruno/Common Cents/Categories/LOC POST Category.bru b/bruno/Common Cents/Categories/LOC POST Category.bru index c8d1602..016814e 100644 --- a/bruno/Common Cents/Categories/LOC POST Category.bru +++ b/bruno/Common Cents/Categories/LOC POST Category.bru @@ -12,6 +12,6 @@ post { body:json { { - "name": "First Cat" + "name": "Household:Supplies" } } diff --git a/bruno/Common Cents/Expenses/LOC POST Expense.bru b/bruno/Common Cents/Expenses/LOC POST Expense.bru index 38c0cf5..7819293 100644 --- a/bruno/Common Cents/Expenses/LOC POST Expense.bru +++ b/bruno/Common Cents/Expenses/LOC POST Expense.bru @@ -14,25 +14,28 @@ body:json { { "year": "2026", "month": "01", - "day": "02", - "cents": 1000, - "description": "With cat, no subcat or merchant or tags", + "day": "03", + "cents": 1234, + "note": "Additional Expense Test", "category": { - "id": "72644e00-f1fa-4029-bd9c-2e82eb965aeb" - } - // "subCategory": { - // "id": "270ceaea-9cb8-4c6a-846f-ea35ed4d12f7" - // }, - // "merchant": { - // "id": "61246db4-3110-4fe2-bdab-d819b8fd0705" - // }, - // "tags": [ - // { - // "id": "2616f724-f3ce-46df-8b30-897f147f6b74" - // }, - // { - // "id": "16ed84e0-2d17-45c7-ada8-6fe7f8cc8720" - // } - // ] + "id": "96db93d8-2f7e-462c-b520-8754a5900253" + }, + "merchant": { + "id": "9afbe4fd-9077-473a-9d08-f5fb4c8f692f" + }, + "tags": [ + { + "id": "db6d60d9-66e1-4005-a5a3-1e165812aa3c", + "name": "Tag One" + }, + { + "id": "999a8e68-5232-43e0-adf5-98af75aa01ba", + "name": "Tag Two" + }, + { + "id": "619d5c95-65fc-4795-8828-ee1adfe289f8", + "name": "Tag Three" + } + ] } } diff --git a/bruno/Common Cents/Expenses/folder.bru b/bruno/Common Cents/Expenses/folder.bru index 5e0ac02..80ea79e 100644 --- a/bruno/Common Cents/Expenses/folder.bru +++ b/bruno/Common Cents/Expenses/folder.bru @@ -1,5 +1,6 @@ meta { name: Expenses + seq: 3 } auth { diff --git a/bruno/Common Cents/Health.bru b/bruno/Common Cents/Healthcheck.bru similarity index 84% rename from bruno/Common Cents/Health.bru rename to bruno/Common Cents/Healthcheck.bru index 4432b1c..d56a5c3 100644 --- a/bruno/Common Cents/Health.bru +++ b/bruno/Common Cents/Healthcheck.bru @@ -1,5 +1,5 @@ meta { - name: Health + name: Healthcheck type: http seq: 1 } diff --git a/bruno/Common Cents/Merchants/folder.bru b/bruno/Common Cents/Merchants/folder.bru index dc13882..c7dce86 100644 --- a/bruno/Common Cents/Merchants/folder.bru +++ b/bruno/Common Cents/Merchants/folder.bru @@ -1,6 +1,6 @@ meta { name: Merchants - seq: 3 + seq: 4 } auth { diff --git a/bruno/Common Cents/Sub-categories/LOC DELETE Sub-category.bru b/bruno/Common Cents/Sub-categories/LOC DELETE Sub-category.bru deleted file mode 100644 index c10a511..0000000 --- a/bruno/Common Cents/Sub-categories/LOC DELETE Sub-category.bru +++ /dev/null @@ -1,15 +0,0 @@ -meta { - name: LOC DELETE Sub-category - type: http - seq: 5 -} - -delete { - url: {{localBaseUrl}}/{{resourcePath}}/{{resourceId}} - body: none - auth: inherit -} - -vars:pre-request { - resourceId: cbf30070-9ff7-419f-a567-f7d145be445b -} diff --git a/bruno/Common Cents/Sub-categories/LOC GET Sub-categories.bru b/bruno/Common Cents/Sub-categories/LOC GET Sub-categories.bru deleted file mode 100644 index e2eb171..0000000 --- a/bruno/Common Cents/Sub-categories/LOC GET Sub-categories.bru +++ /dev/null @@ -1,11 +0,0 @@ -meta { - name: LOC GET Sub-categories - type: http - seq: 1 -} - -get { - url: {{localBaseUrl}}/{{resourcePath}} - body: none - auth: inherit -} diff --git a/bruno/Common Cents/Sub-categories/LOC GET Sub-category By ID.bru b/bruno/Common Cents/Sub-categories/LOC GET Sub-category By ID.bru deleted file mode 100644 index 6703655..0000000 --- a/bruno/Common Cents/Sub-categories/LOC GET Sub-category By ID.bru +++ /dev/null @@ -1,15 +0,0 @@ -meta { - name: LOC GET Sub-category By ID - type: http - seq: 2 -} - -get { - url: {{localBaseUrl}}/{{resourcePath}}/{{resourceId}} - body: none - auth: inherit -} - -vars:pre-request { - resourceId: 1d6d2842-b271-489b-bd93-e3ceaee5a139 -} diff --git a/bruno/Common Cents/Sub-categories/LOC POST Sub-category.bru b/bruno/Common Cents/Sub-categories/LOC POST Sub-category.bru deleted file mode 100644 index 2d221f4..0000000 --- a/bruno/Common Cents/Sub-categories/LOC POST Sub-category.bru +++ /dev/null @@ -1,17 +0,0 @@ -meta { - name: LOC POST Sub-category - type: http - seq: 3 -} - -post { - url: {{localBaseUrl}}/{{resourcePath}} - body: json - auth: inherit -} - -body:json { - { - "name": "Sub-category Three" - } -} diff --git a/bruno/Common Cents/Sub-categories/LOC PUT Sub-category.bru b/bruno/Common Cents/Sub-categories/LOC PUT Sub-category.bru deleted file mode 100644 index 060a9b0..0000000 --- a/bruno/Common Cents/Sub-categories/LOC PUT Sub-category.bru +++ /dev/null @@ -1,18 +0,0 @@ -meta { - name: LOC PUT Sub-category - type: http - seq: 4 -} - -put { - url: {{localBaseUrl}}/{{resourcePath}} - body: json - auth: inherit -} - -body:json { - { - "id": "1d6d2842-b271-489b-bd93-e3ceaee5a139", - "name": "Merchant One" - } -} diff --git a/bruno/Common Cents/Sub-categories/folder.bru b/bruno/Common Cents/Sub-categories/folder.bru deleted file mode 100644 index 47ece91..0000000 --- a/bruno/Common Cents/Sub-categories/folder.bru +++ /dev/null @@ -1,12 +0,0 @@ -meta { - name: Sub-categories - seq: 4 -} - -auth { - mode: inherit -} - -vars:pre-request { - resourcePath: sub-categories -} diff --git a/src/app.module.ts b/src/app.module.ts index 591367f..ff6780e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -4,7 +4,6 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { MerchantsModule } from './merchants/merchants.module'; import { TagsModule } from './tags/tags.module'; import { CategoriesModule } from './categories/categories.module'; -import { SubCategoriesModule } from './sub-categories/sub-categories.module'; import { ExpensesModule } from './expenses/expenses.module'; import { ConfigModule, ConfigService } from '@nestjs/config'; @@ -37,7 +36,6 @@ import { ConfigModule, ConfigService } from '@nestjs/config'; MerchantsModule, TagsModule, CategoriesModule, - SubCategoriesModule, ExpensesModule ], controllers: [HealthcheckController] diff --git a/src/expenses/dto/create-expense.dto.ts b/src/expenses/dto/create-expense.dto.ts index 52a8f38..a5fd18e 100644 --- a/src/expenses/dto/create-expense.dto.ts +++ b/src/expenses/dto/create-expense.dto.ts @@ -1,10 +1,47 @@ import { Category } from '../../categories/entities/category.entity'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; +import { Merchant } from '../../merchants/entities/merchant.entity'; +import { Tag } from '../../tags/entities/tag.entity'; export class CreateExpenseDto { + @ApiProperty({ + description: '4-digit year of expense' + }) year: string; + + @ApiProperty({ + description: '2-digit month of expense' + }) month: string; + + @ApiProperty({ + description: '2-digit day of expense' + }) day: string; + + @ApiProperty({ + description: 'Amount of expense in cents' + }) cents: number; - description: string; + + @ApiProperty({ + description: 'Category of expense' + }) category: Category + + @ApiPropertyOptional({ + description: 'Optional note about expense' + }) + note?: string; + + @ApiPropertyOptional({ + description: 'Optional merchant for the expense' + }) + merchant?: Merchant; + + @ApiPropertyOptional({ + type: [Tag], + description: 'Optional list of tags for the expense' + }) + tags?: Tag[]; } diff --git a/src/expenses/dto/update-expense.dto.ts b/src/expenses/dto/update-expense.dto.ts index e5be379..a03aa4c 100644 --- a/src/expenses/dto/update-expense.dto.ts +++ b/src/expenses/dto/update-expense.dto.ts @@ -1,6 +1,9 @@ -import { PartialType } from '@nestjs/mapped-types'; import { CreateExpenseDto } from './create-expense.dto'; +import { ApiProperty } from '@nestjs/swagger'; -export class UpdateExpenseDto extends PartialType(CreateExpenseDto) { +export class UpdateExpenseDto extends CreateExpenseDto { + @ApiProperty({ + description: 'UUID of the expense' + }) id: string; } diff --git a/src/expenses/entities/expense.entity.ts b/src/expenses/entities/expense.entity.ts index 36a116d..33340ef 100644 --- a/src/expenses/entities/expense.entity.ts +++ b/src/expenses/entities/expense.entity.ts @@ -1,6 +1,5 @@ import { Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Tag } from '../../tags/entities/tag.entity'; -import { SubCategory } from '../../sub-categories/entities/sub-category.entity'; import { Category } from '../../categories/entities/category.entity'; import { Merchant } from '../../merchants/entities/merchant.entity'; @@ -21,14 +20,11 @@ export class Expense { @Column() cents: number; - @Column({ nullable: true }) - description: string; - @ManyToOne(() => Category, { eager: true }) category: Category; - @ManyToOne(() => SubCategory, { nullable: true, eager: true }) - subCategory: SubCategory; + @Column({ nullable: true }) + note: string; @ManyToOne(() => Merchant, { nullable: true, eager: true }) merchant: Merchant; diff --git a/src/sub-categories/dto/create-sub-category.dto.ts b/src/sub-categories/dto/create-sub-category.dto.ts deleted file mode 100644 index 3837548..0000000 --- a/src/sub-categories/dto/create-sub-category.dto.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class CreateSubCategoryDto { - name: string; -} diff --git a/src/sub-categories/dto/update-sub-category.dto.ts b/src/sub-categories/dto/update-sub-category.dto.ts deleted file mode 100644 index 0541922..0000000 --- a/src/sub-categories/dto/update-sub-category.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class UpdateSubCategoryDto { - id: string; - name: string; -} diff --git a/src/sub-categories/entities/sub-category.entity.ts b/src/sub-categories/entities/sub-category.entity.ts deleted file mode 100644 index f6bf282..0000000 --- a/src/sub-categories/entities/sub-category.entity.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; - -@Entity() -export class SubCategory { - @PrimaryGeneratedColumn('uuid') - id: string; - - @Column({ unique: true }) - name: string; -} diff --git a/src/sub-categories/sub-categories.controller.ts b/src/sub-categories/sub-categories.controller.ts deleted file mode 100644 index 9277087..0000000 --- a/src/sub-categories/sub-categories.controller.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { - Controller, - Get, - Post, - Put, - Delete, - Body, - Param, - HttpCode, - HttpStatus, - BadRequestException, - NotFoundException, - InternalServerErrorException -} from '@nestjs/common'; -import { SubCategoriesService } from './sub-categories.service'; -import { CreateSubCategoryDto } from './dto/create-sub-category.dto'; -import { UpdateSubCategoryDto } from './dto/update-sub-category.dto'; -import { SubCategory } from './entities/sub-category.entity'; - -@Controller('sub-categories') -export class SubCategoriesController { - constructor(private readonly subCategoriesService: SubCategoriesService) { } - - @Get() - @HttpCode(HttpStatus.OK) - public async findAll(): Promise { - return await this.subCategoriesService.findAll(); - } - - @Get(':id') - @HttpCode(HttpStatus.OK) - public async findOne(@Param('id') id: string): Promise { - if (!id) { - throw new BadRequestException('No ID provided.'); - } - - try { - return await this.subCategoriesService.findById(id); - } - catch (error) { - throw new NotFoundException(error); - } - } - - @Post() - @HttpCode(HttpStatus.CREATED) - public async create(@Body() subCategory: CreateSubCategoryDto): Promise { - if (!subCategory.name) { - throw new BadRequestException('Sub-category name cannot be empty.'); - } - - try { - return await this.subCategoriesService.create(subCategory); - } - catch (error) { - throw new InternalServerErrorException(error); - } - } - - @Put() - @HttpCode(HttpStatus.OK) - public async update(@Body() subCategory: UpdateSubCategoryDto): Promise { - if (!subCategory.id) { - throw new BadRequestException('Sub-category ID cannot be empty.'); - } - - return await this.subCategoriesService.update(subCategory); - } - - @Delete(':id') - @HttpCode(HttpStatus.NO_CONTENT) - public async remove(@Param('id') id: string): Promise { - return await this.subCategoriesService.remove(id); - } -} diff --git a/src/sub-categories/sub-categories.module.ts b/src/sub-categories/sub-categories.module.ts deleted file mode 100644 index 7374dec..0000000 --- a/src/sub-categories/sub-categories.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Module } from '@nestjs/common'; -import { SubCategoriesService } from './sub-categories.service'; -import { SubCategoriesController } from './sub-categories.controller'; -import { SubCategoryDataService } from './sub-category-data.service'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { SubCategory } from './entities/sub-category.entity'; - -@Module({ - controllers: [SubCategoriesController], - providers: [SubCategoriesService, SubCategoryDataService], - imports: [TypeOrmModule.forFeature([SubCategory])], - exports: [TypeOrmModule] -}) -export class SubCategoriesModule { } diff --git a/src/sub-categories/sub-categories.service.ts b/src/sub-categories/sub-categories.service.ts deleted file mode 100644 index 15c35b1..0000000 --- a/src/sub-categories/sub-categories.service.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { CreateSubCategoryDto } from './dto/create-sub-category.dto'; -import { UpdateSubCategoryDto } from './dto/update-sub-category.dto'; -import { SubCategoryDataService } from './sub-category-data.service'; -import { SubCategory } from './entities/sub-category.entity'; - -@Injectable() -export class SubCategoriesService { - public constructor(private subCategoryDataService: SubCategoryDataService) { } - - public async findAll(): Promise { - return await this.subCategoryDataService.getAll(); - } - - public async findById(id: string): Promise { - const subCategory = await this.subCategoryDataService.getById(id); - if (!subCategory) { - throw new Error('No sub-category found'); - } - - return subCategory; - } - - public async create(subCategory: CreateSubCategoryDto): Promise { - return await this.subCategoryDataService.create(subCategory.name); - } - - public async update(subCategory: UpdateSubCategoryDto): Promise { - return await this.subCategoryDataService.update(subCategory); - } - - public async remove(id: string): Promise { - await this.subCategoryDataService.delete(id); - } -} diff --git a/src/sub-categories/sub-category-data.service.ts b/src/sub-categories/sub-category-data.service.ts deleted file mode 100644 index 3d57e66..0000000 --- a/src/sub-categories/sub-category-data.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { DataSource, Repository } from 'typeorm'; -import { SubCategory } from './entities/sub-category.entity'; -import { UpdateSubCategoryDto } from './dto/update-sub-category.dto'; - -@Injectable() -export class SubCategoryDataService { - private subCategories: Repository; - - public constructor(private dataSource: DataSource) { - this.subCategories = this.dataSource.getRepository(SubCategory); - } - - public async getAll(): Promise { - return await this.subCategories.find(); - } - - public async getById(id: string): Promise { - return await this.subCategories.findOneBy({ id }); - } - - public async create(name: string): Promise { - return await this.subCategories.save({ name }); - } - - public async update(subCategory: UpdateSubCategoryDto): Promise { - return await this.subCategories.save(subCategory); - } - - public async delete(id: string): Promise { - await this.subCategories.delete({ id }); - } -}