fix tbxLastPaymentPerc validation
This commit is contained in:
parent
622f4e75ed
commit
2e74b1a23c
@ -8,7 +8,9 @@ import { z } from 'zod';
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({
|
||||
VATInLeaseObjectPrice: true,
|
||||
balanceHolder: true,
|
||||
firstPaymentRub: true,
|
||||
lastPaymentPerc: true,
|
||||
leaseObjectPriceWthtVAT: true,
|
||||
plPriceRub: true,
|
||||
product: true,
|
||||
@ -24,6 +26,8 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
plPriceRub,
|
||||
firstPaymentRub,
|
||||
subsidySum,
|
||||
balanceHolder,
|
||||
lastPaymentPerc,
|
||||
},
|
||||
ctx
|
||||
) => {
|
||||
@ -74,6 +78,23 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
path: ['tbxFirstPaymentRub'],
|
||||
});
|
||||
}
|
||||
|
||||
if (balanceHolder === 100_000_001) {
|
||||
if (lastPaymentPerc < 1) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.',
|
||||
path: ['tbxLastPaymentPerc'],
|
||||
});
|
||||
}
|
||||
} else if (lastPaymentPerc === 0) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Последний платеж не может быть равен 0. Увеличьте значение',
|
||||
path: ['tbxLastPaymentPerc'],
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import { z } from 'zod';
|
||||
export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
return ValuesSchema.pick({
|
||||
addEquipmentPrice: true,
|
||||
balanceHolder: true,
|
||||
countSeats: true,
|
||||
dealerPerson: true,
|
||||
discountRub: true,
|
||||
@ -45,7 +44,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
countSeats,
|
||||
leaseObjectYear,
|
||||
lastPaymentPerc,
|
||||
balanceHolder,
|
||||
leaseObjectCategory,
|
||||
},
|
||||
ctx
|
||||
@ -236,23 +234,6 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
path: ['tbxLastPaymentPerc'],
|
||||
});
|
||||
}
|
||||
|
||||
if (balanceHolder === 100_000_001) {
|
||||
if (lastPaymentPerc < 1) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
'При балансе лизингодатель последний платеж не может быть меньше 1%! Увеличьте значение.',
|
||||
path: ['tbxLastPaymentPerc'],
|
||||
});
|
||||
}
|
||||
} else if (lastPaymentPerc === 0) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Последний платеж не может быть равен 0. Увеличьте значение',
|
||||
path: ['tbxLastPaymentPerc'],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user