Within the collection ‘Transport Companies’, adding corresponding Transport Orders to incoming Invoices, I only want to be able to choose Transport Orders that belong to this Transport Company.
I currently solve this with a reference set and an union collection.
'Transport Orders': reference-set -> downstream ^ .'Transport Orders'* = inverse >'Transport Company' @breakout
'TOs': collection ['TO'] = union (
'' = <'Transport Orders'[ ^ .'Transport Orders'* ]
) {
'TO': text -> downstream ^ ^ .'Transport Orders'[] = key
}
'Invoices': collection ['Invoice Nr.'] @breakout {
'Invoice Nr.': text
'Transport Orders': collection ['Transport Order'] {
'Transport Order': text ~> ^ ^ .'TOs'[]
}
}
Is there, however, a more efficient way that would directly refer to the original Transport Orders, but only to the ones that are linked to this Transport Company?
(Below functions as an illustration, but is wrong syntax)
'Invoices': collection ['Invoice Nr.'] @breakout {
'Invoice Nr.': text
'Transport Orders': collection ['Transport Order'] {
'Transport Order': text -> downstream ^ ^ ^ .'Transport Orders'[] as $'to' where 'Transport Company' -> ^ ^ ^ sibling [ $'to'.'Transport Company' ]
}
}
Thank you in advance!