region, town registraion fill from kp

This commit is contained in:
Chika 2021-01-28 14:22:36 +03:00
parent a089eae12b
commit d6e3739e76
8 changed files with 78 additions and 4 deletions

View File

@ -55,6 +55,7 @@ const query = gql`
selectRegionRegistration: evo_regions(statecode: $statecode) { selectRegionRegistration: evo_regions(statecode: $statecode) {
evo_name evo_name
evo_regionid evo_regionid
evo_fias_id
} }
selectAccount: accounts( selectAccount: accounts(
evo_account_type: $account_account_type evo_account_type: $account_account_type

View File

@ -12,6 +12,12 @@ const query = gql`
evo_double_agent_accountid evo_double_agent_accountid
evo_broker_accountid evo_broker_accountid
evo_fin_department_accountid evo_fin_department_accountid
accountidData {
evo_address_legalidData {
evo_region_fias_id
evo_city_fias_id
}
}
} }
selectOpportunity: opportunities( selectOpportunity: opportunities(
statecode: $statecode statecode: $statecode
@ -24,6 +30,12 @@ const query = gql`
evo_client_riskid evo_client_riskid
parentaccountid parentaccountid
evo_programsolution evo_programsolution
accountidData {
evo_address_legalidData {
evo_region_fias_id
evo_city_fias_id
}
}
} }
} }
`; `;

View File

@ -79,6 +79,44 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
})), })),
); );
let regionRegistration = quote.evo_regionid,
townRegistration = quote.evo_townid;
let accountidData;
if (lead) {
const selected_lead = calculationStore.options.selectLead?.find(
x => x.value === lead,
);
if (selected_lead && selected_lead.accountidData) {
accountidData = selected_lead.accountidData;
}
}
if (opportunity) {
const selected_opportunity = calculationStore.options.selectOpportunity?.find(
x => x.value === opportunity,
);
if (selected_opportunity && selected_opportunity.accountidData) {
accountidData = selected_opportunity.accountidData;
}
}
let evo_region_fias_id, evo_city_fias_id;
if (accountidData) {
const { evo_address_legalidData } = accountidData;
evo_region_fias_id = evo_address_legalidData.evo_region_fias_id;
evo_city_fias_id = evo_address_legalidData.evo_city_fias_id;
}
if (evo_region_fias_id) {
const region = calculationStore.options.selectRegionRegistration?.find(
x => x.evo_fias_id === evo_region_fias_id,
);
if (region) {
regionRegistration = region.evo_regionid;
}
}
const { entities: options } = await CrmService.crmgqlquery({ const { entities: options } = await CrmService.crmgqlquery({
query: optionsQuery, query: optionsQuery,
variables: { variables: {
@ -96,7 +134,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
findepartment_accountid: findepartment_accountid:
quote.evo_fin_department_accountid || NIL, quote.evo_fin_department_accountid || NIL,
evo_gps_brandid: quote.evo_gps_brandid || NIL, evo_gps_brandid: quote.evo_gps_brandid || NIL,
evo_regionid: quote.evo_regionid || NIL, evo_regionid: regionRegistration || NIL,
}, },
toOptions: [ toOptions: [
'selectModel', 'selectModel',
@ -156,6 +194,15 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
}, },
]); ]);
if (evo_city_fias_id) {
const city = calculationStore.options.selectTownRegistration?.find(
x => x.evo_fias_id === evo_city_fias_id,
);
if (city) {
townRegistration = city.evo_townid;
}
}
const evo_planpayments = quote.evo_graphs.sort( const evo_planpayments = quote.evo_graphs.sort(
(a, b) => b.createdon - a.createdon, (a, b) => b.createdon - a.createdon,
)[0].evo_planpayments; )[0].evo_planpayments;
@ -228,7 +275,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
if (evo_programsolution === 100000000) { if (evo_programsolution === 100000000) {
const midClientRisk = calculationStore.options.selectClientRisk?.find( const midClientRisk = calculationStore.options.selectClientRisk?.find(
x => x.evo_id === 2, x => x.evo_id === '2',
); );
if (midClientRisk) { if (midClientRisk) {
clientRisk = midClientRisk.evo_client_riskid; clientRisk = midClientRisk.evo_client_riskid;
@ -250,6 +297,8 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
recalcWithRevision, recalcWithRevision,
leaseObjectCount, leaseObjectCount,
clientRisk, clientRisk,
regionRegistration,
townRegistration,
}); });
message.success({ message.success({

View File

@ -61,8 +61,6 @@ const mapKPtoValues: TValues<string> = {
finDepartmentRewardSumm: 'evo_fin_department_reward_total', finDepartmentRewardSumm: 'evo_fin_department_reward_total',
GPSBrand: 'evo_gps_brandid', GPSBrand: 'evo_gps_brandid',
GPSModel: 'evo_gps_modelid', GPSModel: 'evo_gps_modelid',
regionRegistration: 'evo_regionid',
townRegistration: 'evo_townid',
infuranceOPF: 'evo_ins_legal_form', infuranceOPF: 'evo_ins_legal_form',
insKaskoType: 'evo_insurance_type', insKaskoType: 'evo_insurance_type',
insKaskoPriceLeasePeriod: 'evo_kasko_price_leasperiod', insKaskoPriceLeasePeriod: 'evo_kasko_price_leasperiod',

View File

@ -129,6 +129,7 @@ export default gql`
) { ) {
evo_name evo_name
evo_townid evo_townid
evo_fias_id
} }
} }
`; `;

View File

@ -29,6 +29,8 @@ export default gql`
evo_quotename evo_quotename
evo_rateid evo_rateid
evo_client_riskid evo_client_riskid
evo_regionid
evo_townid
} }
} }
`; `;

View File

@ -1117,6 +1117,7 @@ export default [
) { ) {
evo_name evo_name
evo_townid evo_townid
evo_fias_id
} }
} }
`, `,

View File

@ -15,6 +15,12 @@ export interface IAccount {
evo_type_ins_policy?: number[]; evo_type_ins_policy?: number[];
customerid?: string; customerid?: string;
evo_kpp?: string; evo_kpp?: string;
evo_address_legalidData?: IEvoAddress;
}
export interface IEvoAddress {
evo_region_fias_id?: string;
evo_city_fias_id?: string;
} }
export interface ILead { export interface ILead {
@ -76,6 +82,8 @@ export interface IQuote {
evo_max_mass?: number; evo_max_mass?: number;
evo_seats?: number; evo_seats?: number;
evo_year?: number; evo_year?: number;
evo_regionid?: string;
evo_townid?: string;
} }
interface IEvoGraph { interface IEvoGraph {
@ -184,12 +192,14 @@ export interface IEvoGPSModel {
export interface IEvoRegion { export interface IEvoRegion {
evo_name?: string; evo_name?: string;
evo_regionid?: string; evo_regionid?: string;
evo_fias_id?: string;
statecode?: number; statecode?: number;
} }
export interface IEvoTown { export interface IEvoTown {
evo_name?: string; evo_name?: string;
evo_townid?: string; evo_townid?: string;
statecode?: number; statecode?: number;
evo_fias_id?: string;
} }
export interface IEvoContact { export interface IEvoContact {
parentcustomerid?: string; parentcustomerid?: string;