Fixes #1600: Fix invoice type formatting and refactor