Erik Darling has some functions for us:
At just about every client site, I see a common set of financial functions being used to calculate various things. The code is all the same, too.
Some of it comes from published government guidelines, and some of it comes straight out of accounting 101 books.
The big problem is that all of these functions were written as scalar UDFs, and performance becomes dead.
Recently, one of my clients was nice enough to agree to let me publish my rewrites of their functions as inline table valued functions.
Check them out on Erik’s GitHub repo.