TR_INSTALLMENTSPLITPAYMENT_INSERTUPDATE_CURRENCY
Definition
Copy
CREATE trigger [dbo].[TR_INSTALLMENTSPLITPAYMENT_INSERTUPDATE_CURRENCY] on [dbo].[INSTALLMENTSPLITPAYMENT]
after insert, update
not for replication
as
begin
set nocount on;
-- If we update the amount and the application currency is null, set the application
-- currency to the organization currency.
if update(AMOUNT)
begin
declare @ORGANIZATIONCURRENCYID uniqueidentifier = dbo.UFN_CURRENCY_GETORGANIZATIONCURRENCY();
update
dbo.INSTALLMENTSPLITPAYMENT
set
INSTALLMENTSPLITPAYMENT.APPLICATIONCURRENCYID = @ORGANIZATIONCURRENCYID,
INSTALLMENTSPLITPAYMENT.CHANGEDBYID = INSTALLMENTSPLITPAYMENT.CHANGEDBYID,
INSTALLMENTSPLITPAYMENT.DATECHANGED = INSTALLMENTSPLITPAYMENT.DATECHANGED
from
inserted
inner join
dbo.INSTALLMENTSPLITPAYMENT on inserted.ID = INSTALLMENTSPLITPAYMENT.ID
where
INSTALLMENTSPLITPAYMENT.APPLICATIONCURRENCYID is null
end
end