fix admn controller
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
@Entity('app_settings')
|
||||
export class AppSetting {
|
||||
@@ -44,9 +45,9 @@ export class AppSetting {
|
||||
@Column({ type: 'varchar', length: 160, nullable: true })
|
||||
smtpFromEmail!: string | null;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'datetime' })
|
||||
@UpdateDateColumn({ type: dateTimeColumnType })
|
||||
updatedAt!: Date;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Category } from './Category.js';
|
||||
import { User } from './User.js';
|
||||
import { decimalTransformer } from '../utils/decimal.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
@Entity('budgets')
|
||||
export class Budget {
|
||||
@@ -24,15 +24,15 @@ export class Budget {
|
||||
@Column({ type: 'boolean', default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'datetime' })
|
||||
@UpdateDateColumn({ type: dateTimeColumnType })
|
||||
updatedAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
user!: Relation<User>;
|
||||
user!: User;
|
||||
|
||||
@ManyToOne(() => Category, { eager: true, nullable: true, onDelete: 'SET NULL' })
|
||||
category!: Relation<Category> | null;
|
||||
category!: Category | null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Expense } from './Expense.js';
|
||||
import { User } from './User.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
@Entity('categories')
|
||||
export class Category {
|
||||
@@ -17,12 +17,12 @@ export class Category {
|
||||
@Column({ type: 'boolean', default: false })
|
||||
isSystem!: boolean;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.categories, { nullable: true, onDelete: 'CASCADE' })
|
||||
user!: Relation<User> | null;
|
||||
user!: User | null;
|
||||
|
||||
@OneToMany(() => Expense, (expense) => expense.category)
|
||||
expenses!: Relation<Expense[]>;
|
||||
expenses!: Expense[];
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Category } from './Category.js';
|
||||
import { Proof } from './Proof.js';
|
||||
import { User } from './User.js';
|
||||
import { decimalTransformer } from '../utils/decimal.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
export type ExpenseStatus = 'DRAFT' | 'PENDING' | 'APPROVED' | 'REJECTED';
|
||||
export type DuplicateReviewStatus = 'OPEN' | 'CONFIRMED' | 'DISMISSED';
|
||||
@@ -49,24 +49,24 @@ export class Expense {
|
||||
@Column({ type: 'varchar', length: 20, nullable: true })
|
||||
duplicateStatus!: DuplicateReviewStatus | null;
|
||||
|
||||
@Column({ type: 'datetime', nullable: true })
|
||||
@Column({ type: dateTimeColumnType, nullable: true })
|
||||
duplicateReviewedAt!: Date | null;
|
||||
|
||||
@Column({ type: 'varchar', length: 36, nullable: true })
|
||||
recurringSourceId!: string | null;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'datetime' })
|
||||
@UpdateDateColumn({ type: dateTimeColumnType })
|
||||
updatedAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.expenses, { onDelete: 'CASCADE' })
|
||||
user!: Relation<User>;
|
||||
user!: User;
|
||||
|
||||
@ManyToOne(() => Category, (category) => category.expenses, { eager: true, onDelete: 'RESTRICT' })
|
||||
category!: Relation<Category>;
|
||||
category!: Category;
|
||||
|
||||
@OneToMany(() => Proof, (proof) => proof.expense, { eager: true, cascade: true })
|
||||
proofs!: Relation<Proof[]>;
|
||||
proofs!: Proof[];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { User } from './User.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
@Entity('merchants')
|
||||
export class Merchant {
|
||||
@@ -19,12 +19,12 @@ export class Merchant {
|
||||
@Column({ type: 'boolean', default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'datetime' })
|
||||
@UpdateDateColumn({ type: dateTimeColumnType })
|
||||
updatedAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
user!: Relation<User>;
|
||||
user!: User;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Expense } from './Expense.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
export type ProofType = 'RECEIPT' | 'INVOICE' | 'NOTE' | 'BANK_STATEMENT' | 'OTHER';
|
||||
|
||||
@@ -30,9 +30,9 @@ export class Proof {
|
||||
@Column({ type: 'int', nullable: true })
|
||||
fileSize!: number | null;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => Expense, (expense) => expense.proofs, { onDelete: 'CASCADE' })
|
||||
expense!: Relation<Expense>;
|
||||
expense!: Expense;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Category } from './Category.js';
|
||||
import { User } from './User.js';
|
||||
import { decimalTransformer } from '../utils/decimal.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
export type RecurringFrequency = 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
||||
|
||||
@@ -65,15 +65,15 @@ export class RecurringExpense {
|
||||
@Column({ type: 'boolean', default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn({ type: 'datetime' })
|
||||
@UpdateDateColumn({ type: dateTimeColumnType })
|
||||
updatedAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
user!: Relation<User>;
|
||||
user!: User;
|
||||
|
||||
@ManyToOne(() => Category, { eager: true, onDelete: 'RESTRICT' })
|
||||
category!: Relation<Category>;
|
||||
category!: Category;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import type { Relation } from 'typeorm';
|
||||
import { Category } from './Category.js';
|
||||
import { Expense } from './Expense.js';
|
||||
import { dateTimeColumnType } from '../utils/db-column-types.js';
|
||||
|
||||
export type UserRole = 'ADMIN' | 'USER';
|
||||
|
||||
@@ -47,12 +47,12 @@ export class User {
|
||||
defaultListId?: string | null;
|
||||
} | null;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
@CreateDateColumn({ type: dateTimeColumnType })
|
||||
createdAt!: Date;
|
||||
|
||||
@OneToMany(() => Category, (category) => category.user)
|
||||
categories!: Relation<Category[]>;
|
||||
categories!: Category[];
|
||||
|
||||
@OneToMany(() => Expense, (expense) => expense.user)
|
||||
expenses!: Relation<Expense[]>;
|
||||
expenses!: Expense[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user