Cant figure out LedgerJournalTrans and CustTrans/VendTrans relation for settlement


i need to settle CustTrans and VendTrans transactions from code, for this i need to figure out what is LedgerJournalTrans -> CustTrans or VendTrans relation,

LedgerJournalTrans.CustTransId and LedgerJournalTrans.VendTransId are both 0, so this doesnt work

what is the relation used for General journal lines (LedgerJournalTrans) -> Vendor or Customer transactions in settlement of general journal line (VendTrans or CustTrans) ?