fix sync elt lists with insurance table lists

This commit is contained in:
vchikalkin 2023-05-22 18:29:08 +03:00
parent 4b3f62ccbe
commit 3e774ab327
2 changed files with 19 additions and 1 deletions

View File

@ -6,7 +6,7 @@ export default function helper({
apolloClient,
store,
}: Pick<ProcessContext, 'apolloClient' | 'store'>) {
const { $calculation } = store;
const { $calculation, $tables } = store;
return {
async init() {
@ -29,6 +29,16 @@ export default function helper({
({ evo_leasingobject_type } = data);
}
const kaskoCompanyIds = $tables.insurance
.row('kasko')
.getOptions('insuranceCompany')
.map((x) => x.value);
const osagoCompanyIds = $tables.insurance
.row('osago')
.getOptions('insuranceCompany')
.map((x) => x.value);
return {
kasko: (accounts
?.filter((x) =>
@ -38,6 +48,7 @@ export default function helper({
? Boolean(x.evo_id_elt_smr)
: Boolean(x?.evo_id_elt)
)
.filter((x) => x?.value && kaskoCompanyIds.includes(x?.value))
.map((x) => ({
id:
evo_leasingobject_type?.evo_id &&
@ -56,6 +67,7 @@ export default function helper({
})) || []) as Row[],
osago: (accounts
?.filter((x) => x?.evo_type_ins_policy?.includes(100_000_001) && x?.evo_id_elt_osago)
.filter((x) => x?.value && osagoCompanyIds.includes(x.value))
.map((x) => ({
id: x?.evo_id_elt_osago,
key: x?.value,

View File

@ -12,6 +12,9 @@ export default function reactions(context: ProcessContext) {
disposableReaction(
() => $process.has('ELT') || $process.has('LoadKP'),
() => ({
kasko: {
options: $tables.insurance.row('kasko').getOptions('insuranceCompany'),
},
values: $calculation.$values.getValues([
'objectRegistration',
'townRegistration',
@ -57,6 +60,9 @@ export default function reactions(context: ProcessContext) {
disposableReaction(
() => $process.has('ELT') || $process.has('LoadKP'),
() => ({
osago: {
options: $tables.insurance.row('osago').getOptions('insuranceCompany'),
},
values: $calculation.$values.getValues([
'legalClientRegion',
'legalClientTown',