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

@ -12,6 +12,7 @@ import {
import { AssetCategory } from './asset_category';
import { Supplier } from './supplier';
import { RequestOrder } from './request_orders';
@Entity('goods')
export class Goods {
@ -19,18 +20,21 @@ export class Goods {
id: string;
@Column({
type: 'varchar',
nullable: false,
length: 128,
})
name: string;
@Column({
type: 'varchar',
nullable: true,
length: 255,
})
description: string;
@Column({
type: 'varchar',
nullable: false,
length: 64,
unique: true,
@ -53,36 +57,42 @@ export class Goods {
@Index()
@Column({
nullable: false,
type: 'varchar',
nullable: false,
})
created_by: string;
@Index()
@Column({
nullable: false,
type: 'varchar',
nullable: false,
})
updated_by: string;
@ManyToOne(() => AssetCategory, (category) => category.goods, {
nullable: false,
onDelete: 'SET NULL'
nullable: true,
onDelete: 'SET NULL',
})
@Index()
@JoinColumn({ name: 'category_id'})
@JoinColumn({ name: 'category_id' })
category: AssetCategory;
@ManyToOne(() => Supplier, (supplier) => supplier.goods, {
nullable: true,
onDelete: 'SET NULL'
onDelete: 'SET NULL',
})
@Index()
@JoinColumn({ name: 'supplier_id' })
supplier: Supplier;
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.goods, {
nullable: true,
onDelete: 'SET NULL',
})
@Index()
@JoinColumn({ name: 'request_order_id' })
request_order: RequestOrder;
@Column({
nullable: false,
default: true,

View File

@ -5,16 +5,9 @@ import {
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
Index,
ManyToOne,
JoinColumn,
OneToMany,
} from 'typeorm';
export enum PurchasingMethod {
PO = 'PO', // Purchase Order
DP = 'DP', // Direct Purchase
}
import { Goods } from './goods';
@Entity('request_orders')
export class RequestOrder {
@ -24,65 +17,100 @@ export class RequestOrder {
@Column({
nullable: false,
length: 128,
unique: true,
})
order_number: string;
@Column({
nullable: false,
type: 'date',
nullable: false,
})
order_date: Date;
@Column({
nullable: false,
type: 'decimal',
precision: 12,
precision: 10,
scale: 2,
nullable: false,
})
total_amount: number;
@Index()
@Column({
type: 'varchar',
nullable: false,
type: 'uuid',
})
requested_by: string;
@Column({
nullable: false,
type: 'uuid',
array: true,
})
goods_ids: string[];
@Column({
nullable: true,
type: 'text',
nullable: true,
})
remarks: string;
remarks: string | null;
@Column({
nullable: false,
length: 64,
nullable: false,
})
status: string;
@Column({
length: 2,
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()
created_at: Date;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@UpdateDateColumn({ nullable: true })
updated_at: Date | null;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@DeleteDateColumn({ nullable: true })
deleted_at: Date | null;
}