UFN_PLEDGE_GETPASTDUEAMOUNT_BYSENTDATE
Returns the amount past due for a given pledge considering the reminder sent date
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PLEDGEID | uniqueidentifier | IN | |
@SENTDATE | datetime | IN |
Definition
Copy
CREATE function dbo.UFN_PLEDGE_GETPASTDUEAMOUNT_BYSENTDATE
(
@PLEDGEID uniqueidentifier,
@SENTDATE datetime
)
returns money
with execute as caller
as
begin
declare @RESULT money;
select @RESULT =
isnull(
(select
sum ( dbo.UFN_INSTALLMENT_GETINSTALLMENTBALANCE(INSTALLMENT.ID))
from dbo.INSTALLMENT
where INSTALLMENT.REVENUEID = @PLEDGEID
--The "GETLATESTTIME" date function has been inlined here for performance (the part with "dateadd(ms, -003...")...
and dateadd(ms, -003, dateadd(d, 1, cast(cast(INSTALLMENT.DATE as date) as datetime))) < @SENTDATE),
0);
return @RESULT;
end