update request order field

This commit is contained in:
fadlydev
2025-01-21 19:35:56 +07:00
parent 1fcec2acc2
commit 4094d62e8a
2 changed files with 84 additions and 46 deletions

View File

@ -11,7 +11,8 @@ import {
} from 'typeorm'; } from 'typeorm';
import { AssetCategory } from './asset_category'; import { AssetCategory } from './asset_category';
import { Supplier } from './supplier'; import { Supplier } from './supplier';
import { RequestOrder } from './request_orders';
@Entity('goods') @Entity('goods')
export class Goods { export class Goods {
@ -19,18 +20,21 @@ export class Goods {
id: string; id: string;
@Column({ @Column({
type: 'varchar',
nullable: false, nullable: false,
length: 128, length: 128,
}) })
name: string; name: string;
@Column({ @Column({
type: 'varchar',
nullable: true, nullable: true,
length: 255, length: 255,
}) })
description: string; description: string;
@Column({ @Column({
type: 'varchar',
nullable: false, nullable: false,
length: 64, length: 64,
unique: true, unique: true,
@ -46,43 +50,49 @@ export class Goods {
price: number; price: number;
@Column({ @Column({
nullable: false, nullable: false,
type: 'int', type: 'int',
}) })
quantity: number; quantity: number;
@Index() @Index()
@Column({ @Column({
nullable: false,
type: 'varchar', type: 'varchar',
nullable: false,
}) })
created_by: string; created_by: string;
@Index() @Index()
@Column({ @Column({
nullable: false,
type: 'varchar', type: 'varchar',
nullable: false,
}) })
updated_by: string; updated_by: string;
@ManyToOne(() => AssetCategory, (category) => category.goods, { @ManyToOne(() => AssetCategory, (category) => category.goods, {
nullable: false, nullable: true,
onDelete: 'SET NULL' onDelete: 'SET NULL',
}) })
@Index() @Index()
@JoinColumn({ name: 'category_id'}) @JoinColumn({ name: 'category_id' })
category: AssetCategory; category: AssetCategory;
@ManyToOne(() => Supplier, (supplier) => supplier.goods, { @ManyToOne(() => Supplier, (supplier) => supplier.goods, {
nullable: true, nullable: true,
onDelete: 'SET NULL' onDelete: 'SET NULL',
}) })
@Index() @Index()
@JoinColumn({ name: 'supplier_id' }) @JoinColumn({ name: 'supplier_id' })
supplier: Supplier; supplier: Supplier;
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.goods, {
nullable: true,
onDelete: 'SET NULL',
})
@Index()
@JoinColumn({ name: 'request_order_id' })
request_order: RequestOrder;
@Column({ @Column({
nullable: false, nullable: false,
default: true, default: true,

View File

@ -5,84 +5,112 @@ import {
CreateDateColumn, CreateDateColumn,
UpdateDateColumn, UpdateDateColumn,
DeleteDateColumn, DeleteDateColumn,
Index, OneToMany,
ManyToOne,
JoinColumn,
} from 'typeorm'; } from 'typeorm';
import { Goods } from './goods';
export enum PurchasingMethod {
PO = 'PO', // Purchase Order
DP = 'DP', // Direct Purchase
}
@Entity('request_orders') @Entity('request_orders')
export class RequestOrder { export class RequestOrder {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
id: string; id: string;
@Column({ @Column({
nullable: false, nullable: false,
length: 128, length: 128,
unique: true,
}) })
order_number: string; order_number: string;
@Column({ @Column({
nullable: false,
type: 'date', type: 'date',
nullable: false,
}) })
order_date: Date; order_date: Date;
@Column({ @Column({
nullable: false,
type: 'decimal', type: 'decimal',
precision: 12, precision: 10,
scale: 2, scale: 2,
nullable: false,
}) })
total_amount: number; total_amount: number;
@Index()
@Column({ @Column({
type: 'varchar',
nullable: false, nullable: false,
type: 'uuid',
}) })
requested_by: string; requested_by: string;
@Column({ @Column({
nullable: false,
type: 'uuid',
array: true,
})
goods_ids: string[];
@Column({
nullable: true,
type: 'text', type: 'text',
nullable: true,
}) })
remarks: string; remarks: string | null;
@Column({ @Column({
nullable: false,
length: 64, length: 64,
nullable: false,
}) })
status: string; status: string;
@Column({ @Column({
length: 2,
nullable: false, nullable: false,
type: 'enum',
enum: PurchasingMethod,
}) })
purchasing_method: PurchasingMethod; purchasing_method: string;
// Supervisor Approval
@Column({
type: 'uuid',
nullable: true,
})
approved_by_spv: string | null;
@Column({
type: 'timestamp',
nullable: true,
})
spv_approval_date: Date | null;
@Column({
type: 'varchar',
length: 16,
nullable: true,
default: 'PENDING',
})
spv_approval_status: 'PENDING' | 'APPROVED' | 'REJECTED';
// General Manager Approval
@Column({
type: 'uuid',
nullable: true,
})
approved_by_gm: string | null;
@Column({
type: 'timestamp',
nullable: true,
})
gm_approval_date: Date | null;
@Column({
type: 'varchar',
length: 16,
nullable: true,
default: 'PENDING',
})
gm_approval_status: 'PENDING' | 'APPROVED' | 'REJECTED';
// Relation with Goods
@OneToMany(() => Goods, (goods) => goods.request_order)
goods: Goods[];
@Column()
@CreateDateColumn() @CreateDateColumn()
created_at: Date; created_at: Date;
@Column({ nullable: true }) @UpdateDateColumn({ nullable: true })
@UpdateDateColumn() updated_at: Date | null;
updated_at: Date;
@Column({ nullable: true }) @DeleteDateColumn({ nullable: true })
@DeleteDateColumn() deleted_at: Date | null;
deleted_at: Date;
} }