process/configurator: удалили реакцию заполнения tbxIRR_Perc из тарифа

добавили валидацию tbxIRR_Perc на диапазон irrInfo
This commit is contained in:
vchikalkin 2024-02-12 15:16:51 +03:00
parent 126302a10a
commit 677ab1d75b
2 changed files with 37 additions and 28 deletions

View File

@ -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(),

View File

@ -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 },