add goods receipt and add relation to goods
This commit is contained in:
@ -14,7 +14,7 @@ import { Status } from '../types/status';
|
||||
import { User } from './users';
|
||||
import { Supplier } from './supplier';
|
||||
import { AssetCategory } from './asset_category';
|
||||
|
||||
import { GoodsReceipt } from './goods_receipt';
|
||||
@Entity('goods')
|
||||
export class Goods {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
@ -89,11 +89,22 @@ export class Goods {
|
||||
@JoinColumn({ name: 'supplier_id' })
|
||||
supplier: Supplier;
|
||||
|
||||
@ManyToOne(() => GoodsReceipt, (goodsReceipt) => goodsReceipt.goods, { nullable: false })
|
||||
@JoinColumn({ name: 'goods_receipt_id' })
|
||||
goodsReceipt: GoodsReceipt;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
|
||||
goods_receipt_id: string;
|
||||
@Index()
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
|
||||
supplier_id: string;
|
||||
|
||||
@Column({
|
||||
|
||||
104
src/entity/goods_receipt.ts
Normal file
104
src/entity/goods_receipt.ts
Normal file
@ -0,0 +1,104 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
DeleteDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
OneToMany,
|
||||
Index,
|
||||
} from 'typeorm';
|
||||
|
||||
import { User } from './users';
|
||||
import { Supplier } from './supplier';
|
||||
import { RequestOrder } from './request_orders';
|
||||
import { Department } from './department';
|
||||
import { Goods } from './goods';
|
||||
|
||||
@Entity('goods_receipts')
|
||||
export class GoodsReceipt {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
receipt_number: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'date',
|
||||
})
|
||||
receipt_date: Date;
|
||||
|
||||
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.id, { nullable: true })
|
||||
@JoinColumn({ name: 'request_order_id' })
|
||||
requestOrder: RequestOrder;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
request_order_id: string;
|
||||
|
||||
@ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false })
|
||||
@JoinColumn({ name: 'supplier_id' })
|
||||
supplier: Supplier;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
supplier_id: string;
|
||||
|
||||
@ManyToOne(() => Department, (department) => department.id, { nullable: false })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
department_id: string;
|
||||
|
||||
@OneToMany(() => Goods, (goods) => goods.goodsReceipt, { cascade: true })
|
||||
goods: Goods[];
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
remarks: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: false })
|
||||
@JoinColumn({ name: 'received_by' })
|
||||
receivedBy: User;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
received_by: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@DeleteDateColumn()
|
||||
deleted_at: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user