SELECT DISTINCT A.PROCESS_INSTANCE ,C.TAX_CD_VAT , C.TAX_CD_VAT_PCT , C.TAX_BASIS_AMT_BSE , C.TAX_AMT_GROSS_BSE , C.TAX_AMT_RCVRY_BSE ,C.TAX_AMT_RBT_BSE ,C.VAT_TXN_SOURCE ,HDR.DESCRSHORT FROM PS_VAT_RPT_INST1 A , PS_VAT_RPT_INST2 B , PS_VAT_TXN_TBL C , PS_VENDOR D , PS_VAT_XREF_VCHR E , PS_VOUCHER F , PS_VAT_USE_TBL G , PS_VCHR_ACCTG_LINE H ,PS_VAT_ENTITY VE ,PS_VAT_ENT_RGSTRN VR ,PS_TAX_HEADER_TBL HDR WHERE A.PROCESS_INSTANCE = B.PROCESS_INSTANCE AND C.VAT_ENTITY=VE.VAT_ENTITY AND A.VAT_RPT_ID = B.VAT_RPT_ID AND B.VAT_ENTITY = C.VAT_ENTITY AND C.VAT_ENTITY=VR.VAT_ENTITY AND VR.COUNTRY='ESP' AND B.COUNTRY_VAT_RPTG = C.COUNTRY_VAT_RPTG AND B.VAT_DCMNT_ID = C.VAT_DCMNT_ID AND B.LINE_NBR = C.LINE_NBR AND B.UNPOST_SEQ = C.UNPOST_SEQ AND D.SETID = F.VENDOR_SETID AND D.VENDOR_ID = F.VENDOR_ID AND C.SETID=HDR.SETID AND C.TAX_CD_VAT=HDR.TAX_CD AND C.VAT_ENTITY = E.VAT_ENTITY AND C.COUNTRY_VAT_RPTG = E.COUNTRY_VAT_RPTG AND C.VAT_DCMNT_ID = E.VAT_DCMNT_ID AND C.LINE_NBR = E.LINE_NBR AND C.UNPOST_SEQ = E.UNPOST_SEQ AND E.BUSINESS_UNIT = F.BUSINESS_UNIT AND E.VOUCHER_ID = F.VOUCHER_ID AND E.VAT_ENTITY = F.VAT_ENTITY AND G.VAT_USE_ID = H.VAT_USE_ID AND G.EFFDT = ( SELECT MAX(G_ED.EFFDT) FROM PS_VAT_USE_TBL G_ED WHERE G.SETID = G_ED.SETID AND G.VAT_USE_ID = G_ED.VAT_USE_ID AND G_ED.EFFDT <= %CurrentDateIn) AND F.BUSINESS_UNIT = H.BUSINESS_UNIT AND F.VOUCHER_ID = H.VOUCHER_ID AND G.EFF_STATUS = 'A' AND B.VAT_RPT_LINE_NBR <> 7
|