USP_DATAFORMTEMPLATE_VIEW_PAYMENTOPPORTUNITY
The load procedure used by the view dataform template "Payment: Opportunity View Form"
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. |
@CONSTITUENTNAME | nvarchar(700) | INOUT | Constituent |
@BALANCE | money | INOUT | Balance |
@DESIGNATIONS | nvarchar(3000) | INOUT | Designations |
@TRANSACTIONCURRENCYID | uniqueidentifier | INOUT | Transaction currency ID |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_PAYMENTOPPORTUNITY
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@CONSTITUENTNAME nvarchar(700) = null output,
@BALANCE money = null output,
@DESIGNATIONS nvarchar(3000) = null output,
@TRANSACTIONCURRENCYID uniqueidentifier = null output
)
as
set nocount on;
set @DATALOADED = 0;
select
@DATALOADED = 1,
@CONSTITUENTNAME = NF.NAME,
--TODO: update this to pull the BASECURRENCYID of the opportunity
@BALANCE = OPPORTUNITY.TRANSACTIONAMOUNT - dbo.UFN_OPPORTUNITY_GETAMOUNTPAID_INCURRENCY(OPPORTUNITY.ID, OPPORTUNITY.TRANSACTIONCURRENCYID),
--TODO: update this to pull the BASECURRENCYID of the opportunity
@TRANSACTIONCURRENCYID = OPPORTUNITY.TRANSACTIONCURRENCYID
from
dbo.OPPORTUNITY
inner join
dbo.PROSPECTPLAN on PROSPECTPLAN.ID = OPPORTUNITY.PROSPECTPLANID
outer apply dbo.UFN_CONSTITUENT_DISPLAYNAME(PROSPECTPLAN.PROSPECTID) NF
where OPPORTUNITY.ID = @ID;
select @DESIGNATIONS = dbo.UDA_BUILDLIST(DESIGNATION.NAME)
from dbo.OPPORTUNITYDESIGNATION
inner join dbo.DESIGNATION on DESIGNATION.ID = OPPORTUNITYDESIGNATION.DESIGNATIONID
where OPPORTUNITYDESIGNATION.OPPORTUNITYID = @ID;
if @BALANCE < 0
set @BALANCE = 0;
return 0;