@@ -22,6 +22,7 @@ import {
2222} from 'shared' ;
2323import prisma from '../prisma/prisma' ;
2424import {
25+ isUserAdminOrOnFinance ,
2526 createReimbursementProducts ,
2627 isUserLeadOrHeadOfFinanceTeam ,
2728 removeDeletedReceiptPictures ,
@@ -771,21 +772,19 @@ export default class ReimbursementRequestService {
771772 /**
772773 * Edits the vendor name
773774 *
774- * @param name name to change of the vendor
775- * @param vendorId id of the vedor used to edit the name
776- * @param submitter the user who is downloading the receipt image
777- * @returns new vendor with a edited name
775+ * @param name the new vendor name
776+ * @param vendorId the requested vendor to be edited
777+ * @param submitter the user editing the vendor name
778+ * @returns the updated vendor
778779 */
779780 static async editVendors ( name : string , vendorId : string , submitter : User ) {
780- if ( ! isAdmin ( submitter . role ) ) throw new AccessDeniedAdminOnlyException ( 'only Admins can edit vendors' ) ;
781+ await isUserAdminOrOnFinance ( submitter ) ;
781782
782- const vendorExists = await prisma . vendor . findUnique ( {
783+ const vendorUniqueName = await prisma . vendor . findUnique ( {
783784 where : { name }
784785 } ) ;
785786
786- console . log ( vendorExists ) ;
787-
788- if ( ! ! vendorExists ) throw new HttpException ( 400 , 'vendor name already exists' ) ;
787+ if ( ! ! vendorUniqueName ) throw new HttpException ( 400 , 'vendor name already exists' ) ;
789788
790789 const vendor = await prisma . vendor . update ( {
791790 where : { vendorId } ,
0 commit comments