перенесли реакции random-1 по процессам
This commit is contained in:
parent
f9412dca2c
commit
928510c845
19
apps/web/process/create-kp/reactions.ts
Normal file
19
apps/web/process/create-kp/reactions.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import type { ReactionsContext } from '../types';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
export default function commonReactions({ store }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('radioBalanceHolder').getValue(),
|
||||
(balanceHolder) => {
|
||||
if (balanceHolder) {
|
||||
if (balanceHolder === 100_000_001) {
|
||||
$calculation.element('cbxLastPaymentRedemption').setValue(true).block();
|
||||
} else {
|
||||
$calculation.element('cbxLastPaymentRedemption').unblock();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -1,22 +1,24 @@
|
||||
import * as calculateReactions from '../../calculate/reactions';
|
||||
import * as configurator from '../../configurator/reactions';
|
||||
import createKPReactions from '../../create-kp/reactions';
|
||||
import * as fingapReactions from '../../fingap/reactions';
|
||||
import * as leadOpportunityReactions from '../../lead-opportunity/reactions';
|
||||
import * as leasingObject from '../../leasing-object/reactions';
|
||||
import * as leasingWithoutKaskoReactions from '../../leasing-without-kasko/reactions';
|
||||
import paymentsReactions from '../../payments/reactions';
|
||||
import loadKpReactions from '../../load-kp/reactions';
|
||||
import * as paymentsReactions from '../../payments/reactions';
|
||||
import * as priceReactions from '../../price/reactions';
|
||||
import * as subsidyReactions from '../../subsidy/reactions';
|
||||
import * as agentsReactions from '../../supplier-agent/reactions/agents';
|
||||
import leasebackReactions from '../../supplier-agent/reactions/leaseback';
|
||||
import * as supplierReactions from '../../supplier-agent/reactions/supplier';
|
||||
import setInitialValuesReactions from '../set-values/reactions';
|
||||
import loadKpReactions from '@/process/load-kp/reactions';
|
||||
|
||||
export default function injectDefaultReactions(context) {
|
||||
leadOpportunityReactions.common(context);
|
||||
leadOpportunityReactions.urls(context);
|
||||
paymentsReactions(context);
|
||||
paymentsReactions.commonReactions(context);
|
||||
paymentsReactions.validationReactions(context);
|
||||
calculateReactions.validation(context);
|
||||
calculateReactions.common(context);
|
||||
supplierReactions.commonReactions(context);
|
||||
@ -40,4 +42,5 @@ export default function injectDefaultReactions(context) {
|
||||
configurator.filters(context);
|
||||
configurator.values(context);
|
||||
configurator.validation(context);
|
||||
createKPReactions(context);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import * as seasonsConstants from './lib/seasons-constants';
|
||||
import * as seasonsTools from './lib/seasons-tools';
|
||||
import validatePaymentsTable from './validation';
|
||||
import { selectHighSeasonStart } from '@/config/default-options';
|
||||
import { MIN_PAYMENT } from '@/constants/values';
|
||||
import { MIN_LASTPAYMENT_NSIB, MIN_PAYMENT } from '@/constants/values';
|
||||
import type { ReactionsContext } from '@/process/types';
|
||||
import type { Row } from '@/stores/tables/payments/types';
|
||||
import ValidationHelper from '@/stores/validation/helper';
|
||||
@ -22,7 +22,7 @@ const {
|
||||
const { DEFAULT_SEASONS_VALUES, FORBIDDEN_HIGH_SEASON_START, SEASONS_PERIOD_NUMBER } =
|
||||
seasonsConstants;
|
||||
|
||||
export default function paymentsReactions({ store }: ReactionsContext) {
|
||||
export function commonReactions({ store }: ReactionsContext) {
|
||||
const { $calculation, $tables, $process } = store;
|
||||
|
||||
reaction(
|
||||
@ -541,10 +541,11 @@ export default function paymentsReactions({ store }: ReactionsContext) {
|
||||
$calculation.element('selectHighSeasonStart').resetValue();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function validationReactions({ store }: ReactionsContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
|
||||
/**
|
||||
* Валидация
|
||||
*/
|
||||
const validationHelper = new ValidationHelper();
|
||||
|
||||
reaction(
|
||||
@ -577,4 +578,22 @@ export default function paymentsReactions({ store }: ReactionsContext) {
|
||||
equals: comparer.structural,
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => {
|
||||
const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue();
|
||||
const insNSIB = $calculation.element('selectInsNSIB').getValue();
|
||||
|
||||
return {
|
||||
insNSIB,
|
||||
lastPaymentRub,
|
||||
};
|
||||
},
|
||||
({ lastPaymentRub, insNSIB }) => {
|
||||
$calculation.element('tbxLastPaymentRub').validate({
|
||||
invalid: Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB,
|
||||
message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,19 +32,6 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('radioBalanceHolder').getValue(),
|
||||
(balanceHolder) => {
|
||||
if (balanceHolder) {
|
||||
if (balanceHolder === 100000001) {
|
||||
$calculation.element('cbxLastPaymentRedemption').setValue(true).block();
|
||||
} else {
|
||||
$calculation.element('cbxLastPaymentRedemption').unblock();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Расчет размера скидки поставщика в валюте
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { MIN_LASTPAYMENT_NSIB, VAT } from '@/constants/values';
|
||||
import { VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ReactionsContext } from '@/process/types';
|
||||
import { reaction } from 'mobx';
|
||||
@ -9,24 +9,6 @@ import { round } from 'tools';
|
||||
export default function validationReactions({ store, apolloClient }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
|
||||
reaction(
|
||||
() => {
|
||||
const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue();
|
||||
const insNSIB = $calculation.element('selectInsNSIB').getValue();
|
||||
|
||||
return {
|
||||
insNSIB,
|
||||
lastPaymentRub,
|
||||
};
|
||||
},
|
||||
({ lastPaymentRub, insNSIB }) => {
|
||||
$calculation.element('tbxLastPaymentRub').validate({
|
||||
invalid: Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB,
|
||||
message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() =>
|
||||
pick($calculation.$values.values, [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user