101 lines
1.5 KiB
TypeScript
101 lines
1.5 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
DeleteDateColumn,
|
|
Index,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
|
|
import { AssetCategory } from './asset_category';
|
|
import { Supplier } from './supplier';
|
|
|
|
@Entity('goods')
|
|
export class Goods {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
length: 128,
|
|
})
|
|
name: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
length: 255,
|
|
})
|
|
description: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
length: 64,
|
|
unique: true,
|
|
})
|
|
item_code: string;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
type: 'decimal',
|
|
precision: 10,
|
|
scale: 2,
|
|
})
|
|
price: number;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
type: 'int',
|
|
})
|
|
quantity: number;
|
|
|
|
@Index()
|
|
@Column({
|
|
nullable: false,
|
|
type: 'uuid',
|
|
})
|
|
created_by: string;
|
|
|
|
@Index()
|
|
@Column({
|
|
nullable: false,
|
|
type: 'uuid',
|
|
})
|
|
updated_by: string;
|
|
|
|
@ManyToOne(() => AssetCategory, (category) => category.goods, {
|
|
nullable: false,
|
|
onDelete: 'SET NULL'
|
|
})
|
|
|
|
@Index()
|
|
@JoinColumn({ name: 'category_id'})
|
|
category: AssetCategory;
|
|
|
|
@ManyToOne(() => Supplier, (supplier) => supplier.goods, {
|
|
nullable: true,
|
|
onDelete: 'SET NULL'
|
|
})
|
|
|
|
@Index()
|
|
@JoinColumn({ name: 'supplier_id' })
|
|
supplier: Supplier;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: true,
|
|
})
|
|
is_active: boolean;
|
|
|
|
@CreateDateColumn()
|
|
created_at: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updated_at: Date;
|
|
|
|
@DeleteDateColumn()
|
|
deleted_at: Date;
|
|
}
|