@@ -10,7 +10,6 @@ import {
10
10
Order ,
11
11
ServerException ,
12
12
Session ,
13
- UnauthorizedException ,
14
13
viewOfChangeset ,
15
14
} from '../../common' ;
16
15
import { HandleIdLookup , ILogger , Logger , ResourceResolver } from '../../core' ;
@@ -288,15 +287,7 @@ export class BudgetService {
288
287
async delete ( id : ID , session : Session ) : Promise < void > {
289
288
const budget = await this . readOne ( id , session ) ;
290
289
291
- if ( ! budget ) {
292
- throw new NotFoundException ( 'Could not find Budget' ) ;
293
- }
294
-
295
- const canDelete = await this . budgetRepo . checkDeletePermission ( id , session ) ;
296
- if ( ! canDelete )
297
- throw new UnauthorizedException (
298
- 'You do not have the permission to delete this Budget' ,
299
- ) ;
290
+ this . privileges . for ( session , Budget , budget ) . verifyCan ( 'delete' ) ;
300
291
301
292
// cascade delete each budget record in this budget
302
293
await Promise . all (
@@ -320,19 +311,7 @@ export class BudgetService {
320
311
viewOfChangeset ( changeset ) ,
321
312
) ;
322
313
323
- if ( ! br ) {
324
- throw new NotFoundException ( 'Could not find Budget Record' ) ;
325
- }
326
-
327
- const canDelete = await this . budgetRecordsRepo . checkDeletePermission (
328
- id ,
329
- session ,
330
- ) ;
331
-
332
- if ( ! canDelete )
333
- throw new UnauthorizedException (
334
- 'You do not have the permission to delete this Budget Record' ,
335
- ) ;
314
+ this . privileges . for ( session , BudgetRecord , br ) . verifyCan ( 'delete' ) ;
336
315
337
316
try {
338
317
await this . budgetRecordsRepo . deleteNode ( br , changeset ) ;
0 commit comments