order number

This commit is contained in:
2026-04-05 08:51:47 +03:30
parent b5d555e9ab
commit f7c57638ff
3 changed files with 42 additions and 11 deletions
+9 -8
View File
@@ -6,7 +6,8 @@ import {
Enum,
PrimaryKey,
OptionalProps,
OneToOne
OneToOne,
Opt
} from '@mikro-orm/core';
import { User } from '../../user/entities/user.entity';
import { ulid } from 'ulid';
@@ -21,9 +22,9 @@ import { OrderPrint } from './print.entity';
@Entity({ tableName: 'orders' })
@Index({ properties: ['user'] })
export class Order extends BaseEntity {
[OptionalProps]?: 'createdAt' | 'deletedAt' | 'orderNumber'
[OptionalProps]?: 'createdAt' | 'deletedAt'
@ManyToOne(() => InvoiceItem,{nullable:true})
@ManyToOne(() => InvoiceItem, { nullable: true })
invoiceItem?: InvoiceItem
@ManyToOne(() => Product, { nullable: true })
@@ -37,10 +38,10 @@ export class Order extends BaseEntity {
id: string = ulid()
@Property({ type: 'string', nullable: true })
title?: string
title?: string
@ManyToOne(() => Category)
type: Category
type: Category
@ManyToOne(() => User)
user!: User;
@@ -53,9 +54,9 @@ export class Order extends BaseEntity {
@Property({
type: 'int',
autoincrement: true
unique: true
})
orderNumber: number;
orderNumber: number & Opt;
@Enum(() => OrderStatusEnum)
@@ -67,5 +68,5 @@ export class Order extends BaseEntity {
@Property({ type: 'json' })
attachments: IAttachment[] = []
}