add invoice

This commit is contained in:
fadlydev
2025-01-14 17:17:05 +07:00
parent 21946124a6
commit 8c1c035b8f
2 changed files with 72 additions and 3 deletions

View File

@ -19,6 +19,19 @@ export enum PaymentStatus {
PARTIALLY_PAID = 'PARTIALLY_PAID', 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') @Entity('invoices')
export class Invoice { export class Invoice {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
@ -36,6 +49,12 @@ export class Invoice {
}) })
invoice_date: Date; invoice_date: Date;
@Column({
nullable: false,
type: 'date',
})
due_date: Date;
@ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false }) @ManyToOne(() => Supplier, (supplier) => supplier.id, { nullable: false })
@JoinColumn({ name: 'supplier_id' }) @JoinColumn({ name: 'supplier_id' })
supplier: Supplier; supplier: Supplier;
@ -64,6 +83,49 @@ export class Invoice {
}) })
total_amount: number; 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 }) @ManyToOne(() => User, (user) => user.id, { nullable: false })
@JoinColumn({ name: 'issued_by' }) @JoinColumn({ name: 'issued_by' })
issuedBy: User; issuedBy: User;
@ -87,6 +149,13 @@ export class Invoice {
}) })
payment_status: PaymentStatus; payment_status: PaymentStatus;
@Column({
nullable: false,
type: 'enum',
enum: InvoiceStatus,
})
invoice_status: InvoiceStatus;
@Column() @Column()
@CreateDateColumn() @CreateDateColumn()
created_at: Date; created_at: Date;

View File

@ -35,7 +35,7 @@ export class Goods {
@Column({ @Column({
nullable: false, nullable: false,
length: 64, length: 64,
unique: true, // Ensure the item code is unique unique: true,
}) })
item_code: string; item_code: string;
@ -89,7 +89,7 @@ export class Goods {
@JoinColumn({ name: 'supplier_id' }) @JoinColumn({ name: 'supplier_id' })
supplier: Supplier; supplier: Supplier;
@ManyToOne(() => GoodsReceipt, (goodsReceipt) => goodsReceipt.goods, { nullable: false }) @ManyToOne(() => GoodsReceipt, (goodsReceipt) => goodsReceipt.goods, { nullable: true })
@JoinColumn({ name: 'goods_receipt_id' }) @JoinColumn({ name: 'goods_receipt_id' })
goodsReceipt: GoodsReceipt; goodsReceipt: GoodsReceipt;
@ -101,7 +101,7 @@ export class Goods {
goods_receipt_id: string; goods_receipt_id: string;
@Index() @Index()
@Column({ @Column({
nullable: false, nullable: true,
type: 'uuid', type: 'uuid',
}) })