USP_BANKACCOUNTDISBURSEMENTS_INVOICES_UPDATEZEROBALANCE
For a given set of voided bank transactions, this updates the invoice balance.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@BANKACCOUNTTRANSACTIONIDS | UDT_GENERICID | IN |
Definition
Copy
CREATE procedure dbo.USP_BANKACCOUNTDISBURSEMENTS_INVOICES_UPDATEZEROBALANCE(
@BANKACCOUNTTRANSACTIONIDS UDT_GENERICID readonly
)
as
begin
declare invoiceupdate_cursor cursor local fast_forward for
select FTS.FINANCIALTRANSACTIONID
from dbo.FINANCIALTRANSACTION FT
inner join dbo.FINANCIALTRANSACTIONAPPLICATION FTA on FTA.FINANCIALTRANSACTIONID = FT.ID
inner join dbo.FINANCIALTRANSACTIONSCHEDULE FTS on FTA.FINANCIALTRANSACTIONSCHEDULEID = FTS.ID
where FT.ID in (select ID from @BANKACCOUNTTRANSACTIONIDS)
open invoiceupdate_cursor
declare @FINANCIALTRANSACTIONID uniqueidentifier = null
declare @AMOUNT money = null
fetch next from invoiceupdate_cursor
into @FINANCIALTRANSACTIONID
while @@FETCH_STATUS = 0
begin
update dbo.INVOICE set ZEROBALANCE = 0 where ID = @FINANCIALTRANSACTIONID
fetch next from invoiceupdate_cursor
into @FINANCIALTRANSACTIONID
end
close invoiceupdate_cursor
deallocate invoiceupdate_cursor
end