USP_DATAFORMTEMPLATE_VIEW_CONSTITUENTGROUP_REVENUEHISTORY_2

The load procedure used by the view dataform template "Constituent Group Revenue History View 2"

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@TOTALNUMBERTRANSACTIONS int INOUT Total number of transactions
@TOTALREVENUE money INOUT Total revenue
@TOTALREVENUEWITHGIFTAID money INOUT Total revenue with Gift Aid
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@ISORGANIZATION bit INOUT Constituent is organization
@TOTALPAID money INOUT Total received
@TOTALPAYMENTS int INOUT Total number of payments
@TOTALEXPECTED money INOUT Total expected
@TOTALOPENCOMMITMENTS int INOUT Total number of open commitments

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_CONSTITUENTGROUP_REVENUEHISTORY_2
(
    @ID uniqueidentifier,
    @DATALOADED bit = 0 output,
    @TOTALNUMBERTRANSACTIONS int = null output,
    @TOTALREVENUE money = null output,
    @TOTALREVENUEWITHGIFTAID money = null output,
    @CURRENTAPPUSERID uniqueidentifier = null,
    @ISORGANIZATION bit = null output,
    @TOTALPAID money = null output,
    @TOTALPAYMENTS int = null output,
    @TOTALEXPECTED money = null output,
    @TOTALOPENCOMMITMENTS int = null output

as
    set nocount on;

    -- households always include member giving, other types get looked up

    declare @GROUPINCLUDESMEMBERREVENUE bit;

    select 
    @GROUPINCLUDESMEMBERREVENUE = 
      case
        when GD.GROUPTYPECODE = 0 then 1
        when GD.GROUPTYPECODE = 1 then GT.INCLUDEMEMBERGIVING
      end
    from dbo.GROUPDATA GD
    left join dbo.GROUPTYPE GT on GD.GROUPTYPEID = GT.ID
    where GD.ID=@ID;

    exec dbo.USP_CONSTITUENT_REVENUEHISTORY_SUMMARY
        @ID,
        @CURRENTAPPUSERID,
        '1E4F82C6-F108-48b3-A7AF-77D3BA145F50',
        @GROUPINCLUDESMEMBERREVENUE,
        @DATALOADED output,
        @TOTALREVENUE output,
        @TOTALNUMBERTRANSACTIONS output,
        @TOTALREVENUEWITHGIFTAID output,
        @TOTALPAID output,
        @TOTALPAYMENTS output,
        @TOTALEXPECTED output,
        @TOTALOPENCOMMITMENTS output,
        @ISORGANIZATION output

    return 0;