
[dbo].[VerifyDateInOpenAccountingPostingPeriod]
CREATE PROCEDURE [dbo].[VerifyDateInOpenAccountingPostingPeriod]
@inDate datetime,
@inGPDBName sysname = null,
@inSeries int = 2,
@outStatusCode int output,
@inAccountingSystem varchar(2) = null
as
set nocount on
declare @theSql nvarchar(512)
declare @theAccountingSystem varchar(2) = isnull( @inAccountingSystem, dbo.GetAccountingSystemType() )
set @outStatusCode = -1
if( @theAccountingSystem = 'XL' )
begin
set @theSql = N'set @outStatusCode =
(
select top 1 [Closed] = case when XLedgerAccountingPeriod.[Open] = 1 then 0 else 1 end
from XLedgerAccountingPeriod
where convert( datetime, ''' + convert( varchar(10), @inDate, 101 ) + ''', 101 ) between XLedgerAccountingPeriod.FromDate and XLedgerAccountingPeriod.ToDate
)'
end
else
begin
set @theSql = N'set @outStatusCode =
(
select top 1 SY40100.[Closed]
from ' + @inGPDBName + '..SY40100 as SY40100
where convert( datetime, ''' + convert( varchar(10), @inDate, 101 ) + ''', 101 ) between SY40100.PeriodDt and SY40100.PerdEnDt and
SY40100.Series = ' + cast( @inSeries as varchar(32) ) + '
order by SY40100.Closed desc
)'
end
if( @theSql is not null )
begin
exec sp_executesql @theSql, N'@outStatusCode int output', @outStatusCode output
end
set @outStatusCode = isnull( @outStatusCode, -1 )
GO
GRANT EXECUTE ON [dbo].[VerifyDateInOpenAccountingPostingPeriod] TO [MssExec]
GO