invoice: add finalize API endpoint