Add Asset Invoice, journal entry, goods handover and payment approval
This commit is contained in:
@ -10,8 +10,14 @@ import {
|
||||
} from 'typeorm';
|
||||
|
||||
import { Supplier } from './supplier';
|
||||
import { RequestOrder } from './request_orders';
|
||||
import { User } from './users';
|
||||
import { Department } from './department';
|
||||
|
||||
export enum PaymentStatus {
|
||||
PAID = 'PAID',
|
||||
UNPAID = 'UNPAID',
|
||||
PARTIALLY_PAID = 'PARTIALLY_PAID',
|
||||
}
|
||||
|
||||
@Entity('invoices')
|
||||
export class Invoice {
|
||||
@ -30,20 +36,6 @@ export class Invoice {
|
||||
})
|
||||
invoice_date: Date;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'date',
|
||||
})
|
||||
due_date: Date;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 14,
|
||||
scale: 2,
|
||||
})
|
||||
total_amount: number;
|
||||
|
||||
@ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false })
|
||||
@JoinColumn({ name: 'supplier_id' })
|
||||
supplier: Supplier;
|
||||
@ -54,43 +46,46 @@ export class Invoice {
|
||||
})
|
||||
supplier_id: string;
|
||||
|
||||
@ManyToOne(() => Department, (department) => department.id, { nullable: false })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.id, { nullable: false })
|
||||
@JoinColumn({ name: 'request_order_id' })
|
||||
requestOrder: RequestOrder;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
department_id: string;
|
||||
request_order_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
})
|
||||
total_amount: number;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: false })
|
||||
@JoinColumn({ name: 'created_by' })
|
||||
createdBy: User;
|
||||
@JoinColumn({ name: 'issued_by' })
|
||||
issuedBy: User;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
created_by: string;
|
||||
issued_by: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
description: string;
|
||||
remarks: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
type: 'enum',
|
||||
enum: PaymentStatus,
|
||||
})
|
||||
status: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
payment_id: string;
|
||||
payment_status: PaymentStatus;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
|
||||
90
src/entity/assets.ts
Normal file
90
src/entity/assets.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { Goods } from './goods';
|
||||
import { Department } from './department';
|
||||
|
||||
@Entity('assets')
|
||||
export class Asset {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => Goods, (goods) => goods.id, { nullable: false })
|
||||
@JoinColumn({ name: 'goods_id' })
|
||||
goods: Goods;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
goods_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
asset_code: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 256,
|
||||
})
|
||||
asset_name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
description: string;
|
||||
|
||||
@ManyToOne(() => Department, (department) => department.id, { nullable: false })
|
||||
@JoinColumn({ name: 'department_id' })
|
||||
department: Department;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
department_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
})
|
||||
purchase_price: number;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'date',
|
||||
})
|
||||
purchase_date: Date;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
location: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 64,
|
||||
})
|
||||
status: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
}
|
||||
79
src/entity/goods_handover.ts
Normal file
79
src/entity/goods_handover.ts
Normal file
@ -0,0 +1,79 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { User } from './users';
|
||||
import { RequestOrder } from './request_orders';
|
||||
import { Goods } from './goods';
|
||||
|
||||
@Entity('goods_handover')
|
||||
export class GoodsHandover {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.id, { nullable: false })
|
||||
@JoinColumn({ name: 'request_order_id' })
|
||||
requestOrder: RequestOrder;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
request_order_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'date',
|
||||
})
|
||||
handover_date: Date;
|
||||
|
||||
@ManyToOne(() => Goods, (goods) => goods.id, { nullable: false })
|
||||
@JoinColumn({ name: 'goods_id' })
|
||||
goods: Goods;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
goods_id: string;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: false })
|
||||
@JoinColumn({ name: 'handed_over_by' })
|
||||
handedOverBy: User;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
handed_over_by: string;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: false })
|
||||
@JoinColumn({ name: 'received_by' })
|
||||
receivedBy: User;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
received_by: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
remarks: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
}
|
||||
56
src/entity/journal_entries.ts
Normal file
56
src/entity/journal_entries.ts
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { PaymentApproval } from './payment_approval';
|
||||
|
||||
@Entity('journal_entries')
|
||||
export class AssetJournalEntry {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => PaymentApproval, (paymentApproval) => paymentApproval.journalEntries, { nullable: false })
|
||||
@JoinColumn({ name: 'payment_approval_id' })
|
||||
paymentApproval: PaymentApproval;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
payment_approval_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
})
|
||||
amount: number;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
account_code: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
length: 128,
|
||||
})
|
||||
description: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
}
|
||||
116
src/entity/payment_approval.ts
Normal file
116
src/entity/payment_approval.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
import { User } from './users';
|
||||
import { RequestOrder } from './request_orders';
|
||||
import { AssetJournalEntry } from './journal_entries';
|
||||
|
||||
export enum ApprovalStatus {
|
||||
PENDING = 'PENDING',
|
||||
APPROVED = 'APPROVED',
|
||||
REJECTED = 'REJECTED',
|
||||
}
|
||||
|
||||
@Entity('payment_approvals')
|
||||
export class PaymentApproval {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@ManyToOne(() => RequestOrder, (requestOrder) => requestOrder.id, { nullable: false })
|
||||
@JoinColumn({ name: 'request_order_id' })
|
||||
requestOrder: RequestOrder;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
request_order_id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'decimal',
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
})
|
||||
approved_amount: number;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'enum',
|
||||
enum: ApprovalStatus,
|
||||
default: ApprovalStatus.PENDING,
|
||||
})
|
||||
finance_approval_status: ApprovalStatus;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: true })
|
||||
@JoinColumn({ name: 'approved_by' })
|
||||
approvedBy: User;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
approved_by: string;
|
||||
|
||||
@OneToMany(() => AssetJournalEntry, (journalEntry) => journalEntry.paymentApproval)
|
||||
journalEntries: AssetJournalEntry[];
|
||||
|
||||
@ManyToOne(() => FinanceMemo, (financeMemo) => financeMemo.paymentApprovals)
|
||||
@JoinColumn({ name: 'finance_memo_id' })
|
||||
financeMemo: FinanceMemo;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'uuid',
|
||||
})
|
||||
finance_memo_id: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
}
|
||||
|
||||
@Entity('finance_memos')
|
||||
export class FinanceMemo {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'text',
|
||||
})
|
||||
memo_content: string;
|
||||
|
||||
@OneToMany(() => PaymentApproval, (paymentApproval) => paymentApproval.financeMemo)
|
||||
paymentApprovals: PaymentApproval[];
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id, { nullable: false })
|
||||
@JoinColumn({ name: 'created_by' })
|
||||
createdBy: User;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'uuid',
|
||||
})
|
||||
created_by: string;
|
||||
|
||||
@Column()
|
||||
@CreateDateColumn()
|
||||
created_at: Date;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@UpdateDateColumn()
|
||||
updated_at: Date;
|
||||
}
|
||||
10
src/index.ts
10
src/index.ts
@ -58,6 +58,11 @@ import { SubmissionRecap } from "./entity/request_submission_recap";
|
||||
import {AssetRealization} from './entity/asset_realizations'
|
||||
import { AssetRealizationRecap } from "./entity/asset_realization_recaps";
|
||||
import { GoodsReceipt } from "./entity/goods_receipt";
|
||||
import { Invoice } from "./entity/asset_invoice";
|
||||
import {Asset} from './entity/assets'
|
||||
import { GoodsHandover } from "./entity/goods_handover";
|
||||
import { AssetJournalEntry } from "./entity/journal_entries";
|
||||
import { PaymentApproval } from "./entity/payment_approval";
|
||||
|
||||
export {
|
||||
User, //
|
||||
@ -104,11 +109,16 @@ export {
|
||||
SummarizeType,
|
||||
Goods,
|
||||
Supplier,
|
||||
Asset,
|
||||
AssetCategory,
|
||||
AssetClassification,
|
||||
FixedAssetClassification,
|
||||
AssetDepreciation,
|
||||
Employee,
|
||||
Invoice,
|
||||
GoodsHandover,
|
||||
AssetJournalEntry,
|
||||
PaymentApproval,
|
||||
Department,
|
||||
GoodsReceipt,
|
||||
RequestSubmission,
|
||||
|
||||
Reference in New Issue
Block a user