@@ -15,6 +15,11 @@ export class CreateOrderAsAdminDto {
|
||||
@IsOptional()
|
||||
userId?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
designerId?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '' })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
|
||||
@@ -24,6 +24,7 @@ import { OrderPrintRepository } from '../repositories/order-print.repository';
|
||||
import { Request } from 'src/modules/request/entities/request.entity';
|
||||
import { Invoice } from 'src/modules/invoice/entities/invoice.entity';
|
||||
import { OrderCreatedEvent } from '../events/order.events';
|
||||
import { InvoiceConfirmStatusEnum } from 'src/modules/invoice/enum/invoice-confirm-status.enum';
|
||||
|
||||
@Injectable()
|
||||
export class OrderService {
|
||||
@@ -48,6 +49,10 @@ export class OrderService {
|
||||
throw new NotFoundException(`Invoice item with ID ${dto.invoiceItemId} not found.`);
|
||||
}
|
||||
|
||||
if (!invoiceItem.confirmedAt ) {
|
||||
throw new BadRequestException(`Invoice item is not confirmed`);
|
||||
}
|
||||
|
||||
user = invoiceItem.invoice.user
|
||||
}
|
||||
|
||||
@@ -83,9 +88,15 @@ export class OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
let designer = null;
|
||||
if (dto.designerId) {
|
||||
designer = await this.adminService.findOrFail(dto.designerId);
|
||||
}
|
||||
|
||||
const order = this.em.create(Order, {
|
||||
user,
|
||||
creator,
|
||||
designer,
|
||||
type,
|
||||
product: product ?? null,
|
||||
title: dto.title,
|
||||
|
||||
Reference in New Issue
Block a user