process/configurator: удалили реакцию заполнения tbxIRR_Perc из тарифа
добавили валидацию tbxIRR_Perc на диапазон irrInfo
This commit is contained in:
parent
126302a10a
commit
677ab1d75b
@ -60,36 +60,36 @@ export default function valuesReactions({ store, apolloClient, trpcClient }: Pro
|
||||
}
|
||||
);
|
||||
|
||||
disposableReaction(
|
||||
() => $process.has('LoadKP'),
|
||||
() => $calculation.$values.getValue('tarif'),
|
||||
async (tarifId) => {
|
||||
if (!tarifId) {
|
||||
$calculation.element('tbxIRR_Perc').resetValue();
|
||||
// disposableReaction(
|
||||
// () => $process.has('LoadKP'),
|
||||
// () => $calculation.$values.getValue('tarif'),
|
||||
// async (tarifId) => {
|
||||
// if (!tarifId) {
|
||||
// $calculation.element('tbxIRR_Perc').resetValue();
|
||||
|
||||
return;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
|
||||
const {
|
||||
data: { evo_tarif },
|
||||
} = await apolloClient.query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetTarifDocument,
|
||||
variables: {
|
||||
tarifId,
|
||||
},
|
||||
});
|
||||
// const {
|
||||
// data: { evo_tarif },
|
||||
// } = await apolloClient.query({
|
||||
// fetchPolicy: 'network-only',
|
||||
// query: CRMTypes.GetTarifDocument,
|
||||
// variables: {
|
||||
// tarifId,
|
||||
// },
|
||||
// });
|
||||
|
||||
if (evo_tarif?.evo_irr) {
|
||||
$calculation.element('tbxIRR_Perc').setValue(evo_tarif?.evo_irr);
|
||||
} else {
|
||||
$calculation.element('tbxIRR_Perc').resetValue();
|
||||
}
|
||||
},
|
||||
{
|
||||
delay: 20,
|
||||
}
|
||||
);
|
||||
// if (evo_tarif?.evo_irr) {
|
||||
// $calculation.element('tbxIRR_Perc').setValue(evo_tarif?.evo_irr);
|
||||
// } else {
|
||||
// $calculation.element('tbxIRR_Perc').resetValue();
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// delay: 20,
|
||||
// }
|
||||
// );
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectTarif').getValue(),
|
||||
|
||||
@ -32,6 +32,7 @@ const Schema = ValuesSchema.pick({
|
||||
indAgentRewardSumm: true,
|
||||
insFranchise: true,
|
||||
insKaskoPriceLeasePeriod: true,
|
||||
irrInfo: true,
|
||||
lastPaymentPerc: true,
|
||||
lastPaymentRub: true,
|
||||
leaseObjectCount: true,
|
||||
@ -72,7 +73,7 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
* При красной рамке в данном поле нельзя осуществить расчет графика.
|
||||
*/
|
||||
|
||||
const { tarif: tarifId, parmentsDecreasePercent } = values;
|
||||
const { tarif: tarifId, parmentsDecreasePercent, irrInfo, IRR_Perc } = values;
|
||||
|
||||
if (!tarifId) {
|
||||
ctx.addIssue({
|
||||
@ -82,6 +83,14 @@ export function createValidationSchema({ apolloClient }: ValidationContext) {
|
||||
});
|
||||
}
|
||||
|
||||
if (IRR_Perc < irrInfo.min || IRR_Perc > irrInfo.max) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Значение не входит в диапазон тарифа',
|
||||
path: ['tbxIRR_Perc'],
|
||||
});
|
||||
}
|
||||
|
||||
if (tarifId) {
|
||||
const {
|
||||
data: { evo_tarif },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user