diff --git a/src/entity/asset_invoice.ts b/src/entity/asset_invoice.ts index 6bede02..60f9920 100644 --- a/src/entity/asset_invoice.ts +++ b/src/entity/asset_invoice.ts @@ -19,6 +19,19 @@ export enum PaymentStatus { PARTIALLY_PAID = 'PARTIALLY_PAID', } +export enum InvoiceStatus { + ISSUED = 'ISSUED', + PENDING = 'PENDING', + CANCELED = 'CANCELED', + SETTLED = 'SETTLED', +} + +export enum PaymentMethod { + BANK_TRANSFER = 'BANK_TRANSFER', + CREDIT_CARD = 'CREDIT_CARD', + PAYPAL = 'PAYPAL', +} + @Entity('invoices') export class Invoice { @PrimaryGeneratedColumn('uuid') @@ -36,6 +49,12 @@ export class Invoice { }) invoice_date: Date; + @Column({ + nullable: false, + type: 'date', + }) + due_date: Date; + @ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false }) @JoinColumn({ name: 'supplier_id' }) supplier: Supplier; @@ -64,6 +83,49 @@ export class Invoice { }) total_amount: number; + @Column({ + nullable: false, + type: 'decimal', + precision: 12, + scale: 2, + }) + tax_amount: number; + + @Column({ + nullable: false, + length: 3, + }) + currency: string; + + @Column({ + nullable: true, + type: 'decimal', + precision: 12, + scale: 2, + }) + discount: number; + + @Column({ + nullable: false, + type: 'decimal', + precision: 12, + scale: 2, + }) + net_amount: number; + + @Column({ + nullable: true, + type: 'text', + }) + payment_terms: string; + + @Column({ + nullable: true, + type: 'enum', + enum: PaymentMethod, + }) + payment_method: PaymentMethod; + @ManyToOne(() => User, (user) => user.id, { nullable: false }) @JoinColumn({ name: 'issued_by' }) issuedBy: User; @@ -87,6 +149,13 @@ export class Invoice { }) payment_status: PaymentStatus; + @Column({ + nullable: false, + type: 'enum', + enum: InvoiceStatus, + }) + invoice_status: InvoiceStatus; + @Column() @CreateDateColumn() created_at: Date; diff --git a/src/entity/goods.ts b/src/entity/goods.ts index 0aeae9a..031eeb6 100644 --- a/src/entity/goods.ts +++ b/src/entity/goods.ts @@ -35,7 +35,7 @@ export class Goods { @Column({ nullable: false, length: 64, - unique: true, // Ensure the item code is unique + unique: true, }) item_code: string; @@ -89,7 +89,7 @@ export class Goods { @JoinColumn({ name: 'supplier_id' }) supplier: Supplier; - @ManyToOne(() => GoodsReceipt, (goodsReceipt) => goodsReceipt.goods, { nullable: false }) + @ManyToOne(() => GoodsReceipt, (goodsReceipt) => goodsReceipt.goods, { nullable: true }) @JoinColumn({ name: 'goods_receipt_id' }) goodsReceipt: GoodsReceipt; @@ -101,7 +101,7 @@ export class Goods { goods_receipt_id: string; @Index() @Column({ - nullable: false, + nullable: true, type: 'uuid', })