yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Function CalcSecondaryQuantityInProcessUOM
{
  TextBody:
  [*
    // Convert the quantity in PIT into the quantity in process secondary uom (defined in TransportCapacity)
    value := 0.0;
    
    // Need to guard this because if we change a periodspec from planning to
    // visualization with trips planned, DepartureUnitPeriod might be null. 
    // Transaction propagate is called before deleting the trips, hence we come
    // in here before deleting trips
    if( guard( not this.Trip().IsTimeBaseTransportation() 
               and this.Trip().DepartureUnitPeriod().HasSecondaryCapacityDefinition(), false ) ) 
    {
      secondaryUom := this.Trip().DepartureUnitPeriod().astype( UnitPeriodTransportQuantity ).TransportCapacity().SecondaryUnitOfMeasure();
      convFactor   := this.DeparturePISPIP().ProductInStockingPoint_MP().UnitOfMeasure_MP().GetConversionFactor( secondaryUom, this.Product_MP() );
    
      value := this.Quantity() * convFactor; 
    }
    
    this.SecondaryQuantityInProcessUOM( value );
  *]
}