add printFormCreatedAt

This commit is contained in:
2026-02-03 08:48:55 +03:30
parent bfb2b3e7ec
commit c43ee29afe
3 changed files with 12 additions and 17 deletions
@@ -1,10 +1,8 @@
import { Entity, Formula, Index, ManyToOne, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Order } from './order.entity';
import { Product } from 'src/modules/product/entities/product.entity';
import { IAttachment, IField } from '../interface/order.interface';
import { Admin } from 'src/modules/admin/entities/admin.entity';
// import { OrderItemStatus } from '../interface/order.interface';
@Entity({ tableName: 'order_items' })
@Index({ properties: ['order'] })
@@ -55,16 +53,15 @@ export class OrderItem {
@Property({ type: 'json', nullable: true })
attachments?: IAttachment[] // user attachments like voice and photos
// @Property({ type: 'json', nullable: true })
// printAttachments?: IAttachment[]
@Property({ type: 'json', nullable: true })
printAttributes?: IField[] // print form selected attributes
@Property({ nullable: true, columnType: 'timestamptz' })
confirmedAt?: Date;
@Property({ nullable: true, columnType: 'timestamptz' })
printFormCreatedAt?: Date;
@Property({ defaultRaw: 'now()', columnType: 'timestamptz' })
createdAt: Date = new Date();
@@ -40,9 +40,9 @@ export interface CreateOrderItem {
attachments?: IAttachment[]
unitPrice?: number
discount?: number
printFormCreatedAt?: Date
printAttributes?: IField[]
printAttachments?: IAttachment[]
designerId?: string
}
+8 -10
View File
@@ -240,11 +240,7 @@ export class OrderService {
const orderItem = await this.findOrderItemOrFail(orderId, itemId)
const updated = await this.updateOrderItem(orderItem, dto)
// await this.calculateOrder(undefined, orderId)
// await this.em.flush()
const updated = await this.updateOrderItem(orderItem, { ...dto, printFormCreatedAt: new Date() })
return updated
}
@@ -372,7 +368,6 @@ export class OrderService {
}
async removeOrderAsUser(userId: string, orderId: string) {
const order = await this.findOrderOrFail(orderId)
@@ -415,7 +410,7 @@ export class OrderService {
private async createOrderItemEntity(order: Order, dto: CreateOrderItemPopulated, em?: EntityManager) {
const { attributes, description, quantity, attachments, discount,
unitPrice, product, designer, printAttributes, printAttachments } = dto
unitPrice, product, designer, printAttributes } = dto
const eM = em ?? this.em
return eM.create(
@@ -431,7 +426,6 @@ export class OrderService {
unitPrice,
product,
printAttributes: printAttributes,
// printAttachments
})
}
@@ -540,8 +534,8 @@ export class OrderService {
}
async updateOrderItem(orderItem: OrderItem, dto: UpdateOrderItem) {
const { attributes, description, product, quantity,
attachments, discount, unitPrice, designer, printAttributes, printAttachments } = dto
const { attributes, description, product, quantity, printFormCreatedAt,
attachments, discount, unitPrice, designer, printAttributes, } = dto
if (product && orderItem.product.id !== product.id) {
orderItem.product = product
@@ -573,6 +567,10 @@ export class OrderService {
orderItem.unitPrice = unitPrice
}
if (printFormCreatedAt != undefined) {
orderItem.printFormCreatedAt = printFormCreatedAt
}
if (printAttributes != undefined) {
orderItem.printAttributes = printAttributes
}