options: add graphType индивидуальный график

This commit is contained in:
vchikalkin 2023-04-19 23:43:44 +03:00
parent 860ecb9384
commit cc1f07d9e4
3 changed files with 19 additions and 9 deletions

View File

@ -68,6 +68,10 @@ export const radioGraphType = [
label: 'легкий старт',
value: 100_000_004,
},
{
label: 'индивидуальный график',
value: 100_000_005,
},
];
export const selectObjectCategoryTax = [

View File

@ -1,3 +1,4 @@
/* eslint-disable sonarjs/cognitive-complexity */
import { radioCalcType, radioGraphType, selectSeasonType } from '@/config/default-options';
import * as CRMTypes from '@/graphql/crm.types';
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
@ -11,7 +12,7 @@ import { diff } from 'radash';
dayjs.extend(utc);
export default function reactions({ store, apolloClient, user }: ProcessContext) {
const { $calculation } = store;
const { $calculation, $process } = store;
reaction(
() => $calculation.$values.getValues(['dealer', 'importProgram', 'product', 'subsidy']),
@ -20,7 +21,6 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
subsidy: subsidyId,
importProgram: importProgramId,
dealer: dealerId,
// eslint-disable-next-line sonarjs/cognitive-complexity
}) => {
/**
* #1
@ -241,15 +241,21 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
({ evo_tarif } = data);
}
if (evo_tarif?.evo_graphtype_exception?.length) {
const filteredGraphTypes = radioGraphType.filter(
let options = radioGraphType;
if (!$process.has('Unlimited')) {
options = options.filter((x) => x.value !== 100_000_005);
}
if (!$process.has('Unlimited') && evo_tarif?.evo_graphtype_exception?.length) {
options = options.filter(
(type) => !evo_tarif?.evo_graphtype_exception?.includes(type.value)
);
$calculation.element('radioGraphType').setOptions(filteredGraphTypes);
} else {
$calculation.element('radioGraphType').resetOptions();
}
$calculation.element('radioGraphType').setOptions(options);
},
{
fireImmediately: true,
}
);

View File

@ -53,7 +53,7 @@ export default function reactions({ store }: ProcessContext) {
};
},
({ graphType, leasingPeriod }) => {
if (graphType === 100_000_000) {
if ([100_000_000, 100_000_005].includes(graphType)) {
const middlePayments: Row[] = Array.from(
{
length: leasingPeriod - 2,