import helper from './lib/helper'; import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { round } from 'tools'; export default function reactions(context: ProcessContext) { const { store } = context; const { $calculation } = store; const { getCoefficient } = helper(context); reaction( () => $calculation.$values.getValues(['product', 'saleBonus']), async ({ product: productId, saleBonus }) => { const coefficient = await getCoefficient(productId); const maxBonus = (coefficient?.evo_sot_coefficient || 0) * 100; $calculation.element('tbxSaleBonus').validate({ invalid: round(saleBonus, 2) > round(maxBonus, 2), message: 'Размер бонуса МПЛ не может быть выше установленного по СОТ', }); } ); }