order
This commit is contained in:
@@ -63,7 +63,7 @@ export class OrderService {
|
||||
|
||||
user = invoiceItem.invoice.user
|
||||
}
|
||||
|
||||
|
||||
if (!invoiceItem) {
|
||||
|
||||
if (!dto.userId) {
|
||||
@@ -196,12 +196,7 @@ export class OrderService {
|
||||
await this.em.flush();
|
||||
}
|
||||
|
||||
async updateStatusAsDesigner(orderId: string, dto: UpdateStatusAsDesignerDto): Promise<Order> {
|
||||
const order = await this.findOrderOrFail(orderId);
|
||||
order.status = dto.status;
|
||||
await this.em.flush();
|
||||
return order
|
||||
}
|
||||
|
||||
|
||||
async updateStatus(orderId: string, adminId: string, dto: UpdateStatusDto): Promise<Order> {
|
||||
const permissions = await this.adminService.hasPermissions(adminId,
|
||||
@@ -215,17 +210,14 @@ export class OrderService {
|
||||
}
|
||||
|
||||
if (permissions.includes(PermissionEnum.VIEW_ASSIGNED_ORDERS)) {
|
||||
//TODO
|
||||
const order = await this.findOrderOrFailAssignedOrder(orderId, adminId);
|
||||
order.status = dto.status;
|
||||
await this.em.flush();
|
||||
return order
|
||||
}
|
||||
|
||||
const order = await this.findOrderOrFail(orderId);
|
||||
|
||||
order.status = dto.status;
|
||||
await this.em.flush();
|
||||
return order
|
||||
|
||||
throw new ForbiddenException("You don't have permission to update order status")
|
||||
}
|
||||
|
||||
async assignDesigner(orderId: string, designerId: string) {
|
||||
@@ -254,7 +246,7 @@ export class OrderService {
|
||||
return print;
|
||||
}
|
||||
|
||||
async getPrint(orderId:string){
|
||||
async getPrint(orderId: string) {
|
||||
const orderPrint = await this.orderPrintRepository.findOne({ order: { id: orderId } });
|
||||
if (!orderPrint) {
|
||||
throw new NotFoundException(`Print with ID ${orderId} not found.`);
|
||||
@@ -264,7 +256,7 @@ export class OrderService {
|
||||
|
||||
// -----------Hrlper Methods -----------
|
||||
async findOrderOrFail(id: string): Promise<Order> {
|
||||
const order = await this.em.findOne(Order, { id }, { populate: ['user', 'type', 'product', 'creator', 'print'] });
|
||||
const order = await this.em.findOne(Order, { id }, { populate: ['user', 'type', 'product', 'creator', 'designer'] });
|
||||
if (!order) {
|
||||
throw new NotFoundException(`Order with ID ${id} not found.`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user