'Factory for payment'

def make_payment(self, participant, team, amount, direction, payday, timestamp=utcnow()):

    if isinstance(participant, Participant):
        participant = participant.username
    if isinstance(team, Team):
        team = team.slug
    payment_id = self.db.one(u'\n                                                INSERT    INTO    payments\n                                                                                                (timestamp,    participant,    team,    amount,    direction,    payday)\n                                                                    VALUES    (%(timestamp)s,    %(participant)s,    %(team)s,    %(amount)s,    %(direction)s,    %(payday)s)\n                                                        RETURNING    id\n                                                ', dict(timestamp=timestamp, participant=participant, team=team, amount=amount, direction=direction, payday=payday))
    return payment_id
