Quintiq file version 2.0
|
#parent: #root
|
Method AddInventoryValue (
|
String scenarioname,
|
MacroPlan macroplan,
|
InventoryValueAndCosts inventoryvalues,
|
Boolean isactual
|
)
|
{
|
Description: 'Create separated method to ease the calculation of start and end'
|
TextBody:
|
[*
|
startofplanning:= macroplan.StartOfPlanning();
|
|
traverse( inventoryvalues, Elements, inv )
|
{
|
start := inv.Start().DateTime();
|
end := inv.End().DateTime();
|
currency := inv.AccountAssignment().Currency_MP();
|
product := inv.Product_MP().Name();
|
stockingpoint := inv.StockingPoint_MP().Name();
|
cost := inv.Cost();
|
if ( currency.IsBase() )
|
{
|
if ( not isactual )
|
{
|
start := maxvalue( startofplanning, start )
|
this.AddPlannedItemCostForExport( scenarioname, product, stockingpoint, start, end, cost );
|
}
|
else
|
{
|
end := minvalue( end, startofplanning );
|
this.AddActualItemCostForExport( product, stockingpoint, start, end, cost )
|
}
|
}
|
|
else
|
{
|
currencyrates := currency.GetCurrencyRates( inv.Start(), inv.End() );
|
i := 0;
|
traverse( currencyrates, Elements, rate )
|
{
|
start := maxvalue( inv.Start().DateTime(), rate.Start().DateTime() );
|
end := guard( currencyrates.Element(i+1).Start().DateTime(), inv.End().DateTime() );
|
end := minvalue( inv.End().DateTime(), end );
|
cost := inv.Cost() * rate.Rate();
|
// if inventoryvaluecost cost with end > start of planning
|
if ( not isactual and end > startofplanning )
|
{
|
start := maxvalue( start, startofplanning );
|
this.AddPlannedItemCostForExport( scenarioname, product, stockingpoint, start, end, cost );
|
}
|
else
|
{
|
end := minvalue( end, startofplanning );
|
this.AddActualItemCostForExport( product, stockingpoint, start, end, cost );
|
}
|
|
i := i +1;
|
}
|
}
|
}
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|