Adding a rule for the outstanding invoice request
Move some boilerplate for the db requests