80 lines
1.4 KiB
TypeScript
80 lines
1.4 KiB
TypeScript
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';
|
|
import {ProductHistoryStatus} from "./product-history-status.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;
|
|
|
|
@Column({
|
|
default: 'prepaid',
|
|
})
|
|
type: string;
|
|
|
|
@ManyToOne(
|
|
() => {
|
|
return ProductSubCategories;
|
|
},
|
|
(subCategories) => {
|
|
return subCategories.product;
|
|
},
|
|
)
|
|
sub_categories: ProductSubCategories;
|
|
|
|
@ManyToOne(
|
|
() => {
|
|
return Supplier;
|
|
},
|
|
(partner) => {
|
|
return partner.id;
|
|
},
|
|
)
|
|
supplier: Supplier;
|
|
|
|
|
|
@OneToMany(
|
|
() => {
|
|
return ProductHistoryStatus;
|
|
},
|
|
(php) => {
|
|
return php.product;
|
|
},
|
|
)
|
|
statusHistory: ProductHistoryStatus;
|
|
|
|
@OneToMany(
|
|
() => {
|
|
return ProductHistoryPrice;
|
|
},
|
|
(php) => {
|
|
return php.product;
|
|
},
|
|
)
|
|
priceHistory: ProductHistoryPrice;
|
|
|
|
currentPrice: ProductHistoryPrice;
|
|
}
|