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