Quintiq file version 2.0
|
#parent: #root
|
StaticMethod GetSalesSegmentToSave (
|
SalesSegment_MPs checkSalesSegments
|
) as owning SalesSegment_MPs
|
{
|
Description:
|
[*
|
Web introduced new bookmark logic. Keep bookmark as short as possible.
|
If all children (and descendants) checked, store the parent only. If partial, then no choice we store the checked children.
|
*]
|
TextBody:
|
[*
|
result := construct( SalesSegment_MPs ); // Sales Segment to bookmark
|
|
// Filter out parent sales segments
|
checkLeafSalesSegments := selectset( checkSalesSegments, Elements, c, c.Child( relsize ) = 0 );
|
|
// Based on filtered sales segment, get all their parents
|
allParentsSorted := selectsortedset( SalesSegment_MP::GetAllParents( checkLeafSalesSegments ),
|
Elements, e,
|
e.Child( relsize ) > 0, // Filter out the leaf as GetAllParents return the sales segment itself as well
|
e.DisplayIndex() ); // Sort from root down to lower level sales segment
|
|
// Important to start with root, as we will remove 'intersecting' leaf salse segment as we loop
|
traverse( allParentsSorted, Elements, parent, checkLeafSalesSegments.Size() > 0 ) // Continue as long as there's sales segment to be considered
|
{
|
leafDescendants := selectset( parent, AllChildren.AsChildren, ss, ss.Child( relsize ) = 0 );
|
|
// If current parent's leaf descendants are found in user checked sales segment
|
// We only bookmark the parent and remove leaf descendants from the list and proceed next parent
|
// Example (Food demo): Add sales segment Target if ALL its children are part of user checked sales segment
|
if( checkLeafSalesSegments.ContainsAll( leafDescendants ) )
|
{
|
checkLeafSalesSegments.Remove( leafDescendants );
|
result.Add( parent );
|
}
|
}
|
|
// If there's leaf sales segment left (not all siblings checked), add them to the result
|
if( checkLeafSalesSegments.Size() > 0 )
|
{
|
result := result.Union( checkLeafSalesSegments );
|
}
|
|
return &result;
|
*]
|
}
|