Select '76', RightSide_ID from Relations where REL_DEF = 1000 AND LeftSide_ID = :OBJID
union Select '73', RightSide_ID from Relations where REL_DEF = 1003 AND LeftSide_ID = :OBJID
union Select '20', RightSide_ID from Relations where REL_DEF = 1011 AND LeftSide_ID = :OBJID
union Select 'CO', RightSide_ID from Relations where REL_DEF = 1015 AND LeftSide_ID = :OBJID
union Select '30', RightSide_ID from Relations where Rel_def = 1030 AND LeftSide_ID = :OBJID
union all
/* DZP */
select distinct '64', A.VATDeposit_ID
from ReceivedInvoices2 A
where
A.Parent_ID = :OBJID AND
A.VATDeposit_ID IS NOT NULL
union all
/* DFP */
Select distinct '61', B.ID
from
ReceivedCreditNotes B
where
B.Source_ID = :OBJID
union all
/* Plat. prikaz */
SELECT distinct '18', PO.ID
FROM PaymentOrders PO
WHERE PO.ID IN (SELECT PO2.Parent_ID
FROM PaymentOrders2 PO2
WHERE PO2.ID IN (SELECT PO3.Parent_ID
FROM PaymentOrders3 PO3
WHERE PO3.PDocumentType='04' AND PO3.PDocument_ID=:OBJID))
union all
/* Žádosti plat. prikazů */
SELECT distinct 'PO', PO2.ID
FROM PaymentOrders2 PO2
WHERE
PO2.parent_id is null AND
PO2.ID IN (SELECT PO3.Parent_ID
FROM PaymentOrders3 PO3
WHERE PO3.PDocumentType='04' AND PO3.PDocument_ID=:OBJID) Generated by ABRA Software a.s. 27.10.2021 16:34:11