Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CreateOrUpdate (
|
MacroPlan macroPlan,
|
String productId,
|
String salesSegmentName,
|
String stockingPointId,
|
String priorityName,
|
String currencyId,
|
String unitOfMeasureName,
|
String id,
|
Date startDate,
|
Date endDate,
|
Real quantity,
|
Real price
|
) as Forecast
|
{
|
TextBody:
|
[*
|
// yypsybs Aug-14-2023 (created)
|
// 查依赖项
|
product := Product_MP::FindById( macroPlan, productId );
|
salesSegment := SalesSegment_MP::FindByName( macroPlan, salesSegmentName );
|
stockingPoint := StockingPoint_MP::FindById( macroPlan, stockingPointId );
|
currency := Currency_MP::FindById( macroPlan, currencyId );
|
unitOfMeasure := null( UnitOfMeasure_MP )
|
priority := null( Priority );
|
if( unitOfMeasureName <> "" ) {
|
unitOfMeasure := UnitOfMeasure_MP::FindByName( macroPlan, unitOfMeasureName );
|
}
|
if( priorityName <> "" ) {
|
priority := Priority::FindByName( macroPlan, priorityName );
|
}
|
// 检查依赖项
|
if( isnull( product ) ) {
|
error( "product not found" );
|
}
|
if( isnull( salesSegment ) ) {
|
error( "sales segment not found" );
|
}
|
if( isnull( stockingPoint ) ) {
|
error( "stock point not found" );
|
}
|
if( isnull( currency ) ) {
|
error( "currency not found" );
|
}
|
if( unitOfMeasureName <> "" and isnull( unitOfMeasure) ) {
|
error( "unit of measure not found" );
|
}
|
if( priorityName <> "" and isnull( stockingPoint) ) {
|
error( "priority not found" );
|
}
|
// 新增/更新
|
result := Forecast::FindById( macroPlan, id );
|
if( isnull( result) ) {
|
result := Forecast::Create( product, stockingPoint, id,
|
startDate, endDate, quantity, price,
|
priorityName, salesSegmentName, guard( currency.Name(), "" ), unitOfMeasureName,
|
0.0, false, true );
|
} else {
|
result.Update( product, stockingPoint,
|
startDate, endDate, quantity, price,
|
priority, 0.0, salesSegment, currency, unitOfMeasure, false, true );
|
}
|
return result;
|
*]
|
}
|