Добавить валидацию:

в lease-object, выделяем tbxMaxSpeed

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

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

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'],
});
}
}
}
);