fix order-prod for b2c temporary
This commit is contained in:
		| @@ -466,26 +466,53 @@ export class ProductService { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async findOneActive(code: string, type: string) { | ||||
|     try { | ||||
|       return await this.productRepository.findOneOrFail({ | ||||
|         relations: ['supplier'], | ||||
|         where: { | ||||
|           code: code, | ||||
|         }, | ||||
|       }); | ||||
|     } catch (e) { | ||||
|       if (e instanceof EntityNotFoundError) { | ||||
|         throw new HttpException( | ||||
|             { | ||||
|               statusCode: HttpStatus.NOT_FOUND, | ||||
|               error: 'Product not found', | ||||
|             }, | ||||
|             HttpStatus.NOT_FOUND, | ||||
|         ); | ||||
|       } else { | ||||
|         throw e; | ||||
|   async findOneActive(code: string, type: string, roles: string, supplierId: string) { | ||||
|     if (roles == "Retail") { | ||||
|       try { | ||||
|         return await this.productRepository.findOneOrFail({ | ||||
|           relations: ['supplier'], | ||||
|           where: { | ||||
|             code: code, | ||||
|             supplier: supplierId | ||||
|           }, | ||||
|         }); | ||||
|       } catch (e) { | ||||
|         if (e instanceof EntityNotFoundError) { | ||||
|           throw new HttpException( | ||||
|               { | ||||
|                 statusCode: HttpStatus.NOT_FOUND, | ||||
|                 error: 'Product not found', | ||||
|               }, | ||||
|               HttpStatus.NOT_FOUND, | ||||
|           ); | ||||
|         } else { | ||||
|           throw e; | ||||
|         } | ||||
|       } | ||||
|     } else { | ||||
|  | ||||
|  | ||||
|       try { | ||||
|         return await this.productRepository.findOneOrFail({ | ||||
|           relations: ['supplier'], | ||||
|           where: { | ||||
|             code: code, | ||||
|           }, | ||||
|         }); | ||||
|       } catch (e) { | ||||
|         if (e instanceof EntityNotFoundError) { | ||||
|           throw new HttpException( | ||||
|               { | ||||
|                 statusCode: HttpStatus.NOT_FOUND, | ||||
|                 error: 'Product not found', | ||||
|               }, | ||||
|               HttpStatus.NOT_FOUND, | ||||
|           ); | ||||
|         } else { | ||||
|           throw e; | ||||
|         } | ||||
|       } | ||||
|  | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user