This commit is contained in:
Mateusz Gruszczyński
2026-04-06 14:37:42 +02:00
parent 237596bd52
commit 80e181ea3f
41 changed files with 14959 additions and 1023 deletions

View File

@@ -0,0 +1,78 @@
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { Category } from './Category.js';
import { User } from './User.js';
import { decimalTransformer } from '../utils/decimal.js';
export type RecurringFrequency = 'WEEKLY' | 'MONTHLY' | 'YEARLY';
@Entity('recurring_expenses')
export class RecurringExpense {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar', length: 140 })
title!: string;
@Column({ type: 'text', nullable: true })
description!: string | null;
@Column({ type: 'decimal', precision: 12, scale: 2, transformer: decimalTransformer })
amount!: number;
@Column({ type: 'varchar', length: 80, nullable: true })
merchant!: string | null;
@Column({ type: 'varchar', length: 50, nullable: true })
paymentMethod!: string | null;
@Column({ type: 'varchar', length: 12, default: 'PLN' })
currency!: string;
@Column({ type: 'varchar', length: 20, default: 'MONTHLY' })
frequency!: RecurringFrequency;
@Column({ type: 'int', default: 1 })
intervalValue!: number;
@Column({ type: 'date' })
startDate!: string;
@Column({ type: 'date' })
nextRunDate!: string;
@Column({ type: 'date', nullable: true })
lastRunDate!: string | null;
@Column({ type: 'date', nullable: true })
endDate!: string | null;
@Column({ type: 'int', nullable: true })
maxOccurrences!: number | null;
@Column({ type: 'int', default: 0 })
generatedCount!: number;
@Column({ type: 'varchar', length: 20, default: 'PENDING' })
defaultStatus!: string;
@Column({ type: 'simple-json', nullable: true })
tags!: string[] | null;
@Column({ type: 'simple-json', nullable: true })
customFields!: Record<string, string> | null;
@Column({ type: 'boolean', default: true })
isActive!: boolean;
@CreateDateColumn({ type: 'datetime' })
createdAt!: Date;
@UpdateDateColumn({ type: 'datetime' })
updatedAt!: Date;
@ManyToOne(() => User, { onDelete: 'CASCADE' })
user!: User;
@ManyToOne(() => Category, { eager: true, onDelete: 'RESTRICT' })
category!: Category;
}