Compare commits

...

5 Commits

Author SHA1 Message Date
vchikalkin
818b843909 fix [3] 2024-07-04 17:33:02 +03:00
vchikalkin
70d26e472f fix [2] 2024-07-04 17:26:39 +03:00
vchikalkin
595d4f34f9 fix 2024-07-04 17:13:32 +03:00
vchikalkin
25723a1939 Добавить реакцию:
Если Тип предмета лизингаselectLeaseObjectType  = Спецтехника (ID=9) и значение в поле tbxMaxSpeed< 20, то insuredOSAGO = Лизингополучатель (100000000), inscostOSAGO = 0, inscompanyOSAGO = ПРОЧИЕ и закрыты для редактирования
2024-07-04 16:44:18 +03:00
vchikalkin
0be3a575f7 Добавить валидацию:
в lease-object, выделяем tbxMaxSpeed

Если Тип предмета лизинга selectLeaseObjectType = Спецтехника (ID=9) или Погрузчик (ID=6) или Трактор (ID=10) И значение в поле tbxMaxSpeed= 0, то выводить сообщение "Необходимо указать Макс. констр. скорость (при ПСМ)"
в insurance выделяем selectLeaseObjectType

Если Тип предмета лизинга selectLeaseObjectType = Спецтехника (ID=9) и значение в поле tbxMaxSpeed< 20 и insuredOSAGO = Лизингодатель (100000001), то выводить сообщение "Нельзя включать в график ОСАГО по Спецтехнике, т.к. полис не требуется"
2024-07-04 13:44:16 +03:00
3 changed files with 79 additions and 0 deletions

View File

@ -303,6 +303,56 @@ export function common({ store, apolloClient }: ProcessContext) {
}
}
);
reaction(
() => $calculation.$values.getValues(['leaseObjectType', 'maxSpeed']),
async ({ leaseObjectType: leaseObjectTypeId, maxSpeed }) => {
if (!leaseObjectTypeId) {
$tables.insurance.row('osago').column('insuranceCompany').unblock();
$tables.insurance.row('osago').column('insured').unblock();
$tables.insurance.row('osago').column('insCost').unblock();
return;
}
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: {
leaseObjectTypeId,
},
});
const {
data: { accounts },
} = await apolloClient.query({
query: CRMTypes.GetInsuranceCompaniesDocument,
});
if (evo_leasingobject_type?.evo_id === '9' && maxSpeed < 20) {
const otherInsuranceCompany = accounts?.find(
(x) => x?.evo_type_ins_policy === null && x.label?.includes('ПРОЧИЕ')
);
if (otherInsuranceCompany) {
$tables.insurance
.row('osago')
.column('insuranceCompany')
.setOptions(normalizeOptions([otherInsuranceCompany]))
.setValue(otherInsuranceCompany.value)
.block();
}
$tables.insurance.row('osago').column('insured').setValue(100_000_000).block();
$tables.insurance.row('osago').column('insCost').setValue(0).block();
} else {
$tables.insurance.row('osago').column('insuranceCompany').unblock();
$tables.insurance.row('osago').column('insured').unblock();
$tables.insurance.row('osago').column('insCost').unblock();
}
}
);
}
export const validation = createValidationReaction(createValidationSchema);

View File

@ -16,6 +16,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
leaseObjectType: true,
leasingPeriod: true,
leasingWithoutKasko: true,
maxSpeed: true,
partialVAT: true,
plPriceRub: true,
product: true,
@ -42,6 +43,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
leaseObjectType: leaseObjectTypeId,
firstPaymentPerc,
plPriceRub,
maxSpeed,
},
ctx
) => {
@ -251,6 +253,19 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
path: ['tbxLeaseObjectPrice'],
});
}
if (
evo_leasingobject_type?.evo_id &&
['9'].includes(evo_leasingobject_type?.evo_id) &&
maxSpeed < 20 &&
insurance.values.osago.insured === 100_000_001
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Нельзя включать в график ОСАГО по Спецтехнике, т.к. полис не требуется',
path: ['insurance'],
});
}
}
);
}

View File

@ -17,6 +17,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
leaseObjectType: true,
leaseObjectUseFor: true,
maxMass: true,
maxSpeed: true,
model: true,
}).superRefine(
async (
@ -32,6 +33,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
model: modelId,
leaseObjectUseFor,
configuration,
maxSpeed,
},
ctx
) => {
@ -174,6 +176,18 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
path: ['selectLeaseObjectCategory'],
});
}
if (
evo_leasingobject_type?.evo_id &&
['6', '9', '10'].includes(evo_leasingobject_type?.evo_id) &&
!maxSpeed
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Не заполнено поле',
path: ['tbxMaxSpeed'],
});
}
}
}
);