export type CRMEntityNames =
  | 'account'
  | 'lead'
  | 'opportunity'
  | 'quote'
  | 'contact'
  | 'transactioncurrency'
  | 'evo_client_type'
  | 'evo_client_risk'
  | 'evo_baseproduct'
  | 'evo_leasingobject_type'
  | 'evo_brand'
  | 'evo_model'
  | 'evo_equipment'
  | 'evo_reward_condition'
  | 'evo_gps_brand'
  | 'evo_gps_model'
  | 'evo_region'
  | 'evo_town'
  | 'connection'
  | 'evo_connection_role'
  | 'evo_impairment_group'
  | 'evo_currencychange'
  | 'evo_statuscode'
  | 'evo_coefficient'
  | 'evo_addproduct_type'
  | 'evo_tarif'
  | 'evo_rate'
  | 'evo_planpayment'
  | 'systemuser'
  | 'evo_sot_coefficient_type'
  | 'evo_subsidy';

export interface CoreEntity {
  __typename: CRMEntityNames;
}

export interface BaseEntity {
  statecode?: number;
  createdon?: Date;
  evo_id?: string;
  evo_name?: string;
}

export interface IAccount extends BaseEntity {
  evo_return_leasing_dealer?: boolean;
  name?: string;
  accountid?: string;
  evo_inn?: string;
  evo_account_type?: number;
  evo_supplier_type?: number;
  evo_fin_department_accountid?: string;
  evo_legal_form?: number;
  ownerid?: string;
  evo_broker_accountid?: string;
  evo_client_riskid?: string;
  evo_type_ins_policy?: number[];
  customerid?: string;
  evo_kpp?: string;
  evo_address_legalidData?: IEvoAddress;
  evo_id_elt?: string;
  evo_id_elt_osago?: string;
  evo_legal_region_calc?: boolean;
  evo_osago_with_kasko?: boolean;
}

export interface ISalonProvider extends IAccount {
  salonaccountid?: string;
}
export interface ISalonAgent extends ISalonProvider {}

export interface IEvoAddress extends BaseEntity {
  evo_region_fias_id?: string;
  evo_city_fias_id?: string;
}

export interface ILead extends BaseEntity {
  leadid?: string;
  fullname?: string;
  evo_opportunityid?: string;
  account?: string;
  ownerid?: string;
  evo_fin_department_accountid?: string;
  evo_broker_accountid?: string;
  evo_double_agent_accountid?: string;
  evo_agent_accountid?: string;
  accountidData?: IAccount;
  owner_domainname?: string;
  evo_inn?: string;
  link?: string;
  evo_programsolution?: number;
}

export interface IOpportunity extends BaseEntity {
  opportunityid?: string;
  accountid?: string;
  evo_leadid?: string;
  evo_client_riskid?: string;
  ownerid?: string;
  accountidData?: IAccount;
  parentaccountid?: string;
  evo_addproduct_types?: IEvoAddproductType[];
  link?: string;
}

export interface IQuote extends BaseEntity {
  evo_vin?: string;
  evo_seasons_type?: number;
  evo_engine_hours?: number;
  evo_client_riskid?: string;
  evo_addproduct_types?: IEvoAddproductType[];
  evo_gps_brandid?: string;
  evo_double_agent_accountid?: string;
  evo_dealer_broker_accountid?: string;
  evo_dealer_person_accountid?: string;
  evo_supplier_accountid?: string;
  evo_modelid?: string;
  evo_brandid?: string;
  quoteid?: string;
  quotenumber?: string;
  evo_leadid?: string;
  evo_recalc_limit?: number;
  evo_approved_first_payment?: number;
  ownerid?: string;
  evo_statuscodeid?: string;
  evo_statuscode?: IEvoStatusCode;
  evo_quotename?: string;
  offerprintform?: string;
  offerprintformapi?: string;
  evo_object_count?: number;
  evo_osago_accountid?: string;
  evo_kasko_accountid?: string;
  evo_kasko_payer?: number;
  evo_kasko_price?: number;
  evo_osago_payer?: number;
  evo_osago_price?: number;
  evo_dgo_price?: number;
  evo_ns_price?: number;
  evo_insurance_period?: number;
  evo_graphs?: IEvoGraph[];
  evo_graph_type?: number;
  evo_period?: number;
  evo_first_payment_perc?: number;
  evo_last_payment_perc?: number;
  evo_min_change_price?: number;
  evo_max_price_change?: number;
  evo_nds_in_price_supplier_currency?: number;
  evo_max_mass?: number;
  evo_seats?: number;
  evo_year?: number;
  evo_regionid?: string;
  evo_townid?: string;
  evo_legal_regionid?: string;
  evo_legal_townid?: string;
  evo_id_elt_kasko?: string;
  evo_id_kasko_calc?: string;
  evo_franchise?: string;
  evo_id_elt_osago?: string;
  evo_object_registration?: number;
  link?: string;
  evo_accept_control_addproduct_typeid?: string;
  evo_req_telematic?: number;
  evo_req_telematic_accept?: number;
  evo_one_year_insurance?: boolean;
  evo_payment_redemption_sum?: number;
  evo_agent_accountid?: string;
  evo_agent_reward_conditionid?: string;
  evo_agent_reward_total?: number;
  evo_agent_reward_summ?: number;
  evo_broker_accountid?: string;
  evo_fin_department_reward_total?: number;
  evo_fin_department_reward_conditionid?: string;
  evo_fin_department_accountid?: string;
  evo_broker_reward_total?: number;
  evo_broker_reward_conditionid?: string;

  evo_fingap_accountid?: string;
  evo_fingap_payer?: number;
  evo_fingap_price?: number;
  evo_fingap_period?: number;
  evo_product_risks?: {
    evo_addproduct_typeid: string;
  }[];
  evo_program_import_subsidyid?: string;
  evo_equip_price?: number;
  evo_accept_period?: number;
  evo_db_accept_registration?: number;
}

export interface IEvoGraph extends BaseEntity {
  evo_sumpay_withnds?: number;
  evo_planpayments?: IEvoPlanPayment[];
}

export interface ITransactionCurrency extends BaseEntity {
  transactioncurrencyid?: string;
  isocurrencycode?: string;
}

export interface IEvoClientType extends BaseEntity {
  evo_client_typeid?: string;
}

export interface IEvoClientRisk extends BaseEntity {
  evo_client_riskid?: string;
}

export interface IEvoBaseproduct extends BaseEntity {
  evo_baseproductid?: string;
  evo_relation?: number;
  evo_datefrom?: Date;
  evo_datefrom_param?: Date;
  evo_dateto_param?: Date;
  evo_leasingobject_types?: IEvoLeasingObjectType[];
  evo_brands?: IEvoBrand[];
  systemusers?: ISystemUser[];
  evo_sale_without_nds?: boolean;
  evo_cut_proportion_bonus_director?: boolean;
  evo_cut_irr_with_bonus?: boolean;
  evo_calculation_method?: number[];
  evo_baseproducts?: IEvoBaseproduct[];
}

export interface IEvoLeasingObjectType extends BaseEntity {
  evo_leasingobject_typeid?: string;
  evo_depreciation_rate1?: number;
  evo_depreciation_rate2?: number;
  evo_expluatation_period1?: number;
  evo_expluatation_period2?: number;
  evo_type_code?: string;
  evo_baseproduct?: any;
  evo_category?: number;
  evo_category_tr?: number[];
  evo_vehicle_type_tax?: number;
  evo_vehicle_type?: number[];
}
export interface IEvoBrand extends BaseEntity {
  evo_brandid?: string;
  evo_brand_owner?: number;
  evo_importer_reward_perc?: number;
  evo_importer_reward_rub?: number;
  evo_vehicle_type?: number[];
}

export interface IEvoModel extends BaseEntity {
  evo_brandid?: string;
  evo_modelid?: string;
  evo_impairment_groupid?: string;
  evo_leasingobject_risk?: number;
  evo_importer_reward_perc?: number;
  evo_importer_reward_rub?: number;
  evo_baseproduct?: any;
  evo_vehicle_type?: number;
  evo_gps?: boolean;
  evo_vehicle_body_typeidData?: {
    evo_id_elt: string;
  };
  evo_running_gear?: number;
}

export interface IEvoEquipment extends BaseEntity {
  evo_equipmentid?: string;
  evo_modelid?: string;
  evo_impairment_groupid?: string;
  evo_leasingobject_risk?: number;
  evo_start_production_year?: number;
  evo_supplier_accountid?: string;
  evo_dealer_person_accountid?: string;
  evo_dealer_broker_accountid?: string;
  evo_vehicle_type?: number;
}

export interface IEvoRewardCondition extends BaseEntity {
  evo_reward_conditionid?: string;
  evo_datefrom?: Date;
  evo_dateto?: Date;
  evo_agent_accountid?: string;
  evo_double_agent_accountid?: string;
  evo_reward_summ?: number;
  evo_reduce_reward?: boolean;
  evo_agency_agreementid?: string;
  evo_agency_agreementidData?: {
    evo_reward_without_other_agent?: boolean;
    evo_required_reward?: boolean;
    evo_leasingobject_price?: number;
  };
  evo_min_reward_summ?: number;
  evo_calc_reward_rules?: number;
}

export interface IEvoGPSBrand extends BaseEntity {
  evo_gps_brandid?: string;
}
export interface IEvoGPSModel extends BaseEntity {
  evo_gps_modelid?: string;
  evo_gps_brandid?: string;
  evo_moto?: boolean;
}
export interface IEvoRegion extends BaseEntity {
  evo_regionid?: string;
  evo_fias_id?: string;
  evo_businessunit_evolution?: boolean;
  evo_oktmo?: string;
  accounts?: IAccount[];
  evo_kladr_id?: string;
}
export interface IEvoTown extends BaseEntity {
  evo_townid?: string;
  evo_fias_id?: string;
  evo_kladr_id?: string;
  evo_businessunit_evolution?: boolean;
}
export interface IEvoContact extends BaseEntity {
  parentcustomerid?: string;
  contactid?: string;
  fullname?: string;
}

export interface IConnection extends BaseEntity {
  connectionid?: string;
  record1id?: string;
  record2id?: string;
  record2roleid?: string;
}

export interface IEvoConnectionRole extends BaseEntity {
  evo_connection_roleid?: string;
}

export interface IEvoImpairmentGroup extends BaseEntity {
  evo_impairment_groupid?: string;
}

export interface IEvoCurrencyChange extends BaseEntity {
  evo_currencychangeid?: string;
  evo_ref_transactioncurrency?: string;
  evo_currencychange?: number;
  evo_coursedate?: Date;
  evo_coursedate_param?: any;
}

export interface IEvoStatusCode extends BaseEntity {
  evo_statuscodeid?: string;
  importsequencenumber?: number;
}

export interface IEvoBusinessunit extends BaseEntity {
  evo_businessunitid?: string;
  evo_sale_businessunitid?: string;
}

export interface IEvoCoefficient extends BaseEntity {
  evo_coefficientid?: string;
  evo_corfficient_type?: number;
  evo_datefrom?: Date;
  evo_dateto?: Date;
  evo_min_period?: number;
  evo_max_period?: number;
  evo_graph_type?: number;
  evo_season_type?: number;
  evo_correction_coefficient?: number;
  evo_sot_coefficient_typeid?: string;
  evo_sot_coefficient?: number;
  evo_client_risks?: IEvoClientRisk[];
  evo_client_types?: IEvoClientType[];
  evo_risk_delta?: number;
  evo_leasingobject_types?: IEvoLeasingObjectType[];
  evo_job_titleid?: string;
  evo_businessunits?: IEvoBusinessunit[];
  evo_baseproducts?: IEvoBaseproduct[];
}

export interface IEvoAddproductType extends BaseEntity {
  evo_addproduct_typeid?: string;
  evo_graph_price?: number;
  evo_prime_cost?: number;
  evo_cost_service_provider?: number;
  evo_retro_bonus?: number;
  evo_product_type?: number;
  evo_datefrom?: Date;
  evo_dateto?: Date;
  evo_baseproductid?: string;
  evo_min_period?: number;
  evo_max_period?: number;
  evo_leasingobject_typeid?: string;
  evo_accountid?: string;
  evo_leasingobject_types?: IEvoLeasingObjectType[];
  evo_graph_price_withoutnds?: number;
  evo_cost_service_provider_withoutnds?: number;
  evo_retro_bonus_withoutnds?: number;
  evo_planpayments?: IEvoPlanPayment[];
  evo_cost_telematics?: number;
  evo_cost_price_telematics?: number;
  evo_cost_equipment?: number;
  evo_controls_program?: number[];
  evo_visible_calc?: boolean;
  evo_helpcard_type?: number;
  evo_towtruck?: boolean;
  evo_pts_type?: number[];
  evo_description?: string;
  evo_whom_register?: number;
  evo_gibdd_region?: boolean;
  evo_type_calc_cerebellum?: number;
  evo_addproduct_types?: IEvoAddproductType[];
  evo_evokasko_calc_type?: number;
  evo_min_price?: number;
  evo_max_price?: number;
  evo_loss_kv?: number;
  evo_min_first_payment_perc?: number;
  evo_max_first_payment_perc?: number;
  evo_models?: IEvoModel;
}

export interface IEvoTarif extends BaseEntity {
  evo_tarifid?: string;
  evo_baseproductid?: string;
  evo_irr?: number;
  evo_max_last_payment?: number;
  evo_max_first_payment?: number;
  evo_max_period?: number;
  evo_min_last_payment?: number;
  evo_min_first_payment?: number;
  evo_min_period?: number;
  evo_balance_holder?: number[];
  evo_transactioncurrencyid?: string;
  evo_max_irr?: number;
  evo_min_profit?: number;
  evo_min_irr?: number;
  evo_datefrom?: Date;
  evo_graphtype_exception?: number[];
  evo_seasons_type_exception?: number[];
  evo_dateto?: Date;
  evo_irr_plan?: number;
  evo_used?: boolean;
  evo_ins_type?: number;
  evo_client_risks?: IEvoClientRisk[];
  evo_leasingobject_types?: IEvoLeasingObjectType[];
  evo_models?: IEvoModel[];
  evo_model_exceptions?: IEvoModel[];
  evo_rates?: IEvoRate[];
  evo_delivery_time?: number[];
  evo_cut_irr_with_bonus_coefficient?: number;
  evo_margin_min?: number;
}

export interface IEvoRate extends BaseEntity {
  evo_rateid?: string;
  evo_base_rate?: number;
  evo_coeff_12_23?: number;
  evo_coeff_24_35?: number;
  evo_coeff_36_47?: number;
  evo_coeff_48_60?: number;
  evo_coeff_7_11?: number;
  evo_datefrom?: Date;
  evo_dateto?: Date;
  evo_brands?: IEvoBrand[];
  evo_credit_period?: number;
  evo_tarifs?: IEvoTarif[];
}

export interface IEvoPlanPayment extends BaseEntity {
  evo_planpaymentid?: string;
  evo_cost_telematics_withoutnds?: number;
  evo_cost_price_telematics_withoutnds?: number;
  evo_cost_equipment_withoutnds?: number;
  evo_addproduct_typeid?: string;
  evo_payment_ratio?: number;
}

export interface ISystemUser extends BaseEntity {
  domainname?: string;
  systemuserid?: string;
  evo_job_titleid?: string;
  firstname?: string;
  lastname?: string;
  fullname?: string;
  businessunitid?: string;
}

export interface IEvoSotCoefficientType extends BaseEntity {
  evo_sot_coefficient_typeid?: string;
}

export interface IEvoJobTitle extends BaseEntity {
  evo_job_titleid?: string;
}

export interface IEvoSubsidy extends BaseEntity {
  evo_subsidy_summ?: number;
  evo_percent_subsidy?: number;
  evo_max_subsidy_summ?: number;
  evo_subsidyid?: string;
  evo_get_subsidy_payment?: number;
  evo_brands?: IEvoBrand[];
  evo_models?: IEvoModel[];
  accounts?: IAccount[];
  evo_subsidy_type?: number;
}

export type CRMEntity = IAccount &
  ILead &
  IOpportunity &
  IQuote &
  ITransactionCurrency &
  IEvoClientType &
  IEvoClientRisk &
  IEvoBaseproduct &
  IEvoLeasingObjectType &
  IEvoBrand &
  IEvoModel &
  IEvoEquipment &
  IEvoRewardCondition &
  IEvoGPSBrand &
  IEvoGPSModel &
  IEvoRegion &
  IEvoTown &
  IEvoContact &
  IConnection &
  IEvoConnectionRole &
  IEvoImpairmentGroup &
  IEvoCurrencyChange &
  IEvoStatusCode &
  IEvoBusinessunit &
  IEvoCoefficient &
  IEvoAddproductType &
  IEvoTarif &
  IEvoRate &
  IEvoPlanPayment &
  ISystemUser &
  IEvoJobTitle &
  IEvoSotCoefficientType &
  IEvoSubsidy;
