import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { ProductSubCategories } from './product-sub-category.entity'; import { BaseModel } from '../../config/basemodel.entity'; import { Supplier } from '../../users/entities/supplier.entity'; import { ProductHistoryPrice } from './product-history-price.entity'; @Entity() export class Product extends BaseModel { @PrimaryGeneratedColumn('uuid') id: string; @Column() name: string; @Column() code: string; @Column() status: string; @Column({ nullable: true, }) price: number; @Column({ nullable: true, }) basePrice: number; @ManyToOne( () => { return ProductSubCategories; }, (subCategories) => { return subCategories.product; }, ) sub_categories: ProductSubCategories; @ManyToOne( () => { return Supplier; }, (partner) => { return partner.id; }, ) supplier: Supplier; @OneToMany( () => { return ProductHistoryPrice; }, (php) => { return php.product; }, ) priceHistory: ProductHistoryPrice; currentPrice: ProductHistoryPrice; }