@@ -63,7 +63,7 @@ export class OrderService {
|
|||||||
private readonly orderPrintRepository: OrderPrintRepository,
|
private readonly orderPrintRepository: OrderPrintRepository,
|
||||||
private readonly eventEmitter: EventEmitter2,
|
private readonly eventEmitter: EventEmitter2,
|
||||||
private readonly chatService: ChattService,
|
private readonly chatService: ChattService,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
async createOrderAsAdmin(adminId: string, dto: CreateOrderAsAdminDto): Promise<Order> {
|
async createOrderAsAdmin(adminId: string, dto: CreateOrderAsAdminDto): Promise<Order> {
|
||||||
let invoiceItem: null | InvoiceItem = null
|
let invoiceItem: null | InvoiceItem = null
|
||||||
@@ -75,7 +75,7 @@ export class OrderService {
|
|||||||
throw new NotFoundException(`Invoice item with ID ${dto.invoiceItemId} not found.`);
|
throw new NotFoundException(`Invoice item with ID ${dto.invoiceItemId} not found.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!invoiceItem.confirmedAt ) {
|
if (!invoiceItem.confirmedAt) {
|
||||||
throw new BadRequestException(`Invoice item is not confirmed`);
|
throw new BadRequestException(`Invoice item is not confirmed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,13 +162,13 @@ export class OrderService {
|
|||||||
async findOrdersAsAdmin(adminId: string, dto: FindOrdersDto): Promise<PaginatedResult<Order>> {
|
async findOrdersAsAdmin(adminId: string, dto: FindOrdersDto): Promise<PaginatedResult<Order>> {
|
||||||
const permissions = await this.adminService.ownedPermissions(adminId,
|
const permissions = await this.adminService.ownedPermissions(adminId,
|
||||||
[PermissionEnum.VIEW_ORDERS, PermissionEnum.VIEW_ASSIGNED_ORDERS])
|
[PermissionEnum.VIEW_ORDERS, PermissionEnum.VIEW_ASSIGNED_ORDERS])
|
||||||
|
|
||||||
if (permissions.includes(PermissionEnum.VIEW_ORDERS)) {
|
if (permissions.includes(PermissionEnum.VIEW_ORDERS)) {
|
||||||
|
|
||||||
return this.orderRepository.findAllPaginated(dto)
|
return this.orderRepository.findAllPaginated(dto)
|
||||||
|
|
||||||
} else if (permissions.includes(PermissionEnum.VIEW_ASSIGNED_ORDERS)) {
|
} else if (permissions.includes(PermissionEnum.VIEW_ASSIGNED_ORDERS)) {
|
||||||
return this.orderRepository.findAllPaginated({
|
return this.orderRepository.findAllPaginated({
|
||||||
...dto,
|
...dto,
|
||||||
designerId: adminId,
|
designerId: adminId,
|
||||||
})
|
})
|
||||||
@@ -435,7 +435,10 @@ export class OrderService {
|
|||||||
|
|
||||||
// -----------Hrlper Methods -----------
|
// -----------Hrlper Methods -----------
|
||||||
async findOrderOrFail(id: string): Promise<Order> {
|
async findOrderOrFail(id: string): Promise<Order> {
|
||||||
const order = await this.em.findOne(Order, { id }, { populate: ['user', 'type', 'product', 'creator', 'designer'] });
|
const order = await this.em.findOne(Order, { id },
|
||||||
|
{
|
||||||
|
populate: ['user', 'type', 'product', 'creator', 'designer', 'invoiceItem'],
|
||||||
|
});
|
||||||
if (!order) {
|
if (!order) {
|
||||||
throw new NotFoundException(`Order with ID ${id} not found.`);
|
throw new NotFoundException(`Order with ID ${id} not found.`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user