UFN_HASUNPOSTEDREVERSAL
Checks a revenue transaction for unposted reversals.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_HASUNPOSTEDREVERSAL(@ID as uniqueidentifier)
returns bit
with execute as caller
as begin
declare @HASUNPOSTEDREVERSAL bit = 0;
if exists (
select LI.FINANCIALTRANSACTIONID from DBO.FINANCIALTRANSACTIONLINEITEM as LI
inner join dbo.FINANCIALTRANSACTION as FT on LI.FINANCIALTRANSACTIONID = FT.ID
where
FT.PARENTID = @ID
and LI.TYPECODE = 1
and LI.POSTSTATUSCODE = 1
and FT.TYPECODE in (20,21,22,26,27)
union all
select LI.FINANCIALTRANSACTIONID from dbo.FINANCIALTRANSACTIONLINEITEM as LI
where
LI.FINANCIALTRANSACTIONID=@ID
and LI.TYPECODE = 1
and LI.POSTSTATUSCODE = 1
and LI.DELETEDON is NULL
)
set @HASUNPOSTEDREVERSAL = 1
return @HASUNPOSTEDREVERSAL;
end