Quintiq file version 2.0
|
#parent: #root
|
Method MappingOperationCostData (
|
Strings businesstypes
|
)
|
{
|
Description: 'Get operation cost data from operation mapping'
|
TextBody:
|
[*
|
// Administrator Aug-21-2023 (created)
|
// list to deal
|
listtodeal := construct( structured[MappingOperation] );
|
|
if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
|
listtodeal := selectset( this, MappingOperation, item, true );
|
} else {
|
listtodeal := selectset( this, MappingOperation, item, businesstypes.Find( item.BusinessType() ) <> -1 );
|
}
|
|
// Get the list to deal with max sequence number
|
listtodealwithmaxsn := construct( structured[MappingOperation] );
|
traverse( listtodeal, Elements, item ){
|
maxsn := maxselect( this,
|
MappingOperation,
|
moperation,
|
moperation.OrganCode() = item.OrganCode(),
|
moperation.ProductID() = item.ProductID(),
|
moperation.SequenceNumber() ).SequenceNumber()
|
if( item.SequenceNumber() = maxsn ){
|
listtodealwithmaxsn.Add( item );
|
}
|
}
|
|
// Get the operation cost data
|
traverse( listtodealwithmaxsn, Elements, item ){
|
id := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection() + "_" + item.Line();
|
operation := Operation::FindOperationTypeIndex( id );
|
account := Account_MP::FindByName( this, "Operation cost" );
|
isfromdb := false;
|
existoperationcost := OperationCost::FindOperationCostTypeIndex( id );
|
if( isnull( existoperationcost ) ){
|
connecteditem := select( this,
|
MappingOperationCost,
|
moperationcost,
|
moperationcost.OrgCode() = item.OrganCode(),
|
moperationcost.ProductID() = item.ProductID() );
|
cost := connecteditem.Cost();
|
lengthoftime := connecteditem.LengthOfTime();
|
start := connecteditem.Start();
|
timeunit := connecteditem.TimeUnit();
|
OperationCost::Create( id, operation, account, "Volume", start, timeunit, lengthoftime, cost, isfromdb );
|
}
|
}
|
*]
|
}
|