SELECT DISTINCT
P.ID as ID,
'03' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
IssuedInvoices2 A
JOIN IssuedInvoices P ON P.ID=A.Parent_ID
LEFT JOIN IntrastatExchangeRates IEX on IEX.Currency_ID = P.currency_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.VATDate$Date >= {$DATE_FROM} and P.VATDate$Date < {$DATE_TO}) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnOutput})
{ANDWHERE}
union all
SELECT DISTINCT
P.ID as ID,
'05' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
CashReceived2 A
JOIN CashReceived 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.VATDate$Date >= {$DATE_FROM} and P.VATDate$Date < {$DATE_TO}) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnOutput})
{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.VATDate$Date >= {$DATE_FROM} and P.VATDate$Date < {$DATE_TO}) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
{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.VATDate$Date >= {$DATE_FROM} and P.VATDate$Date < {$DATE_TO}) and P.VATDocument = 'A'
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
{ANDWHERE}
union all
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.IntrastatDate$Date >= {$DATE_FROM} and P.IntrastatDate$Date < {$DATE_TO})
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnInput})
{ANDWHERE}
union all
SELECT DISTINCT
P.ID as ID,
'30' as DocumentType,
P.IntrastatCompleteKind as IntrastatCompleteKind
FROM
StoreDocuments2 A
JOIN StoreDocuments 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) and P.DocumentType = '30' and
(P.IntrastatDate$Date >= {$DATE_FROM} and P.IntrastatDate$Date < {$DATE_TO})
and P.IntrastatCompleteKind in ({$IntrastatCompleteKindOnOutput})
{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 | 2 | Stav vyplnění |
P.DocDate$DATE >= {:LOW} and
P.DocDate$DATE < {:HIGH}
Generated by ABRA Software a.s. 27.10.2021 16:36