added database logic for invoice module