Support querying open/closed memos

This should provide the backend component for #74.

Invoices and Memos can now contain no pieces.  (This is due to the fact that a closed memo is just a memo with no remaining pieces.)