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
Quintiq file version 2.0
#parent: #root
Method GetBaseCost (
  output Real accountcost,
  ProductInStockingPointInPeriod pispip
) remote as Real
{
  Description: 'Returns base cost of a given period - used in designer'
  TextBody:
  [*
    basecost := 0.0;
    
    if( not isnull( pispip ) )
    {
      if( pispip.IsPlanning() )
      {
        if( this.CostDriver() = Translations::MP_AccountAssignmentCostDriverSales() )
        {
          basecost := sum( pispip, astype( ProductInStockingPointInPeriodPlanningLeaf ).PlanningBaseSalesDemandInPeriod, sdip, sdip.BasePrice() );   
        }
        else if( this.IsInventoryValue() )  //inventory value including WIP
        {
          accountcost := pispip.GetBaseInventoryValuePerQuantity( this );
          basecost := pispip.GetInventoryAndPreProcessingValue( this ); 
        }
        else if( this.IsInventoryHolding() ) //inventory holding cost including WIP
        {                                                        
          accountcost := pispip.GetBaseInventoryHoldingCostPerQuantity( this );
          basecost := pispip.GetBaseInventoryHoldingCost( this );
        }
        else if( this.IsInventorySupply() ) //inventory supply
        {
          basecost := pispip.GetBaseInventorySupplyCost( this );
        }
      }
      else if( pispip.IsBase() )  // Base, fraction the value from planning period
      {
        basecost := this.GetBaseCost( accountcost, pispip.astype( ProductInStockingPointInPeriodNonPlanningBase ).PlanningPISPIP() ) * pispip.Period_MP().PlanningSystemRatio();
      }
      else                        // Non base non planning, retrieve the value of base periods
      {
        basecost := sum( pispip.GetChildrenOfPeriodDimension(), Elements, e, this.GetBaseCost( accountcost, e ) )
      }
    }
    
    return basecost;
  *]
}