USP_DATAFORMTEMPLATE_ADD_PLEDGEFROMCONSTITUENT

The save procedure used by the add dataform template "Pledge From Constituent Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@CONSTITUENTID uniqueidentifier IN Constituent
@DATE datetime IN Date
@AMOUNT money IN Amount
@POSTSTATUSCODE tinyint IN Post status
@POSTDATE datetime IN Post date
@SENDPLEDGEREMINDER bit IN Send reminders
@SPLITS xml IN Designations
@FREQUENCYCODE tinyint IN Frequency
@NUMBEROFINSTALLMENTS int IN No. installments
@STARTDATE datetime IN Starting on
@INSTALLMENTS xml IN
@AUTOPAY bit IN Pay installments automatically by:
@PAYMENTMETHODCODE tinyint IN Payment method
@CARDHOLDERNAME nvarchar(255) IN Name on card
@CREDITCARDNUMBER nvarchar(20) IN Card number
@CREDITTYPECODEID uniqueidentifier IN Card type
@EXPIRESON UDT_FUZZYDATE IN Expires on
@REFERENCEDATE UDT_FUZZYDATE IN Reference date
@REFERENCENUMBER nvarchar(20) IN Reference number
@CONSTITUENTACCOUNTID uniqueidentifier IN Account
@FINDERNUMBER bigint IN Finder number
@SOURCECODE nvarchar(50) IN Source code
@APPEALID uniqueidentifier IN Appeal
@BENEFITS xml IN Benefits
@BENEFITSWAIVED bit IN Benefits waived
@GIVENANONYMOUSLY bit IN Pledge is anonymous
@MAILINGID uniqueidentifier IN Effort
@CHANNELCODEID uniqueidentifier IN Inbound channel
@DONOTACKNOWLEDGE bit IN Do not acknowledge
@PLEDGESUBTYPEID uniqueidentifier IN Pledge subtype
@OPPORTUNITYID uniqueidentifier IN Opportunity
@REFERENCE nvarchar(255) IN Reference
@CATEGORYCODEID uniqueidentifier IN Revenue category
@CREDITCARDTOKEN uniqueidentifier IN Credit card token
@STANDINGORDERSETUP bit IN Standing order has been setup
@STANDINGORDERSETUPDATE datetime IN Setup on
@DDISOURCECODEID uniqueidentifier IN DDI source
@DDISOURCEDATE date IN DDI source date
@PERCENTAGEBENEFITS xml IN Benefits
@CONTEXTID uniqueidentifier IN Input parameter indicating the context ID for the record being added.
@TRANSACTIONCURRENCYID uniqueidentifier IN Transaction currency
@BASEEXCHANGERATEID uniqueidentifier IN Exchange rate ID
@EXCHANGERATE decimal(20, 8) IN Exchange rate
@PDACCOUNTSYSTEMID uniqueidentifier IN Account system
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_PLEDGEFROMCONSTITUENT
                    (
                        @ID uniqueidentifier = null output,
                        @CHANGEAGENTID uniqueidentifier,
                        @CONSTITUENTID uniqueidentifier,
                        @DATE datetime,
                        @AMOUNT money,
                        @POSTSTATUSCODE tinyint = 1,
                        @POSTDATE datetime = null,
                        @SENDPLEDGEREMINDER bit = 1,
                        @SPLITS xml,
                        @FREQUENCYCODE tinyint = 5,
                        @NUMBEROFINSTALLMENTS int = 1,
                        @STARTDATE datetime = null,
                        @INSTALLMENTS xml = null,
                        @AUTOPAY bit = 0,
                        @PAYMENTMETHODCODE tinyint = 2,
                        @CARDHOLDERNAME nvarchar(255) = '',
                        @CREDITCARDNUMBER nvarchar(20) = '',
                        @CREDITTYPECODEID uniqueidentifier = null,
                        @EXPIRESON dbo.UDT_FUZZYDATE = '00000000',
                        @REFERENCEDATE dbo.UDT_FUZZYDATE = '00000000',
                        @REFERENCENUMBER nvarchar(20) = '',        
                        @CONSTITUENTACCOUNTID uniqueidentifier = null,
                        @FINDERNUMBER bigint = null,
                        @SOURCECODE nvarchar(50) = null,
                        @APPEALID uniqueidentifier = null,
                        @BENEFITS xml = null,
                        @BENEFITSWAIVED bit = 0,
                        @GIVENANONYMOUSLY bit = null,
                        @MAILINGID uniqueidentifier = null,
                        @CHANNELCODEID uniqueidentifier = null,
                        @DONOTACKNOWLEDGE bit = 0,
                        @PLEDGESUBTYPEID uniqueidentifier = null,
                        @OPPORTUNITYID uniqueidentifier = null,
                        @REFERENCE nvarchar(255) = null,
                        @CATEGORYCODEID uniqueidentifier = null,
                        @CREDITCARDTOKEN uniqueidentifier = null,
                        @STANDINGORDERSETUP bit = 0,
                        @STANDINGORDERSETUPDATE datetime = null,
                        @DDISOURCECODEID uniqueidentifier = null,
                        @DDISOURCEDATE date = null,
                        @PERCENTAGEBENEFITS xml = null,
                        @CONTEXTID uniqueidentifier,
                        @TRANSACTIONCURRENCYID uniqueidentifier = null,
                        @BASEEXCHANGERATEID uniqueidentifier = null,
                        @EXCHANGERATE decimal(20,8) = null,
                        @PDACCOUNTSYSTEMID uniqueidentifier  = null,
                        @CURRENTAPPUSERID uniqueidentifier = null
                    )

                    as
                    begin
                        set nocount on;

                        if @CHANGEAGENTID is null
                            exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

                        declare @CURRENTDATE datetime = getdate();

                        if @PDACCOUNTSYSTEMID is null
                            set @PDACCOUNTSYSTEMID = '4B121C2C-CCE6-440D-894C-EA0DEF80D50B'

                        --if we have a finder number make sure the constituent has been added to the tables

                        if isnull(@FINDERNUMBER, 0) > 0
                                exec dbo.[USP_DATAFORMTEMPLATE_ADD_ACQUISITIONLISTMEMBER] @CONSTITUENTID, @CHANGEAGENTID, @FINDERNUMBER;

                        --Multicurrency - AdamBu 3/30/10 - Retrieve base currency from the account system's currency set.

                        declare @CURRENCYSETID uniqueidentifier
                        select 
                            @CURRENCYSETID = CURRENCYSETID
                        from 
                            dbo.PDACCOUNTSYSTEM
                        where 
                            ID = @PDACCOUNTSYSTEMID

                        declare @BASECURRENCYID uniqueidentifier;
                        select 
                            @BASECURRENCYID = BASECURRENCYID
                        from 
                            dbo.CURRENCYSET
                        where 
                            ID = coalesce(@CURRENCYSETID,dbo.UFN_CURRENCYSET_GETAPPUSERDEFAULTCURRENCYSET())

                        --Multicurrency - AdamBu 4/1/10 - Add a spot exchange rate if an existing rate hasn't

                        --been selected, the base and transaction currencies are different, and the rate

                        --entered isn't zero (which indicates that the user wants to enter the record without a rate).

                        if @BASEEXCHANGERATEID = '00000000-0000-0000-0000-000000000001'
                        begin
                            set @BASEEXCHANGERATEID = newid()


                            --Replace with call to USP_CURRENCYEXCHANGERATE_ENSURESPOTRATEEXISTS for PBI 102747 in the future

                            /*if not dbo.UFN_SECURITY_APPUSER_GRANTED_SYSTEMPRIVILEGE_IN_SYSTEMROLE(@CURRENTAPPUSERID,'911f104d-ba5f-4469-b0ae-184c879aea99') = 1
                                and not dbo.UFN_APPUSER_ISSYSADMIN(@CURRENTAPPUSERID) = 1
                            begin
                                raiserror('User does not have the right to add a new spot rate.', 13, 1);
                                return 1;
                            end*/

                            insert into dbo.CURRENCYEXCHANGERATE(
                                ID, 
                                FROMCURRENCYID,
                                TOCURRENCYID,
                                RATE,
                                ASOFDATE,
                                TYPECODE,
                                SOURCECODEID,
                                ADDEDBYID, 
                                CHANGEDBYID, 
                                DATEADDED, 
                                DATECHANGED
                            )
                            values(
                                @BASEEXCHANGERATEID,
                                @TRANSACTIONCURRENCYID,
                                @BASECURRENCYID,
                                @EXCHANGERATE,
                                @DATE,
                                2,
                                null,
                                @CHANGEAGENTID,
                                @CHANGEAGENTID,
                                @CURRENTDATE,
                                @CURRENTDATE
                            );
                        end

                        if @ID is null
                            set @ID = NewID();

                        if @PAYMENTMETHODCODE = 11 and @STANDINGORDERSETUP = 0 --Standing order

                            set @STANDINGORDERSETUPDATE = null;

                        begin try
                            declare @SPLITSDECLININGGIFTAID xml
                            exec dbo.USP_PLEDGE_ADD
                                @ID output,
                                @CHANGEAGENTID,
                                @CONSTITUENTID,
                                @DATE,
                                @AMOUNT,
                                @POSTSTATUSCODE,
                                @POSTDATE,
                                @SENDPLEDGEREMINDER,
                                @SPLITS,
                                @FREQUENCYCODE,
                                @NUMBEROFINSTALLMENTS,
                                @STARTDATE,
                                @INSTALLMENTS,
                                @AUTOPAY,
                                @PAYMENTMETHODCODE,
                                @CARDHOLDERNAME,
                                @CREDITCARDNUMBER,
                                @CREDITTYPECODEID,
                                @EXPIRESON,
                                @REFERENCEDATE,
                                @REFERENCENUMBER,
                                @CONSTITUENTACCOUNTID,
                                @FINDERNUMBER,
                                @SOURCECODE,
                                @APPEALID,
                                @BENEFITS,
                                @BENEFITSWAIVED,
                                @GIVENANONYMOUSLY,
                                @MAILINGID,
                                @CHANNELCODEID,
                                @DONOTACKNOWLEDGE,
                                @PLEDGESUBTYPEID,
                                '', -- batch number

                                @OPPORTUNITYID,
                                @REFERENCE,
                                @CATEGORYCODEID,
                                @CREDITCARDTOKEN,
                                @STANDINGORDERSETUP,
                                @STANDINGORDERSETUPDATE,
                                @DDISOURCECODEID,
                                @DDISOURCEDATE,
                                @SPLITSDECLININGGIFTAID output,
                                @PERCENTAGEBENEFITS,
                                @TRANSACTIONCURRENCYID,
                                @BASECURRENCYID,
                                @BASEEXCHANGERATEID,
                                @PDACCOUNTSYSTEMID

                            exec dbo.USP_GIFTAIDREVENUESPLIT_ADDUPDATESPLITS @ID, @APPEALID, @PAYMENTMETHODCODE, @CREDITTYPECODEID, @CHANGEAGENTID, @DATE, 1, @SPLITSDECLININGGIFTAID; --revenue transaction type code of pledge is 1

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

                        return 0;
                    end