adding asset category
This commit is contained in:
43
src/entity/asset_category.ts
Normal file
43
src/entity/asset_category.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import {
|
||||||
|
Entity,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
Column,
|
||||||
|
CreateDateColumn,
|
||||||
|
UpdateDateColumn,
|
||||||
|
DeleteDateColumn,
|
||||||
|
OneToMany,
|
||||||
|
} from 'typeorm';
|
||||||
|
import { Goods } from './goods';
|
||||||
|
|
||||||
|
@Entity('categories')
|
||||||
|
export class AssetCategory {
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
length: 128,
|
||||||
|
})
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@OneToMany(() => Goods, (goods) => goods.category_id)
|
||||||
|
goods: Goods[];
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
@CreateDateColumn()
|
||||||
|
created_at: Date;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
@UpdateDateColumn()
|
||||||
|
updated_at: Date;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
@DeleteDateColumn()
|
||||||
|
deleted_at: Date;
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ import {
|
|||||||
import { Status } from '../types/status';
|
import { Status } from '../types/status';
|
||||||
import { User } from './users';
|
import { User } from './users';
|
||||||
import { Supplier } from './supplier';
|
import { Supplier } from './supplier';
|
||||||
|
import { AssetCategory } from './asset_category';
|
||||||
|
|
||||||
@Entity('goods')
|
@Entity('goods')
|
||||||
export class Goods {
|
export class Goods {
|
||||||
@ -31,6 +32,13 @@ export class Goods {
|
|||||||
})
|
})
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
length: 64,
|
||||||
|
unique: true, // Ensure the item code is unique
|
||||||
|
})
|
||||||
|
item_code: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
type: 'decimal',
|
type: 'decimal',
|
||||||
@ -45,6 +53,10 @@ export class Goods {
|
|||||||
})
|
})
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => AssetCategory, (category) => category.goods, { nullable: true })
|
||||||
|
@JoinColumn({ name: 'category_id' })
|
||||||
|
category: AssetCategory;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
type: 'uuid',
|
type: 'uuid',
|
||||||
@ -62,6 +74,17 @@ export class Goods {
|
|||||||
})
|
})
|
||||||
created_by: string;
|
created_by: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => User, (user) => user.id, { nullable: true })
|
||||||
|
@JoinColumn({ name: 'updated_by' })
|
||||||
|
updatedBy: User;
|
||||||
|
|
||||||
|
@Index()
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: 'uuid',
|
||||||
|
})
|
||||||
|
updated_by: string;
|
||||||
|
|
||||||
@ManyToOne(() => Supplier, { nullable: false })
|
@ManyToOne(() => Supplier, { nullable: false })
|
||||||
@JoinColumn({ name: 'supplier_id' })
|
@JoinColumn({ name: 'supplier_id' })
|
||||||
supplier: Supplier;
|
supplier: Supplier;
|
||||||
|
|||||||
@ -37,6 +37,7 @@ import { SummarizeLog } from "./entity/summarize_log";
|
|||||||
import { SummarizeLogStatus, SummarizeType } from "./types/summarize";
|
import { SummarizeLogStatus, SummarizeType } from "./types/summarize";
|
||||||
import { Goods } from "./entity/goods";
|
import { Goods } from "./entity/goods";
|
||||||
import { Supplier } from "./entity/supplier";
|
import { Supplier } from "./entity/supplier";
|
||||||
|
import { AssetCategory } from "./entity/asset_category";
|
||||||
import { TelegramBody, TelegramResponseSend } from "./types/telegram";
|
import { TelegramBody, TelegramResponseSend } from "./types/telegram";
|
||||||
import { Ledger } from "./entity/ledgers";
|
import { Ledger } from "./entity/ledgers";
|
||||||
import { CreditCompany } from "./entity/credit_companies";
|
import { CreditCompany } from "./entity/credit_companies";
|
||||||
@ -92,6 +93,7 @@ export {
|
|||||||
SummarizeType,
|
SummarizeType,
|
||||||
Goods,
|
Goods,
|
||||||
Supplier,
|
Supplier,
|
||||||
|
AssetCategory,
|
||||||
Ledger,
|
Ledger,
|
||||||
CreditCompany,
|
CreditCompany,
|
||||||
CreditDebtor,
|
CreditDebtor,
|
||||||
|
|||||||
Reference in New Issue
Block a user