module FFaker::IdentificationMX

def curp

Clave Única de Registro de Población
http://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Registro_de_Poblaci%C3%B3n
def curp
  all_letters = CONSONANTS + VOWELS
  hm = %w[H M]
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  [
    fetch_sample(CONSONANTS),
    fetch_sample(VOWELS),
    fetch_sample(all_letters, count: 2).join,
    date,
    fetch_sample(hm),
    fetch_sample(ESTADOS_CURP),
    fetch_sample(CONSONANTS, count: 3).join,
    fetch_sample(HOMOCLAVE),
    rand(0..9)
  ].join
end

def rfc

Registro Federal de Contribuyentes (R.F.C.)
http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
def rfc
  fetch_sample([rfc_persona_moral, rfc_persona_fisica])
end

def rfc_persona_fisica

Registro Federal de Contribuyentes (R.F.C.) para persona física
http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
def rfc_persona_fisica
  consonants_n = CONSONANTS + ['Ñ']
  all_letters = consonants_n + VOWELS
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  [
    fetch_sample(consonants_n),
    fetch_sample(VOWELS),
    fetch_sample(all_letters, count: 2).join,
    date,
    fetch_sample(HOMOCLAVE, count: 3).join
  ].join
end

def rfc_persona_moral

Registro Federal de Contribuyentes (R.F.C.) para persona moral
http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
def rfc_persona_moral
  consonants_n_amp = CONSONANTS + ['Ñ', '&']
  all_letters = consonants_n_amp + VOWELS
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  "#{fetch_sample(all_letters, count: 3).join}#{date}#{fetch_sample(HOMOCLAVE, count: 3).join}"
end