Compare commits
5 Commits
dev
...
release/dy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
818b843909 | ||
|
|
70d26e472f | ||
|
|
595d4f34f9 | ||
|
|
25723a1939 | ||
|
|
0be3a575f7 |
@ -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);
|
||||
|
||||
@ -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'],
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -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'],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user