USP_DATAFORMTEMPLATE_PRELOAD_ADD_MGPLEDGE_2
The load procedure used by the edit dataform template "Matching Gift Claim Add Form 2"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ORIGINALGIFTID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@ORIGINALGIFTAMOUNT | money | INOUT | Original gift amount |
@ORIGINALRECEIPTAMOUNT | money | INOUT | Original receipt amount |
@CONSTITUENTID | uniqueidentifier | INOUT | Constituent ID |
@CONSTITUENTNAME | nvarchar(700) | INOUT | Constituent name |
@DATE | datetime | INOUT | Date |
@SPLITS | xml | INOUT | Designations |
@RELATIONSHIPCONTEXTID | nvarchar(73) | INOUT | Relationship Context ID |
@ELIGIBLEFORMATCHINGGIFTCLAIM | bit | INOUT | Eligible for matching gift claim |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@BASECURRENCYID | uniqueidentifier | INOUT | Base currency |
@BASEDECIMALDIGITS | tinyint | INOUT | Decimal digits |
@BASEROUNDINGTYPECODE | tinyint | INOUT | Rounding type |
@ORIGINALGIFTTRANSACTIONCURRENCYID | uniqueidentifier | INOUT | Original gift transaction currency |
@HASNEEDEDEXCHANGERATES | bit | INOUT |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_PRELOAD_ADD_MGPLEDGE_2
(
@ORIGINALGIFTID uniqueidentifier,
@ORIGINALGIFTAMOUNT money = null output,
@ORIGINALRECEIPTAMOUNT money = null output,
@CONSTITUENTID uniqueidentifier = null output,
@CONSTITUENTNAME nvarchar(700) = null output,
@DATE datetime = null output,
@SPLITS xml = null output,
@RELATIONSHIPCONTEXTID nvarchar(73) = null output,
@ELIGIBLEFORMATCHINGGIFTCLAIM bit = null output,
@CURRENTAPPUSERID uniqueidentifier = null,
@BASECURRENCYID uniqueidentifier = null output,
@BASEDECIMALDIGITS tinyint = null output,
@BASEROUNDINGTYPECODE tinyint = null output,
@ORIGINALGIFTTRANSACTIONCURRENCYID uniqueidentifier = null output,
@HASNEEDEDEXCHANGERATES bit = null output
)
as
set nocount on;
if @ORIGINALGIFTID is null
return 1;
declare @SPLITSTABLE table
(
DESIGNATIONID uniqueidentifier,
AMOUNT money,
APPLICATIONCODE tinyint
);
--Quick check to see if the revenue exists, if it doesn't throw an error.
if not exists (select ID from dbo.REVENUE where ID=@ORIGINALGIFTID)
raiserror('The record specified does not exist for this data form.',13,1)
set @ORIGINALGIFTAMOUNT = 0;
set @DATE = dbo.UFN_DATE_GETEARLIESTTIME(getdate());
select
top 1
@CONSTITUENTID = REVENUE.CONSTITUENTID,
@ORIGINALRECEIPTAMOUNT = REVENUE.RECEIPTAMOUNT,
@ELIGIBLEFORMATCHINGGIFTCLAIM = REVENUE.ELIGIBLEFORMATCHINGGIFTCLAIM,
@ORIGINALGIFTTRANSACTIONCURRENCYID = REVENUE.TRANSACTIONCURRENCYID
from dbo.REVENUE
where REVENUE.ID = @ORIGINALGIFTID;
select
@ORIGINALGIFTAMOUNT = sum(TRANSACTIONAMOUNT)
from dbo.UFN_REVENUE_GETSPLITS_2(@ORIGINALGIFTID)
where TYPECODE = 0;
--Bug 33720 KevinKoe - Grouping by designation does not provide sum of all amounts for the payment, only the sum for each
-- designation in the payment, which meant that only the sum of the amounts for the first designation
-- was being returned.
--group by DESIGNATIONID;
select @CONSTITUENTNAME = NF.NAME
from dbo.UFN_CONSTITUENT_DISPLAYNAME(@CONSTITUENTID) NF
insert into @SPLITSTABLE
select
DESIGNATIONID,
sum(AMOUNT),
APPLICATIONCODE
from dbo.UFN_REVENUE_GETSPLITS_2(@ORIGINALGIFTID)
where TYPECODE = 0
group by DESIGNATIONID, APPLICATIONCODE;
select @SPLITS =
(
select
AMOUNT,
DESIGNATIONID,
newid() ID,
case when APPLICATIONCODE = 2 then 0 else APPLICATIONCODE end
from @SPLITSTABLE
for xml raw('ITEM'),type,elements,root('SPLITS'),binary base64
);
select
@BASECURRENCYID = ID,
@BASEDECIMALDIGITS = CURRENCY.DECIMALDIGITS,
@BASEROUNDINGTYPECODE = CURRENCY.ROUNDINGTYPECODE
from dbo.CURRENCY
where ID = dbo.UFN_APPUSER_GETBASECURRENCY(@CURRENTAPPUSERID);
set @HASNEEDEDEXCHANGERATES = dbo.UFN_REVENUE_HASNEEDEDRATES(@ORIGINALGIFTID);
return 0;