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
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
Quintiq file version 2.0
#parent: #root
Method GetSuggestedQuantity (
  ProductInStockingPointInPeriod pispip
) as Real
{
  Description: 'Get sugested quantity for product in trip'
  TextBody:
  [*
    // desmondt May-18-2015 (created)
    
    upt := this.DepartureUnitPeriod()
    
    // First, get what is the demanded quantity
    suggestedqty := pispip.GetUnfulfilledQuantity();
    
    if( isnull( upt ) )
    {
      // Use UnitPeriodTransport instead of "this" because we need suggested quantity in one tracsaction quite often.
      upt := maxselect( this,
                        LaneLeg.Lane.Unit.UnitPeriod.astype( UnitPeriodTransportBase ),
                        unitperiod,
                        unitperiod.Start() <= this.Arrival() - this.LaneLeg().LeadTime(),
                        unitperiod.Period_MP().SequenceNr() );
    }
    
    //upt can be null when trip departs before the start of planning horizon 
    if( not isnull( upt ) and suggestedqty > 0  )
    {
      if( upt.MinimumPerLot() > 0 ) // If have minimum per lot
      {
        /*
        The lot devision remainder, eg, lot size 10, demand quantity 512
        The remainder is 2, which means we have 51 lot with 10 ton/lot.
        The remainder quantity(ton) will be use to check with minimum per lot
        */
    
        remainedqty := GlobalParameters_MP::GetRemainder( suggestedqty, upt.LotSize() ); // eg. 51.123, number = 51, real = 51.123, real - number = 0.123 (remainder)
    
        // Then check if lot remainder is greater than min per lot, if < min per lot, increase it to fulfill conform minimum per lot.
        if( remainedqty < upt.MinimumPerLot() )
        {
          suggestedqty := suggestedqty - remainedqty + upt.MinimumPerLot();
        }
      }
    }
    
    return suggestedqty;
  *]
}