/* Expense Processing / Information Audit — Auth TE list (ReloAction) BackOffice: frmExpProcAuditRpt (lblReportType = Auth, default date type) Crystal: ExpenseProcessingAuditRpt.rpt Pm-TransType = A (Authorization Date) TE universe = DISTINCT TEFileNo from vwTEFullServiceList where AuthDate in range and CancelDate IS NULL (form PopulateTable), then descriptors into tblTmpRptTEDescriptors. This sample returns authorized TEs with expense-info descriptors (raw). Service-level AuthDate is used for the filter (matches BO). Initial-auth AuthDate is also shown from vwTEInitialAuthorization when available. Run on ReloAction. */ DECLARE @StartDate datetime = '2026-01-01'; DECLARE @EndDate datetime = '2026-01-31'; DECLARE @CorpCode varchar(15) = NULL; DECLARE @ParentRollup bit = 0; DECLARE @DomesticIntl varchar(1) = NULL; -- NULL = all; 'D' / 'I' DECLARE @PrimaryContact varchar(4) = NULL; SELECT DISTINCT fs.CorpCode, fs.ParentCompany, fs.TEFileNo, m.TELastName, m.TEFirstName, m.EmpNumber, fs.PrimaryContact, m.DivisionName, m.ReloPolicy, m.MoveType, mt.DomesticIntl, m.DisplayType, fs.AuthDate AS ServiceAuthDate, ia.AuthDate AS InitialAuthDate, ei.Descriptor1, ei.Descriptor2, ei.Descriptor3, ei.Descriptor4, ei.Descriptor5, fs.ServiceCode, fs.CancelDate FROM dbo.vwTEFullServiceList fs INNER JOIN dbo.tblTEMain1 m ON fs.TEFileNo = m.TEFileNo LEFT JOIN dbo.tblMoveTypes mt ON m.MoveType = mt.MoveType LEFT JOIN dbo.tblTEExpenseInfo ei ON m.TEFileNo = ei.TEFileNo LEFT JOIN dbo.vwTEInitialAuthorization ia ON m.TEFileNo = ia.TEFileNo WHERE fs.AuthDate BETWEEN @StartDate AND @EndDate AND fs.CancelDate IS NULL AND ( (@ParentRollup = 0 AND (@CorpCode IS NULL OR @CorpCode = '' OR fs.CorpCode = @CorpCode)) OR (@ParentRollup = 1 AND (@CorpCode IS NULL OR @CorpCode = '' OR fs.ParentCompany = @CorpCode OR fs.CorpCode = @CorpCode)) ) AND (@DomesticIntl IS NULL OR @DomesticIntl = '' OR mt.DomesticIntl = @DomesticIntl) AND (@PrimaryContact IS NULL OR @PrimaryContact = '' OR fs.PrimaryContact = @PrimaryContact) ORDER BY fs.CorpCode, m.TELastName, m.TEFirstName, fs.TEFileNo, fs.AuthDate;