51 lines
1016 B
TypeScript
51 lines
1016 B
TypeScript
import { User } from 'src/objects/user/user.entity';
|
|
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { TransactionType } from '../enums/transaction-type.enum';
|
|
import { StoredItem } from './stored-item.entity';
|
|
|
|
@Entity()
|
|
export class StoredItemTransaction {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ type: String, default: TransactionType.ACQUIRED })
|
|
type: TransactionType;
|
|
|
|
@Column({ nullable: true })
|
|
price?: number;
|
|
|
|
@Column({ nullable: true, default: 'EUR', length: 3 })
|
|
currency?: string;
|
|
|
|
@ManyToOne(() => StoredItem, {
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
storedItem: StoredItem;
|
|
|
|
@ManyToOne(() => User, {
|
|
onDelete: 'SET NULL',
|
|
nullable: true,
|
|
})
|
|
actor?: User;
|
|
|
|
@Column({ nullable: true })
|
|
notes?: string;
|
|
|
|
@Column({ type: 'datetime', nullable: true })
|
|
actionAt?: Date;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|