yanyuan
2023-11-10 143ef74e2eeee697ac8fda3d9032a790fbb4e146
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Quintiq file version 2.0
#parent: #root
StaticMethod CanPostpone (
  BaseSalesDemandInPeriods salesdemands,
  Period_MPs postponementperiods,
  output String feedback_o
) remote as Boolean
{
  Description: 'Check whether sales demand can be postponed'
  TextBody:
  [*
    // Check if there are any sales demand
    if( salesdemands.Size() = 0 )
    {
      feedback_o := Translations::MP_SalesDemand_CanPostpone_SalesDemandEmpty();
    }
    // Check if there are any postponed sales demand
    else if( exists( salesdemands, Elements, e, e.IsPostponed() ) )
    {
      feedback_o := Translations::MP_SalesDemand_CanPostpone_PostponedSDIPCannotBePostponed();
    }
    // Check if there are disaggregated sales demand, disabled manual postpone of DisaggregatedSalesDemandInPeriod
    else if ( exists( salesdemands, Elements.astype( DisaggregatedSalesDemandInPeriod ), dsdip , true ) )
    {
      feedback_o := Translations::MP_DisaggregatedSalesDemandInPeriod_CannotPostponedManually();  
    }          
    // Check if there are any sales demand without quantity
    else if( exists( salesdemands, Elements, e, e.Quantity() = 0 ) )
    {
      feedback_o := Translations::MP_SalesDemandInPeriod_CanPostpone_QuantityZero();
    }
    // Check if all sales demand can be postponed
    else if( forall( salesdemands, Elements, e, not e.CanBePostponed() ) )
    {
      feedback_o := Translations::MP_SalesDemand_CanPostpone_SalesDemandCannotPostpone();
    }
    // Check if there are any periods to postpone
    else if( postponementperiods.Size() = 0 )
    {
      feedback_o := Translations::MP_SalesDemandInPeriod_CanPostpone_NoAllowedPeriod();
    }
    // Check if there are any period that will be postponed till out of the planning horizon
    else if( exists( salesdemands, Elements, e, e.AsPlanningBaseSalesDemandInPeriod().Period_MP() = e.MacroPlan().LastPlanningPeriod() ) )
    {
      feedback_o := Translations::MP_SalesDemand_CanPostpone_LastPeriod();
    }
    else if ( exists( salesdemands, Elements.AsPlanningSalesDemandInPeriod.astype( CustomerOrder ), co, true, co.IsFirmed() ) )
    {
      feedback_o := Translations::MP_CustomerOrder_CanPostpone_IsFirmed();
    }
                       
    return feedback_o = '';
  *]
}