yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Quintiq file version 2.0
#parent: #root
Method ResequenceOnGap (
  DateTime droptime,
  output DateTime newcampaignstart,
  output DateTime newcampaignend
)
{
  Description: 'Resequence source campaign on an empty gap of gantt chart row,, push following campaigns back if resequencing will cause overlap.'
  TextBody:
  [*
    newcampaignstart := this.Start();
    newcampaignend := this.End();
    sourceduration := this.End() - this.Start();
    previoustarget := maxselect( this, Unit.Campaign_MP_DELETED_Q320, cpg, cpg.End() <= droptime, cpg.End() );
    firsttarget := this.GetNextCampaignExcludingSelf( previoustarget );
    target := firsttarget;
    source := this;
                    
    if( not isnull( previoustarget ) and previoustarget <> this )
    {
      newcampaignstart := previoustarget.End() + Campaign_MP_DELETED_Q320::GetMinTransitionDuration( guard( previoustarget.CampaignType_MP(), null( CampaignType_MP ) ), this.CampaignType_MP() );
      newcampaignend := newcampaignstart + sourceduration;
    }
    else if( isnull( previoustarget ) )
    {
      newcampaignstart := this.MacroPlan().StartOfPlanning();
      newcampaignend := newcampaignstart + sourceduration;
      firsttarget := this.Unit().FirstCampaign_Old();
      target := firsttarget;
    }
    
    this.UpdateTargetCampaignsStartEnd( newcampaignend,
                                        source,
                                        target,
                                        firsttarget );
  *]
}