add: bill module
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { Cascade, Collection, Entity, EntityRepositoryType, Enum, ManyToOne, OneToMany } from "@mikro-orm/core";
|
||||
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { Business } from "../../businesses/entities/business.entity";
|
||||
import { Invoice } from "../../invoices/entities/invoice.entity";
|
||||
import { BillType } from "../enums/bill-type.enum";
|
||||
import { BillsRepository } from "../repositories/bill.repository";
|
||||
|
||||
@Entity({ repository: () => BillsRepository })
|
||||
export class Bill extends BaseEntity {
|
||||
|
||||
@Enum({ items: () => BillType })
|
||||
type: BillType;
|
||||
|
||||
@ManyToOne(() => Business, { nullable: false, deleteRule: "cascade" })
|
||||
business!: Business;
|
||||
|
||||
@OneToMany(() => Invoice, (invoice) => invoice.bill, { cascade: [Cascade.PERSIST, Cascade.REMOVE], orphanRemoval: true })
|
||||
invoices = new Collection<Invoice>(this);
|
||||
|
||||
[EntityRepositoryType]?: BillsRepository;
|
||||
}
|
||||
Reference in New Issue
Block a user