diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts index 8729837..d5e6711 100644 --- a/apps/web/process/configurator/reactions/values.ts +++ b/apps/web/process/configurator/reactions/values.ts @@ -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(), diff --git a/apps/web/process/configurator/validation.ts b/apps/web/process/configurator/validation.ts index 5c6adf7..c308cee 100644 --- a/apps/web/process/configurator/validation.ts +++ b/apps/web/process/configurator/validation.ts @@ -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 },