Dynamický dotaz - INTRASTAT - Podrobný výpis

ID:
CJJ334PFMP34ZGYQCYU1Q15H4C

Datasety

MAIN

Popis:
INTRASTAT- podrobný výpis
SQL definice:
SELECT
'A' as Status,
IE.Code as Extra,
A.IntrastatAmount as Amount,
A.LocalIntrastatAmount as LocalAmount,
A.StatisticAmount as StatisticAmount,
P.Currency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
CAST(' ' as VARCHAR(3)) as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
IssuedInvoices2 A
JOIN IssuedInvoices P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.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'
{ANDWHERE}
union all
SELECT
'A' as Status,
IE.Code as Extra,
A.IntrastatAmount as Amount,
A.LocalIntrastatAmount as LocalAmount,
A.StatisticAmount as StatisticAmount,
P.Currency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
CAST(' ' as VARCHAR(3)) as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
CashReceived2 A
JOIN CashReceived P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.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'
{ANDWHERE}
union all
SELECT
'N' as Status,
IE.Code as Extra,
A.IntrastatAmount as Amount,
A.LocalIntrastatAmount as LocalAmount,
A.StatisticAmount as StatisticAmount,
P.Currency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
OCT.Code as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
IssuedCreditNotes2 A
JOIN IssuedCreditNotes P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN Countries OCT on OCT.ID=S.Country_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.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'
{ANDWHERE}
union all
SELECT
'N' as Status,
IE.Code as Extra,
A.TAmountWithoutVAT as Amount,
A.LocalTAmountWithoutVAT as LocalAmount,
A.StatisticAmount as StatisticAmount,
P.Currency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
OCT.Code as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
RefundedCashReceived2 A
JOIN RefundedCashReceived P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN Countries OCT on OCT.ID=S.Country_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.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'
{ANDWHERE}
union all
SELECT
'N' as Status,
IE.Code as Extra,
A.IntrastatAmount as Amount,
A.LocalIntrastatAmount as LocalAmount,
A.StatisticAmount as StatisticAmount,
P.Currency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
OCT.Code as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
StoreDocuments2 A
JOIN PMStates PMS ON A.PMState_ID=PMS.ID
JOIN StoreDocuments P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
LEFT JOIN Countries OCT on OCT.ID=A.OriginCountry_ID
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.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})
{ANDWHERE}
union all
SELECT
'A' as Status,
IE.Code as Extra,
A.IntrastatAmount as Amount,
A.LocalIntrastatAmount as LocalAmount,
A.StatisticAmount as StatisticAmount,
A.IntrastatCurrency_ID as Currency_ID,
CT.Code as CountryCode,
IR.Code as IntrastatRegionCode,
IC.Code as CommodityCode,
IDT.Code as DeliveryTermCode,
ITT.Code as TransportationTypeCode,
IT.Code as TransactionTypeCode,
IC.UnitCode as IntrastatUnitCode,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) as IntrastatQuantity,
CAST(CAST(A.Quantity AS DOUBLE PRECISION) / CAST((CAST(S.IntrastatUnitRate AS DOUBLE PRECISION) / CAST(S.IntrastatUnitRateRef AS DOUBLE PRECISION)) AS DOUBLE PRECISION) as NUMERIC(15,6)) * CAST(S.IntrastatWeight AS DOUBLE PRECISION) as Weight,
S.IntrastatWeightUnit as WeightUnit,
OCT.Code as OriginCountryCode,
IC.WeightIsOptional as WeightIsOptional,
IC.ConstantWeight as ConstantWeight,
IC.Description as CommodityDescription,
P.ORDNUMBER as ParentOrdNumber,
P.PERIOD_ID as ParentPeriod,
P.DOCQUEUE_ID as ParentDOCQUEUE,
A.StoreCard_ID as StoreCard,
DQ.Code as DocQueueCode,
PE.Code as PeriodCode
FROM
StoreDocuments2 A
JOIN PMStates PMS ON A.PMState_ID=PMS.ID
JOIN StoreDocuments P ON P.ID=A.Parent_ID
LEFT JOIN StoreCards S ON S.ID=A.StoreCard_ID
/*JOIN Currencies C on C.ID=P.Currency_ID*/
LEFT JOIN Countries OCT on OCT.ID=A.OriginCountry_ID
JOIN Countries CT on CT.ID=P.Country_ID
JOIN Firms F on F.ID=P.Firm_ID
LEFT JOIN IntrastatRegions IR on IR.ID=A.IntrastatRegion_ID
LEFT JOIN IntrastatCommodities IC on IC.ID=S.IntrastatCommodity_ID
LEFT JOIN IntrastatExtraTypes IE on IE.ID=S.IntrastatExtraType_ID
LEFT JOIN IntrastatDeliveryTerms IDT on IDT.ID=P.IntrastatDeliveryTerm_ID
LEFT JOIN IntrastatTransportationTypes ITT on ITT.ID=P.IntrastatTransportationType_ID
LEFT JOIN IntrastatTransactionTypes IT on IT.ID=P.IntrastatTransactionType_ID
LEFT JOIN DocQueues DQ on P.DocQueue_ID = DQ.ID
LEFT JOIN Periods PE on P.Period_ID = PE.ID
WHERE
PMS.SystemState=3 AND
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})
{ANDWHERE}
Order By
1, 7, 8, 9, 10, 11, 12, 2, 16, 17, 25, 26, 21
Fields:
Jméno Typ Velikost Výraz CLSID Popis
Amount dtFloat 10

						
Částka
CommodityCode dtString 10

						
Kód komodity
CommodityDescription dtString 240

						
Popis komodity
ConstantWeight dtFloat 15

						
Konstantní hmotnost
CountryCode dtString 3

						
Kód země
Currency_ID dtString 10

						
4R5FINKNYNDL3C5P00CA141B44 Měna
DeliveryTermCode dtString 3

						
Kód dodací podmínky
Extra dtString 2

						
Zvláštní pohyb
IntrastatQuantity dtFloat 10

						
Množství INTRASTAT
IntrastatRegionCode dtString 10

						
Kód kraje
IntrastatUnitCode dtString 3

						
Jednotka INTRASTAT
LocalAmount dtFloat 10

						
Částka v lokální měně
OriginCountryCode dtString 3

						
Kód země původu
ParentDOCQUEUE dtString 10

						
OFTMKVQH3ZD13ACL03KIU0CLP4 Řada dokladů dokladu
ParentOrdNumber dtInteger 6

						
Číslo dokladu
ParentPeriod dtString 10

						
CAQPAYUOXVCL3ACL03KIU0CLP4 Období dokladu
StatisticAmount dtFloat 10

						
Statistická hodnota
Status dtString 1

						
Typ pohybu
StoreCard dtString 10

						
C3V5QDVZ5BDL342M01C0CX3FCC Skladová karta
TransactionTypeCode dtString 2

						
Kód povahy transakce
TransportationTypeCode dtString 1

						
Kód druhu dopravy
Weight dtFloat 10

						
Hmotnost
WeightIsOptional dtBoolean 1

						
Nepovinná hmotnost
WeightUnit dtInteger 10

						
Hmotnostní jednotka

Podmínky

Date

Popiska:
Datum
Typ/Subtyp:
ctDateTime/0
ckRange:
{:LOW}{:HIGH}
Dataset:
MAIN
Speciální parametry:
AlwaysUsed=True
ReplacementLink=True
{$DATE_FROM}=VALUE;0
{$DATE_TO}=VALUEHIGH;0

Division_ID

Šablona:
Division_ID
Dataset:
MAIN

Firm_ID

Šablona:
Firm_ID (joined)
Dataset:
MAIN

BusOrder_ID

Šablona:
BusOrder_ID
Dataset:
MAIN

BusTransaction_ID

Šablona:
BusTransaction_ID
Dataset:
MAIN

BusProject_ID

Šablona:
BusProject_ID
Dataset:
MAIN

CreatedBy_ID

Šablona:
CreatedBy_ID
Dataset:
MAIN

CorrectedBy_ID

Šablona:
CorrectedBy_ID
Dataset:
MAIN

Currency_ID

Šablona:
Currency_ID
Dataset:
MAIN

Country_ID

Šablona:
Country_ID - Target
Dataset:
MAIN

Store_ID

Šablona:
Store_ID
Dataset:
MAIN

StoreCard_ID

Šablona:
StoreCard_ID
Dataset:
MAIN

Generated by ABRA Software a.s. 27.10.2021 16:36