# Register client formats

# Borrowers

data = {
  account: 'Número da conta cadastrada na socinal para atualizar e vazio para novo cadastro',
  person_type: 'J',
  cpf_cnpj: 'borrower cnpj',
  name: 'Razão Social da empresa',
  contact_data: {
    email: 'Email do responsável pela empresa',
    phone_number: 'Telefone do Responsável pela empresa',
    comercial_number: 'Telefone 2 do Responsável pela empresa',
    mobile_number: 'Celular do Responsável pela empresa'
  },
  birthday: 'Data de fundação da empresa',
  fantasy_name: 'Nome Fantasia',
  main_address: { # Endereço da empresa
    street: address_street,
    number: address_number,
    complement: address_complement,
    neighborhood: address_neighborhood,
    city: address_city,
    state: address_state,
    zipcode: address_zip_code
  },
  other_info_data: { # Outras informações, manter como está pois são campos obrigatórios
    client_origin: 'nao_informado',
    has_another_bank_account: false,
    has_overdraft_another_bank: false,
    has_credit_card: false,
    billet_message: 'Pague até a data de vencimento para evitar juros.',
    agreed: true,
    cannot_withdraw_loan: false,
    allow_rotative_credit_line: false
  },
  bank_data: {
    bank_code: 'Código da emrpesa com 3 dígitos',
    agency_number: 'Número da agencia',
    account_number: 'Número da conta'
  },
  company_data: {
    state_registration: 'Inscrição estadual',
    last_year_reveue: 'Faturamento do último ano',
    share_capital: 'Capital social',
    responsible_cpf: 'CPF do responsável (Avalista)',
    responsible_name: 'Nome do Responsável (Avalista)',
    pj_control_type: 'privado',
    optante_simples: 'true ou false'
  },
  partner_data: { # Dados do Avalista
    can_sign: true,
    name: 'Nome',
    rg: 'Número do Documento',
    rg_issuer: 'Emissor Documento',
    rg_issuer_uf: 'Estado do órgão emissor do Documento',
    rg_issue_date: 'Data de emissão do Documento',
    civil_status: 'Estado Civil',
    gender: 'Sexo',
    father_name: 'Nome do Pai',
    mother_name: 'Nome da Mãe',
    birth_place: 'Naturalidade',
    nationality: 'Nacionalidade',
    address: { # Endereço do Avalista
      street: lg.address_street,
      number: lg.address_number,
      complement: lg.address_complement,
      neighborhood: lg.address_neighborhood,
      city: lg.address_city,
      state: lg.address_state,
      zipcode: lg.address_zip_code
    },
    cpf: 'CPF',
    birthday: 'Nascimento',
    profession: 'Profissão',
    phone_number: 'Telefone',
    assets_value: 'Patrimônio',
    incomings: 'Renda mensal',
    person_type: 'F'
  },
  business_caracteristics: {
    economic_activity: 'Atividade Econômica',
    operation_time: 'Tempo de operação',
    activity_type: 'formal',
    employees_sustained: 'Número de empregados',
    employees_generated: 0, # Manter em 0
    monthly_revenue: 'Faturamento mensal'
  }
}

# Lender

data = { # Dados do lender
  account: financial_institution_account, # Enviar vazio para novos cadastros
  person_type: 'F',
  cpf_cnpj: cpf,
  name: get_name, # Nome completo
  contact_data: {
    email: email,
    phone_number: phone_number,
    mobile_number: phone_number2
  },
  birthday: birthday,
  main_address: {
    street: address_street,
    number: address_number,
    complement: address_complement,
    neighborhood: address_neighborhood,
    city: address_city,
    state: address_state,
    zipcode: address_cep
  },
  professional_data: {
    salary: monthly_income.to_f,
    phone_number: phone_number,
    email: email,
    retired: false
  },
  bank_data: {
    bank_code: lender_bank_account.bank.code,
    agency_number: lender_bank_account.agency_number,
    account_number: lender_bank_account.account_number
  },
  person_data: {
    rg: rg,
    rg_issuer: rg_issuer,
    rg_issuer_uf: rg_issuer_uf,
    rg_issue_date: rg_issue_date,
    civil_status: civil_status,
    gender: gender,
    mother_name: mother_name,
    father_name: father_name,
    birth_place: birth_place,
    nationality: nationality
  }
}

# Loan guarantors
data = { # Dados do avalista da operação
  account: financial_institution_account, # Enviar vazio para novos cadastros
  person_type: 'F',
  cpf_cnpj: cpf,
  name: name,
  contact_data: {
    email: email,
    phone_number: phone_number,
    mobile_number: phone_number
  },
  birthday: birthday,
  main_address: {
    street: address_street,
    number: address_number,
    complement: address_complement,
    neighborhood: address_neighborhood,
    city: address_city,
    state: address_state,
    zipcode: address_zip_code
  },
  person_data: {
    rg: rg,
    rg_issuer: rg_issuer,
    rg_issuer_uf: rg_issuer_uf,
    rg_issue_date: rg_issue_date,
    mother_name: mother_name,
    father_name: father_name,
    civil_status: civil_status,
    gender: gender,
    birth_place: birth_place,
    nationality: nationality
  }
}

# Loan Methods

# Insert CCB into socinal

data = { # Loan data
  account: borrower.financial_institution_account,
  release_date: contract_initial_date.strftime('%Y/%m/%d'),
  net_value: loan_value, # Net value adjusted with loan.adjust_values_to_include_into_socinal
  cad_value: total_fee, # Socinal and Nexoos
  use_credit_insurance: false,
  loan_term: loan_term,
  interest_rate: monthly_interest,
  expiration_day: contract_initial_date.day,
  expiration_month_year: (contract_initial_date + 1.month).strftime('%m/%Y'),
  payment_method: '4',
  oav_code: generate_oav_code
}

# Get balance of CCB

data = {
  contract: '00000000-000',
  date: 'dd/mm/yyyy'
}

# Get statement of CCB

data = {
  contract: '00000000-000',
  date: 'dd/mm/yyyy'
}

# Exclude CCB

data = {
  contract: '00000000-000'
}


# RBDs numbers

# RDB Inclusion

data = {
  account: lender.financial_institution_account,
  interest: monthly_interest,
  application_date: loan.contract_initial_date,
  due_to_date: working_day(loan.contract_initial_date + loan.terms.months + 60.days),
  value: investment_value,
  reason: oav_code,
  observation: '',
  oav_code: oav_code
}

# RDB Withdraw

data = { # Investment Data
  contract: investment.rdb_oav_num,
  date: ir_date,
  type: withdraw_type, # Parcial ou Total
  value: withdraw_type == 'Total' ? 0.0 : value
}

# RDB 
