USP_DATAFORMTEMPLATE_ADD_GRANTAWARDFROMOPPORTUNITY_PRELOAD
The load procedure used by the edit dataform template "Grant Award From Opportunity Add Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@OPPORTUNITYID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@PROSPECTNAME | nvarchar(154) | INOUT | Prospect |
@SPLITS | xml | INOUT | Designations |
@AMOUNT | money | INOUT | Amount |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@PDACCOUNTSYSTEMID | uniqueidentifier | INOUT | Account system |
@SHOWACCOUNTSYSTEM | bit | INOUT | Show account system |
@TRANSACTIONCURRENCYID | uniqueidentifier | INOUT | Transaction currency |
@EXCHANGERATE | decimal(20, 8) | INOUT | Exchange rate |
@SINGLEDESIGNATIONID | uniqueidentifier | INOUT | Designation |
@BASEEXCHANGERATEID | uniqueidentifier | INOUT | Exchange rate ID |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_GRANTAWARDFROMOPPORTUNITY_PRELOAD
(
@OPPORTUNITYID uniqueidentifier,
@PROSPECTNAME nvarchar(154) = null output,
@SPLITS xml = null output,
@AMOUNT money = null output,
@CURRENTAPPUSERID uniqueidentifier = null,
@PDACCOUNTSYSTEMID uniqueidentifier = null output,
@SHOWACCOUNTSYSTEM bit = null output,
@TRANSACTIONCURRENCYID uniqueidentifier = null output,
@EXCHANGERATE decimal(20,8) = null output,
@SINGLEDESIGNATIONID uniqueidentifier = null output,
@BASEEXCHANGERATEID uniqueidentifier = null output
)
as
set nocount on;
declare @OPPORTUNITYTRANSACTIONCURRENCYID uniqueidentifier;
select
@PROSPECTNAME = dbo.UFN_CONSTITUENT_BUILDNAME(PROSPECTPLAN.PROSPECTID),
@OPPORTUNITYTRANSACTIONCURRENCYID = OPPORTUNITY.TRANSACTIONCURRENCYID
from
dbo.OPPORTUNITY
inner join dbo.PROSPECTPLAN on OPPORTUNITY.PROSPECTPLANID = PROSPECTPLAN.ID
where
OPPORTUNITY.ID = @OPPORTUNITYID
if dbo.UFN_VALID_BASICGL_INSTALLED() != 0
begin
declare @NUMBEROFACCOUNTSYSTEMSFORUSER smallint
set @NUMBEROFACCOUNTSYSTEMSFORUSER = dbo.UFN_PDACCOUNTSYSTEM_GETNUMBEROFSYSTEMSFORUSER(@CURRENTAPPUSERID)
if @NUMBEROFACCOUNTSYSTEMSFORUSER = 1
begin
set @SHOWACCOUNTSYSTEM = 0
select @PDACCOUNTSYSTEMID = T1.ID from dbo.UFN_PDACCOUNTSYSTEM_GETSYSTEMIDSFORUSER(@CURRENTAPPUSERID) as T1
end
else
begin
set @SHOWACCOUNTSYSTEM = 1
set @PDACCOUNTSYSTEMID = dbo.UFN_PDACCOUNTSYSTEM_GETDEFAULTSYSTEMIDSFORUSER(@CURRENTAPPUSERID)
end
end
else
begin
set @SHOWACCOUNTSYSTEM = 0
set @PDACCOUNTSYSTEMID = '4B121C2C-CCE6-440D-894C-EA0DEF80D50B'
end
if exists(select PDACCOUNTSYSTEM.ID
from dbo.PDACCOUNTSYSTEM
inner join dbo.CURRENCYSET on PDACCOUNTSYSTEM.CURRENCYSETID = CURRENCYSET.ID
inner join dbo.CURRENCYSETTRANSACTIONCURRENCY on CURRENCYSET.ID = CURRENCYSETTRANSACTIONCURRENCY.CURRENCYSETID
where CURRENCYSETTRANSACTIONCURRENCY.CURRENCYID = @OPPORTUNITYTRANSACTIONCURRENCYID
and CURRENCYSET.BASECURRENCYID != @OPPORTUNITYTRANSACTIONCURRENCYID
and PDACCOUNTSYSTEM.ID = @PDACCOUNTSYSTEMID)
begin
set @TRANSACTIONCURRENCYID = @OPPORTUNITYTRANSACTIONCURRENCYID;
set @BASEEXCHANGERATEID = dbo.UFN_CURRENCYEXCHANGERATE_GETLATEST(@OPPORTUNITYTRANSACTIONCURRENCYID, (select BASECURRENCYID from dbo.PDACCOUNTSYSTEM left join dbo.CURRENCYSET on PDACCOUNTSYSTEM.CURRENCYSETID = CURRENCYSET.ID where PDACCOUNTSYSTEM.ID = @PDACCOUNTSYSTEMID), getdate(), 1, null)
set @EXCHANGERATE = coalesce((select RATE from dbo.CURRENCYEXCHANGERATE where ID = @BASEEXCHANGERATEID), 1)
end
else
begin
--Set the transaction currency initially to the base currency of the account system.
select
@TRANSACTIONCURRENCYID = BASECURRENCYID,
@EXCHANGERATE = 1
from
dbo.PDACCOUNTSYSTEM
left join dbo.CURRENCYSET on PDACCOUNTSYSTEM.CURRENCYSETID = CURRENCYSET.ID
where
PDACCOUNTSYSTEM.ID = @PDACCOUNTSYSTEMID;
end
--TYPECODE = 3; APPLICATIONCODE = 0
set @SPLITS = dbo.UFN_REVENUE_BUILDSPLITSFOROPPORTUNITYGIFTINCURRENCY(@OPPORTUNITYID, 3, 0, @TRANSACTIONCURRENCYID);
select @AMOUNT = sum(AMOUNT) from dbo.UFN_REVENUE_GETSPLITS_2_FROMITEMLISTXML(@SPLITS);
return 0;