Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CreateOrUpdate (
|
MacroPlan macroPlan,
|
String id,
|
String productId,
|
String stockingPointId,
|
String accountName,
|
String costDriver,
|
Date start,
|
Real cost
|
) as InventoryValueAndCost
|
{
|
TextBody:
|
[*
|
// yypsybs Aug-16-2023 (created)
|
if( accountName = '' ) {
|
accountName := 'Inventory holding cost';
|
}
|
if( costDriver = '' ) {
|
costDriver := 'Inventory holding';
|
}
|
product := Product_MP::FindById( macroPlan, productId );
|
stockingPoint := StockingPoint_MP::FindById( macroPlan, stockingPointId );
|
account := Account_MP::FindByName( macroPlan, accountName );
|
if( isnull( product ) ) {
|
error( "product not found" );
|
}
|
if( isnull( stockingPoint ) ) {
|
error( "stocking point not found" );
|
}
|
if( isnull( account ) ) {
|
error( "account not found" );
|
}
|
result := InventoryValueAndCost::FindById( macroPlan, id );
|
if( isnull( result ) ) {
|
result := InventoryValueAndCost::Create( id, product, stockingPoint, account, costDriver, start, cost, true ).astype( InventoryValueAndCost );
|
} else if( result.ProductID() <> productId ) {
|
error( "cannot change product of inventory value and cost" )
|
} else {
|
result.Update( account, costDriver, start, account.DefaultTimeUnit(), account.DefaultLengthOfTime(), cost, true );
|
}
|
return result;
|
*]
|
}
|