getDebitAccount :: Ext Record -> Maybe AccountID
getDebitAccount r =
  case getContent r of
    Transaction (TEntry (UEntry dr cr corr _)) ->
      case dr of
        [] -> if null cr then Nothing else ((getID . fst) <$> corr)
        (DPosting acc _ _: _) -> Just (getID acc)
    _ -> Nothing

-- | Search for record with matching attributes in list.
-- Returns (Maybe found record, all records except found).
getDebitAccount :: Ext Record -> Maybe AccountID
getDebitAccount r =
  case getContent r of
    Transaction (TEntry (UEntry dr cr corr _)) ->
      case dr of
        [] -> if null cr then Nothing else ((getID . fst) <$> corr)
        (DPosting acc _ _: _) -> Just (getID acc)
    _ -> Nothing

-- | Search for record with matching attributes in list.
-- Returns (Maybe found record, all records except found).
getDebitAccount r =
  case getContent r of
    Transaction (TEntry (UEntry dr cr corr _)) ->
      case dr of
        [] -> if null cr then Nothing else ((getID . fst) <$> corr)
        (DPosting acc _ _: _) -> Just (getID acc)
    _ -> Nothing

-- | Search for record with matching attributes in list.
-- Returns (Maybe found record, all records except found).