code: def elect(self, candidate_aggregates, candidate_id):
          
  
          # somewhat paranoid cross-check, but we've had this bug before..
          assert(candidate_id not in self.candidates_elected)
  
          elected_no = len(self.candidates_elected) + 1
          self.candidates_elected[candidate_id] = True
  
          transfer_value = 0
          excess_votes = paper_count = None
          if len(self.candidates_elected) != self.vacancies:
              excess_votes = max(candidate_aggregates.get_vote_count(candidate_id) - self.quota, 0)
              assert(excess_votes >= 0)
              paper_count = self.candidate_bundle_transactions.get_paper_count(candidate_id)
              if paper_count > 0:
                  transfer_value = fractions.Fraction(excess_votes, paper_count)
              assert(transfer_value >= 0)
              self.election_distributions_pending.append((candidate_id, transfer_value, excess_votes))
          self.results.candidate_elected(
              CandidateElected(
                  candidate_id=candidate_id,
                  order=elected_no,
                  excess_votes=excess_votes,
                  paper_count=paper_count,
                  transfer_value=transfer_value))
docs: Elect a candidate, updating internal state to track this.
          Calculate the paper count to be transferred on to other candidates,
          and if required schedule a distribution fo papers.