@Override
  public void registerPerson(Person person) {
    if (person.getSameBillingAddress() == true) {
      logger.debug("same billing address");
      person.setBillingAddress(person.getMainAddress());
    }
    person.getRegistrationInfo().setJunkRegister(false);
    personRepository.save(person);

    // now generate refcode which will be 2012-0001
    person.getRegistrationInfo().setRefCode("2012-" + String.format("%05d", person.getId()));
    person.getRegistrationInfo().setRegisterDate(new Date());
    //

    personRepository.save(person);
    return;
  }
  @Override
  public Person getNewPerson() {
    Person p = new Person();

    // now initialize
    p.setBillingAddress(new Address());
    p.setMainAddress(new Address());
    p.setRegistrationInfo(new RegistrationInfo());
    p.getRegistrationInfo().setStatus(RegistrationStatus.Unpaid);
    p.setSameBillingAddress(true);

    // return
    return p;
  }
  @Override
  public Boolean checkRegistratorByEmailAndRefCode(Person registrator, MessageContext context) {
    // now find the person
    Person p =
        personRepository.findByEmailAndRegistrationInfo_refCode(
            registrator.getEmail(), registrator.getRegistrationInfo().getRefCode());

    if (p != null && p.getId() != null) {
      // registrator = p;
      // logger.debug(registrator.getTitleDisplayValue());
      return true;
    }

    context.addMessage(
        new MessageBuilder()
            .error()
            .defaultText(
                "There is no record of such Email and Invoice Number, Please Enter both information again.")
            .build());
    return false;
  }
 @Override
 public Person getRegistratorByEmailAndRefCode(Person registrator) {
   return personRepository.findByEmailAndRegistrationInfo_refCode(
       registrator.getEmail(), registrator.getRegistrationInfo().getRefCode());
 }