Wrap the insert and update to dbo.AFR_Accounts in a transaction. This way, it will rollback the changes made if it doesn't make it all the way to the end
BEGIN TRY
BEGIN TRANSACTION
Insert dbo.AFR_Accounts ....
Update dbo.AFR_Accounts ...
COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
END CATCH