UFN_GLDISTRIBUTION_VALIDPOSTDATE
Validates distributions postdate.
Return
Return Type |
---|
nvarchar(255) |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@POSTDATE | datetime | IN |
Definition
Copy
CREATE function dbo.UFN_GLDISTRIBUTION_VALIDPOSTDATE
(
@POSTDATE datetime
)
returns nvarchar(255)
with execute as caller
as
begin
declare @RETVAL nvarchar(255) = '';
if @POSTDATE is null
begin
if dbo.UFN_GLACCOUNT_EXISTS() != 0
set @RETVAL = 'Post date must be in an open period.';
else
set @RETVAL = '';
end
else
begin
if dbo.UFN_GLACCOUNT_EXISTS() != 0
begin
--The "GETEARLIESTTIME" date function has been inlined here for performance (the part with "cast(@DATE as date)")...
--The "GETLATESTTIME" date function has been inlined here for performance (the part with "dateadd(ms, -003...")...
if not exists(select ID from GLFISCALPERIOD where closed = 0 and @POSTDATE between cast(STARTDATE as date) and dateadd(ms, -003, dateadd(d, 1, cast(cast(ENDDATE as date) as datetime))))
set @RETVAL = 'Post date must be in an open period.';
end
else
set @RETVAL = '';
end
return @RETVAL;
end