diff --git a/src/entity/asset_invoice.ts b/src/entity/asset_invoice.ts index fe7bc17..6bede02 100644 --- a/src/entity/asset_invoice.ts +++ b/src/entity/asset_invoice.ts @@ -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 { @@ -28,21 +34,7 @@ export class Invoice { nullable: false, type: 'date', }) - invoice_date: Date; - - @Column({ - nullable: false, - type: 'date', - }) - due_date: Date; - - @Column({ - nullable: false, - type: 'decimal', - precision: 14, - scale: 2, - }) - total_amount: number; + invoice_date: Date; @ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false }) @JoinColumn({ name: 'supplier_id' }) @@ -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() @@ -102,5 +97,5 @@ export class Invoice { @Column({ nullable: true }) @DeleteDateColumn() - deleted_at: Date; + deleted_at: Date; } diff --git a/src/entity/assets.ts b/src/entity/assets.ts new file mode 100644 index 0000000..0a3a734 --- /dev/null +++ b/src/entity/assets.ts @@ -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; +} diff --git a/src/entity/goods_handover.ts b/src/entity/goods_handover.ts new file mode 100644 index 0000000..a12d308 --- /dev/null +++ b/src/entity/goods_handover.ts @@ -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; +} diff --git a/src/entity/journal_entries.ts b/src/entity/journal_entries.ts new file mode 100644 index 0000000..692823b --- /dev/null +++ b/src/entity/journal_entries.ts @@ -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; +} diff --git a/src/entity/payment_approval.ts b/src/entity/payment_approval.ts new file mode 100644 index 0000000..b46a538 --- /dev/null +++ b/src/entity/payment_approval.ts @@ -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; +} diff --git a/src/index.ts b/src/index.ts index c726071..e6bd582 100644 --- a/src/index.ts +++ b/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,