common-cents-api/src/expenses/entities/expense.entity.ts
2026-02-13 11:47:12 -06:00

35 lines
784 B
TypeScript

import { Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Tag } from '../../tags/entities/tag.entity';
import { Category } from '../../categories/entities/category.entity';
import { Merchant } from '../../merchants/entities/merchant.entity';
@Entity()
export class Expense {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
year: string;
@Column()
month: string;
@Column()
day: string;
@Column()
cents: number;
@ManyToOne(() => Category, { eager: true })
category: Category;
@Column({ nullable: true })
note: string;
@ManyToOne(() => Merchant, { nullable: true, eager: true })
merchant: Merchant;
@ManyToMany(() => Tag, { nullable: true, eager: true })
@JoinTable()
tags: Tag[];
}