@@ -11,12 +11,14 @@ import {
11
11
ServerException ,
12
12
Session ,
13
13
UnauthorizedException ,
14
+ UnsecuredDto ,
14
15
} from '../../common' ;
15
16
import { ConfigService , DatabaseService , ILogger , Logger } from '../../core' ;
16
17
import { ACTIVE , INACTIVE } from '../../core/database/query' ;
17
18
import { AuthenticationService } from '../authentication' ;
18
19
import { Role , withoutScope } from '../authorization' ;
19
20
import { EngagementService , EngagementStatus } from '../engagement' ;
21
+ import { ProjectType } from '../project' ;
20
22
import { User , UserService } from '../user' ;
21
23
import {
22
24
Project ,
@@ -78,10 +80,13 @@ export class ProjectRules {
78
80
private async getStepRule (
79
81
step : ProjectStep ,
80
82
id : ID ,
83
+ projectType : ProjectType ,
81
84
changeset ?: ID ,
82
85
) : Promise < StepRule > {
83
86
const mostRecentPreviousStep = ( steps : ProjectStep [ ] ) =>
84
87
this . getMostRecentPreviousStep ( id , steps , changeset ) ;
88
+ const isMultiplication =
89
+ projectType === ProjectType . MultiplicationTranslation ;
85
90
86
91
switch ( step ) {
87
92
case ProjectStep . EarlyConversations :
@@ -93,11 +98,26 @@ export class ProjectRules {
93
98
Role . FieldOperationsDirector ,
94
99
] ,
95
100
transitions : [
96
- {
97
- to : ProjectStep . PendingConceptApproval ,
98
- type : TransitionType . Approve ,
99
- label : 'Submit for Concept Approval' ,
100
- } ,
101
+ ...( isMultiplication
102
+ ? [
103
+ {
104
+ to : ProjectStep . PendingRegionalDirectorApproval ,
105
+ type : TransitionType . Approve ,
106
+ label : 'Submit for Regional Director Approval' ,
107
+ } ,
108
+ {
109
+ to : ProjectStep . PendingFinanceConfirmation ,
110
+ type : TransitionType . Approve ,
111
+ label : 'Submit for Finance Confirmation' ,
112
+ } ,
113
+ ]
114
+ : [
115
+ {
116
+ to : ProjectStep . PendingConceptApproval ,
117
+ type : TransitionType . Approve ,
118
+ label : 'Submit for Concept Approval' ,
119
+ } ,
120
+ ] ) ,
101
121
{
102
122
to : ProjectStep . DidNotDevelop ,
103
123
type : TransitionType . Reject ,
@@ -281,21 +301,41 @@ export class ProjectRules {
281
301
Role . FieldOperationsDirector ,
282
302
] ,
283
303
transitions : [
284
- {
285
- to : ProjectStep . PendingFinanceConfirmation ,
286
- type : TransitionType . Approve ,
287
- label : 'Approve Project' ,
288
- } ,
289
- {
290
- to : ProjectStep . PendingZoneDirectorApproval ,
291
- type : TransitionType . Approve ,
292
- label : 'Approve for Zonal Director Review' ,
293
- } ,
294
- {
295
- to : ProjectStep . FinalizingProposal ,
296
- type : TransitionType . Reject ,
297
- label : 'Send Back for Corrections' ,
298
- } ,
304
+ ...( isMultiplication
305
+ ? [
306
+ {
307
+ to : ProjectStep . EarlyConversations ,
308
+ type : TransitionType . Reject ,
309
+ label : 'Send Back for Corrections' ,
310
+ } ,
311
+ {
312
+ to : ProjectStep . PendingFinanceConfirmation ,
313
+ type : TransitionType . Approve ,
314
+ label : 'Submit for Finance Confirmation' ,
315
+ } ,
316
+ {
317
+ to : ProjectStep . DidNotDevelop ,
318
+ type : TransitionType . Reject ,
319
+ label : 'End Development' ,
320
+ } ,
321
+ ]
322
+ : [
323
+ {
324
+ to : ProjectStep . PendingFinanceConfirmation ,
325
+ type : TransitionType . Approve ,
326
+ label : 'Approve Project' ,
327
+ } ,
328
+ {
329
+ to : ProjectStep . PendingZoneDirectorApproval ,
330
+ type : TransitionType . Approve ,
331
+ label : 'Approve for Zonal Director Review' ,
332
+ } ,
333
+ {
334
+ to : ProjectStep . FinalizingProposal ,
335
+ type : TransitionType . Reject ,
336
+ label : 'Send Back for Corrections' ,
337
+ } ,
338
+ ] ) ,
299
339
{
300
340
to : ProjectStep . Rejected ,
301
341
type : TransitionType . Reject ,
@@ -330,6 +370,36 @@ export class ProjectRules {
330
370
return {
331
371
approvers : [ Role . Administrator , Role . Controller ] ,
332
372
transitions : [
373
+ ...( isMultiplication
374
+ ? [
375
+ {
376
+ to : ProjectStep . PendingRegionalDirectorApproval ,
377
+ type : TransitionType . Reject ,
378
+ label : 'Send Back for Corrections' ,
379
+ } ,
380
+ {
381
+ to : ProjectStep . DidNotDevelop ,
382
+ type : TransitionType . Reject ,
383
+ label : 'End Development' ,
384
+ } ,
385
+ ]
386
+ : [
387
+ {
388
+ to : ProjectStep . OnHoldFinanceConfirmation ,
389
+ type : TransitionType . Neutral ,
390
+ label : 'Hold Project for Confirmation' ,
391
+ } ,
392
+ {
393
+ to : ProjectStep . FinalizingProposal ,
394
+ type : TransitionType . Reject ,
395
+ label : 'Send Back for Corrections' ,
396
+ } ,
397
+ {
398
+ to : ProjectStep . Rejected ,
399
+ type : TransitionType . Reject ,
400
+ label : 'Reject' ,
401
+ } ,
402
+ ] ) ,
333
403
{
334
404
to : ProjectStep . Active ,
335
405
type : TransitionType . Approve ,
@@ -340,21 +410,6 @@ export class ProjectRules {
340
410
341
411
] ,
342
412
} ,
343
- {
344
- to : ProjectStep . OnHoldFinanceConfirmation ,
345
- type : TransitionType . Neutral ,
346
- label : 'Hold Project for Confirmation' ,
347
- } ,
348
- {
349
- to : ProjectStep . FinalizingProposal ,
350
- type : TransitionType . Reject ,
351
- label : 'Send Back for Corrections' ,
352
- } ,
353
- {
354
- to : ProjectStep . Rejected ,
355
- type : TransitionType . Reject ,
356
- label : 'Reject' ,
357
- } ,
358
413
] ,
359
414
getNotifiers : async ( ) => [
360
415
...( await this . getProjectTeamUserIds ( id ) ) ,
@@ -823,6 +878,7 @@ export class ProjectRules {
823
878
async getAvailableTransitions (
824
879
projectId : ID ,
825
880
session : Session ,
881
+ projectType : ProjectType ,
826
882
currentUserRoles ?: Role [ ] ,
827
883
changeset ?: ID ,
828
884
) : Promise < ProjectStepTransition [ ] > {
@@ -836,6 +892,7 @@ export class ProjectRules {
836
892
const { approvers, transitions } = await this . getStepRule (
837
893
currentStep ,
838
894
projectId ,
895
+ projectType ,
839
896
changeset ,
840
897
) ;
841
898
@@ -854,7 +911,7 @@ export class ProjectRules {
854
911
}
855
912
856
913
async verifyStepChange (
857
- projectId : ID ,
914
+ project : UnsecuredDto < Project > ,
858
915
session : Session ,
859
916
nextStep : ProjectStep ,
860
917
changeset ?: ID ,
@@ -867,8 +924,9 @@ export class ProjectRules {
867
924
}
868
925
869
926
const transitions = await this . getAvailableTransitions (
870
- projectId ,
927
+ project . id ,
871
928
session ,
929
+ project . type ,
872
930
currentUserRoles ,
873
931
changeset ,
874
932
) ;
@@ -924,6 +982,7 @@ export class ProjectRules {
924
982
925
983
async getNotifications (
926
984
projectId : ID ,
985
+ projectType : ProjectType ,
927
986
step : ProjectStep ,
928
987
changedById : ID ,
929
988
previousStep : ProjectStep ,
@@ -932,11 +991,12 @@ export class ProjectRules {
932
991
const { getNotifiers : arrivalNotifiers } = await this . getStepRule (
933
992
step ,
934
993
projectId ,
994
+ projectType ,
935
995
changeset ,
936
996
) ;
937
997
938
998
const transitionNotifiers = (
939
- await this . getStepRule ( previousStep , projectId )
999
+ await this . getStepRule ( previousStep , projectId , projectType )
940
1000
) . transitions . find ( ( t ) => t . to === step ) ?. notifiers ;
941
1001
942
1002
const resolve = async ( notifiers ?: Notifiers ) =>
0 commit comments