USP_REVENUEBATCH_RECURRINGGIFTCOMMITMENT

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@DATALOADED bit INOUT
@CONSTITUENTNAME nvarchar(255) INOUT
@NEXTTRANSACTIONDATE date INOUT
@DESIGNATIONLIST nvarchar(max) INOUT
@TRANSACTIONAMOUNT money INOUT
@TRANSACTIONCURRENCYID uniqueidentifier INOUT
@ISSPONSORSHIP bit INOUT

Definition

Copy


CREATE procedure dbo.USP_REVENUEBATCH_RECURRINGGIFTCOMMITMENT
(
  @ID uniqueidentifier,
  @DATALOADED bit = 0 output,
  @CONSTITUENTNAME nvarchar(255) = null output,
  @NEXTTRANSACTIONDATE date = null output,
  @DESIGNATIONLIST nvarchar(max) = null output,
  @TRANSACTIONAMOUNT money = null output,
  @TRANSACTIONCURRENCYID uniqueidentifier = null output,
  @ISSPONSORSHIP bit = 0 output
)
as begin
  set nocount on;

  begin try

    select
      @DATALOADED = 1,
      @CONSTITUENTNAME = CONSTITUENT_NF.NAME,
      @NEXTTRANSACTIONDATE = REVENUESCHEDULE.NEXTTRANSACTIONDATE,
      @DESIGNATIONLIST = 
      (
        select top 1
          dbo.UDA_BUILDLIST(DESIGNATION.USERID)
        from
          dbo.REVENUESPLIT
        inner join
          dbo.DESIGNATION on REVENUESPLIT.DESIGNATIONID = DESIGNATION.ID
        where
          REVENUESPLIT.REVENUEID = REVENUE.ID
      ),
      @TRANSACTIONAMOUNT = REVENUE.TRANSACTIONAMOUNT,
      @TRANSACTIONCURRENCYID = REVENUE.TRANSACTIONCURRENCYID,
      @ISSPONSORSHIP =
        case
          when exists(select top 1 1 from dbo.REVENUESPLIT where REVENUEID = REVENUE.ID and TYPECODE = 17)
            then 1
          else
            0
        end
    from
      dbo.REVENUE
    left join
      dbo.REVENUESCHEDULE on REVENUE.ID = REVENUESCHEDULE.ID
    cross apply
      dbo.UFN_CONSTITUENT_DISPLAYNAME(REVENUE.CONSTITUENTID) CONSTITUENT_NF
    where
      dbo.REVENUE.ID = @ID;

  end try
  begin catch
    exec dbo.USP_RAISE_ERROR;
    return 1;
  end catch

  return 0;

end;