vchikalkin bbf4cfb848 comment:
В таблице ELT добавить фильтр по списку Страховых компаний  в зависимости от Категории ТС leaseObjectCategory:

для КАСКО:
если значение из поля Категория ТС leaseObjectCategory содержится в списке поля "Допустимые категории ТС КАСКО" evo_kasko_category карточки Контрагента,

то выводить данную СК в списке, иначе не выводить

для ОСАГО:
если значение из поля Категория ТС leaseObjectCategory содержится в списке поля "Допустимые категории ТС ОСАГО" evo_osago_category карточки Контрагента,

то выводить данную СК в списке, иначе не выводить
2024-08-15 11:43:16 +03:00

80 lines
2.5 KiB
TypeScript

import type { ProcessContext } from '../../types';
import type { Row } from '@/Components/Calculation/Form/ELT/types';
import * as CRMTypes from '@/graphql/crm.types';
import { defaultRow } from '@/stores/tables/elt/default-values';
export default function helper({
apolloClient,
store,
}: Pick<ProcessContext, 'apolloClient' | 'store'>) {
const { $calculation } = store;
return {
async init() {
const {
data: { accounts },
} = await apolloClient.query({
query: CRMTypes.GetInsuranceCompaniesDocument,
});
let evo_leasingobject_type: CRMTypes.GetLeaseObjectTypeQuery['evo_leasingobject_type'];
const leaseObjectTypeId = $calculation.element('selectLeaseObjectType').getValue();
if (leaseObjectTypeId) {
const { data } = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: {
leaseObjectTypeId,
},
});
({ evo_leasingobject_type } = data);
}
// const leaseObjectCategory = $calculation.element('selectLeaseObjectCategory').getValue();
return {
kasko: (accounts
?.filter(
(x) =>
x?.evo_type_ins_policy?.includes(100_000_000) &&
// leaseObjectCategory &&
// x.evo_kasko_category?.includes(leaseObjectCategory) &&
evo_leasingobject_type?.evo_id
)
.filter(
(x) =>
(evo_leasingobject_type?.evo_id &&
['6', '9', '10'].includes(evo_leasingobject_type.evo_id) &&
x?.evo_id_elt_smr) ||
x?.evo_id_elt
)
.map((x) => ({
...defaultRow,
id:
evo_leasingobject_type?.evo_id &&
['6', '9', '10'].includes(evo_leasingobject_type?.evo_id)
? x?.evo_id_elt_smr
: x?.evo_id_elt,
key: x?.value,
name: x?.label,
})) || []) as Row[],
osago: (accounts
?.filter(
(x) =>
x?.evo_type_ins_policy?.includes(100_000_001) &&
// leaseObjectCategory &&
// x.evo_osago_category?.includes(leaseObjectCategory) &&
(x?.evo_id_elt_osago || x.evo_osago_id)
)
.map((x) => ({
...defaultRow,
id: x?.evo_id_elt_osago || x?.evo_osago_id,
key: x?.value,
metodCalc: x?.evo_osago_id ? 'CRM' : 'ELT',
name: x?.label,
})) || []) as Row[],
};
},
};
}