68 lines
1.3 KiB
TypeScript
68 lines
1.3 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
Index,
|
|
} from 'typeorm';
|
|
import { User } from '../../users/entities/user.entity';
|
|
import { Store } from '../../stores/entities/store.entity';
|
|
import { InventoryItem } from '../../inventory/entities/inventory-item.entity';
|
|
|
|
export enum CorrectionType {
|
|
QUANTITY = 'QUANTITY',
|
|
SKU = 'SKU',
|
|
CONFIRMATION = 'CONFIRMATION',
|
|
}
|
|
|
|
@Entity('corrections')
|
|
@Index(['inventoryItemId'])
|
|
@Index(['userId'])
|
|
@Index(['storeId'])
|
|
@Index(['type', 'createdAt'])
|
|
export class Correction {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column('uuid')
|
|
inventoryItemId: string;
|
|
|
|
@Column('uuid')
|
|
userId: string;
|
|
|
|
@Column('uuid')
|
|
storeId: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: CorrectionType,
|
|
})
|
|
type: CorrectionType;
|
|
|
|
@Column('jsonb')
|
|
previousValue: Record<string, any>;
|
|
|
|
@Column('jsonb')
|
|
newValue: Record<string, any>;
|
|
|
|
@Column({ type: 'varchar', length: 255, nullable: true })
|
|
reason?: string;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@ManyToOne(() => InventoryItem, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'inventoryItemId' })
|
|
inventoryItem: InventoryItem;
|
|
|
|
@ManyToOne(() => User)
|
|
@JoinColumn({ name: 'userId' })
|
|
user: User;
|
|
|
|
@ManyToOne(() => Store)
|
|
@JoinColumn({ name: 'storeId' })
|
|
store: Store;
|
|
}
|