Hello All
I have transformed my profit and loss report by employee into a more detailed account listing and have added few additional fields to the below formula (extract):
Declare @yr int, @pr int
SET @yr = {?yr1}
SET @pr = {?pr1}
SELECT Q1.*, Q2.*, pvt2.*, Qr3.* FROM
(SELECT 'JE ' + RTRIM(c.TransId) AS DocNum, c.RefDate, c.Account,c.U_P11D, c.Debit-c.Credit+c.VatAmount AS LineTotal, c.SYSDeb-c.SYSCred+c.SYSVatSum AS SysTotal, c.LineMemo AS RowDescription, d.Ref2, d.Memo AS JournalRemarks, d.TaxDate,
c.TransId, c.FinncPriod, f.Year, e.SubNum, e.F_RefDate, e.T_RefDate, f.F_RefDate as F_YDate, f.T_RefDate as T_YDate,
g.AcctName, g.ActType,g.AcctCode, g.FatherNum, g.Levels,g.GrpLine, g.GroupMask, h.AcctName AS Father, OADM.CompnyName, OADM.MainCurncy, OADM.SysCurrncy
From JDT1 c
INNER JOIN OJDT d on c.TransId = d.TransId
INNER JOIN OFPR e on e.AbsEntry=c.FinncPriod
INNER JOIN OACP f on f.PeriodCat=e.Category
INNER JOIN OACT g on g.AcctCode=c.Account
INNER JOIN OACT h on h.AcctCode=g.FatherNum, OADM
WHERE f.Year = @yr AND e.SubNum <= @pr AND d.TransType not in (13,14,18,19)
UNION ALL
SELECT 'IN ' + RTRIM(d.DocNum) AS DocNum, c.DocDate, c.AcctCode,c.U_P11D, c.PriceAfVAT*-1 AS LineTotal, (c.TotalSumSy+c.VatSumSy)*-1 AS SysTotal, c.Dscription AS RowDescription, d.NumAtCard AS Ref2, d.JrnlMemo AS JournalRemarks, d.TaxDate,
d.TransId, c.FinncPriod, f.Year, e.SubNum, e.F_RefDate, e.T_RefDate, f.F_RefDate as F_YDate, f.T_RefDate as T_YDate,
g.AcctName, g.ActType,g.AcctCode, g.FatherNum, g.Levels,g.GrpLine, g.GroupMask, h.AcctName AS Father, OADM.CompnyName, OADM.MainCurncy, OADM.SysCurrncy
From INV1 c
INNER JOIN OINV d on d.DocEntry = c.DocEntry
INNER JOIN OFPR e on e.AbsEntry=c.FinncPriod
INNER JOIN OACP f on f.PeriodCat=e.Category
INNER JOIN OACT g on g.AcctCode=c.AcctCode
INNER JOIN OACT h on h.AcctCode=g.FatherNum, OADM
WHERE f.Year = @yr AND e.SubNum <= @pr
The problem I have now is that when I run my report for period 6, transactions from all periods are being shown (transaction date, reference, description) but with the amount 0. I do not want to show any transactions that are not posted in period 6.
Please help!! What am I missing?
many thanks