USP_DATAFORMTEMPLATE_EDITLOAD_UNPAIDINVOICESCHEDULE
The load procedure used by the edit dataform template "Unpaid Invoice Schedule Edit 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. |
@TSLONG | bigint | INOUT | Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record. |
@FREQUENCYCODE | smallint | INOUT | Frequency |
@STARTDATE | date | INOUT | Starting on |
@NUMBEROFINSTALLMENTS | int | INOUT | Number of installments |
@INVOICEAMOUNT | money | INOUT | Invoice amount |
@INVOICESCHEDULES | xml | INOUT | Invoice schedules |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_UNPAIDINVOICESCHEDULE
(
@ID uniqueidentifier
,@DATALOADED bit = 0 output
,@TSLONG bigint = 0 output
,@FREQUENCYCODE smallint = null output
,@STARTDATE date = null output
,@NUMBEROFINSTALLMENTS integer = null output
,@INVOICEAMOUNT money = null output
,@INVOICESCHEDULES xml = null output
)
as
set nocount on;
set @DATALOADED = 0
set @TSLONG = 0
declare @INVOICEBALANCE money;
select
@DATALOADED = 1
,@TSLONG = I.TSLONG
,@STARTDATE = coalesce(ISI.STARTDATE, I.DATEDUE)
,@NUMBEROFINSTALLMENTS = coalesce(ISI.NUMBEROFINSTALLMENTS, 1)
,@FREQUENCYCODE = coalesce(ISI.FREQUENCYCODE, 4) -- Irregular
,@INVOICEAMOUNT = FT.TRANSACTIONAMOUNT
,@INVOICEBALANCE = I.BALANCE
,@INVOICESCHEDULES = dbo.UFN_INVOICE_SCHEDULES_TOITEMLISTXML(I.ID)
from dbo.INVOICE as I
inner join dbo.FINANCIALTRANSACTION as FT
on I.ID = FT.ID
left outer join dbo.INVOICESCHEDULEINFORMATION as ISI
on I.ID = ISI.ID
where I.ID = @ID
and I.DISBURSEMENTPROCESSID is NULL;
if @INVOICEAMOUNT<>@INVOICEBALANCE
raiserror('Cannot use this edit form for an invoice that has been paid.', 16, 1);
return 0;