SELECT DISTINCT
P.ID as ID,
'20' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
StoreDocuments2 A
JOIN PMStates PMS ON A.PMState_ID=PMS.ID
JOIN StoreDocuments P ON P.ID=A.Parent_ID
JOIN Firms F on F.ID=P.Firm_ID
WHERE
PMS.SystemState=3 AND
A.RowType=3 and A.ToIntrastat = 'A' and P.TradeType in (2, 4, 5, 6) and P.DocumentType='20'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
AND
((P.IntrastatDate$DATE >= {$DATE_FROM}) AND (P.IntrastatDate$DATE < {$DATE_TO}))
{ANDWHERE}
union all
SELECT DISTINCT
P.ID as ID,
'60' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
IssuedCreditNotes2 A
JOIN IssuedCreditNotes P ON P.ID=A.Parent_ID
JOIN Firms F on F.ID=P.Firm_ID
WHERE
A.RowType=3 and A.ToIntrastat = 'A' and P.TradeType in (2, 4, 5, 6, 7, 8) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
AND
((P.VATDate$DATE >= {$DATE_FROM}) AND (P.VATDate$DATE < {$DATE_TO}))
{ANDWHERE}
union all
SELECT DISTINCT
P.ID as ID,
'07' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
RefundedCashReceived2 A
JOIN RefundedCashReceived P ON P.ID=A.Parent_ID
JOIN Firms F on F.ID=P.Firm_ID
WHERE
A.RowType=3 and A.ToIntrastat = 'A' and P.TradeType in (2, 4, 5, 6, 7, 8) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
AND
((P.VATDate$DATE >= {$DATE_FROM}) AND (P.VATDate$DATE < {$DATE_TO}))
{ANDWHERE}
group by P.ID, P.IntrastatCompleteKind
| Jméno | Typ | Velikost | Výraz | CLSID | Popis |
|---|---|---|---|---|---|
| DocumentType | dtString | 2 | Typ dokladu | ||
| ID | dtString | 10 | Vlastní ID dokladu | ||
| IntrastatCompleteKind | dtInteger | 10 | Stav vyplnění |
{:LOW}{:HIGH}
Generated by ABRA Software a.s. 27.10.2021 16:36