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,37 @@
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';
@Entity('budgets')
export class Budget {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar', length: 7 })
month!: string;
@Column({ type: 'varchar', length: 120, nullable: true })
name!: string | null;
@Column({ type: 'decimal', precision: 12, scale: 2, transformer: decimalTransformer })
amount!: number;
@Column({ type: 'simple-json', nullable: true })
alertThresholds!: number[] | 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, nullable: true, onDelete: 'SET NULL' })
category!: Category | null;
}

View File

@@ -4,6 +4,9 @@ import { Proof } from './Proof.js';
import { User } from './User.js';
import { decimalTransformer } from '../utils/decimal.js';
export type ExpenseStatus = 'DRAFT' | 'PENDING' | 'APPROVED' | 'REJECTED';
export type DuplicateReviewStatus = 'OPEN' | 'CONFIRMED' | 'DISMISSED';
@Entity('expenses')
export class Expense {
@PrimaryGeneratedColumn('uuid')
@@ -30,9 +33,27 @@ export class Expense {
@Column({ type: 'varchar', length: 12, default: 'PLN' })
currency!: string;
@Column({ type: 'varchar', length: 20, default: 'PENDING' })
status!: ExpenseStatus;
@Column({ type: 'simple-json', nullable: true })
tags!: string[] | null;
@Column({ type: 'simple-json', nullable: true })
customFields!: Record<string, string> | null;
@Column({ type: 'boolean', default: false })
possibleDuplicate!: boolean;
@Column({ type: 'varchar', length: 20, nullable: true })
duplicateStatus!: DuplicateReviewStatus | null;
@Column({ type: 'datetime', nullable: true })
duplicateReviewedAt!: Date | null;
@Column({ type: 'varchar', length: 36, nullable: true })
recurringSourceId!: string | null;
@CreateDateColumn({ type: 'datetime' })
createdAt!: Date;

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;
}

View File

@@ -36,6 +36,16 @@ export class User {
categoryIds?: string[];
} | null;
@Column({ type: 'simple-json', nullable: true })
shoppingListIntegration!: {
enabled?: boolean;
baseUrl?: string;
apiToken?: string;
authMode?: 'bearer' | 'x-api-token' | 'both';
ownerId?: string | null;
defaultListId?: string | null;
} | null;
@CreateDateColumn({ type: 'datetime' })
createdAt!: Date;