fill kladr for osago & fix reset btn

This commit is contained in:
Chika 2021-06-24 14:37:54 +03:00
parent f865885b61
commit 8e6cf4fb86
5 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import { currentDate } from 'core/tools/date';
import { ICalculationStore } from 'core/types/Calculation/Store';
import { IAccount } from 'core/types/Entities/crmEntities';
import { get, isNull } from 'lodash';
const mapCategory = {
@ -38,11 +39,20 @@ const mapSubCategoryBuilder = (leaseObjectUseFor, maxMass, countSeats) => ({
const getSpecified = value => !isNull(value);
export default function (this: ICalculationStore) {
export default function (this: ICalculationStore, company: IAccount) {
const city = this.getOption('selectTownRegistration');
let kladr = '7700000000000';
if (this.getValue('objectRegistration') === 100000001) {
kladr = get(city, 'evo_kladr_id', kladr);
kladr = city?.evo_kladr_id || kladr;
} else {
if (company.evo_legal_region_calc === true) {
const legalClientRegion = this.getOption('selectLegalClientRegion');
const legalClientTown = this.getOption('selectLegalClientTown');
kladr =
legalClientTown?.evo_kladr_id ||
legalClientRegion?.evo_kladr_id ||
kladr;
}
}
const brandId = this.getOption('selectBrand')?.evo_id;
const modelId = this.getOption('selectModel')?.evo_id;

View File

@ -17,7 +17,6 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) =>
sources[insType] = CancelToken.source();
const { ELTStore } = this.stores;
const request = composeRequest.call(this);
const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType];
@ -26,6 +25,7 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) =>
//@ts-ignore
company.isFetching = true;
return new Promise<void>((resolve, reject) => {
const request = composeRequest.call(this, company);
ELTService[insType]
.getCalculation(
{
@ -51,7 +51,6 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) =>
i,
Object.assign(company, converted),
);
resolve();
})
.catch(err => {
reject(err);
@ -59,6 +58,7 @@ export const fetchData = (insType: string, composeRequest, convertEltResult) =>
.finally(() => {
//@ts-ignore
company.isFetching = false;
resolve();
});
});
},

View File

@ -18,6 +18,7 @@ export const initFields = [
'evo_id_elt',
'name',
'accountid',
'evo_legal_region_calc',
];
export function initIns(this: ICalculationStore, insType) {

View File

@ -12,6 +12,7 @@ const query = gql`
evo_type_ins_policy
evo_id_elt
evo_id_elt_osago
evo_legal_region_calc
}
}
`;

View File

@ -18,6 +18,7 @@ export interface IAccount {
evo_address_legalidData?: IEvoAddress;
evo_id_elt?: string;
evo_id_elt_osago?: string;
evo_legal_region_calc?: boolean;
}
export interface IEvoAddress {