admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
StaticMethod CanCreate (
  Trip trip,
  ProductInStockingPointInPeriods pispips,
  output String feedback_o
) const declarative remote as Boolean
{
  Description: 'Given Trip and PISPIP, check if able to create product in trip.'
  TextBody:
  [*
    cancreate := true;
    
    traverse( pispips, Elements, pispip, cancreate )
    {
      cancreate := trip.HasValidArrival() // has valid arrival
                   and trip.ArrivalUnitPeriod().Period_MP() = pispip.Period_MP() // within the same period
                   and exists( trip, LaneLeg.LaneLegOutput.ProductInStockingPoint_MP, pisp,
                               pisp = pispip.ProductInStockingPoint_MP() ); // check if leg transport the product
      
      if( not cancreate )
      {
        originspname := MacroPlan::GetSubstituteName( trip.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().Name() );
        destspname := MacroPlan::GetSubstituteName( trip.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().Name() );
        unitname := MacroPlan::GetSubstituteName( trip.LaneLeg().Lane().Unit().Name() );
        productname := MacroPlan::GetSubstituteName( pispip.ProductInStockingPoint_MP().Product_MP().Name() );
        feedback_o := Translations::MP_ProductInTrip_CanCreate_IsInvalidPISPIP( originspname,
                                                                                destspname,
                                                                                trip.ArrivalUnitPeriod().StartDate(),
                                                                                unitname,
                                                                                productname );
      }
    }
    
    return cancreate;
  *]
}