Fix getLastInvoice query
Merge branch 'test-fix' into develop