USP_MEMBERSHIPPLEDGE_VALIDATESPLITS
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SPLITS | xml | IN | |
@REVENUEAMOUNT | money | IN | |
@TRANSACTIONTYPECODE | int | IN | |
@REVENUEID | uniqueidentifier | IN | |
@TRANSACTIONCURRENCYID | uniqueidentifier | IN | |
@VALIDATETRANSACTIONCURRENCY | bit | IN |
Definition
Copy
create procedure dbo.USP_MEMBERSHIPPLEDGE_VALIDATESPLITS
(
@SPLITS xml,
@REVENUEAMOUNT money,
@TRANSACTIONTYPECODE int = 0,
@REVENUEID uniqueidentifier = null,
@TRANSACTIONCURRENCYID uniqueidentifier = null,
@VALIDATETRANSACTIONCURRENCY bit = 1
)
as
set nocount on;
declare @SUM money;
declare @TOTALSPLITCOUNT int;
--Set currency parameters for backwards compatibility
declare @ORGANIZATIONCURRENCYID uniqueidentifier;
set @ORGANIZATIONCURRENCYID = dbo.UFN_CURRENCY_GETORGANIZATIONCURRENCY();
if @TRANSACTIONCURRENCYID is null
set @TRANSACTIONCURRENCYID = @ORGANIZATIONCURRENCYID;
if @VALIDATETRANSACTIONCURRENCY is null
set @VALIDATETRANSACTIONCURRENCY = 1;
declare @SPLITSTABLE table
(
AMOUNT money,
TRANSACTIONCURRENCYID uniqueidentifier
);
insert into @SPLITSTABLE(
AMOUNT,
TRANSACTIONCURRENCYID
)
select
[SPLITS].AMOUNT,
case
when [SPLITS].TRANSACTIONCURRENCYID is null then
@ORGANIZATIONCURRENCYID
else
[SPLITS].TRANSACTIONCURRENCYID
end
from
dbo.UFN_REVENUE_GETSPLITS_2_FROMITEMLISTXML(@SPLITS) as [SPLITS]
-- AdamBu 3/17/10 - Ensure that the split's transaction currency is the same as its revenue.
if (@VALIDATETRANSACTIONCURRENCY = 1) and exists(
select 1
from @SPLITSTABLE
where TRANSACTIONCURRENCYID <> @TRANSACTIONCURRENCYID
)
begin
raiserror('A split''s transaction currency must match that of its revenue.',13,7);
return 7;
end
select
@SUM = sum(AMOUNT),
@TOTALSPLITCOUNT=count(*)
from @SPLITSTABLE;
if @SUM <> @REVENUEAMOUNT
begin
raiserror('The total amount must equal the cost of the membership.',13,2);
return 2;
end
if @TOTALSPLITCOUNT = 0
begin
raiserror('There is no application specified for this pledge.', 13, 3);
return 3;
end
return 0;