'Creates an account in the database.'

def create(self, account_type, name, active, third_party, notes, identifier, custom_fields=None):

    account_type_result = _get_or_create_account_type(account_type)
    account = Account.query.filter((Account.name == name), (Account.account_type_id == account_type_result.id)).first()
    if account:
        app.logger.error('Account    with    name    {}    already    exists!'.format(name))
        return None
    account = Account()
    account = self._populate_account(account, account_type_result.id, name, active, third_party, notes, self.sanitize_account_identifier(identifier), custom_fields)
    db.session.add(account)
    db.session.commit()
    db.session.refresh(account)
    account = self._load(account)
    return account
